Mercurial > vim
diff src/term.c @ 34136:36843e079f64 v9.1.0030
patch 9.1.0030: Cannot use terminal alternate font
Commit: https://github.com/vim/vim/commit/a606f3ac036e5f3dc313f620e6b4bc00812314f9
Author: PMunch <peterme@peterme.net>
Date: Wed Nov 15 15:35:49 2023 +0100
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>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 15 Jan 2024 22:30:03 +0100 |
parents | 8f94a72dfbed |
children | adc185c5ca29 |
line wrap: on
line diff
--- a/src/term.c +++ b/src/term.c @@ -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) {