From 384372e6c859c2fde4b808cabe191a4f534e1f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 10 Sep 2017 02:13:34 +0200 Subject: [PATCH] backend support for SGR overline, bit 7 of attrib byte --- user/apars_csi.c | 20 +++++++++++--------- user/screen.h | 1 + user/sgr.h | 11 +++++++++++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/user/apars_csi.c b/user/apars_csi.c index 9d847a9..acccf48 100644 --- a/user/apars_csi.c +++ b/user/apars_csi.c @@ -552,7 +552,7 @@ do_csi_sgr(CSI_Data *opts) else if (n == SGR_FG_256 || n == SGR_BG_256) { if (i < count-2) { if (opts->n[i + 1] == 5) { - int color = opts->n[i + 2]; + u16 color = (u16) opts->n[i + 2]; bool fg = n == SGR_FG_256; if (fg) { screen_set_fg_ext(color); @@ -582,15 +582,17 @@ do_csi_sgr(CSI_Data *opts) else if (n == SGR_FRAKTUR) screen_set_sgr(ATTR_FRAKTUR, 1); else if (n == SGR_INVERSE) screen_set_sgr_inverse(1); else if (n == SGR_CONCEAL) screen_set_sgr_conceal(1); + else if (n == SGR_OVERLINE) screen_set_sgr(ATTR_OVERLINE, 1); // -- clear attr -- - else if (n == SGR_OFF(SGR_BOLD)) screen_set_sgr(ATTR_BOLD, 0); // can also mean "Double Underline" - else if (n == SGR_OFF(SGR_FAINT)) screen_set_sgr(ATTR_FAINT | ATTR_BOLD, 0); // "normal" - else if (n == SGR_OFF(SGR_ITALIC)) screen_set_sgr(ATTR_ITALIC | ATTR_FRAKTUR, 0); // there is no dedicated OFF code for Fraktur - else if (n == SGR_OFF(SGR_UNDERLINE)) screen_set_sgr(ATTR_UNDERLINE, 0); - else if (n == SGR_OFF(SGR_BLINK)) screen_set_sgr(ATTR_BLINK, 0); - else if (n == SGR_OFF(SGR_STRIKE)) screen_set_sgr(ATTR_STRIKE, 0); - else if (n == SGR_OFF(SGR_INVERSE)) screen_set_sgr_inverse(0); - else if (n == SGR_OFF(SGR_CONCEAL)) screen_set_sgr_conceal(0); + else if (n == SGR_NO_BOLD) screen_set_sgr(ATTR_BOLD, 0); // can also mean "Double Underline" + else if (n == SGR_NO_BOLD_FAINT) screen_set_sgr(ATTR_FAINT | ATTR_BOLD, 0); // "normal" + else if (n == SGR_NO_ITALIC_FRACTUR) screen_set_sgr(ATTR_ITALIC | ATTR_FRAKTUR, 0); // there is no dedicated OFF code for Fraktur + else if (n == SGR_NO_UNDERLINE) screen_set_sgr(ATTR_UNDERLINE, 0); + else if (n == SGR_NO_BLINK) screen_set_sgr(ATTR_BLINK, 0); + else if (n == SGR_NO_STRIKE) screen_set_sgr(ATTR_STRIKE, 0); + else if (n == SGR_NO_INVERSE) screen_set_sgr_inverse(0); + else if (n == SGR_NO_CONCEAL) screen_set_sgr_conceal(0); + else if (n == SGR_NO_OVERLINE) screen_set_sgr(ATTR_OVERLINE, 0); else { ansi_noimpl("SGR %d", n); } diff --git a/user/screen.h b/user/screen.h index 64be988..ba35209 100644 --- a/user/screen.h +++ b/user/screen.h @@ -230,6 +230,7 @@ typedef uint8_t Color; // 0-16 #define ATTR_BLINK (1<<4) #define ATTR_FRAKTUR (1<<5) #define ATTR_STRIKE (1<<6) +#define ATTR_OVERLINE (1<<7) /** Set cursor foreground color */ void screen_set_fg(Color color); diff --git a/user/sgr.h b/user/sgr.h index e4a086d..d55fcc9 100644 --- a/user/sgr.h +++ b/user/sgr.h @@ -17,6 +17,17 @@ enum SGR_CODES { SGR_CONCEAL = 8, SGR_STRIKE = 9, SGR_FRAKTUR = 20, + SGR_OVERLINE = 53, + + SGR_NO_BOLD = 21, + SGR_NO_BOLD_FAINT = 22, + SGR_NO_ITALIC_FRACTUR = 23, + SGR_NO_UNDERLINE = 24, + SGR_NO_BLINK = 25, + SGR_NO_INVERSE = 27, + SGR_NO_CONCEAL = 28, + SGR_NO_STRIKE = 29, + SGR_NO_OVERLINE = 55, SGR_FG_START = 30, SGR_FG_END = 37,