Commit: patch 9.1.0030: Cannot use terminal alternate font

22 views
Skip to first unread message

Christian Brabandt

unread,
Jan 15, 2024, 4:30:08 PM1/15/24
to vim...@googlegroups.com
patch 9.1.0030: Cannot use terminal alternate font

Commit: https://github.com/vim/vim/commit/a606f3ac036e5f3dc313f620e6b4bc00812314f9
Author: PMunch <pet...@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 <pet...@peterme.net>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 6715f655b..5abc4e95b 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -5304,6 +5304,14 @@ ctermul={color-nr} *highlight-ctermul*
command is given. If the Normal group colors are changed later, the
"fg" and "bg" colors will not be adjusted.

+ctermfont={font-nr} *highlight-ctermfont*
+ This gives the alternative font number to use in the terminal. The
+ available fonts depend on the terminal, and if the terminal is not set
+ up for alternative fonts this simply won't do anything. The range of
+ {font-nr} is 0-10 where 0 resets the font to the default font, 1-9
+ selects one of the 9 alternate fonts, and 10 selects the Fraktur font.
+ For more information see your terminal's handling of SGR parameters
+ 10-20. |t_CF|

3. highlight arguments for the GUI

diff --git a/runtime/doc/tags b/runtime/doc/tags
index 88518600f..d7eb1dd7f 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -7947,6 +7947,7 @@ highlight-clear syntax.txt /*highlight-clear*
highlight-cterm syntax.txt /*highlight-cterm*
highlight-ctermbg syntax.txt /*highlight-ctermbg*
highlight-ctermfg syntax.txt /*highlight-ctermfg*
+highlight-ctermfont syntax.txt /*highlight-ctermfont*
highlight-ctermul syntax.txt /*highlight-ctermul*
highlight-default syntax.txt /*highlight-default*
highlight-font syntax.txt /*highlight-font*
diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt
index 546b0bf90..8154ec596 100644
--- a/runtime/doc/term.txt
+++ b/runtime/doc/term.txt
@@ -1,4 +1,4 @@
-*term.txt* For Vim version 9.1. Last change: 2023 Dec 09
+*term.txt* For Vim version 9.1. Last change: 2024 Jan 15


VIM REFERENCE MANUAL by Bram Moolenaar
@@ -448,6 +448,7 @@ Added by Vim (there are no standard codes for these):
t_AU set underline color (ANSI) *t_AU* *'t_AU'*
t_Ce undercurl and underline end *t_Ce* *'t_Ce'*
t_Cs undercurl (curly underline) mode *t_Cs* *'t_Cs'*
+ t_CF set alternate font (using index 0 - 10) *t_CF* *'t_CF'*
t_Us double underline mode *t_Us* *'t_Us'*
t_ds dotted underline mode *t_ds* *'t_ds'*
t_Ds dashed underline mode *t_Ds* *'t_Ds'*
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index 12e6f3474..ceeb3dbd5 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -9,6 +9,7 @@
" 2023 Dec 21 by Vim Project (improve ex command matching)
" 2023 Dec 30 by Vim Project (:syntax improvements)
" 2024 Jan 14 by Vim Project (TermResponseAll autocommand)
+" 2024 Jan 15 by Vim Project (:hi ctermfont attribute)
" Version: 9.0-25
" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_VIM
" Automatically generated keyword lists: {{{1
@@ -663,7 +664,7 @@ syn match vimHiGuiFontname contained "'[a-zA-Z\-* ]\+'"
syn match vimHiGuiRgb contained "#\x\{6}"

" Highlighting: hi group key=arg ... {{{2
-syn cluster vimHiCluster contains=vimGroup,vimHiGroup,vimHiTerm,vimHiCTerm,vimHiStartStop,vimHiCtermFgBg,vimHiCtermul,vimHiGui,vimHiGuiFont,vimHiGuiFgBg,vimHiKeyError,vimNotation
+syn cluster vimHiCluster contains=vimGroup,vimHiGroup,vimHiTerm,vimHiCTerm,vimHiStartStop,vimHiCtermFgBg,vimHiCtermul,vimHiCtermfont,vimHiGui,vimHiGuiFont,vimHiGuiFgBg,vimHiKeyError,vimNotation
syn region vimHiKeyList contained oneline start="\i\+" skip="\\\|\|" end="$\||" contains=@vimHiCluster
if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_vimhikeyerror")
syn match vimHiKeyError contained "\i\+="he=e-1
@@ -673,6 +674,7 @@ syn match vimHiStartStop contained "

John Marriott

unread,
Jan 16, 2024, 2:12:57 PM1/16/24
to vim...@googlegroups.com

On 16-Jan-2024 08:30, Christian Brabandt wrote:
patch 9.1.0030: Cannot use terminal alternate font

Commit: https://github.com/vim/vim/commit/a606f3ac036e5f3dc313f620e6b4bc00812314f9
Author: PMunch <pet...@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 <pet...@peterme.net>
    Signed-off-by: Christian Brabandt <c...@256bit.org>


After this patch, clang x64 17.0.6 (msys2 on Windows 10), gives this warning:
<snip>
clang -c -I. -Iproto -DWIN32 -DWINVER=0x0A00 -D_WIN32_WINNT=0x0A00 -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO -pipe -Wall -O3 -fomit-frame-pointer -fpie -fPIE  term.c -o objx86-64/term.o
term.c:640:21: warning: unused variable 'special_term' [-Wunused-variable]

  640 | static tcap_entry_T special_term[] = {

      |                     ^~~~~~~~~~~~

1 warning generated.

</snip>

The attached patch tries to fix it.

Cheers
John
term.c.9.1.0030.patch

Christian Brabandt

unread,
Jan 17, 2024, 2:20:24 PM1/17/24
to vim...@googlegroups.com

On Mi, 17 Jan 2024, John Marriott wrote:

> After this patch, clang x64 17.0.6 (msys2 on Windows 10), gives this
> warning:
> <snip>
> clang -c -I. -Iproto -DWIN32 -DWINVER=0x0A00 -D_WIN32_WINNT=0x0A00
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO -pipe
> -Wall -O3 -fomit-frame-pointer -fpie -fPIE  term.c -o objx86-64/term.o
> term.c:640:21: warning: unused variable 'special_term' [-Wunused-variable]
>
>   640 | static tcap_entry_T special_term[] = {
>
>       |                     ^~~~~~~~~~~~
>
> 1 warning generated.
>
> </snip>
>
> The attached patch tries to fix it.

Thanks. Included as of v9.1.0036


Thanks,
Christian
--
Your object is to save the world, while still leading a pleasant life.
Reply all
Reply to author
Forward
0 new messages