Mercurial > vim
comparison src/os_win32.c @ 14650:99e45fab9d17 v8.1.0338
patch 8.1.0338: MS-Windows: VTP doesn't work properly with Powershell
commit https://github.com/vim/vim/commit/f6ceaf1e058c64775fd46cbdb8962f5c19ef83e0
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 30 17:47:05 2018 +0200
patch 8.1.0338: MS-Windows: VTP doesn't work properly with Powershell
Problem: MS-Windows: VTP doesn't work properly with Powershell.
Solution: Adjust the color index. (Nobuhiro Takasaki, closes https://github.com/vim/vim/issues/3347)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 30 Aug 2018 18:00:06 +0200 |
parents | 5e85d326d616 |
children | f1b7d308de2f |
comparison
equal
deleted
inserted
replaced
14649:ea486a54b47e | 14650:99e45fab9d17 |
---|---|
211 static void vtp_sgr_bulks(int argc, int *argv); | 211 static void vtp_sgr_bulks(int argc, int *argv); |
212 | 212 |
213 static guicolor_T save_console_bg_rgb; | 213 static guicolor_T save_console_bg_rgb; |
214 static guicolor_T save_console_fg_rgb; | 214 static guicolor_T save_console_fg_rgb; |
215 | 215 |
216 static int g_color_index_bg = 0; | |
217 static int g_color_index_fg = 7; | |
218 | |
219 # ifdef FEAT_TERMGUICOLORS | |
220 static int default_console_color_bg = 0x000000; // black | |
221 static int default_console_color_fg = 0xc0c0c0; // white | |
222 # endif | |
223 | |
216 # ifdef FEAT_TERMGUICOLORS | 224 # ifdef FEAT_TERMGUICOLORS |
217 # define USE_VTP (vtp_working && is_term_win32() && (p_tgc || (!p_tgc && t_colors >= 256))) | 225 # define USE_VTP (vtp_working && is_term_win32() && (p_tgc || (!p_tgc && t_colors >= 256))) |
218 # else | 226 # else |
219 # define USE_VTP 0 | 227 # define USE_VTP 0 |
220 # endif | 228 # endif |
2625 #endif | 2633 #endif |
2626 if (cterm_normal_fg_color == 0) | 2634 if (cterm_normal_fg_color == 0) |
2627 cterm_normal_fg_color = (g_attrCurrent & 0xf) + 1; | 2635 cterm_normal_fg_color = (g_attrCurrent & 0xf) + 1; |
2628 if (cterm_normal_bg_color == 0) | 2636 if (cterm_normal_bg_color == 0) |
2629 cterm_normal_bg_color = ((g_attrCurrent >> 4) & 0xf) + 1; | 2637 cterm_normal_bg_color = ((g_attrCurrent >> 4) & 0xf) + 1; |
2638 | |
2639 // Fg and Bg color index nunmber at startup | |
2640 g_color_index_fg = g_attrDefault & 0xf; | |
2641 g_color_index_bg = (g_attrDefault >> 4) & 0xf; | |
2630 | 2642 |
2631 /* set termcap codes to current text attributes */ | 2643 /* set termcap codes to current text attributes */ |
2632 update_tcap(g_attrCurrent); | 2644 update_tcap(g_attrCurrent); |
2633 | 2645 |
2634 GetConsoleCursorInfo(g_hConOut, &g_cci); | 2646 GetConsoleCursorInfo(g_hConOut, &g_cci); |
7662 vtp_init(void) | 7674 vtp_init(void) |
7663 { | 7675 { |
7664 DWORD ver, mode; | 7676 DWORD ver, mode; |
7665 HMODULE hKerneldll; | 7677 HMODULE hKerneldll; |
7666 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi; | 7678 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi; |
7679 # ifdef FEAT_TERMGUICOLORS | |
7680 COLORREF fg, bg; | |
7681 # endif | |
7667 | 7682 |
7668 ver = get_build_number(); | 7683 ver = get_build_number(); |
7669 vtp_working = (ver >= VTP_FIRST_SUPPORT_BUILD) ? 1 : 0; | 7684 vtp_working = (ver >= VTP_FIRST_SUPPORT_BUILD) ? 1 : 0; |
7670 GetConsoleMode(g_hConOut, &mode); | 7685 GetConsoleMode(g_hConOut, &mode); |
7671 mode |= (ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING); | 7686 mode |= (ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING); |
7688 } | 7703 } |
7689 | 7704 |
7690 csbi.cbSize = sizeof(csbi); | 7705 csbi.cbSize = sizeof(csbi); |
7691 if (has_csbiex) | 7706 if (has_csbiex) |
7692 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi); | 7707 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi); |
7693 save_console_bg_rgb = (guicolor_T)csbi.ColorTable[0]; | 7708 save_console_bg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_bg]; |
7694 save_console_fg_rgb = (guicolor_T)csbi.ColorTable[7]; | 7709 save_console_fg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_fg]; |
7710 | |
7711 # ifdef FEAT_TERMGUICOLORS | |
7712 bg = (COLORREF)csbi.ColorTable[g_color_index_bg]; | |
7713 fg = (COLORREF)csbi.ColorTable[g_color_index_fg]; | |
7714 bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg); | |
7715 fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); | |
7716 default_console_color_bg = bg; | |
7717 default_console_color_fg = fg; | |
7718 #endif | |
7695 | 7719 |
7696 set_console_color_rgb(); | 7720 set_console_color_rgb(); |
7697 } | 7721 } |
7698 | 7722 |
7699 static void | 7723 static void |
7786 if (fg == INVALCOLOR) | 7810 if (fg == INVALCOLOR) |
7787 { | 7811 { |
7788 ctermfg = -1; | 7812 ctermfg = -1; |
7789 if (id > 0) | 7813 if (id > 0) |
7790 syn_id2cterm_bg(id, &ctermfg, &ctermbg); | 7814 syn_id2cterm_bg(id, &ctermfg, &ctermbg); |
7791 fg = ctermfg != -1 ? ctermtoxterm(ctermfg) : 0xc0c0c0; /* white */ | 7815 fg = ctermfg != -1 ? ctermtoxterm(ctermfg) : default_console_color_fg; |
7816 cterm_normal_fg_gui_color = fg; | |
7792 } | 7817 } |
7793 if (bg == INVALCOLOR) | 7818 if (bg == INVALCOLOR) |
7794 { | 7819 { |
7795 ctermbg = -1; | 7820 ctermbg = -1; |
7796 if (id > 0) | 7821 if (id > 0) |
7797 syn_id2cterm_bg(id, &ctermfg, &ctermbg); | 7822 syn_id2cterm_bg(id, &ctermfg, &ctermbg); |
7798 bg = ctermbg != -1 ? ctermtoxterm(ctermbg) : 0x000000; /* black */ | 7823 bg = ctermbg != -1 ? ctermtoxterm(ctermbg) : default_console_color_bg; |
7824 cterm_normal_bg_gui_color = bg; | |
7799 } | 7825 } |
7800 fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); | 7826 fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); |
7801 bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg); | 7827 bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg); |
7802 | 7828 |
7803 csbi.cbSize = sizeof(csbi); | 7829 csbi.cbSize = sizeof(csbi); |
7805 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi); | 7831 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi); |
7806 | 7832 |
7807 csbi.cbSize = sizeof(csbi); | 7833 csbi.cbSize = sizeof(csbi); |
7808 csbi.srWindow.Right += 1; | 7834 csbi.srWindow.Right += 1; |
7809 csbi.srWindow.Bottom += 1; | 7835 csbi.srWindow.Bottom += 1; |
7810 csbi.ColorTable[0] = (COLORREF)bg; | 7836 csbi.ColorTable[g_color_index_bg] = (COLORREF)bg; |
7811 csbi.ColorTable[7] = (COLORREF)fg; | 7837 csbi.ColorTable[g_color_index_fg] = (COLORREF)fg; |
7812 if (has_csbiex) | 7838 if (has_csbiex) |
7813 pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi); | 7839 pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi); |
7814 # endif | 7840 # endif |
7815 } | 7841 } |
7816 | 7842 |
7825 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi); | 7851 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi); |
7826 | 7852 |
7827 csbi.cbSize = sizeof(csbi); | 7853 csbi.cbSize = sizeof(csbi); |
7828 csbi.srWindow.Right += 1; | 7854 csbi.srWindow.Right += 1; |
7829 csbi.srWindow.Bottom += 1; | 7855 csbi.srWindow.Bottom += 1; |
7830 csbi.ColorTable[0] = (COLORREF)save_console_bg_rgb; | 7856 csbi.ColorTable[g_color_index_bg] = (COLORREF)save_console_bg_rgb; |
7831 csbi.ColorTable[7] = (COLORREF)save_console_fg_rgb; | 7857 csbi.ColorTable[g_color_index_fg] = (COLORREF)save_console_fg_rgb; |
7832 if (has_csbiex) | 7858 if (has_csbiex) |
7833 pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi); | 7859 pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi); |
7834 # endif | 7860 # endif |
7835 } | 7861 } |
7836 | 7862 |