diff options
author | 2009-10-28 08:52:36 +0000 | |
---|---|---|
committer | 2009-10-28 08:52:36 +0000 | |
commit | 4963bffa67cf8097e634c069b6f9360779a1b03e (patch) | |
tree | 897beb2cfecf3c005c41a392ebf8046ee97391f9 /usr.bin/tmux/tty.c | |
parent | style(9) has all these fascist rules... (diff) | |
download | wireguard-openbsd-4963bffa67cf8097e634c069b6f9360779a1b03e.tar.xz wireguard-openbsd-4963bffa67cf8097e634c069b6f9360779a1b03e.zip |
Add a minor optimisatin: if the character being printed is space, don't worry
about setting the background colour or attributes (except reverse).
Diffstat (limited to 'usr.bin/tmux/tty.c')
-rw-r--r-- | usr.bin/tmux/tty.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index adb27046c77..64084468f39 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.62 2009/10/28 08:33:20 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.63 2009/10/28 08:52:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1119,10 +1119,24 @@ out: void tty_attributes(struct tty *tty, const struct grid_cell *gc) { - struct grid_cell *tc = &tty->cell; + struct grid_cell *tc = &tty->cell, gc2; u_char changed; u_int fg = gc->fg, bg = gc->bg, attr = gc->attr; + /* If the character is space, don't care about foreground. */ + if (gc->data == ' ' && !(gc->flags & GRID_FLAG_UTF8)) { + memcpy(&gc2, gc, sizeof gc2); + + if (gc->attr & GRID_ATTR_REVERSE) + gc2.bg = tc->bg; + else + gc2.fg = tc->fg; + gc2.attr = tc->attr & ~GRID_ATTR_REVERSE; + gc2.attr |= gc->attr & GRID_ATTR_REVERSE; + + gc = &gc2; + } + /* If any bits are being cleared, reset everything. */ if (tc->attr & ~attr) tty_reset(tty); @@ -1185,7 +1199,7 @@ tty_colours(struct tty *tty, const struct grid_cell *gc, int *attr) /* No changes? Nothing is necessary. */ if (fg == tc->fg && bg == tc->bg && ((flags ^ tc->flags) & (GRID_FLAG_FG256|GRID_FLAG_BG256)) == 0) - return; + return; /* * Is either the default colour? This is handled specially because the |