mirror of
				https://github.com/vim/vim.git
				synced 2025-10-30 09:47:20 -04:00 
			
		
		
		
	patch 9.0.1232: ColorTable saving and restoring does not work properly
Problem:    ColorTable saving and restoring does not work properly.
Solution:   Restore ColorTable[16] usage. (Christopher Plewright,
            closes #11836)
			
			
This commit is contained in:
		
				
					committed by
					
						 Bram Moolenaar
						Bram Moolenaar
					
				
			
			
				
	
			
			
			
						parent
						
							3770f4c9cd
						
					
				
				
					commit
					d343c60df4
				
			| @@ -3426,7 +3426,6 @@ mch_init_c(void) | |||||||
|  |  | ||||||
|     wt_init(); |     wt_init(); | ||||||
|     vtp_flag_init(); |     vtp_flag_init(); | ||||||
|     vtp_init(); |  | ||||||
| # ifdef FEAT_RESTORE_ORIG_SCREEN | # ifdef FEAT_RESTORE_ORIG_SCREEN | ||||||
|     // Save the initial console buffer for later restoration |     // Save the initial console buffer for later restoration | ||||||
|     SaveConsoleBuffer(&g_cbOrig); |     SaveConsoleBuffer(&g_cbOrig); | ||||||
| @@ -3463,6 +3462,8 @@ mch_init_c(void) | |||||||
|  |  | ||||||
|     ui_get_shellsize(); |     ui_get_shellsize(); | ||||||
|  |  | ||||||
|  |     vtp_init(); | ||||||
|  |  | ||||||
| # ifdef MCH_WRITE_DUMP | # ifdef MCH_WRITE_DUMP | ||||||
|     fdDump = fopen("dump", "wt"); |     fdDump = fopen("dump", "wt"); | ||||||
|  |  | ||||||
| @@ -8456,8 +8457,6 @@ vtp_flag_init(void) | |||||||
| vtp_init(void) | vtp_init(void) | ||||||
| { | { | ||||||
| # ifdef FEAT_TERMGUICOLORS | # ifdef FEAT_TERMGUICOLORS | ||||||
|     if (!vtp_working) |  | ||||||
|     { |  | ||||||
|     CONSOLE_SCREEN_BUFFER_INFOEX csbi; |     CONSOLE_SCREEN_BUFFER_INFOEX csbi; | ||||||
|     csbi.cbSize = sizeof(csbi); |     csbi.cbSize = sizeof(csbi); | ||||||
|     GetConsoleScreenBufferInfoEx(g_hConOut, &csbi); |     GetConsoleScreenBufferInfoEx(g_hConOut, &csbi); | ||||||
| @@ -8475,7 +8474,6 @@ vtp_init(void) | |||||||
|     fg = (COLORREF)csbi.ColorTable[g_color_index_fg]; |     fg = (COLORREF)csbi.ColorTable[g_color_index_fg]; | ||||||
|     fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); |     fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); | ||||||
|     default_console_color_fg = fg; |     default_console_color_fg = fg; | ||||||
|     } |  | ||||||
| # endif | # endif | ||||||
|     use_alternate_screen_buffer = win10_22H2_or_later && p_rs && vtp_working |     use_alternate_screen_buffer = win10_22H2_or_later && p_rs && vtp_working | ||||||
| 						&& !mch_getenv("VIM_TERMINAL"); | 						&& !mch_getenv("VIM_TERMINAL"); | ||||||
| @@ -8667,6 +8665,12 @@ wt_init(void) | |||||||
|     wt_working = mch_getenv("WT_SESSION") != NULL; |     wt_working = mch_getenv("WT_SESSION") != NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |     int | ||||||
|  | use_wt(void) | ||||||
|  | { | ||||||
|  |     return USE_WT; | ||||||
|  | } | ||||||
|  |  | ||||||
| # ifdef FEAT_TERMGUICOLORS | # ifdef FEAT_TERMGUICOLORS | ||||||
|     static int |     static int | ||||||
| ctermtoxterm( | ctermtoxterm( | ||||||
| @@ -8699,8 +8703,6 @@ set_console_color_rgb(void) | |||||||
| 	return; | 	return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (!conpty_working) |  | ||||||
|     { |  | ||||||
|     fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); |     fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); | ||||||
|     bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg); |     bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg); | ||||||
|  |  | ||||||
| @@ -8715,7 +8717,6 @@ set_console_color_rgb(void) | |||||||
|     csbi.ColorTable[g_color_index_bg] = (COLORREF)bg; |     csbi.ColorTable[g_color_index_bg] = (COLORREF)bg; | ||||||
|     csbi.ColorTable[g_color_index_fg] = (COLORREF)fg; |     csbi.ColorTable[g_color_index_fg] = (COLORREF)fg; | ||||||
|     SetConsoleScreenBufferInfoEx(g_hConOut, &csbi); |     SetConsoleScreenBufferInfoEx(g_hConOut, &csbi); | ||||||
|     } |  | ||||||
| # endif | # endif | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -8742,40 +8743,25 @@ get_default_console_color( | |||||||
| 	ctermfg = -1; | 	ctermfg = -1; | ||||||
| 	if (id > 0) | 	if (id > 0) | ||||||
| 	    syn_id2cterm_bg(id, &ctermfg, &dummynull); | 	    syn_id2cterm_bg(id, &ctermfg, &dummynull); | ||||||
| 	if (vtp_working) | 	if (ctermfg != -1) | ||||||
| 	{ | 	    guifg = ctermtoxterm(ctermfg); | ||||||
| 	    cterm_normal_fg_gui_color = guifg = |  | ||||||
| 			    ctermfg != -1 ? ctermtoxterm(ctermfg) : INVALCOLOR; |  | ||||||
| 	    ctermfg = ctermfg < 0 ? 0 : ctermfg; |  | ||||||
| 	} |  | ||||||
| 	else | 	else | ||||||
| 	{ | 	    guifg = USE_WT ? INVALCOLOR : default_console_color_fg; | ||||||
| 	    guifg = ctermfg != -1 ? ctermtoxterm(ctermfg) |  | ||||||
| 						    : default_console_color_fg; |  | ||||||
| 	cterm_normal_fg_gui_color = guifg; | 	cterm_normal_fg_gui_color = guifg; | ||||||
| 	ctermfg = ctermfg < 0 ? 0 : ctermfg; | 	ctermfg = ctermfg < 0 ? 0 : ctermfg; | ||||||
|     } |     } | ||||||
|     } |  | ||||||
|     if (guibg == INVALCOLOR) |     if (guibg == INVALCOLOR) | ||||||
|     { |     { | ||||||
| 	ctermbg = -1; | 	ctermbg = -1; | ||||||
| 	if (id > 0) | 	if (id > 0) | ||||||
| 	    syn_id2cterm_bg(id, &dummynull, &ctermbg); | 	    syn_id2cterm_bg(id, &dummynull, &ctermbg); | ||||||
| 	if (vtp_working) | 	if (ctermbg != -1) | ||||||
| 	{ | 	    guibg = ctermtoxterm(ctermbg); | ||||||
| 	    cterm_normal_bg_gui_color = guibg = |  | ||||||
| 			    ctermbg != -1 ? ctermtoxterm(ctermbg) : INVALCOLOR; |  | ||||||
| 	    if (ctermbg < 0) |  | ||||||
| 		ctermbg = 0; |  | ||||||
| 	} |  | ||||||
| 	else | 	else | ||||||
| 	{ | 	    guibg = USE_WT ? INVALCOLOR : default_console_color_bg; | ||||||
| 	    guibg = ctermbg != -1 ? ctermtoxterm(ctermbg) |  | ||||||
| 						    : default_console_color_bg; |  | ||||||
| 	cterm_normal_bg_gui_color = guibg; | 	cterm_normal_bg_gui_color = guibg; | ||||||
| 	ctermbg = ctermbg < 0 ? 0 : ctermbg; | 	ctermbg = ctermbg < 0 ? 0 : ctermbg; | ||||||
|     } |     } | ||||||
|     } |  | ||||||
|  |  | ||||||
|     *cterm_fg = ctermfg; |     *cterm_fg = ctermfg; | ||||||
|     *cterm_bg = ctermbg; |     *cterm_bg = ctermbg; | ||||||
| @@ -8792,9 +8778,6 @@ reset_console_color_rgb(void) | |||||||
| { | { | ||||||
| # ifdef FEAT_TERMGUICOLORS | # ifdef FEAT_TERMGUICOLORS | ||||||
|  |  | ||||||
|     if (vtp_working) |  | ||||||
| 	return; |  | ||||||
|  |  | ||||||
|     CONSOLE_SCREEN_BUFFER_INFOEX csbi; |     CONSOLE_SCREEN_BUFFER_INFOEX csbi; | ||||||
|  |  | ||||||
|     csbi.cbSize = sizeof(csbi); |     csbi.cbSize = sizeof(csbi); | ||||||
| @@ -8816,8 +8799,6 @@ reset_console_color_rgb(void) | |||||||
| restore_console_color_rgb(void) | restore_console_color_rgb(void) | ||||||
| { | { | ||||||
| # ifdef FEAT_TERMGUICOLORS | # ifdef FEAT_TERMGUICOLORS | ||||||
|     if (vtp_working) |  | ||||||
| 	return; |  | ||||||
|  |  | ||||||
|     CONSOLE_SCREEN_BUFFER_INFOEX csbi; |     CONSOLE_SCREEN_BUFFER_INFOEX csbi; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -73,6 +73,7 @@ void set_alist_count(void); | |||||||
| void fix_arg_enc(void); | void fix_arg_enc(void); | ||||||
| int mch_setenv(char *var, char *value, int x); | int mch_setenv(char *var, char *value, int x); | ||||||
| int vtp_printf(char *format, ...); | int vtp_printf(char *format, ...); | ||||||
|  | int use_wt(void); | ||||||
| void get_default_console_color(int *cterm_fg, int *cterm_bg, guicolor_T *gui_fg, guicolor_T *gui_bg); | void get_default_console_color(int *cterm_fg, int *cterm_bg, guicolor_T *gui_fg, guicolor_T *gui_bg); | ||||||
| void control_console_color_rgb(void); | void control_console_color_rgb(void); | ||||||
| int use_vtp(void); | int use_vtp(void); | ||||||
|   | |||||||
| @@ -3222,7 +3222,7 @@ term_rgb_color(char_u *s, guicolor_T rgb) | |||||||
|     vim_snprintf(buf, MAX_COLOR_STR_LEN, |     vim_snprintf(buf, MAX_COLOR_STR_LEN, | ||||||
| 				  (char *)s, RED(rgb), GREEN(rgb), BLUE(rgb)); | 				  (char *)s, RED(rgb), GREEN(rgb), BLUE(rgb)); | ||||||
| #ifdef FEAT_VTP | #ifdef FEAT_VTP | ||||||
|     if (has_vtp_working()) |     if (use_wt()) | ||||||
|     { |     { | ||||||
| 	out_flush(); | 	out_flush(); | ||||||
| 	buf[1] = '['; | 	buf[1] = '['; | ||||||
|   | |||||||
| @@ -695,6 +695,8 @@ static char *(features[]) = | |||||||
|  |  | ||||||
| static int included_patches[] = | static int included_patches[] = | ||||||
| {   /* Add new patch number below this line */ | {   /* Add new patch number below this line */ | ||||||
|  | /**/ | ||||||
|  |     1232, | ||||||
| /**/ | /**/ | ||||||
|     1231, |     1231, | ||||||
| /**/ | /**/ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user