1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Merge pull request #82 from ailin-nemui/256colour-cleanup

fix compiler warnings in extended colour code
This commit is contained in:
Alexander Færøy 2014-07-06 19:58:26 +02:00
commit 2ff95c0649
5 changed files with 32 additions and 20 deletions

View File

@ -302,11 +302,6 @@ static int get_attr(int color)
} }
/* Change active 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) void term_set_color(TERM_WINDOW *window, int col)
{ {
wattrset(window->win, get_attr(col)); wattrset(window->win, get_attr(col));

View File

@ -305,7 +305,7 @@ inline static int term_putchar(int c)
/* copied from terminfo-core.c */ /* copied from terminfo-core.c */
int tputs(); 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]; static char buf[20];
const unsigned char color[] = { lc >> 16, lc >> 8, lc }; 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 #define COLOR_RESET UINT_MAX
/* Change active color */ /* Change active color */
#ifdef TERM_TRUECOLOR
void term_set_color2(TERM_WINDOW *window, int col, unsigned int fgcol24, unsigned int bgcol24) 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; int set_normal;
unsigned int fg = (col & ATTR_FGCOLOR24) ? fgcol24 << 8 : (col & FG_MASK); unsigned int fg =
unsigned int bg = (col & ATTR_BGCOLOR24) ? bgcol24 << 8 : ((col & BG_MASK) >> BG_SHIFT); #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) || set_normal = ((col & ATTR_RESETFG) && last_fg != COLOR_RESET) ||
((col & ATTR_RESETBG) && last_bg != 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) { if (term_use_colors) {
last_fg = fg; last_fg = fg;
if (!(fg & 0xff)) if (!(fg & 0xff))
term_set_color_24bit(0, last_fg >> 8); termctl_set_color_24bit(0, last_fg >> 8);
else else
terminfo_set_fg(last_fg); 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) { if (term_use_colors) {
last_bg = bg; last_bg = bg;
if (!(bg & 0xff)) if (!(bg & 0xff))
term_set_color_24bit(1, last_bg >> 8); termctl_set_color_24bit(1, last_bg >> 8);
else else
terminfo_set_bg(last_bg); 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 ); 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) void term_move(TERM_WINDOW *window, int x, int y)
{ {
if (x >= 0 && y >= 0) { if (x >= 0 && y >= 0) {

View File

@ -71,8 +71,13 @@ void term_window_clear(TERM_WINDOW *window);
/* Scroll window up/down */ /* Scroll window up/down */
void term_window_scroll(TERM_WINDOW *window, int count); 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); 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); void term_set_color(TERM_WINDOW *window, int col);
#endif
void term_move(TERM_WINDOW *window, int x, int y); void term_move(TERM_WINDOW *window, int x, int y);
void term_addch(TERM_WINDOW *window, char chr); void term_addch(TERM_WINDOW *window, char chr);

View File

@ -22,6 +22,7 @@
#include "module.h" #include "module.h"
#include "textbuffer-view.h" #include "textbuffer-view.h"
#include "signals.h"
#include "utf8.h" #include "utf8.h"
typedef struct { typedef struct {
@ -150,7 +151,7 @@ static void update_cmd_color(unsigned char cmd, int *color)
} }
#ifdef TERM_TRUECOLOR #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 int color;
unsigned char rgbx[4]; unsigned char rgbx[4];
@ -201,7 +202,7 @@ view_update_line_cache(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line)
unsigned char cmd; unsigned char cmd;
const unsigned char *ptr, *next_ptr, *last_space_ptr; const unsigned char *ptr, *next_ptr, *last_space_ptr;
int xpos, pos, indent_pos, last_space, last_color, color, linecount; 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; int char_width;
g_return_val_if_fail(line->text != NULL, NULL); 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; color = ATTR_RESETFG | ATTR_RESETBG;
xpos = 0; indent_pos = view->default_indent; xpos = 0; indent_pos = view->default_indent;
last_space = last_color = 0; last_space_ptr = NULL; sub = NULL; last_space = last_color = 0; last_space_ptr = NULL; sub = NULL;
last_bg24 = last_fg24 = UINT_MAX;
indent_func = view->default_indent_func; indent_func = view->default_indent_func;
linecount = 1; 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; const unsigned char *text, *end, *text_newline;
unsigned char *tmp; unsigned char *tmp;
unichar chr; 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 */ if (view->dirty) /* don't bother drawing anything - redraw is coming */
return 0; return 0;

View File

@ -16,7 +16,7 @@ typedef struct {
INDENT_FUNC indent_func; INDENT_FUNC indent_func;
int color; int color;
#ifdef TERM_TRUECOLOR #ifdef TERM_TRUECOLOR
int fg24, bg24; unsigned int fg24, bg24;
#endif #endif
/* first word in line belong to the end of the last word in /* first word in line belong to the end of the last word in