Sync OpenBSD patchset 322:

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".
This commit is contained in:
Tiago Cunha
2009-09-11 14:13:52 +00:00
parent f0cb57d8ac
commit 0ec1ce005c
13 changed files with 136 additions and 73 deletions

View File

@ -1,4 +1,4 @@
/* $Id: screen-write.c,v 1.71 2009-09-07 23:37:48 tcunha Exp $ */
/* $Id: screen-write.c,v 1.72 2009-09-11 14:13:52 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -300,7 +300,7 @@ screen_write_parsestyle(
char tmp[32];
int val;
size_t end;
u_char fg, bg, attr;
u_char fg, bg, attr, flags;
if (*in == '\0')
return;
@ -309,7 +309,8 @@ screen_write_parsestyle(
fg = gc->fg;
bg = gc->bg;
attr = 0;
attr = gc->attr;
flags = gc->flags;
do {
end = strcspn(in, delimiters);
if (end > (sizeof tmp) - 1)
@ -325,14 +326,24 @@ screen_write_parsestyle(
if ((val = colour_fromstring(tmp + 3)) == -1)
return;
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;
else
} else
fg = defgc->fg;
} 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;
else
} else
bg = defgc->bg;
} else
return;
@ -347,6 +358,7 @@ screen_write_parsestyle(
gc->fg = fg;
gc->bg = bg;
gc->attr = attr;
gc->flags = flags;
}
/* Copy from another screen. */
@ -1002,7 +1014,8 @@ screen_write_cell(
if (screen_check_selection(s, s->cx - width, s->cy)) {
memcpy(&tmp_gc2, &s->sel.cell, sizeof tmp_gc2);
tmp_gc2.data = gc->data;
tmp_gc2.flags = gc->flags;
tmp_gc2.flags = gc->flags & ~(GRID_FLAG_FG256|GRID_FLAG_BG256);
tmp_gc2.flags |= s->sel.cell.flags & (GRID_FLAG_FG256|GRID_FLAG_BG256);
ttyctx.cell = &tmp_gc2;
tty_write(tty_cmd_cell, &ttyctx);
} else {