=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/style.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- src/usr.bin/tmux/style.c 2016/01/19 15:59:12 1.9 +++ src/usr.bin/tmux/style.c 2016/07/15 00:42:56 1.10 @@ -1,4 +1,4 @@ -/* $OpenBSD: style.c,v 1.9 2016/01/19 15:59:12 nicm Exp $ */ +/* $OpenBSD: style.c,v 1.10 2016/07/15 00:42:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -33,7 +33,8 @@ char tmp[32]; int val; size_t end; - u_char fg, bg, attr, flags; + int fg, bg; + u_char attr, flags; if (*in == '\0') return (0); @@ -56,38 +57,20 @@ fg = defgc->fg; bg = defgc->bg; attr = defgc->attr; - flags &= ~(GRID_FLAG_FG256|GRID_FLAG_BG256); - flags |= - defgc->flags & (GRID_FLAG_FG256|GRID_FLAG_BG256); + flags = defgc->flags; } else if (end > 3 && strncasecmp(tmp + 1, "g=", 2) == 0) { if ((val = colour_fromstring(tmp + 3)) == -1) goto error; if (*in == 'f' || *in == 'F') { - if (val != 8) { - if (val & 0x100) { - flags |= GRID_FLAG_FG256; - val &= ~0x100; - } else - flags &= ~GRID_FLAG_FG256; + if (val != 8) fg = val; - } else { + else fg = defgc->fg; - flags &= ~GRID_FLAG_FG256; - flags |= defgc->flags & GRID_FLAG_FG256; - } } else if (*in == 'b' || *in == 'B') { - if (val != 8) { - if (val & 0x100) { - flags |= GRID_FLAG_BG256; - val &= ~0x100; - } else - flags &= ~GRID_FLAG_BG256; + if (val != 8) bg = val; - } else { + else bg = defgc->bg; - flags &= ~GRID_FLAG_BG256; - flags |= defgc->flags & GRID_FLAG_BG256; - } } else goto error; } else if (strcasecmp(tmp, "none") == 0) @@ -120,27 +103,19 @@ const char * style_tostring(struct grid_cell *gc) { - int c, off = 0, comma = 0; + int off = 0, comma = 0; static char s[256]; *s = '\0'; - if (gc->fg != 8 || gc->flags & GRID_FLAG_FG256) { - if (gc->flags & GRID_FLAG_FG256) - c = gc->fg | 0x100; - else - c = gc->fg; - off += xsnprintf(s, sizeof s, "fg=%s", colour_tostring(c)); + if (gc->fg != 8) { + off += xsnprintf(s, sizeof s, "fg=%s", colour_tostring(gc->fg)); comma = 1; } - if (gc->bg != 8 || gc->flags & GRID_FLAG_BG256) { - if (gc->flags & GRID_FLAG_BG256) - c = gc->bg | 0x100; - else - c = gc->bg; + if (gc->bg != 8) { off += xsnprintf(s + off, sizeof s - off, "%sbg=%s", - comma ? "," : "", colour_tostring(c)); + comma ? "," : "", colour_tostring(gc->bg)); comma = 1; } @@ -177,9 +152,9 @@ value = o->num; if (strstr(name, "-bg") != NULL) - colour_set_bg(gc, value); + gc->bg = value; else if (strstr(name, "-fg") != NULL) - colour_set_fg(gc, value); + gc->fg = value; else if (strstr(name, "-attr") != NULL) gc->attr = value; } @@ -189,23 +164,15 @@ style_update_old(struct options *oo, const char *name, struct grid_cell *gc) { char newname[128]; - int c, size; + int size; size = strrchr(name, '-') - name; - if (gc->flags & GRID_FLAG_BG256) - c = gc->bg | 0x100; - else - c = gc->bg; xsnprintf(newname, sizeof newname, "%.*s-bg", size, name); - options_set_number(oo, newname, c); + options_set_number(oo, newname, gc->bg); - if (gc->flags & GRID_FLAG_FG256) - c = gc->fg | 0x100; - else - c = gc->fg; xsnprintf(newname, sizeof newname, "%.*s-fg", size, name); - options_set_number(oo, newname, c); + options_set_number(oo, newname, gc->fg); xsnprintf(newname, sizeof newname, "%.*s-attr", size, name); options_set_number(oo, newname, gc->attr); @@ -219,14 +186,8 @@ memcpy(gc, &grid_default_cell, sizeof *gc); gcp = options_get_style(oo, name); - if (gcp->flags & GRID_FLAG_FG256) - colour_set_fg(gc, gcp->fg | 0x100); - else - colour_set_fg(gc, gcp->fg); - if (gcp->flags & GRID_FLAG_BG256) - colour_set_bg(gc, gcp->bg | 0x100); - else - colour_set_bg(gc, gcp->bg); + gc->fg = gcp->fg; + gc->bg = gcp->bg; gc->attr |= gcp->attr; } @@ -237,18 +198,10 @@ struct grid_cell *gcp; gcp = options_get_style(oo, name); - if (gcp->fg != 8 || gcp->flags & GRID_FLAG_FG256) { - if (gcp->flags & GRID_FLAG_FG256) - colour_set_fg(gc, gcp->fg | 0x100); - else - colour_set_fg(gc, gcp->fg); - } - if (gcp->bg != 8 || gcp->flags & GRID_FLAG_BG256) { - if (gcp->flags & GRID_FLAG_BG256) - colour_set_bg(gc, gcp->bg | 0x100); - else - colour_set_bg(gc, gcp->bg); - } + if (gcp->fg != 8) + gc->fg = gcp->fg; + if (gcp->bg != 8) + gc->bg = gcp->bg; if (gcp->attr != 0) gc->attr |= gcp->attr; } @@ -257,10 +210,10 @@ int style_equal(const struct grid_cell *gc1, const struct grid_cell *gc2) { - return gc1->fg == gc2->fg && - gc1->bg == gc2->bg && - (gc1->flags & ~GRID_FLAG_PADDING) == - (gc2->flags & ~GRID_FLAG_PADDING) && - (gc1->attr & ~GRID_ATTR_CHARSET) == - (gc2->attr & ~GRID_ATTR_CHARSET); + return (gc1->fg == gc2->fg && + gc1->bg == gc2->bg && + (gc1->flags & ~GRID_FLAG_PADDING) == + (gc2->flags & ~GRID_FLAG_PADDING) && + (gc1->attr & ~GRID_ATTR_CHARSET) == + (gc2->attr & ~GRID_ATTR_CHARSET)); }