mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05:00
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
This commit is contained in:
parent
efe2bad590
commit
621761cff3
5
NEWS
5
NEWS
@ -1,4 +1,9 @@
|
|||||||
v0.8.13
|
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.
|
+ Revert recode changes introduced in 0.8.12.
|
||||||
+ Add completion for /WINDOW SERVER.
|
+ Add completion for /WINDOW SERVER.
|
||||||
+ Support for reading kicks/msgs from TARGMAX/MAXTARGETS 005 tokens.
|
+ Support for reading kicks/msgs from TARGMAX/MAXTARGETS 005 tokens.
|
||||||
|
@ -1052,13 +1052,6 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text)
|
|||||||
default:
|
default:
|
||||||
if (*ptr != FORMAT_COLOR_NOCHANGE) {
|
if (*ptr != FORMAT_COLOR_NOCHANGE) {
|
||||||
fgcolor = (unsigned char) *ptr-'0';
|
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')
|
if (ptr[1] == '\0')
|
||||||
break;
|
break;
|
||||||
@ -1066,13 +1059,6 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text)
|
|||||||
ptr++;
|
ptr++;
|
||||||
if (*ptr != FORMAT_COLOR_NOCHANGE) {
|
if (*ptr != FORMAT_COLOR_NOCHANGE) {
|
||||||
bgcolor = *ptr-'0';
|
bgcolor = *ptr-'0';
|
||||||
if (bgcolor <= 7)
|
|
||||||
flags &= ~GUI_PRINT_FLAG_BLINK;
|
|
||||||
else {
|
|
||||||
/* blink */
|
|
||||||
bgcolor -= 8;
|
|
||||||
flags |= GUI_PRINT_FLAG_BLINK;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptr++;
|
ptr++;
|
||||||
|
@ -306,7 +306,7 @@ void term_set_color(TERM_WINDOW *window, int col)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* set background color */
|
/* set background color */
|
||||||
if (col & 0x80)
|
if (col & 0x80 && window->term->TI_colors == 8)
|
||||||
col |= ATTR_BLINK;
|
col |= ATTR_BLINK;
|
||||||
if (col & ATTR_BLINK)
|
if (col & ATTR_BLINK)
|
||||||
current_term->set_blink(current_term);
|
current_term->set_blink(current_term);
|
||||||
@ -320,7 +320,7 @@ void term_set_color(TERM_WINDOW *window, int col)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* bold */
|
/* bold */
|
||||||
if (col & 0x08)
|
if (col & 0x08 && window->term->TI_colors == 8)
|
||||||
col |= ATTR_BOLD;
|
col |= ATTR_BOLD;
|
||||||
if (col & ATTR_BOLD)
|
if (col & ATTR_BOLD)
|
||||||
terminfo_set_bold();
|
terminfo_set_bold();
|
||||||
|
@ -13,7 +13,7 @@ typedef struct _TERM_WINDOW TERM_WINDOW;
|
|||||||
|
|
||||||
#define ATTR_RESET (ATTR_RESETFG|ATTR_RESETBG)
|
#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 */
|
/* terminal types */
|
||||||
#define TERM_TYPE_8BIT 0 /* normal 8bit text */
|
#define TERM_TYPE_8BIT 0 /* normal 8bit text */
|
||||||
|
@ -104,8 +104,8 @@ static void textbuffer_cache_unref(TEXT_BUFFER_CACHE_REC *cache)
|
|||||||
textbuffer_cache_destroy(cache);
|
textbuffer_cache_destroy(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FGATTR (ATTR_NOCOLORS | ATTR_RESETFG | ATTR_BOLD | 0x0f)
|
#define FGATTR (ATTR_NOCOLORS | ATTR_RESETFG | 0x0f)
|
||||||
#define BGATTR (ATTR_NOCOLORS | ATTR_RESETBG | ATTR_BLINK | 0xf0)
|
#define BGATTR (ATTR_NOCOLORS | ATTR_RESETBG | 0xf0)
|
||||||
|
|
||||||
static void update_cmd_color(unsigned char cmd, int *color)
|
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;
|
*color |= (cmd & 0x0f) << 4;
|
||||||
else {
|
else {
|
||||||
*color = (*color & FGATTR) | ATTR_RESETBG;
|
*color = (*color & FGATTR) | ATTR_RESETBG;
|
||||||
if (cmd & LINE_COLOR_BLINK)
|
|
||||||
*color |= ATTR_BLINK;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* set foreground color */
|
/* set foreground color */
|
||||||
@ -127,8 +125,6 @@ static void update_cmd_color(unsigned char cmd, int *color)
|
|||||||
*color |= cmd & 0x0f;
|
*color |= cmd & 0x0f;
|
||||||
else {
|
else {
|
||||||
*color = (*color & BGATTR) | ATTR_RESETFG;
|
*color = (*color & BGATTR) | ATTR_RESETFG;
|
||||||
if (cmd & LINE_COLOR_BOLD)
|
|
||||||
*color |= ATTR_BOLD;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else switch (cmd) {
|
} else switch (cmd) {
|
||||||
@ -138,6 +134,12 @@ static void update_cmd_color(unsigned char cmd, int *color)
|
|||||||
case LINE_CMD_REVERSE:
|
case LINE_CMD_REVERSE:
|
||||||
*color ^= ATTR_REVERSE;
|
*color ^= ATTR_REVERSE;
|
||||||
break;
|
break;
|
||||||
|
case LINE_CMD_BLINK:
|
||||||
|
*color ^= ATTR_BLINK;
|
||||||
|
break;
|
||||||
|
case LINE_CMD_BOLD:
|
||||||
|
*color ^= ATTR_BOLD;
|
||||||
|
break;
|
||||||
case LINE_CMD_COLOR0:
|
case LINE_CMD_COLOR0:
|
||||||
*color &= BGATTR;
|
*color &= BGATTR;
|
||||||
break;
|
break;
|
||||||
|
@ -246,10 +246,6 @@ void textbuffer_line_add_colors(TEXT_BUFFER_REC *buffer, LINE_REC **line,
|
|||||||
/* get the fg & bg command chars */
|
/* get the fg & bg command chars */
|
||||||
fg = fg < 0 ? LINE_COLOR_DEFAULT : fg & 0x0f;
|
fg = fg < 0 ? LINE_COLOR_DEFAULT : fg & 0x0f;
|
||||||
bg = LINE_COLOR_BG | (bg < 0 ? LINE_COLOR_DEFAULT : bg & 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;
|
pos = 0;
|
||||||
if (fg != buffer->last_fg) {
|
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++] = 0;
|
||||||
data[pos++] = LINE_CMD_REVERSE;
|
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) {
|
if (flags & GUI_PRINT_FLAG_INDENT) {
|
||||||
data[pos++] = 0;
|
data[pos++] = 0;
|
||||||
data[pos++] = LINE_CMD_INDENT;
|
data[pos++] = LINE_CMD_INDENT;
|
||||||
@ -371,54 +375,33 @@ void textbuffer_remove_all_lines(TEXT_BUFFER_REC *buffer)
|
|||||||
buffer->last_eol = TRUE;
|
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) {
|
int color = -1;
|
||||||
g_string_sprintfa(str, "\004%c", FORMAT_STYLE_DEFAULTS);
|
|
||||||
|
|
||||||
/* need to reset the fg/bg color */
|
if (!(cmd & LINE_COLOR_DEFAULT))
|
||||||
if (cmd & LINE_COLOR_BG) {
|
color = (cmd & 0x0f)+'0';
|
||||||
*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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((cmd & LINE_COLOR_BG) == 0) {
|
if ((cmd & LINE_COLOR_BG) == 0) {
|
||||||
/* change foreground color */
|
/* change foreground color */
|
||||||
*last_fg = (cmd & 0x0f)+'0';
|
g_string_sprintfa(str, "\004%c%c",
|
||||||
g_string_sprintfa(str, "\004%c%c", *last_fg,
|
color, FORMAT_COLOR_NOCHANGE);
|
||||||
FORMAT_COLOR_NOCHANGE);
|
|
||||||
} else {
|
} else {
|
||||||
/* change background color */
|
/* change background color */
|
||||||
*last_bg = (cmd & 0x0f)+'0';
|
|
||||||
g_string_sprintfa(str, "\004%c%c",
|
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)
|
void textbuffer_line2text(LINE_REC *line, int coloring, GString *str)
|
||||||
{
|
{
|
||||||
unsigned char cmd, *ptr, *tmp;
|
unsigned char cmd, *ptr, *tmp;
|
||||||
int last_fg, last_bg;
|
|
||||||
|
|
||||||
g_return_if_fail(line != NULL);
|
g_return_if_fail(line != NULL);
|
||||||
g_return_if_fail(str != NULL);
|
g_return_if_fail(str != NULL);
|
||||||
|
|
||||||
g_string_truncate(str, 0);
|
g_string_truncate(str, 0);
|
||||||
|
|
||||||
last_fg = last_bg = -1;
|
|
||||||
for (ptr = line->text;;) {
|
for (ptr = line->text;;) {
|
||||||
if (*ptr != 0) {
|
if (*ptr != 0) {
|
||||||
g_string_append_c(str, (char) *ptr);
|
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) {
|
if ((cmd & 0x80) == 0) {
|
||||||
/* set color */
|
/* set color */
|
||||||
set_color(str, cmd, &last_fg, &last_bg);
|
set_color(str, cmd);
|
||||||
} else switch (cmd) {
|
} else switch (cmd) {
|
||||||
case LINE_CMD_UNDERLINE:
|
case LINE_CMD_UNDERLINE:
|
||||||
g_string_append_c(str, 31);
|
g_string_append_c(str, 31);
|
||||||
@ -457,6 +440,14 @@ void textbuffer_line2text(LINE_REC *line, int coloring, GString *str)
|
|||||||
case LINE_CMD_REVERSE:
|
case LINE_CMD_REVERSE:
|
||||||
g_string_append_c(str, 22);
|
g_string_append_c(str, 22);
|
||||||
break;
|
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:
|
case LINE_CMD_COLOR0:
|
||||||
g_string_sprintfa(str, "\004%c%c",
|
g_string_sprintfa(str, "\004%c%c",
|
||||||
'0', FORMAT_COLOR_NOCHANGE);
|
'0', FORMAT_COLOR_NOCHANGE);
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
#define LINE_COLOR_BG 0x20
|
#define LINE_COLOR_BG 0x20
|
||||||
#define LINE_COLOR_DEFAULT 0x10
|
#define LINE_COLOR_DEFAULT 0x10
|
||||||
#define LINE_COLOR_BOLD 0x08
|
|
||||||
#define LINE_COLOR_BLINK 0x08
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
LINE_CMD_EOL=0x80, /* line ends here */
|
LINE_CMD_EOL=0x80, /* line ends here */
|
||||||
@ -22,7 +20,9 @@ enum {
|
|||||||
text in format <module><format_name><arg><arg2...> - fields are separated
|
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
|
with \0<format> and last argument ends with \0<eol>. \0<continue> is allowed
|
||||||
anywhere */
|
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 {
|
typedef struct {
|
||||||
@ -40,8 +40,7 @@ typedef struct _LINE_REC {
|
|||||||
Bit:
|
Bit:
|
||||||
5 - Setting a background color
|
5 - Setting a background color
|
||||||
4 - Use "default terminal color"
|
4 - Use "default terminal color"
|
||||||
3 - Bold (fg) / blink (bg) - can be used with 4th bit
|
0-3 - Color
|
||||||
0-2 - Color
|
|
||||||
|
|
||||||
DO NOT ADD BLACK WITH \0\0 - this will break things. Use
|
DO NOT ADD BLACK WITH \0\0 - this will break things. Use
|
||||||
LINE_CMD_COLOR0 instead. */
|
LINE_CMD_COLOR0 instead. */
|
||||||
|
Loading…
Reference in New Issue
Block a user