version 1.9, 2016/01/19 15:59:12 |
version 1.10, 2016/07/15 00:42:56 |
|
|
char tmp[32]; |
char tmp[32]; |
int val; |
int val; |
size_t end; |
size_t end; |
u_char fg, bg, attr, flags; |
int fg, bg; |
|
u_char attr, flags; |
|
|
if (*in == '\0') |
if (*in == '\0') |
return (0); |
return (0); |
|
|
fg = defgc->fg; |
fg = defgc->fg; |
bg = defgc->bg; |
bg = defgc->bg; |
attr = defgc->attr; |
attr = defgc->attr; |
flags &= ~(GRID_FLAG_FG256|GRID_FLAG_BG256); |
flags = defgc->flags; |
flags |= |
|
defgc->flags & (GRID_FLAG_FG256|GRID_FLAG_BG256); |
|
} else if (end > 3 && strncasecmp(tmp + 1, "g=", 2) == 0) { |
} else if (end > 3 && strncasecmp(tmp + 1, "g=", 2) == 0) { |
if ((val = colour_fromstring(tmp + 3)) == -1) |
if ((val = colour_fromstring(tmp + 3)) == -1) |
goto error; |
goto error; |
if (*in == 'f' || *in == 'F') { |
if (*in == 'f' || *in == 'F') { |
if (val != 8) { |
if (val != 8) |
if (val & 0x100) { |
|
flags |= GRID_FLAG_FG256; |
|
val &= ~0x100; |
|
} else |
|
flags &= ~GRID_FLAG_FG256; |
|
fg = val; |
fg = val; |
} else { |
else |
fg = defgc->fg; |
fg = defgc->fg; |
flags &= ~GRID_FLAG_FG256; |
|
flags |= defgc->flags & GRID_FLAG_FG256; |
|
} |
|
} else if (*in == 'b' || *in == 'B') { |
} else if (*in == 'b' || *in == 'B') { |
if (val != 8) { |
if (val != 8) |
if (val & 0x100) { |
|
flags |= GRID_FLAG_BG256; |
|
val &= ~0x100; |
|
} else |
|
flags &= ~GRID_FLAG_BG256; |
|
bg = val; |
bg = val; |
} else { |
else |
bg = defgc->bg; |
bg = defgc->bg; |
flags &= ~GRID_FLAG_BG256; |
|
flags |= defgc->flags & GRID_FLAG_BG256; |
|
} |
|
} else |
} else |
goto error; |
goto error; |
} else if (strcasecmp(tmp, "none") == 0) |
} else if (strcasecmp(tmp, "none") == 0) |
|
|
const char * |
const char * |
style_tostring(struct grid_cell *gc) |
style_tostring(struct grid_cell *gc) |
{ |
{ |
int c, off = 0, comma = 0; |
int off = 0, comma = 0; |
static char s[256]; |
static char s[256]; |
|
|
*s = '\0'; |
*s = '\0'; |
|
|
if (gc->fg != 8 || gc->flags & GRID_FLAG_FG256) { |
if (gc->fg != 8) { |
if (gc->flags & GRID_FLAG_FG256) |
off += xsnprintf(s, sizeof s, "fg=%s", colour_tostring(gc->fg)); |
c = gc->fg | 0x100; |
|
else |
|
c = gc->fg; |
|
off += xsnprintf(s, sizeof s, "fg=%s", colour_tostring(c)); |
|
comma = 1; |
comma = 1; |
} |
} |
|
|
if (gc->bg != 8 || gc->flags & GRID_FLAG_BG256) { |
if (gc->bg != 8) { |
if (gc->flags & GRID_FLAG_BG256) |
|
c = gc->bg | 0x100; |
|
else |
|
c = gc->bg; |
|
off += xsnprintf(s + off, sizeof s - off, "%sbg=%s", |
off += xsnprintf(s + off, sizeof s - off, "%sbg=%s", |
comma ? "," : "", colour_tostring(c)); |
comma ? "," : "", colour_tostring(gc->bg)); |
comma = 1; |
comma = 1; |
} |
} |
|
|
|
|
value = o->num; |
value = o->num; |
|
|
if (strstr(name, "-bg") != NULL) |
if (strstr(name, "-bg") != NULL) |
colour_set_bg(gc, value); |
gc->bg = value; |
else if (strstr(name, "-fg") != NULL) |
else if (strstr(name, "-fg") != NULL) |
colour_set_fg(gc, value); |
gc->fg = value; |
else if (strstr(name, "-attr") != NULL) |
else if (strstr(name, "-attr") != NULL) |
gc->attr = value; |
gc->attr = value; |
} |
} |
|
|
style_update_old(struct options *oo, const char *name, struct grid_cell *gc) |
style_update_old(struct options *oo, const char *name, struct grid_cell *gc) |
{ |
{ |
char newname[128]; |
char newname[128]; |
int c, size; |
int size; |
|
|
size = strrchr(name, '-') - name; |
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); |
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); |
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); |
xsnprintf(newname, sizeof newname, "%.*s-attr", size, name); |
options_set_number(oo, newname, gc->attr); |
options_set_number(oo, newname, gc->attr); |
|
|
|
|
memcpy(gc, &grid_default_cell, sizeof *gc); |
memcpy(gc, &grid_default_cell, sizeof *gc); |
gcp = options_get_style(oo, name); |
gcp = options_get_style(oo, name); |
if (gcp->flags & GRID_FLAG_FG256) |
gc->fg = gcp->fg; |
colour_set_fg(gc, gcp->fg | 0x100); |
gc->bg = gcp->bg; |
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->attr |= gcp->attr; |
gc->attr |= gcp->attr; |
} |
} |
|
|
|
|
struct grid_cell *gcp; |
struct grid_cell *gcp; |
|
|
gcp = options_get_style(oo, name); |
gcp = options_get_style(oo, name); |
if (gcp->fg != 8 || gcp->flags & GRID_FLAG_FG256) { |
if (gcp->fg != 8) |
if (gcp->flags & GRID_FLAG_FG256) |
gc->fg = gcp->fg; |
colour_set_fg(gc, gcp->fg | 0x100); |
if (gcp->bg != 8) |
else |
gc->bg = gcp->bg; |
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->attr != 0) |
if (gcp->attr != 0) |
gc->attr |= gcp->attr; |
gc->attr |= gcp->attr; |
} |
} |
|
|
int |
int |
style_equal(const struct grid_cell *gc1, const struct grid_cell *gc2) |
style_equal(const struct grid_cell *gc1, const struct grid_cell *gc2) |
{ |
{ |
return gc1->fg == gc2->fg && |
return (gc1->fg == gc2->fg && |
gc1->bg == gc2->bg && |
gc1->bg == gc2->bg && |
(gc1->flags & ~GRID_FLAG_PADDING) == |
(gc1->flags & ~GRID_FLAG_PADDING) == |
(gc2->flags & ~GRID_FLAG_PADDING) && |
(gc2->flags & ~GRID_FLAG_PADDING) && |
(gc1->attr & ~GRID_ATTR_CHARSET) == |
(gc1->attr & ~GRID_ATTR_CHARSET) == |
(gc2->attr & ~GRID_ATTR_CHARSET); |
(gc2->attr & ~GRID_ATTR_CHARSET)); |
} |
} |