From 14b9462ae4168e18421a6c49d906fd1ae9abb778 Mon Sep 17 00:00:00 2001 From: Emanuele Giaquinta Date: Fri, 5 Dec 2008 13:55:23 +0000 Subject: [PATCH] Factor computation of fg/bg. git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4943 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-text/term-terminfo.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c index bc8a1868..ba1c2cbc 100644 --- a/src/fe-text/term-terminfo.c +++ b/src/fe-text/term-terminfo.c @@ -270,6 +270,8 @@ void term_window_scroll(TERM_WINDOW *window, int count) void term_set_color(TERM_WINDOW *window, int col) { int set_normal; + int fg = col & 0x0f; + int bg = (col & 0xf0) >> 4; set_normal = ((col & ATTR_RESETFG) && last_fg != -1) || ((col & ATTR_RESETBG) && last_bg != -1); @@ -297,10 +299,10 @@ void term_set_color(TERM_WINDOW *window, int col) terminfo_set_standout(FALSE); /* set foreground color */ - if ((col & 0x0f) != last_fg && - ((col & 0x0f) != 0 || (col & ATTR_RESETFG) == 0)) { + if (fg != last_fg && + (fg != 0 || (col & ATTR_RESETFG) == 0)) { if (term_use_colors) { - last_fg = col & 0x0f; + last_fg = fg; terminfo_set_fg(last_fg); } } @@ -311,10 +313,10 @@ void term_set_color(TERM_WINDOW *window, int col) if (col & ATTR_BLINK) current_term->set_blink(current_term); - if ((col & 0xf0) >> 4 != last_bg && - ((col & 0xf0) != 0 || (col & ATTR_RESETBG) == 0)) { + if (bg != last_bg && + (bg != 0 || (col & ATTR_RESETBG) == 0)) { if (term_use_colors) { - last_bg = (col & 0xf0) >> 4; + last_bg = bg; terminfo_set_bg(last_bg); } }