summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Hauwaerts <geert@hauwaerts.be>2014-07-24 21:52:01 +0200
committerGeert Hauwaerts <geert@hauwaerts.be>2014-07-24 21:52:01 +0200
commit924f26144887552af4f4b459c29ccfda31c7bb77 (patch)
treec113e88027098d2effb37d1e8436b659d803739b
parente7f83c1dd2743a8f4f0d240f4550d6f52e6250c0 (diff)
parent1cf7017ac9a46ffbd85caf697beed234f2cda7fd (diff)
downloadirssi-924f26144887552af4f4b459c29ccfda31c7bb77.zip
Merge pull request #111 from ailin-nemui/colour-break
fix colour 0 again
-rw-r--r--src/fe-text/term-terminfo.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c
index 529faeb9..b13426d1 100644
--- a/src/fe-text/term-terminfo.c
+++ b/src/fe-text/term-terminfo.c
@@ -324,6 +324,7 @@ static int termctl_set_color_24bit(int bg, unsigned int lc)
}
#define COLOR_RESET UINT_MAX
+#define COLOR_BLACK24 COLOR_RESET - 1
/* Change active color */
#ifdef TERM_TRUECOLOR
@@ -334,17 +335,26 @@ void term_set_color(TERM_WINDOW *window, int col)
{
int set_normal;
- unsigned int fg =
+ unsigned int fg, bg;
#ifdef TERM_TRUECOLOR
- (col & ATTR_FGCOLOR24) ? fgcol24 << 8 :
+ if (col & ATTR_FGCOLOR24) {
+ if (fgcol24)
+ fg = fgcol24 << 8;
+ else
+ fg = COLOR_BLACK24;
+ } else
#endif
- (col & FG_MASK);
+ fg = (col & FG_MASK);
- unsigned int bg =
#ifdef TERM_TRUECOLOR
- (col & ATTR_BGCOLOR24) ? bgcol24 << 8 :
+ if (col & ATTR_BGCOLOR24) {
+ if (bgcol24)
+ bg = bgcol24 << 8;
+ else
+ bg = COLOR_BLACK24;
+ } else
#endif
- ((col & BG_MASK) >> BG_SHIFT);
+ bg = ((col & BG_MASK) >> BG_SHIFT);
if (!term_use_colors && bg > 0)
col |= ATTR_REVERSE;
@@ -370,8 +380,10 @@ void term_set_color(TERM_WINDOW *window, int col)
(fg != 0 || (col & ATTR_RESETFG) == 0)) {
if (term_use_colors) {
last_fg = fg;
- if (fg && !(fg & 0xff))
- termctl_set_color_24bit(0, last_fg >> 8);
+ if (fg >> 8)
+ termctl_set_color_24bit(0,
+ last_fg == COLOR_BLACK24 ? 0
+ : last_fg >> 8);
else
terminfo_set_fg(last_fg);
}
@@ -387,8 +399,10 @@ void term_set_color(TERM_WINDOW *window, int col)
(bg != 0 || (col & ATTR_RESETBG) == 0)) {
if (term_use_colors) {
last_bg = bg;
- if (bg && !(bg & 0xff))
- termctl_set_color_24bit(1, last_bg >> 8);
+ if (bg >> 8)
+ termctl_set_color_24bit(1,
+ last_bg == COLOR_BLACK24 ? 0
+ : last_bg >> 8);
else
terminfo_set_bg(last_bg);
}