Patch 9.0.1111

9 views
Skip to first unread message

Bram Moolenaar

unread,
Dec 30, 2022, 6:16:33 AM12/30/22
to vim...@googlegroups.com

Patch 9.0.1111
Problem: Termcap entries for RGB colors are not set automatically.
Solution: Always set the termcap entries when +termguicolors is enabled.
Files: src/term.c


*** ../vim-9.0.1110/src/term.c 2022-12-20 20:01:09.624090908 +0000
--- src/term.c 2022-12-30 11:15:00.566645530 +0000
***************
*** 476,487 ****
{(int)KS_RFG, "\033]10;?\007"},
{(int)KS_RBG, "\033]11;?\007"},
{(int)KS_U7, "\033[6n"},
- # ifdef FEAT_TERMGUICOLORS
- // These are printf strings, not terminal codes.
- {(int)KS_8F, "\033[38;2;%lu;%lu;%lum"},
- {(int)KS_8B, "\033[48;2;%lu;%lu;%lum"},
- {(int)KS_8U, "\033[58;2;%lu;%lu;%lum"},
- # endif
{(int)KS_CAU, "\033[58;5;%dm"},
{(int)KS_CBE, "\033[?2004h"},
{(int)KS_CBD, "\033[?2004l"},
--- 476,481 ----
***************
*** 627,632 ****
--- 621,640 ----
{(int)KS_NAME, NULL} // end marker
};

+ #ifdef FEAT_TERMGUICOLORS
+ /*
+ * Additions for using the RGB colors
+ */
+ static tcap_entry_T builtin_rgb[] = {
+ // These are printf strings, not terminal codes.
+ {(int)KS_8F, "\033[38;2;%lu;%lu;%lum"},
+ {(int)KS_8B, "\033[48;2;%lu;%lu;%lum"},
+ {(int)KS_8U, "\033[58;2;%lu;%lu;%lum"},
+
+ {(int)KS_NAME, NULL} // end marker
+ };
+ #endif
+
/*
* iris-ansi for Silicon Graphics machines.
*/
***************
*** 892,901 ****
# else
{(int)KS_CS, "\033|%i%d;%dr"}, // scroll region
# endif
- # ifdef FEAT_TERMGUICOLORS
- {(int)KS_8F, "\033|38;2;%lu;%lu;%lum"},
- {(int)KS_8B, "\033|48;2;%lu;%lu;%lum"},
- # endif

{K_UP, "\316H"},
{K_DOWN, "\316P"},
--- 900,905 ----
***************
*** 1674,1679 ****
--- 1678,1692 ----
};
#endif

+ /*
+ * Return TRUE if "term_strings[idx]" was not set.
+ */
+ static int
+ term_strings_not_set(enum SpecialKey idx)
+ {
+ return TERM_STR(idx) == NULL || TERM_STR(idx) == empty_option;
+ }
+
#ifdef HAVE_TGETENT
/*
* Get the termcap entries we need with tgetstr(), tgetflag() and tgetnum().
***************
*** 1730,1737 ****
*/
for (i = 0; string_names[i].name != NULL; ++i)
{
! if (TERM_STR(string_names[i].dest) == NULL
! || TERM_STR(string_names[i].dest) == empty_option)
{
TERM_STR(string_names[i].dest) = TGETSTR(string_names[i].name, &tp);
#ifdef FEAT_EVAL
--- 1741,1747 ----
*/
for (i = 0; string_names[i].name != NULL; ++i)
{
! if (term_strings_not_set(string_names[i].dest))
{
TERM_STR(string_names[i].dest) = TGETSTR(string_names[i].name, &tp);
#ifdef FEAT_EVAL
***************
*** 1778,1784 ****
/*
* Get number of colors (if not done already).
*/
! if (TERM_STR(KS_CCO) == NULL || TERM_STR(KS_CCO) == empty_option)
{
set_color_count(tgetnum("Co"));
#ifdef FEAT_EVAL
--- 1789,1795 ----
/*
* Get number of colors (if not done already).
*/
! if (term_strings_not_set(KS_CCO))
{
set_color_count(tgetnum("Co"));
#ifdef FEAT_EVAL
***************
*** 2069,2074 ****
--- 2080,2096 ----
apply_builtin_tcap(term, builtin_kitty, TRUE);
else if (kpc == KEYPROTOCOL_MOK2)
apply_builtin_tcap(term, builtin_mok2, TRUE);
+
+ #ifdef FEAT_TERMGUICOLORS
+ // There is no good way to detect that the terminal supports RGB
+ // colors. Since these termcap entries are non-standard anyway and
+ // only used when the user sets 'termguicolors' we might as well add
+ // them. But not when one of them was alredy set.
+ if (term_strings_not_set(KS_8F)
+ && term_strings_not_set(KS_8B)
+ && term_strings_not_set(KS_8U))
+ apply_builtin_tcap(term, builtin_rgb, TRUE);
+ #endif
}

/*
*** ../vim-9.0.1110/src/version.c 2022-12-30 10:42:19.770143913 +0000
--- src/version.c 2022-12-30 11:06:38.954172580 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1111,
/**/

--
Q: What kind of stuff do you do?
A: I collect hobbies.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

John Marriott

unread,
Dec 30, 2022, 1:52:19 PM12/30/22
to vim...@googlegroups.com

On 30-Dec-2022 22:16, Bram Moolenaar wrote:
> Patch 9.0.1111
> Problem: Termcap entries for RGB colors are not set automatically.
> Solution: Always set the termcap entries when +termguicolors is enabled.
> Files: src/term.c
>
>
After this patch, msys2-64 (clang 15.0.5) gives this warning:
<snip>
clang -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO
-pipe -Wall -O3 -fomit-frame-pointer -fpie -fPIE -DFEAT_GUI_MSWIN
-DFEAT_CLIPBOARD term.c -o gobjx86-64/term.o
term.c:1685:1: warning: unused function 'term_strings_not_set'
[-Wunused-function]
term_strings_not_set(enum SpecialKey idx)
^
1 warning generated.
</snip>


The attached patch tries to fix it.

Cheers
John
term.c.9.0.1111.patch

Bram Moolenaar

unread,
Dec 30, 2022, 2:55:31 PM12/30/22
to vim...@googlegroups.com, John Marriott
Thanks!

--
Citizens are not allowed to attend a movie house or theater nor ride in a
public streetcar within at least four hours after eating garlic.
[real standing law in Indiana, United States of America]
Reply all
Reply to author
Forward
0 new messages