diff options
-rw-r--r-- | runtime/doc/terminal.txt | 3 | ||||
-rw-r--r-- | src/highlight.c | 12 | ||||
-rw-r--r-- | src/proto/terminal.pro | 1 | ||||
-rw-r--r-- | src/terminal.c | 126 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 44 insertions, 100 deletions
diff --git a/runtime/doc/terminal.txt b/runtime/doc/terminal.txt index 2f2556a50..510f1c399 100644 --- a/runtime/doc/terminal.txt +++ b/runtime/doc/terminal.txt @@ -168,9 +168,6 @@ terminal window will start with a white or black background. 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()`. diff --git a/src/highlight.c b/src/highlight.c index defbe5517..a08d1f1d2 100644 --- a/src/highlight.c +++ b/src/highlight.c @@ -641,9 +641,6 @@ do_highlight( 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 @@ -882,10 +879,6 @@ do_highlight( 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; @@ -1534,11 +1527,6 @@ do_highlight( 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) diff --git a/src/proto/terminal.pro b/src/proto/terminal.pro index d2e599256..061a668bf 100644 --- a/src/proto/terminal.pro +++ b/src/proto/terminal.pro @@ -19,7 +19,6 @@ cursorentry_T *term_get_cursor_shape(guicolor_T *fg, guicolor_T *bg); 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); diff --git a/src/terminal.c b/src/terminal.c index eb9e780cf..cabcf9d1b 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -204,10 +204,6 @@ static void handle_postponed_scrollback(term_T *term); // 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; @@ -2722,48 +2718,6 @@ may_toggle_cursor(term_T *term) } /* - * 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). */ @@ -2909,10 +2863,34 @@ cell2attr( #ifdef FEAT_TERMGUICOLORS if (p_tgc) { - guicolor_T fg, bg; + 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; - fg = gui_get_rgb_color_cmn(cellfg.red, cellfg.green, cellfg.blue); - bg = gui_get_rgb_color_cmn(cellbg.red, cellbg.green, cellbg.blue); + 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,41 +2905,20 @@ cell2attr( // colors. if ((fg == 0 || bg == 0) && t_colors >= 16) { - int wincolor_fg = -1; - int wincolor_bg = -1; + int cterm_fg = -1; + int cterm_bg = -1; + int id = 0; 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; - } - } + 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,8 +3998,9 @@ init_default_colors(term_T *term, win_T *wp) #endif if (id != 0 && t_colors >= 16) { - int cterm_fg = get_default_cterm_fg(term); - int cterm_bg = get_default_cterm_bg(term); + 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); diff --git a/src/version.c b/src/version.c index f7af2d759..dfe5139a9 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3516, +/**/ 3515, /**/ 3514, |