diff options
author | Emanuele Giaquinta <exg@irssi.org> | 2008-11-15 21:51:07 +0000 |
---|---|---|
committer | exg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2008-11-15 21:51:07 +0000 |
commit | 621761cff31437baa2a154e95c6f2461c3bcaf23 (patch) | |
tree | 45f8d6f3cede9a1307acb0a3bc55d97f634021ce | |
parent | efe2bad59043ab0489a1cc2daf227713a50b6ccc (diff) | |
download | irssi-621761cff31437baa2a154e95c6f2461c3bcaf23.zip |
Handle bold/blink attributes like other attributes rather than mapping them to
the eighth bit of the color. The formats KBGCRMYW and the mirc colors are now
mapped to colors 8-15. fe-text translates colors 8-15 to bold/blink+0-7 if the
terminal supports only 8 colors.
git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4909 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | src/fe-common/core/formats.c | 14 | ||||
-rw-r--r-- | src/fe-text/term-terminfo.c | 4 | ||||
-rw-r--r-- | src/fe-text/term.h | 2 | ||||
-rw-r--r-- | src/fe-text/textbuffer-view.c | 14 | ||||
-rw-r--r-- | src/fe-text/textbuffer.c | 59 | ||||
-rw-r--r-- | src/fe-text/textbuffer.h | 9 |
7 files changed, 45 insertions, 62 deletions
@@ -1,4 +1,9 @@ v0.8.13 + + Add support for 16 colors. Formats KBGCRMYW and mirc colors are now + mapped to colors 8-15. fe-text translates colors 8-15 to bold/blink+0-7 + if the terminal supports only 8 colors. If your theme uses one of + the high color formats and you really want bold you can change + %FMT<string> to %fmt%_<string>%_, it will work fine in all irssi versions. + Revert recode changes introduced in 0.8.12. + Add completion for /WINDOW SERVER. + Support for reading kicks/msgs from TARGMAX/MAXTARGETS 005 tokens. diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c index e6a1e0ad..4830090a 100644 --- a/src/fe-common/core/formats.c +++ b/src/fe-common/core/formats.c @@ -1052,13 +1052,6 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text) default: if (*ptr != FORMAT_COLOR_NOCHANGE) { fgcolor = (unsigned char) *ptr-'0'; - if (fgcolor <= 7) - flags &= ~GUI_PRINT_FLAG_BOLD; - else { - /* bold */ - if (fgcolor != 8) fgcolor -= 8; - flags |= GUI_PRINT_FLAG_BOLD; - } } if (ptr[1] == '\0') break; @@ -1066,13 +1059,6 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text) ptr++; if (*ptr != FORMAT_COLOR_NOCHANGE) { bgcolor = *ptr-'0'; - if (bgcolor <= 7) - flags &= ~GUI_PRINT_FLAG_BLINK; - else { - /* blink */ - bgcolor -= 8; - flags |= GUI_PRINT_FLAG_BLINK; - } } } ptr++; diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c index 7cf61e20..bc8a1868 100644 --- a/src/fe-text/term-terminfo.c +++ b/src/fe-text/term-terminfo.c @@ -306,7 +306,7 @@ void term_set_color(TERM_WINDOW *window, int col) } /* set background color */ - if (col & 0x80) + if (col & 0x80 && window->term->TI_colors == 8) col |= ATTR_BLINK; if (col & ATTR_BLINK) current_term->set_blink(current_term); @@ -320,7 +320,7 @@ void term_set_color(TERM_WINDOW *window, int col) } /* bold */ - if (col & 0x08) + if (col & 0x08 && window->term->TI_colors == 8) col |= ATTR_BOLD; if (col & ATTR_BOLD) terminfo_set_bold(); diff --git a/src/fe-text/term.h b/src/fe-text/term.h index 2334edaf..d0cc637f 100644 --- a/src/fe-text/term.h +++ b/src/fe-text/term.h @@ -13,7 +13,7 @@ typedef struct _TERM_WINDOW TERM_WINDOW; #define ATTR_RESET (ATTR_RESETFG|ATTR_RESETBG) -#define ATTR_NOCOLORS (ATTR_UNDERLINE|ATTR_REVERSE) +#define ATTR_NOCOLORS (ATTR_UNDERLINE|ATTR_REVERSE|ATTR_BLINK|ATTR_BOLD) /* terminal types */ #define TERM_TYPE_8BIT 0 /* normal 8bit text */ diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c index 59411b01..9960911c 100644 --- a/src/fe-text/textbuffer-view.c +++ b/src/fe-text/textbuffer-view.c @@ -104,8 +104,8 @@ static void textbuffer_cache_unref(TEXT_BUFFER_CACHE_REC *cache) textbuffer_cache_destroy(cache); } -#define FGATTR (ATTR_NOCOLORS | ATTR_RESETFG | ATTR_BOLD | 0x0f) -#define BGATTR (ATTR_NOCOLORS | ATTR_RESETBG | ATTR_BLINK | 0xf0) +#define FGATTR (ATTR_NOCOLORS | ATTR_RESETFG | 0x0f) +#define BGATTR (ATTR_NOCOLORS | ATTR_RESETBG | 0xf0) static void update_cmd_color(unsigned char cmd, int *color) { @@ -117,8 +117,6 @@ static void update_cmd_color(unsigned char cmd, int *color) *color |= (cmd & 0x0f) << 4; else { *color = (*color & FGATTR) | ATTR_RESETBG; - if (cmd & LINE_COLOR_BLINK) - *color |= ATTR_BLINK; } } else { /* set foreground color */ @@ -127,8 +125,6 @@ static void update_cmd_color(unsigned char cmd, int *color) *color |= cmd & 0x0f; else { *color = (*color & BGATTR) | ATTR_RESETFG; - if (cmd & LINE_COLOR_BOLD) - *color |= ATTR_BOLD; } } } else switch (cmd) { @@ -138,6 +134,12 @@ static void update_cmd_color(unsigned char cmd, int *color) case LINE_CMD_REVERSE: *color ^= ATTR_REVERSE; break; + case LINE_CMD_BLINK: + *color ^= ATTR_BLINK; + break; + case LINE_CMD_BOLD: + *color ^= ATTR_BOLD; + break; case LINE_CMD_COLOR0: *color &= BGATTR; break; diff --git a/src/fe-text/textbuffer.c b/src/fe-text/textbuffer.c index 4cccb924..5a5a6b5c 100644 --- a/src/fe-text/textbuffer.c +++ b/src/fe-text/textbuffer.c @@ -246,10 +246,6 @@ void textbuffer_line_add_colors(TEXT_BUFFER_REC *buffer, LINE_REC **line, /* get the fg & bg command chars */ fg = fg < 0 ? LINE_COLOR_DEFAULT : fg & 0x0f; bg = LINE_COLOR_BG | (bg < 0 ? LINE_COLOR_DEFAULT : bg & 0x0f); - if (flags & GUI_PRINT_FLAG_BOLD) - fg |= LINE_COLOR_BOLD; - if (flags & GUI_PRINT_FLAG_BLINK) - bg |= LINE_COLOR_BLINK; pos = 0; if (fg != buffer->last_fg) { @@ -271,6 +267,14 @@ void textbuffer_line_add_colors(TEXT_BUFFER_REC *buffer, LINE_REC **line, data[pos++] = 0; data[pos++] = LINE_CMD_REVERSE; } + if ((flags & GUI_PRINT_FLAG_BLINK) != (buffer->last_flags & GUI_PRINT_FLAG_BLINK)) { + data[pos++] = 0; + data[pos++] = LINE_CMD_BLINK; + } + if ((flags & GUI_PRINT_FLAG_BOLD) != (buffer->last_flags & GUI_PRINT_FLAG_BOLD)) { + data[pos++] = 0; + data[pos++] = LINE_CMD_BOLD; + } if (flags & GUI_PRINT_FLAG_INDENT) { data[pos++] = 0; data[pos++] = LINE_CMD_INDENT; @@ -371,54 +375,33 @@ void textbuffer_remove_all_lines(TEXT_BUFFER_REC *buffer) buffer->last_eol = TRUE; } -static void set_color(GString *str, int cmd, int *last_fg, int *last_bg) +static void set_color(GString *str, int cmd) { - if (cmd & LINE_COLOR_DEFAULT) { - g_string_sprintfa(str, "\004%c", FORMAT_STYLE_DEFAULTS); - - /* need to reset the fg/bg color */ - if (cmd & LINE_COLOR_BG) { - *last_bg = -1; - if (*last_fg != -1) { - g_string_sprintfa(str, "\004%c%c", - *last_fg, - FORMAT_COLOR_NOCHANGE); - } - } else { - *last_fg = -1; - if (*last_bg != -1) { - g_string_sprintfa(str, "\004%c%c", - FORMAT_COLOR_NOCHANGE, - *last_bg); - } - } - return; - } + int color = -1; + + if (!(cmd & LINE_COLOR_DEFAULT)) + color = (cmd & 0x0f)+'0'; if ((cmd & LINE_COLOR_BG) == 0) { /* change foreground color */ - *last_fg = (cmd & 0x0f)+'0'; - g_string_sprintfa(str, "\004%c%c", *last_fg, - FORMAT_COLOR_NOCHANGE); + g_string_sprintfa(str, "\004%c%c", + color, FORMAT_COLOR_NOCHANGE); } else { /* change background color */ - *last_bg = (cmd & 0x0f)+'0'; g_string_sprintfa(str, "\004%c%c", - FORMAT_COLOR_NOCHANGE, *last_bg); + FORMAT_COLOR_NOCHANGE, color); } } void textbuffer_line2text(LINE_REC *line, int coloring, GString *str) { unsigned char cmd, *ptr, *tmp; - int last_fg, last_bg; g_return_if_fail(line != NULL); g_return_if_fail(str != NULL); g_string_truncate(str, 0); - last_fg = last_bg = -1; for (ptr = line->text;;) { if (*ptr != 0) { g_string_append_c(str, (char) *ptr); @@ -449,7 +432,7 @@ void textbuffer_line2text(LINE_REC *line, int coloring, GString *str) if ((cmd & 0x80) == 0) { /* set color */ - set_color(str, cmd, &last_fg, &last_bg); + set_color(str, cmd); } else switch (cmd) { case LINE_CMD_UNDERLINE: g_string_append_c(str, 31); @@ -457,6 +440,14 @@ void textbuffer_line2text(LINE_REC *line, int coloring, GString *str) case LINE_CMD_REVERSE: g_string_append_c(str, 22); break; + case LINE_CMD_BLINK: + g_string_sprintfa(str, "\004%c", + FORMAT_STYLE_BLINK); + break; + case LINE_CMD_BOLD: + g_string_sprintfa(str, "\004%c", + FORMAT_STYLE_BOLD); + break; case LINE_CMD_COLOR0: g_string_sprintfa(str, "\004%c%c", '0', FORMAT_COLOR_NOCHANGE); diff --git a/src/fe-text/textbuffer.h b/src/fe-text/textbuffer.h index 92001723..52935981 100644 --- a/src/fe-text/textbuffer.h +++ b/src/fe-text/textbuffer.h @@ -7,8 +7,6 @@ #define LINE_COLOR_BG 0x20 #define LINE_COLOR_DEFAULT 0x10 -#define LINE_COLOR_BOLD 0x08 -#define LINE_COLOR_BLINK 0x08 enum { LINE_CMD_EOL=0x80, /* line ends here */ @@ -22,7 +20,9 @@ enum { text in format <module><format_name><arg><arg2...> - fields are separated with \0<format> and last argument ends with \0<eol>. \0<continue> is allowed anywhere */ - LINE_CMD_FORMAT_CONT /* multiline format, continues to next line */ + LINE_CMD_FORMAT_CONT, /* multiline format, continues to next line */ + LINE_CMD_BLINK, /* enable/disable blink */ + LINE_CMD_BOLD, /* enable/disable bold */ }; typedef struct { @@ -40,8 +40,7 @@ typedef struct _LINE_REC { Bit: 5 - Setting a background color 4 - Use "default terminal color" - 3 - Bold (fg) / blink (bg) - can be used with 4th bit - 0-2 - Color + 0-3 - Color DO NOT ADD BLACK WITH \0\0 - this will break things. Use LINE_CMD_COLOR0 instead. */ |