Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
34135:65a3e7bb12b7 | 34136:36843e079f64 |
---|---|
623 {(int)KS_NAME, NULL} // end marker | 623 {(int)KS_NAME, NULL} // end marker |
624 }; | 624 }; |
625 | 625 |
626 #ifdef FEAT_TERMGUICOLORS | 626 #ifdef FEAT_TERMGUICOLORS |
627 /* | 627 /* |
628 * Additions for using the RGB colors | 628 * Additions for using the RGB colors and terminal font |
629 */ | 629 */ |
630 static tcap_entry_T builtin_rgb[] = { | 630 static tcap_entry_T builtin_rgb[] = { |
631 // These are printf strings, not terminal codes. | 631 // These are printf strings, not terminal codes. |
632 {(int)KS_8F, "\033[38;2;%lu;%lu;%lum"}, | 632 {(int)KS_8F, "\033[38;2;%lu;%lu;%lum"}, |
633 {(int)KS_8B, "\033[48;2;%lu;%lu;%lum"}, | 633 {(int)KS_8B, "\033[48;2;%lu;%lu;%lum"}, |
634 {(int)KS_8U, "\033[58;2;%lu;%lu;%lum"}, | 634 {(int)KS_8U, "\033[58;2;%lu;%lu;%lum"}, |
635 | 635 |
636 {(int)KS_NAME, NULL} // end marker | 636 {(int)KS_NAME, NULL} // end marker |
637 }; | 637 }; |
638 #endif | 638 #endif |
639 | |
640 static tcap_entry_T special_term[] = { | |
641 // These are printf strings, not terminal codes. | |
642 {(int)KS_CF, "\033[%dm"}, | |
643 {(int)KS_NAME, NULL} // end marker | |
644 }; | |
639 | 645 |
640 /* | 646 /* |
641 * iris-ansi for Silicon Graphics machines. | 647 * iris-ansi for Silicon Graphics machines. |
642 */ | 648 */ |
643 static tcap_entry_T builtin_iris_ansi[] = { | 649 static tcap_entry_T builtin_iris_ansi[] = { |
1233 {(int)KS_CRV, "[CRV]"}, | 1239 {(int)KS_CRV, "[CRV]"}, |
1234 {(int)KS_CXM, "[CXM]"}, | 1240 {(int)KS_CXM, "[CXM]"}, |
1235 {(int)KS_U7, "[U7]"}, | 1241 {(int)KS_U7, "[U7]"}, |
1236 {(int)KS_RFG, "[RFG]"}, | 1242 {(int)KS_RFG, "[RFG]"}, |
1237 {(int)KS_RBG, "[RBG]"}, | 1243 {(int)KS_RBG, "[RBG]"}, |
1244 {(int)KS_CF, "[CF%d]"}, | |
1238 {K_UP, "[KU]"}, | 1245 {K_UP, "[KU]"}, |
1239 {K_DOWN, "[KD]"}, | 1246 {K_DOWN, "[KD]"}, |
1240 {K_LEFT, "[KL]"}, | 1247 {K_LEFT, "[KL]"}, |
1241 {K_RIGHT, "[KR]"}, | 1248 {K_RIGHT, "[KR]"}, |
1242 {K_XUP, "[xKU]"}, | 1249 {K_XUP, "[xKU]"}, |
1752 {KS_U7, "u7"}, {KS_RFG, "RF"}, {KS_RBG, "RB"}, | 1759 {KS_U7, "u7"}, {KS_RFG, "RF"}, {KS_RBG, "RB"}, |
1753 {KS_8F, "8f"}, {KS_8B, "8b"}, {KS_8U, "8u"}, | 1760 {KS_8F, "8f"}, {KS_8B, "8b"}, {KS_8U, "8u"}, |
1754 {KS_CBE, "BE"}, {KS_CBD, "BD"}, | 1761 {KS_CBE, "BE"}, {KS_CBD, "BD"}, |
1755 {KS_CST, "ST"}, {KS_CRT, "RT"}, | 1762 {KS_CST, "ST"}, {KS_CRT, "RT"}, |
1756 {KS_SSI, "Si"}, {KS_SRI, "Ri"}, | 1763 {KS_SSI, "Si"}, {KS_SRI, "Ri"}, |
1764 {KS_CF, "CF"}, | |
1757 {(enum SpecialKey)0, NULL} | 1765 {(enum SpecialKey)0, NULL} |
1758 }; | 1766 }; |
1759 int i; | 1767 int i; |
1760 static char_u tstrbuf[TBUFSZ]; | 1768 static char_u tstrbuf[TBUFSZ]; |
1761 char_u *tp = tstrbuf; | 1769 char_u *tp = tstrbuf; |
2111 if (term_strings_not_set(KS_8F) | 2119 if (term_strings_not_set(KS_8F) |
2112 && term_strings_not_set(KS_8B) | 2120 && term_strings_not_set(KS_8B) |
2113 && term_strings_not_set(KS_8U)) | 2121 && term_strings_not_set(KS_8U)) |
2114 apply_builtin_tcap(term, builtin_rgb, TRUE); | 2122 apply_builtin_tcap(term, builtin_rgb, TRUE); |
2115 #endif | 2123 #endif |
2124 if (term_strings_not_set(KS_CF)) | |
2125 apply_builtin_tcap(term, special_term, TRUE); | |
2116 } | 2126 } |
2117 | 2127 |
2118 /* | 2128 /* |
2119 * special: There is no info in the termcap about whether the cursor | 2129 * special: There is no info in the termcap about whether the cursor |
2120 * positioning is relative to the start of the screen or to the start of the | 2130 * positioning is relative to the start of the screen or to the start of the |
3113 term_set_winsize(int height, int width) | 3123 term_set_winsize(int height, int width) |
3114 { | 3124 { |
3115 OUT_STR(tgoto((char *)T_CWS, width, height)); | 3125 OUT_STR(tgoto((char *)T_CWS, width, height)); |
3116 } | 3126 } |
3117 #endif | 3127 #endif |
3128 | |
3129 void | |
3130 term_font(int n) | |
3131 { | |
3132 if (*T_CFO) | |
3133 { | |
3134 char buf[20]; | |
3135 sprintf(buf, (char *)T_CFO, 9 + n); | |
3136 OUT_STR(buf); | |
3137 } | |
3138 } | |
3118 | 3139 |
3119 static void | 3140 static void |
3120 term_color(char_u *s, int n) | 3141 term_color(char_u *s, int n) |
3121 { | 3142 { |
3122 char buf[20]; | 3143 char buf[20]; |