Patch 8.2.3516
Problem: Terminal window does not have transparent background when
'termguicolors' is used.
Solution: Fix the background color. (closes #2361, closes #9002)
Files: runtime/doc/terminal.txt, src/highlight.c, src/proto/terminal.pro,
src/terminal.c
*** ../vim-8.2.3515/runtime/doc/terminal.txt 2021-01-31 16:02:06.262490144
+0000
--- runtime/doc/terminal.txt 2021-10-15 22:19:13.415424605 +0100
***************
*** 151,159 ****
To use a different color the Terminal highlight group can be used, for
example: >
hi Terminal ctermbg=lightgrey ctermfg=blue guibg=lightgrey guifg=blue
- The highlight needs to be defined before the terminal is created. Doing it
- later, or setting 'wincolor', will only have effect when the program running
- in the terminal displays text or clears the terminal.
Instead of Terminal another group can be specified with the "term_highlight"
option for `term_start()`.
--- 168,173 ----
*** ../vim-8.2.3515/src/highlight.c 2021-06-02 12:28:11.431120460 +0100
--- src/highlight.c 2021-10-15 22:19:13.415424605 +0100
***************
*** 641,649 ****
int error = FALSE;
int color;
int is_normal_group = FALSE; // "Normal" group
- #ifdef FEAT_TERMINAL
- int is_terminal_group = FALSE; // "Terminal" group
- #endif
#ifdef FEAT_GUI_X11
int is_menu_group = FALSE; // "Menu" group
int is_scrollbar_group = FALSE; // "Scrollbar" group
--- 641,646 ----
***************
*** 882,891 ****
if (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0)
is_normal_group = TRUE;
- #ifdef FEAT_TERMINAL
- else if (STRCMP(HL_TABLE()[idx].sg_name_u, "TERMINAL") == 0)
- is_terminal_group = TRUE;
- #endif
#ifdef FEAT_GUI_X11
else if (STRCMP(HL_TABLE()[idx].sg_name_u, "MENU") == 0)
is_menu_group = TRUE;
--- 879,884 ----
***************
*** 1534,1544 ****
control_console_color_rgb();
#endif
}
- #ifdef FEAT_TERMINAL
- else if (is_terminal_group)
- set_terminal_default_colors(
- HL_TABLE()[idx].sg_cterm_fg, HL_TABLE()[idx].sg_cterm_bg);
- #endif
#ifdef FEAT_GUI_X11
# ifdef FEAT_MENU
else if (is_menu_group)
--- 1527,1532 ----
*** ../vim-8.2.3515/src/proto/terminal.pro 2021-05-03 19:40:35.263818664
+0100
--- src/proto/terminal.pro 2021-10-15 22:19:13.415424605 +0100
***************
*** 19,25 ****
int term_use_loop(void);
void term_win_entered(void);
int terminal_loop(int blocking);
- void set_terminal_default_colors(int cterm_fg, int cterm_bg);
int may_close_term_popup(void);
void term_channel_closed(channel_T *ch);
void term_check_channel_closed_recently(void);
--- 19,24 ----
*** ../vim-8.2.3515/src/terminal.c 2021-09-08 13:57:38.237188053 +0100
--- src/terminal.c 2021-10-15 22:19:13.415424605 +0100
***************
*** 204,213 ****
// backspace key.
static int term_backspace_char = BS;
- // "Terminal" highlight group colors.
- static int term_default_cterm_fg = -1;
- static int term_default_cterm_bg = -1;
-
// Store the last set and the desired cursor properties, so that we only
update
// them when needed. Doing it unnecessary may result in flicker.
static char_u *last_set_cursor_color = NULL;
--- 204,209 ----
***************
*** 2722,2769 ****
}
/*
- * Cache "Terminal" highlight group colors.
- */
- void
- set_terminal_default_colors(int cterm_fg, int cterm_bg)
- {
- term_default_cterm_fg = cterm_fg - 1;
- term_default_cterm_bg = cterm_bg - 1;
- }
-
- static int
- get_default_cterm_fg(term_T *term)
- {
- if (term->tl_highlight_name != NULL)
- {
- int id = syn_name2id(term->tl_highlight_name);
- int fg = -1;
- int bg = -1;
-
- if (id > 0)
- syn_id2cterm_bg(id, &fg, &bg);
- return fg;
- }
- return term_default_cterm_fg;
- }
-
- static int
- get_default_cterm_bg(term_T *term)
- {
- if (term->tl_highlight_name != NULL)
- {
- int id = syn_name2id(term->tl_highlight_name);
- int fg = -1;
- int bg = -1;
-
- if (id > 0)
- syn_id2cterm_bg(id, &fg, &bg);
- return bg;
- }
- return term_default_cterm_bg;
- }
-
- /*
* Reverse engineer the RGB value into a cterm color index.
* First color is 1. Return 0 if no match found (default color).
*/
--- 2718,2723 ----
***************
*** 2909,2918 ****
#ifdef FEAT_TERMGUICOLORS
if (p_tgc)
{
! guicolor_T fg, bg;
! fg = gui_get_rgb_color_cmn(cellfg.red, cellfg.green, cellfg.blue);
! bg = gui_get_rgb_color_cmn(cellbg.red, cellbg.green, cellbg.blue);
return get_tgc_attr_idx(attr, fg, bg);
}
--- 2863,2896 ----
#ifdef FEAT_TERMGUICOLORS
if (p_tgc)
{
! guicolor_T fg = INVALCOLOR;
! guicolor_T bg = INVALCOLOR;
!
! // Use the 'wincolor' or "Terminal" highlighting for the default
! // colors.
! if (VTERM_COLOR_IS_DEFAULT_FG(&cellfg)
! || VTERM_COLOR_IS_DEFAULT_BG(&cellbg))
! {
! int id = 0;
! if (wp != NULL && *wp->w_p_wcr != NUL)
! id = syn_name2id(wp->w_p_wcr);
! if (id == 0)
! id = syn_name2id(term_get_highlight_name(term));
! if (id > 0)
! syn_id2colors(id, &fg, &bg);
! if (!VTERM_COLOR_IS_DEFAULT_FG(&cellfg))
! fg = gui_get_rgb_color_cmn(cellfg.red, cellfg.green,
! cellfg.blue);
! if (!VTERM_COLOR_IS_DEFAULT_BG(&cellbg))
! bg = gui_get_rgb_color_cmn(cellbg.red, cellbg.green,
! cellbg.blue);
! }
! else
! {
! fg = gui_get_rgb_color_cmn(cellfg.red, cellfg.green, cellfg.blue);
! bg = gui_get_rgb_color_cmn(cellbg.red, cellbg.green, cellbg.blue);
! }
return get_tgc_attr_idx(attr, fg, bg);
}
***************
*** 2927,2967 ****
// colors.
if ((fg == 0 || bg == 0) && t_colors >= 16)
{
! int wincolor_fg = -1;
! int wincolor_bg = -1;
if (wp != NULL && *wp->w_p_wcr != NUL)
! {
! int id = syn_name2id(curwin->w_p_wcr);
!
! // Get the 'wincolor' group colors.
! if (id > 0)
! syn_id2cterm_bg(id, &wincolor_fg, &wincolor_bg);
! }
! if (fg == 0)
! {
! if (wincolor_fg >= 0)
! fg = wincolor_fg + 1;
! else
! {
! int cterm_fg = get_default_cterm_fg(term);
!
! if (cterm_fg >= 0)
! fg = cterm_fg + 1;
! }
! }
! if (bg == 0)
! {
! if (wincolor_bg >= 0)
! bg = wincolor_bg + 1;
! else
! {
! int cterm_bg = get_default_cterm_bg(term);
!
! if (cterm_bg >= 0)
! bg = cterm_bg + 1;
! }
! }
}
// with 8 colors set the bold attribute to get a bright foreground
--- 2905,2924 ----
// colors.
if ((fg == 0 || bg == 0) && t_colors >= 16)
{
! int cterm_fg = -1;
! int cterm_bg = -1;
! int id = 0;
if (wp != NULL && *wp->w_p_wcr != NUL)
! id = syn_name2id(wp->w_p_wcr);
! if (id == 0)
! id = syn_name2id(term_get_highlight_name(term));
! if (id > 0)
! syn_id2cterm_bg(id, &cterm_fg, &cterm_bg);
! if (fg == 0 && cterm_fg >= 0)
! fg = cterm_fg + 1;
! if (bg == 0 && cterm_bg >= 0)
! bg = cterm_bg + 1;
}
// with 8 colors set the bold attribute to get a bright foreground
***************
*** 4041,4048 ****
#endif
if (id != 0 && t_colors >= 16)
{
! int cterm_fg = get_default_cterm_fg(term);
! int cterm_bg = get_default_cterm_bg(term);
if (cterm_fg >= 0)
cterm_color2vterm(cterm_fg, fg);
--- 3998,4006 ----
#endif
if (id != 0 && t_colors >= 16)
{
! int cterm_fg = -1;
! int cterm_bg = -1;
! syn_id2cterm_bg(id, &cterm_fg, &cterm_bg);
if (cterm_fg >= 0)
cterm_color2vterm(cterm_fg, fg);
*** ../vim-8.2.3515/src/version.c 2021-10-15 17:23:08.755565587 +0100
--- src/version.c 2021-10-15 22:21:31.361598496 +0100
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 3516,
/**/
--
hundred-and-one symptoms of being an internet addict:
165. You have a web page burned into your glasses
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20211015212618.41EA8C80053%40moolenaar.net.