Use reverse rather than background which doesn't show up when terminal doesn't

support colours.
pull/1/head
Nicholas Marriott 2009-01-19 19:01:11 +00:00
parent 5e55b28d81
commit 94471aab82
4 changed files with 24 additions and 14 deletions

View File

@ -1,5 +1,7 @@
19 January 2009
* Use reverse attributes for clock and cursor, otherwise they do not
appear on black and white terminals.
* An error in a command sequence now stops execution of that sequence.
Internally, each command code now passes a return code back rather than
talking to the calling client (if any) directly.
@ -967,7 +969,7 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
$Id: CHANGES,v 1.222 2009-01-19 18:23:40 nicm Exp $
$Id: CHANGES,v 1.223 2009-01-19 19:01:11 nicm Exp $
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms

View File

@ -1,4 +1,4 @@
/* $Id: clock.c,v 1.1 2009-01-11 00:48:42 nicm Exp $ */
/* $Id: clock.c,v 1.2 2009-01-19 19:01:11 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@ -113,6 +113,7 @@ clock_draw(struct screen_write_ctx *ctx, u_int colour, int style)
screen_write_clearscreen(ctx);
memcpy(&gc, &grid_default_cell, sizeof gc);
gc.fg = colour;
if (screen_size_x(s) < 6 * strlen(tim) || screen_size_y(s) < 6) {
if (screen_size_x(s) >= strlen(tim) && screen_size_y(s) != 0) {
@ -149,9 +150,9 @@ clock_draw(struct screen_write_ctx *ctx, u_int colour, int style)
screen_write_cursormove(ctx, x, y + j);
for (i = 0; i < 5; i++) {
if (clock_table[idx][j][i])
gc.bg = colour;
gc.attr |= GRID_ATTR_REVERSE;
else
gc.bg = 0;
gc.attr &= ~GRID_ATTR_REVERSE;
screen_write_putc(ctx, &gc, ' ');
}
}

View File

@ -1,4 +1,4 @@
/* $Id: status.c,v 1.64 2009-01-17 18:47:37 nicm Exp $ */
/* $Id: status.c,v 1.65 2009-01-19 19:01:11 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -498,8 +498,8 @@ status_prompt_redraw(struct client *c)
ch = c->prompt_buffer[c->prompt_index];
if (ch == '\0')
ch = ' ';
gc.bg = gc.fg;
gc.fg = options_get_number(&s->options, "message-bg");
gc.bg = options_get_number(&s->options, "message-bg");
gc.attr |= GRID_ATTR_REVERSE;
screen_write_putc(&ctx, &gc, ch);
screen_write_stop(&ctx);

21
tty.c
View File

@ -1,4 +1,4 @@
/* $Id: tty.c,v 1.61 2009-01-18 21:46:30 nicm Exp $ */
/* $Id: tty.c,v 1.62 2009-01-19 19:01:11 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -753,6 +753,7 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc)
{
struct grid_cell *tc = &tty->cell;
u_char changed;
u_int fg, bg;
/* If any bits are being cleared, reset everything. */
if (tc->attr & ~gc->attr)
@ -763,6 +764,8 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc)
tc->attr = gc->attr;
/* Set the attributes. */
fg = gc->fg;
bg = gc->bg;
if (changed & GRID_ATTR_BRIGHT)
tty_putcode(tty, TTYC_BOLD);
if (changed & GRID_ATTR_DIM)
@ -773,25 +776,29 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc)
tty_putcode(tty, TTYC_SMUL);
if (changed & GRID_ATTR_BLINK)
tty_putcode(tty, TTYC_BLINK);
if (changed & GRID_ATTR_REVERSE)
tty_putcode(tty, TTYC_REV);
if (changed & GRID_ATTR_REVERSE) {
if (tty_term_has(tty->term, TTYC_REV))
tty_putcode(tty, TTYC_REV);
else if (tty_term_has(tty->term, TTYC_SMSO))
tty_putcode(tty, TTYC_SMSO);
}
if (changed & GRID_ATTR_HIDDEN)
tty_putcode(tty, TTYC_INVIS);
if (changed & GRID_ATTR_CHARSET)
tty_putcode(tty, TTYC_SMACS);
/* Set foreground colour. */
if (gc->fg != tc->fg ||
if (fg != tc->fg ||
(gc->flags & GRID_FLAG_FG256) != (tc->flags & GRID_FLAG_FG256)) {
tty_attributes_fg(tty, gc);
tc->fg = gc->fg;
tc->fg = fg;
}
/* Set background colour. */
if (gc->bg != tc->bg ||
if (bg != tc->bg ||
(gc->flags & GRID_FLAG_BG256) != (tc->flags & GRID_FLAG_BG256)) {
tty_attributes_bg(tty, gc);
tc->bg = gc->bg;
tc->bg = bg;
}
}