mirror of
https://github.com/tmux/tmux.git
synced 2025-01-14 12:48:56 +00:00
Sync OpenBSD patchset 220:
If colours are not supported by the terminal, try to emulate a coloured background by setting or clearing the reverse attribute. This makes a few applications which don't use the reverse attribute themselves a little happier, and allows the status, message and mode options to have default attributes and fg/bg options that work as expected when set as reverse.
This commit is contained in:
parent
65a28912eb
commit
88b83be07b
14
status.c
14
status.c
@ -1,4 +1,4 @@
|
||||
/* $Id: status.c,v 1.107 2009-07-30 21:14:04 tcunha Exp $ */
|
||||
/* $Id: status.c,v 1.108 2009-08-09 16:50:57 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -64,8 +64,8 @@ status_redraw(struct client *c)
|
||||
if (gettimeofday(&c->status_timer, NULL) != 0)
|
||||
fatal("gettimeofday");
|
||||
memcpy(&stdgc, &grid_default_cell, sizeof gc);
|
||||
stdgc.bg = options_get_number(&s->options, "status-fg");
|
||||
stdgc.fg = options_get_number(&s->options, "status-bg");
|
||||
stdgc.fg = options_get_number(&s->options, "status-fg");
|
||||
stdgc.bg = options_get_number(&s->options, "status-bg");
|
||||
stdgc.attr |= options_get_number(&s->options, "status-attr");
|
||||
|
||||
yy = c->tty.sy - 1;
|
||||
@ -563,8 +563,8 @@ status_message_redraw(struct client *c)
|
||||
len = c->tty.sx;
|
||||
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
gc.bg = options_get_number(&s->options, "message-fg");
|
||||
gc.fg = options_get_number(&s->options, "message-bg");
|
||||
gc.fg = options_get_number(&s->options, "message-fg");
|
||||
gc.bg = options_get_number(&s->options, "message-bg");
|
||||
gc.attr |= options_get_number(&s->options, "message-attr");
|
||||
|
||||
screen_write_start(&ctx, NULL, &c->status);
|
||||
@ -662,8 +662,8 @@ status_prompt_redraw(struct client *c)
|
||||
len = c->tty.sx;
|
||||
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
gc.bg = options_get_number(&s->options, "message-fg");
|
||||
gc.fg = options_get_number(&s->options, "message-bg");
|
||||
gc.fg = options_get_number(&s->options, "message-fg");
|
||||
gc.bg = options_get_number(&s->options, "message-bg");
|
||||
gc.attr |= options_get_number(&s->options, "message-attr");
|
||||
|
||||
screen_write_start(&ctx, NULL, &c->status);
|
||||
|
8
tmux.c
8
tmux.c
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.c,v 1.155 2009-08-09 16:39:40 tcunha Exp $ */
|
||||
/* $Id: tmux.c,v 1.156 2009-08-09 16:50:57 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -354,7 +354,7 @@ main(int argc, char **argv)
|
||||
options_set_number(&global_s_options, "display-time", 750);
|
||||
options_set_number(&global_s_options, "history-limit", 2000);
|
||||
options_set_number(&global_s_options, "lock-after-time", 0);
|
||||
options_set_number(&global_s_options, "message-attr", GRID_ATTR_REVERSE);
|
||||
options_set_number(&global_s_options, "message-attr", 0);
|
||||
options_set_number(&global_s_options, "message-bg", 3);
|
||||
options_set_number(&global_s_options, "message-fg", 0);
|
||||
options_set_number(&global_s_options, "prefix", '\002');
|
||||
@ -362,7 +362,7 @@ main(int argc, char **argv)
|
||||
options_set_number(&global_s_options, "set-remain-on-exit", 0);
|
||||
options_set_number(&global_s_options, "set-titles", 0);
|
||||
options_set_number(&global_s_options, "status", 1);
|
||||
options_set_number(&global_s_options, "status-attr", GRID_ATTR_REVERSE);
|
||||
options_set_number(&global_s_options, "status-attr", 0);
|
||||
options_set_number(&global_s_options, "status-bg", 2);
|
||||
options_set_number(&global_s_options, "status-fg", 0);
|
||||
options_set_number(&global_s_options, "status-interval", 15);
|
||||
@ -392,7 +392,7 @@ main(int argc, char **argv)
|
||||
options_set_number(&global_w_options, "force-width", 0);
|
||||
options_set_number(&global_w_options, "main-pane-width", 81);
|
||||
options_set_number(&global_w_options, "main-pane-height", 24);
|
||||
options_set_number(&global_w_options, "mode-attr", GRID_ATTR_REVERSE);
|
||||
options_set_number(&global_w_options, "mode-attr", 0);
|
||||
options_set_number(&global_w_options, "mode-bg", 3);
|
||||
options_set_number(&global_w_options, "mode-fg", 0);
|
||||
options_set_number(&global_w_options, "mode-keys", MODEKEY_EMACS);
|
||||
|
28
tty.c
28
tty.c
@ -1,4 +1,4 @@
|
||||
/* $Id: tty.c,v 1.120 2009-08-09 15:26:24 tcunha Exp $ */
|
||||
/* $Id: tty.c,v 1.121 2009-08-09 16:50:57 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -961,19 +961,33 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc)
|
||||
{
|
||||
struct grid_cell *tc = &tty->cell;
|
||||
u_char changed;
|
||||
u_int fg, bg;
|
||||
u_int fg, bg, attr;
|
||||
|
||||
/*
|
||||
* If no setab, try to use the reverse attribute as a best-effort for a
|
||||
* non-default background. This is a bit of a hack but it doesn't do
|
||||
* any serious harm and makes a couple of applications happier.
|
||||
*/
|
||||
fg = gc->fg; bg = gc->bg; attr = gc->attr;
|
||||
if (!tty_term_has(tty->term, TTYC_SETAB)) {
|
||||
if (attr & GRID_ATTR_REVERSE) {
|
||||
if (fg != 7 && fg != 8)
|
||||
attr &= ~GRID_ATTR_REVERSE;
|
||||
} else {
|
||||
if (bg != 0 && bg != 8)
|
||||
attr |= GRID_ATTR_REVERSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* If any bits are being cleared, reset everything. */
|
||||
if (tc->attr & ~gc->attr)
|
||||
if (tc->attr & ~attr)
|
||||
tty_reset(tty);
|
||||
|
||||
/* Filter out attribute bits already set. */
|
||||
changed = gc->attr & ~tc->attr;
|
||||
tc->attr = gc->attr;
|
||||
changed = attr & ~tc->attr;
|
||||
tc->attr = 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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: window-choose.c,v 1.21 2009-07-30 20:32:05 tcunha Exp $ */
|
||||
/* $Id: window-choose.c,v 1.22 2009-08-09 16:50:57 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -305,8 +305,8 @@ window_choose_write_line(
|
||||
utf8flag = options_get_number(&wp->window->options, "utf8");
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
if (data->selected == data->top + py) {
|
||||
gc.fg = options_get_number(&wp->window->options, "mode-bg");
|
||||
gc.bg = options_get_number(&wp->window->options, "mode-fg");
|
||||
gc.fg = options_get_number(&wp->window->options, "mode-fg");
|
||||
gc.bg = options_get_number(&wp->window->options, "mode-bg");
|
||||
gc.attr |= options_get_number(&wp->window->options, "mode-attr");
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: window-copy.c,v 1.72 2009-07-30 20:32:05 tcunha Exp $ */
|
||||
/* $Id: window-copy.c,v 1.73 2009-08-09 16:50:57 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -264,8 +264,8 @@ window_copy_write_line(struct window_pane *wp, struct screen_write_ctx *ctx, u_i
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
size = xsnprintf(hdr, sizeof hdr,
|
||||
"[%u,%u/%u]", data->ox, data->oy, screen_hsize(&wp->base));
|
||||
gc.bg = options_get_number(&wp->window->options, "mode-fg");
|
||||
gc.fg = options_get_number(&wp->window->options, "mode-bg");
|
||||
gc.fg = options_get_number(&wp->window->options, "mode-fg");
|
||||
gc.bg = options_get_number(&wp->window->options, "mode-bg");
|
||||
gc.attr |= options_get_number(&wp->window->options, "mode-attr");
|
||||
screen_write_cursormove(ctx, screen_size_x(s) - size, 0);
|
||||
screen_write_puts(ctx, &gc, "%s", hdr);
|
||||
@ -368,8 +368,8 @@ window_copy_update_selection(struct window_pane *wp)
|
||||
|
||||
/* Set colours. */
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
gc.bg = options_get_number(&wp->window->options, "mode-fg");
|
||||
gc.fg = options_get_number(&wp->window->options, "mode-bg");
|
||||
gc.fg = options_get_number(&wp->window->options, "mode-fg");
|
||||
gc.bg = options_get_number(&wp->window->options, "mode-bg");
|
||||
gc.attr |= options_get_number(&wp->window->options, "mode-attr");
|
||||
|
||||
/* Find top-left of screen. */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: window-more.c,v 1.35 2009-07-28 23:11:18 tcunha Exp $ */
|
||||
/* $Id: window-more.c,v 1.36 2009-08-09 16:50:57 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -176,8 +176,8 @@ window_more_write_line(
|
||||
size = xsnprintf(hdr, sizeof hdr,
|
||||
"[%u/%u]", data->top, ARRAY_LENGTH(&data->list));
|
||||
screen_write_cursormove(ctx, screen_size_x(s) - size, 0);
|
||||
gc.bg = options_get_number(&wp->window->options, "mode-fg");
|
||||
gc.fg = options_get_number(&wp->window->options, "mode-bg");
|
||||
gc.fg = options_get_number(&wp->window->options, "mode-fg");
|
||||
gc.bg = options_get_number(&wp->window->options, "mode-bg");
|
||||
gc.attr |= options_get_number(&wp->window->options, "mode-attr");
|
||||
screen_write_puts(ctx, &gc, "%s", hdr);
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: window-scroll.c,v 1.37 2009-07-28 23:11:18 tcunha Exp $ */
|
||||
/* $Id: window-scroll.c,v 1.38 2009-08-09 16:50:57 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -176,8 +176,8 @@ window_scroll_write_line(
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
size = xsnprintf(hdr, sizeof hdr,
|
||||
"[%u,%u/%u]", data->ox, data->oy, screen_hsize(&wp->base));
|
||||
gc.bg = options_get_number(&wp->window->options, "mode-fg");
|
||||
gc.fg = options_get_number(&wp->window->options, "mode-bg");
|
||||
gc.fg = options_get_number(&wp->window->options, "mode-fg");
|
||||
gc.bg = options_get_number(&wp->window->options, "mode-bg");
|
||||
gc.attr |= options_get_number(&wp->window->options, "mode-attr");
|
||||
screen_write_cursormove(ctx, screen_size_x(s) - size, 0);
|
||||
screen_write_puts(ctx, &gc, "%s", hdr);
|
||||
|
Loading…
Reference in New Issue
Block a user