diff --git a/src/fe-text/term-curses.c b/src/fe-text/term-curses.c index f1ee3131..fd24bbe3 100644 --- a/src/fe-text/term-curses.c +++ b/src/fe-text/term-curses.c @@ -302,11 +302,6 @@ static int get_attr(int color) } /* Change active color */ -void term_set_color2(TERM_WINDOW *window, int col, unsigned int fg_ignore, unsigned int bg_ignore) -{ - term_set_color(window, col); -} - void term_set_color(TERM_WINDOW *window, int col) { wattrset(window->win, get_attr(col)); diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c index 2ca2f347..3aecabb7 100644 --- a/src/fe-text/term-terminfo.c +++ b/src/fe-text/term-terminfo.c @@ -305,7 +305,7 @@ inline static int term_putchar(int c) /* copied from terminfo-core.c */ int tputs(); -static int term_set_color_24bit(int bg, unsigned int lc) +static int termctl_set_color_24bit(int bg, unsigned int lc) { static char buf[20]; const unsigned char color[] = { lc >> 16, lc >> 8, lc }; @@ -326,12 +326,25 @@ static int term_set_color_24bit(int bg, unsigned int lc) #define COLOR_RESET UINT_MAX /* Change active color */ +#ifdef TERM_TRUECOLOR void term_set_color2(TERM_WINDOW *window, int col, unsigned int fgcol24, unsigned int bgcol24) +#else +void term_set_color(TERM_WINDOW *window, int col) +#endif { int set_normal; - unsigned int fg = (col & ATTR_FGCOLOR24) ? fgcol24 << 8 : (col & FG_MASK); - unsigned int bg = (col & ATTR_BGCOLOR24) ? bgcol24 << 8 : ((col & BG_MASK) >> BG_SHIFT); + unsigned int fg = +#ifdef TERM_TRUECOLOR + (col & ATTR_FGCOLOR24) ? fgcol24 << 8 : +#endif + (col & FG_MASK); + + unsigned int bg = +#ifdef TERM_TRUECOLOR + (col & ATTR_BGCOLOR24) ? bgcol24 << 8 : +#endif + ((col & BG_MASK) >> BG_SHIFT); set_normal = ((col & ATTR_RESETFG) && last_fg != COLOR_RESET) || ((col & ATTR_RESETBG) && last_bg != COLOR_RESET); @@ -364,7 +377,7 @@ void term_set_color2(TERM_WINDOW *window, int col, unsigned int fgcol24, unsigne if (term_use_colors) { last_fg = fg; if (!(fg & 0xff)) - term_set_color_24bit(0, last_fg >> 8); + termctl_set_color_24bit(0, last_fg >> 8); else terminfo_set_fg(last_fg); } @@ -381,7 +394,7 @@ void term_set_color2(TERM_WINDOW *window, int col, unsigned int fgcol24, unsigne if (term_use_colors) { last_bg = bg; if (!(bg & 0xff)) - term_set_color_24bit(1, last_bg >> 8); + termctl_set_color_24bit(1, last_bg >> 8); else terminfo_set_bg(last_bg); } @@ -404,12 +417,6 @@ void term_set_color2(TERM_WINDOW *window, int col, unsigned int fgcol24, unsigne last_attrs = col & ~( BG_MASK | FG_MASK ); } -void term_set_color(TERM_WINDOW *window, int col) -{ - term_set_color2(window, col &~(ATTR_FGCOLOR24|ATTR_BGCOLOR24), UINT_MAX, UINT_MAX); -} - - void term_move(TERM_WINDOW *window, int x, int y) { if (x >= 0 && y >= 0) { diff --git a/src/fe-text/term.h b/src/fe-text/term.h index e5f66644..05a31573 100644 --- a/src/fe-text/term.h +++ b/src/fe-text/term.h @@ -71,8 +71,13 @@ void term_window_clear(TERM_WINDOW *window); /* Scroll window up/down */ void term_window_scroll(TERM_WINDOW *window, int count); +#ifdef TERM_TRUECOLOR +#define term_set_color(window, col) term_set_color2(window, (col) &~(ATTR_FGCOLOR24|ATTR_BGCOLOR24), UINT_MAX, UINT_MAX) void term_set_color2(TERM_WINDOW *window, int col, unsigned int fgcol24, unsigned int bgcol24); +#else +#define term_set_color2(window, col, unused1, unused2) term_set_color(window, col) void term_set_color(TERM_WINDOW *window, int col); +#endif void term_move(TERM_WINDOW *window, int x, int y); void term_addch(TERM_WINDOW *window, char chr); diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c index 81deaf54..c878fc57 100644 --- a/src/fe-text/textbuffer-view.c +++ b/src/fe-text/textbuffer-view.c @@ -22,6 +22,7 @@ #include "module.h" #include "textbuffer-view.h" +#include "signals.h" #include "utf8.h" typedef struct { @@ -150,7 +151,7 @@ static void update_cmd_color(unsigned char cmd, int *color) } #ifdef TERM_TRUECOLOR -static void unformat_24bit_line_color(const unsigned char **ptr, int off, int *flags, int *fg, int *bg) +static void unformat_24bit_line_color(const unsigned char **ptr, int off, int *flags, unsigned int *fg, unsigned int *bg) { unsigned int color; unsigned char rgbx[4]; @@ -201,7 +202,7 @@ view_update_line_cache(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line) unsigned char cmd; const unsigned char *ptr, *next_ptr, *last_space_ptr; int xpos, pos, indent_pos, last_space, last_color, color, linecount; - int last_bg24, last_fg24, bg24, fg24; + unsigned int last_bg24, last_fg24, bg24, fg24; int char_width; g_return_val_if_fail(line->text != NULL, NULL); @@ -209,6 +210,7 @@ view_update_line_cache(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line) color = ATTR_RESETFG | ATTR_RESETBG; xpos = 0; indent_pos = view->default_indent; last_space = last_color = 0; last_space_ptr = NULL; sub = NULL; + last_bg24 = last_fg24 = UINT_MAX; indent_func = view->default_indent_func; linecount = 1; @@ -387,7 +389,10 @@ static int view_line_draw(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line, const unsigned char *text, *end, *text_newline; unsigned char *tmp; unichar chr; - int xpos, color, fg24, bg24, drawcount, first, need_move, need_clrtoeol, char_width; + int xpos, color, drawcount, first, need_move, need_clrtoeol, char_width; +#ifdef TERM_TRUECOLOR + unsigned int fg24, bg24; +#endif if (view->dirty) /* don't bother drawing anything - redraw is coming */ return 0; diff --git a/src/fe-text/textbuffer-view.h b/src/fe-text/textbuffer-view.h index 48cba093..ab6786e0 100644 --- a/src/fe-text/textbuffer-view.h +++ b/src/fe-text/textbuffer-view.h @@ -16,7 +16,7 @@ typedef struct { INDENT_FUNC indent_func; int color; #ifdef TERM_TRUECOLOR - int fg24, bg24; + unsigned int fg24, bg24; #endif /* first word in line belong to the end of the last word in