feat(tui): support altfont mode in tui.c

This commit is contained in:
Paul "LeoNerd" Evans
2023-01-18 18:19:21 +00:00
parent f3039ce531
commit a56dc7a7f6

View File

@@ -137,6 +137,7 @@ struct TUIData {
int enable_bracketed_paste, disable_bracketed_paste; int enable_bracketed_paste, disable_bracketed_paste;
int enable_lr_margin, disable_lr_margin; int enable_lr_margin, disable_lr_margin;
int enter_strikethrough_mode; int enter_strikethrough_mode;
int enter_altfont_mode;
int set_rgb_foreground, set_rgb_background; int set_rgb_foreground, set_rgb_background;
int set_cursor_color; int set_cursor_color;
int reset_cursor_color; int reset_cursor_color;
@@ -251,6 +252,7 @@ static void terminfo_start(TUIData *tui)
tui->unibi_ext.enable_bracketed_paste = -1; tui->unibi_ext.enable_bracketed_paste = -1;
tui->unibi_ext.disable_bracketed_paste = -1; tui->unibi_ext.disable_bracketed_paste = -1;
tui->unibi_ext.enter_strikethrough_mode = -1; tui->unibi_ext.enter_strikethrough_mode = -1;
tui->unibi_ext.enter_altfont_mode = -1;
tui->unibi_ext.enable_lr_margin = -1; tui->unibi_ext.enable_lr_margin = -1;
tui->unibi_ext.disable_lr_margin = -1; tui->unibi_ext.disable_lr_margin = -1;
tui->unibi_ext.enable_focus_reporting = -1; tui->unibi_ext.enable_focus_reporting = -1;
@@ -531,6 +533,7 @@ static void update_attrs(TUIData *tui, int attr_id)
bool reverse = attr & HL_INVERSE; bool reverse = attr & HL_INVERSE;
bool standout = attr & HL_STANDOUT; bool standout = attr & HL_STANDOUT;
bool strikethrough = attr & HL_STRIKETHROUGH; bool strikethrough = attr & HL_STRIKETHROUGH;
bool altfont = attr & HL_ALTFONT;
bool underline; bool underline;
bool undercurl; bool undercurl;
@@ -590,6 +593,9 @@ static void update_attrs(TUIData *tui, int attr_id)
if (italic) { if (italic) {
unibi_out(tui, unibi_enter_italics_mode); unibi_out(tui, unibi_enter_italics_mode);
} }
if (altfont && tui->unibi_ext.enter_altfont_mode != -1) {
unibi_out_ext(tui, tui->unibi_ext.enter_altfont_mode);
}
if (strikethrough && tui->unibi_ext.enter_strikethrough_mode != -1) { if (strikethrough && tui->unibi_ext.enter_strikethrough_mode != -1) {
unibi_out_ext(tui, tui->unibi_ext.enter_strikethrough_mode); unibi_out_ext(tui, tui->unibi_ext.enter_strikethrough_mode);
} }
@@ -2038,6 +2044,11 @@ static void augment_terminfo(TUIData *tui, const char *term, long vte_version, l
// to the ECMA-48 strikeout/crossed-out attributes. // to the ECMA-48 strikeout/crossed-out attributes.
tui->unibi_ext.enter_strikethrough_mode = unibi_find_ext_str(ut, "smxx"); tui->unibi_ext.enter_strikethrough_mode = unibi_find_ext_str(ut, "smxx");
// It should be pretty safe to always enable this, as terminals will ignore
// unrecognised SGR numbers.
tui->unibi_ext.enter_altfont_mode = (int)unibi_add_ext_str(ut, "ext.enter_altfont_mode",
"\x1b[11m");
// Dickey ncurses terminfo does not include the setrgbf and setrgbb // Dickey ncurses terminfo does not include the setrgbf and setrgbb
// capabilities, proposed by Rüdiger Sonderfeld on 2013-10-15. Adding // capabilities, proposed by Rüdiger Sonderfeld on 2013-10-15. Adding
// them here when terminfo lacks them is an augmentation, not a fixup. // them here when terminfo lacks them is an augmentation, not a fixup.