Twaek this slightly to avoid confusing use of flags variable.

This commit is contained in:
Nicholas Marriott 2009-10-28 08:33:20 +00:00
parent eb5f4460d1
commit 5730cbf3e3
1 changed files with 9 additions and 10 deletions

19
tty.c
View File

@ -1179,14 +1179,13 @@ void
tty_colours(struct tty *tty, const struct grid_cell *gc, int *attr) tty_colours(struct tty *tty, const struct grid_cell *gc, int *attr)
{ {
struct grid_cell *tc = &tty->cell; struct grid_cell *tc = &tty->cell;
u_char fg = gc->fg, bg = gc->bg; u_char fg = gc->fg, bg = gc->bg, flags = gc->flags;
int flags, have_ax; int have_ax, fg_default, bg_default;
int fg_default, bg_default;
/* No changes? Nothing is necessary. */ /* No changes? Nothing is necessary. */
flags = (gc->flags ^ tc->flags) & (GRID_FLAG_FG256|GRID_FLAG_BG256); if (fg == tc->fg && bg == tc->bg &&
if (fg == tc->fg && bg == tc->bg && flags == 0) ((flags ^ tc->flags) & (GRID_FLAG_FG256|GRID_FLAG_BG256)) == 0)
return; return;
/* /*
* Is either the default colour? This is handled specially because the * Is either the default colour? This is handled specially because the
@ -1194,8 +1193,8 @@ tty_colours(struct tty *tty, const struct grid_cell *gc, int *attr)
* case if only one is default need to fall onward to set the other * case if only one is default need to fall onward to set the other
* colour. * colour.
*/ */
fg_default = (fg == 8 && !(gc->flags & GRID_FLAG_FG256)); fg_default = (fg == 8 && !(flags & GRID_FLAG_FG256));
bg_default = (bg == 8 && !(gc->flags & GRID_FLAG_BG256)); bg_default = (bg == 8 && !(flags & GRID_FLAG_BG256));
if (fg_default || bg_default) { if (fg_default || bg_default) {
/* /*
* If don't have AX but do have op, send sgr0 (op can't * If don't have AX but do have op, send sgr0 (op can't
@ -1231,7 +1230,7 @@ tty_colours(struct tty *tty, const struct grid_cell *gc, int *attr)
/* Set the foreground colour. */ /* Set the foreground colour. */
if (!fg_default && (fg != tc->fg || if (!fg_default && (fg != tc->fg ||
((gc->flags & GRID_FLAG_FG256) != (tc->flags & GRID_FLAG_FG256)))) ((flags & GRID_FLAG_FG256) != (tc->flags & GRID_FLAG_FG256))))
tty_colours_fg(tty, gc, attr); tty_colours_fg(tty, gc, attr);
/* /*
@ -1239,7 +1238,7 @@ tty_colours(struct tty *tty, const struct grid_cell *gc, int *attr)
* tty_colour_fg() can call tty_reset(). * tty_colour_fg() can call tty_reset().
*/ */
if (!bg_default && (bg != tc->bg || if (!bg_default && (bg != tc->bg ||
((gc->flags & GRID_FLAG_BG256) != (tc->flags & GRID_FLAG_BG256)))) ((flags & GRID_FLAG_BG256) != (tc->flags & GRID_FLAG_BG256))))
tty_colours_bg(tty, gc, attr); tty_colours_bg(tty, gc, attr);
} }