commit a56dc7a7f6f4cae9461921cf9253152a40cd7619
parent f3039ce531f49a63f8fd07317c1f957fb28fc6a7
Author: Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
Date: Wed, 18 Jan 2023 18:19:21 +0000
feat(tui): support altfont mode in tui.c
Diffstat:
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
@@ -137,6 +137,7 @@ struct TUIData {
int enable_bracketed_paste, disable_bracketed_paste;
int enable_lr_margin, disable_lr_margin;
int enter_strikethrough_mode;
+ int enter_altfont_mode;
int set_rgb_foreground, set_rgb_background;
int set_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.disable_bracketed_paste = -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.disable_lr_margin = -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 standout = attr & HL_STANDOUT;
bool strikethrough = attr & HL_STRIKETHROUGH;
+ bool altfont = attr & HL_ALTFONT;
bool underline;
bool undercurl;
@@ -590,6 +593,9 @@ static void update_attrs(TUIData *tui, int attr_id)
if (italic) {
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) {
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.
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
// capabilities, proposed by RĂ¼diger Sonderfeld on 2013-10-15. Adding
// them here when terminfo lacks them is an augmentation, not a fixup.