summaryrefslogtreecommitdiff
path: root/src/fe-text/textbuffer.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-10-28 11:30:26 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-10-28 11:30:26 +0000
commit2ba339a26bc02bf4caa92e735ba79bd0dcc76a9f (patch)
treec5bdd6b1e1dfe58f3f7cc279cbdf9392578c699a /src/fe-text/textbuffer.c
parent8567481fd058a9f66c76a55e02305c97153b7588 (diff)
downloadirssi-2ba339a26bc02bf4caa92e735ba79bd0dcc76a9f.zip
Added support for using terminfo/termcap instead of curses. By default,
configure chooses to use ncurses if found, of terminfo if only curses was found. --with-terminfo parameter can be used to specify if you want it or not. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1924 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-text/textbuffer.c')
-rw-r--r--src/fe-text/textbuffer.c50
1 files changed, 40 insertions, 10 deletions
diff --git a/src/fe-text/textbuffer.c b/src/fe-text/textbuffer.c
index f99aacca..b08e6fec 100644
--- a/src/fe-text/textbuffer.c
+++ b/src/fe-text/textbuffer.c
@@ -340,16 +340,55 @@ 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)
+{
+ 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;
+ }
+
+ 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);
+ } else {
+ /* change background color */
+ *last_bg = (cmd & 0x0f)+'0';
+ g_string_sprintfa(str, "\004%c%c",
+ FORMAT_COLOR_NOCHANGE, *last_bg);
+ }
+}
+
void textbuffer_line2text(LINE_REC *line, int coloring, GString *str)
{
unsigned char cmd;
char *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, *ptr);
@@ -380,9 +419,7 @@ void textbuffer_line2text(LINE_REC *line, int coloring, GString *str)
if ((cmd & 0x80) == 0) {
/* set color */
- g_string_sprintfa(str, "\004%c%c",
- (cmd & 0x0f)+'0',
- ((cmd & 0xf0) >> 4)+'0');
+ set_color(str, cmd, &last_fg, &last_bg);
} else switch (cmd) {
case LINE_CMD_UNDERLINE:
g_string_append_c(str, 31);
@@ -394,13 +431,6 @@ void textbuffer_line2text(LINE_REC *line, int coloring, GString *str)
g_string_sprintfa(str, "\004%c%c",
'0', FORMAT_COLOR_NOCHANGE);
break;
- case LINE_CMD_COLOR8:
- g_string_sprintfa(str, "\004%c%c",
- '8', FORMAT_COLOR_NOCHANGE);
- break;
- case LINE_CMD_BLINK:
- g_string_sprintfa(str, "\004%c", FORMAT_STYLE_BLINK);
- break;
case LINE_CMD_INDENT:
break;
case LINE_CMD_INDENT_FUNC: