1
0
forked from aniani/vim

patch 9.1.0030: Cannot use terminal alternate font

Problem:  Cannot use terminal alternate fonts (PMunch)
Solution: Support terminal alternate fonts using
          CSI SGR 10-20 and t_CF code (PMunch)

Add support for alternate font highlighting

This adds support for alternate font highlighting using CSI SGR 10-20.
Few terminals currently support this, but with added tool support this
should improve over time. The change here is more or less taken from how
colors are configured and applied, but there might be some parts I
missed while implementing it. Changing fonts is done through the new
`:hi ctermfont` attribute which takes a number, 0 is the normal font, and
the numbers 1-9 select an "alternative" font. Which fonts are in use is
up to the terminal.

fixes: #13513
closes: #13537

Signed-off-by: PMunch <peterme@peterme.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
PMunch
2023-11-15 15:35:49 +01:00
committed by Christian Brabandt
parent eb3475df0d
commit a606f3ac03
13 changed files with 130 additions and 8 deletions

View File

@@ -625,7 +625,7 @@ static tcap_entry_T builtin_kitty[] = {
#ifdef FEAT_TERMGUICOLORS
/*
* Additions for using the RGB colors
* Additions for using the RGB colors and terminal font
*/
static tcap_entry_T builtin_rgb[] = {
// These are printf strings, not terminal codes.
@@ -637,6 +637,12 @@ static tcap_entry_T builtin_rgb[] = {
};
#endif
static tcap_entry_T special_term[] = {
// These are printf strings, not terminal codes.
{(int)KS_CF, "\033[%dm"},
{(int)KS_NAME, NULL} // end marker
};
/*
* iris-ansi for Silicon Graphics machines.
*/
@@ -1235,6 +1241,7 @@ static tcap_entry_T builtin_debug[] = {
{(int)KS_U7, "[U7]"},
{(int)KS_RFG, "[RFG]"},
{(int)KS_RBG, "[RBG]"},
{(int)KS_CF, "[CF%d]"},
{K_UP, "[KU]"},
{K_DOWN, "[KD]"},
{K_LEFT, "[KL]"},
@@ -1754,6 +1761,7 @@ get_term_entries(int *height, int *width)
{KS_CBE, "BE"}, {KS_CBD, "BD"},
{KS_CST, "ST"}, {KS_CRT, "RT"},
{KS_SSI, "Si"}, {KS_SRI, "Ri"},
{KS_CF, "CF"},
{(enum SpecialKey)0, NULL}
};
int i;
@@ -2113,6 +2121,8 @@ set_termname(char_u *term)
&& term_strings_not_set(KS_8U))
apply_builtin_tcap(term, builtin_rgb, TRUE);
#endif
if (term_strings_not_set(KS_CF))
apply_builtin_tcap(term, special_term, TRUE);
}
/*
@@ -3116,6 +3126,17 @@ term_set_winsize(int height, int width)
}
#endif
void
term_font(int n)
{
if (*T_CFO)
{
char buf[20];
sprintf(buf, (char *)T_CFO, 9 + n);
OUT_STR(buf);
}
}
static void
term_color(char_u *s, int n)
{