From 6f6f355bd3ce7f1ad3e8ff2d88fbb63f988f1da9 Mon Sep 17 00:00:00 2001 From: Werner LEMBERG Date: Wed, 13 Feb 2002 23:50:43 +0000 Subject: [PATCH] Don't use `CSI 39 m' and `CSI 49 m' but `CSI 0 m'. * src/devices/grotty/tty.cc (SGR_DEFAULT_COLOR, SGR_BACK_DEFAULT_COLOR): Replaced with ... (tty_printer::put_color): Use it. (ttr_printer::end_page): Simplify. --- ChangeLog | 9 +++++++++ src/devices/grotty/tty.cc | 42 ++++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 827200dd..751f1477 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2002-02-14 Werner LEMBERG + + Don't use `CSI 39 m' and `CSI 49 m' but `CSI 0 m'. + + * src/devices/grotty/tty.cc (SGR_DEFAULT_COLOR, + SGR_BACK_DEFAULT_COLOR): Replaced with ... + (tty_printer::put_color): Use it. + (ttr_printer::end_page): Simplify. + 2002-02-13 Werner LEMBERG * tmac/groff_tmac.man: Moved to... diff --git a/src/devices/grotty/tty.cc b/src/devices/grotty/tty.cc index 10f4d2e6..a2e82989 100644 --- a/src/devices/grotty/tty.cc +++ b/src/devices/grotty/tty.cc @@ -69,8 +69,10 @@ static unsigned char bold_underline_mode = BOLD_MODE|UNDERLINE_MODE; #define SGR_NO_ITALIC CSI "23m" #define SGR_UNDERLINE CSI "4m" #define SGR_NO_UNDERLINE CSI "24m" -#define SGR_DEFAULT_COLOR CSI "39m" -#define SGR_BACK_DEFAULT_COLOR CSI "49m" +// many terminals can't handle `CSI 39 m' and `CSI 49 m' to reset +// the foreground and bachground color, respectively; thus we use +// `CSI 0 m' exclusively +#define SGR_DEFAULT CSI "0m" #define TTY_MAX_COLORS 8 #define DEFAULT_COLOR_IDX TTY_MAX_COLORS @@ -429,8 +431,21 @@ void tty_printer::put_char(unsigned int wc) void tty_printer::put_color(unsigned char color_index, int back) { - if (color_index == DEFAULT_COLOR_IDX) - color_index = 9; + if (color_index == DEFAULT_COLOR_IDX) { + putstring(SGR_DEFAULT); + // set bold and underline again + if (is_bold) + putstring(SGR_BOLD); + if (is_underline) { + if (italic_flag) + putstring(SGR_ITALIC); + else + putstring(SGR_UNDERLINE); + } + // set other color again + back = !back; + color_index = back ? curr_back_idx : curr_fore_idx; + } putstring(CSI); if (back) putchar('4'); @@ -577,20 +592,11 @@ void tty_printer::end_page(int page_length) put_char(p->code); hpos++; } - if (!old_drawing_scheme) { - if (is_underline) { - if (italic_flag) - putstring(SGR_NO_ITALIC); - else - putstring(SGR_NO_UNDERLINE); - } - if (is_bold) - putstring(SGR_NO_BOLD); - if (curr_fore_idx != DEFAULT_COLOR_IDX) - putstring(SGR_DEFAULT_COLOR); - if (curr_back_idx != DEFAULT_COLOR_IDX) - putstring(SGR_BACK_DEFAULT_COLOR); - } + if (!old_drawing_scheme + && (is_bold || is_underline + || curr_fore_idx != DEFAULT_COLOR_IDX + || curr_back_idx != DEFAULT_COLOR_IDX)) + putstring(SGR_DEFAULT); putchar('\n'); } if (form_feed_flag) { -- 2.11.4.GIT