diff options
author | Tom Feist <shabble@metavore.org> | 2011-05-03 15:40:34 +0100 |
---|---|---|
committer | Ailin Nemui <ailin@esf51.localdomain> | 2014-06-30 00:54:16 +0200 |
commit | 2d4edc51877719c49d712271967313310f4796fb (patch) | |
tree | a427b451338dd0e7b27b462a971528acdfbaca4d /src/fe-text/gui-printtext.c | |
parent | 2e6f16c0faf345245c5a224de529827a51203d1c (diff) | |
download | irssi-2d4edc51877719c49d712271967313310f4796fb.zip |
Initial implementation of 256 colour support for Irssi
This patch implements some 256 colour support for Irssi up from the
previous 16 colours. Initial parsing of the %x/%X format codes is
implemented and the parser accounts in advances the char* for
that.
The colour attributes are widened from 4 to 8 bit. The colour protocol
is changed to a new format. Some pointers to remaining work are
written in the comment in textbuffer.h.
Note that Irssi already does support requesting 256 colours from the
terminal in the original source code, so this part did not have to be
touched.
Diffstat (limited to 'src/fe-text/gui-printtext.c')
-rw-r--r-- | src/fe-text/gui-printtext.c | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/src/fe-text/gui-printtext.c b/src/fe-text/gui-printtext.c index 76b116d8..556fae1b 100644 --- a/src/fe-text/gui-printtext.c +++ b/src/fe-text/gui-printtext.c @@ -146,24 +146,43 @@ static void remove_old_lines(TEXT_BUFFER_VIEW_REC *view) static void get_colors(int flags, int *fg, int *bg, int *attr) { if (flags & GUI_PRINT_FLAG_MIRC_COLOR) { + g_message( "getcolor: handling mirc colors\n"); + /* mirc colors - real range is 0..15, but after 16 colors wrap to 0, 1, ... */ if (*bg >= 0) *bg = mirc_colors[*bg % 16]; if (*fg >= 0) *fg = mirc_colors[*fg % 16]; + /* TODO: What to do here? */ if (settings_get_bool("mirc_blink_fix")) *bg &= ~0x08; } - if (*fg < 0 || *fg > 15) + if (*fg < 0 || *fg > 255) { + g_message( "getcolor: fg %d outside range, setting to -1\n", *fg); *fg = -1; - if (*bg < 0 || *bg > 15) + } + if (*bg < 0 || *bg > 255) { + g_message( "getcolor: bf %d outside range, setting to -1\n", *bg); *bg = -1; + } *attr = 0; - if (flags & GUI_PRINT_FLAG_REVERSE) *attr |= ATTR_REVERSE; - if (flags & GUI_PRINT_FLAG_BOLD) *attr |= ATTR_BOLD; - if (flags & GUI_PRINT_FLAG_UNDERLINE) *attr |= ATTR_UNDERLINE; - if (flags & GUI_PRINT_FLAG_BLINK) *attr |= ATTR_BLINK; + if (flags & GUI_PRINT_FLAG_REVERSE) { + *attr |= ATTR_REVERSE; + g_message( "getcolor: setting flag_reverse\n"); + } + if (flags & GUI_PRINT_FLAG_BOLD) { + *attr |= ATTR_BOLD; + g_message( "getcolor: setting flag_bold\n"); + } + if (flags & GUI_PRINT_FLAG_UNDERLINE) { + *attr |= ATTR_UNDERLINE; + g_message( "getcolor: setting flag_underline\n"); + } + if (flags & GUI_PRINT_FLAG_BLINK) { + *attr |= ATTR_BLINK; + g_message( "getcolor: setting flag_blink\n"); + } } static void view_add_eol(TEXT_BUFFER_VIEW_REC *view, LINE_REC **line) @@ -184,16 +203,32 @@ static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor, LINE_INFO_REC lineinfo; int fg, bg, flags, attr; + attr = 0; + flags = GPOINTER_TO_INT(pflags); fg = GPOINTER_TO_INT(fgcolor); bg = GPOINTER_TO_INT(bgcolor); + + g_message( "SGPT str: '%s'\n", str); + + + g_message( "SGPT start: fg: %d (%02x), bg: %d (%02x) attr: %d (%04x), flags: %d (0x%04x)\n", + fg, fg, bg, bg, attr, attr, flags, flags); + get_colors(flags, &fg, &bg, &attr); + g_message( "SGPT getcol: fg: %d (%02x), bg: %d (%02x) attr: %d (%04x)\n", + fg, fg, (bg << 8), (bg << 8), attr, attr); + if (window == NULL) { g_return_if_fail(next_xpos != -1); attr |= fg >= 0 ? fg : ATTR_RESETFG; - attr |= bg >= 0 ? (bg << 4) : ATTR_RESETBG; + attr |= bg >= 0 ? (bg << 8) : ATTR_RESETBG; + g_message( + "SGPT nowin: fg: %d (%02x), bg: %d (%02x) attr: %d (%04x)\n", + fg, fg, (bg << 8), (bg << 8), attr, attr); + term_set_color(root_window, attr); term_move(root_window, next_xpos, next_ypos); |