To: vim_dev@googlegroups.com Subject: Patch 8.1.0338 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0338 Problem: MS-Windows: VTP doesn't work properly with Powershell. Solution: Adjust the color index. (Nobuhiro Takasaki, closes #3347) Files: src/os_win32.c *** ../vim-8.1.0337/src/os_win32.c 2018-08-23 22:38:27.915001621 +0200 --- src/os_win32.c 2018-08-30 17:45:38.582500357 +0200 *************** *** 213,218 **** --- 213,226 ---- static guicolor_T save_console_bg_rgb; static guicolor_T save_console_fg_rgb; + static int g_color_index_bg = 0; + static int g_color_index_fg = 7; + + # ifdef FEAT_TERMGUICOLORS + static int default_console_color_bg = 0x000000; // black + static int default_console_color_fg = 0xc0c0c0; // white + # endif + # ifdef FEAT_TERMGUICOLORS # define USE_VTP (vtp_working && is_term_win32() && (p_tgc || (!p_tgc && t_colors >= 256))) # else *************** *** 2628,2633 **** --- 2636,2645 ---- if (cterm_normal_bg_color == 0) cterm_normal_bg_color = ((g_attrCurrent >> 4) & 0xf) + 1; + // Fg and Bg color index nunmber at startup + g_color_index_fg = g_attrDefault & 0xf; + g_color_index_bg = (g_attrDefault >> 4) & 0xf; + /* set termcap codes to current text attributes */ update_tcap(g_attrCurrent); *************** *** 7664,7669 **** --- 7676,7684 ---- DWORD ver, mode; HMODULE hKerneldll; DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi; + # ifdef FEAT_TERMGUICOLORS + COLORREF fg, bg; + # endif ver = get_build_number(); vtp_working = (ver >= VTP_FIRST_SUPPORT_BUILD) ? 1 : 0; *************** *** 7690,7697 **** csbi.cbSize = sizeof(csbi); if (has_csbiex) pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi); ! save_console_bg_rgb = (guicolor_T)csbi.ColorTable[0]; ! save_console_fg_rgb = (guicolor_T)csbi.ColorTable[7]; set_console_color_rgb(); } --- 7705,7721 ---- csbi.cbSize = sizeof(csbi); if (has_csbiex) pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi); ! save_console_bg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_bg]; ! save_console_fg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_fg]; ! ! # ifdef FEAT_TERMGUICOLORS ! bg = (COLORREF)csbi.ColorTable[g_color_index_bg]; ! fg = (COLORREF)csbi.ColorTable[g_color_index_fg]; ! bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg); ! fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); ! default_console_color_bg = bg; ! default_console_color_fg = fg; ! #endif set_console_color_rgb(); } *************** *** 7788,7801 **** ctermfg = -1; if (id > 0) syn_id2cterm_bg(id, &ctermfg, &ctermbg); ! fg = ctermfg != -1 ? ctermtoxterm(ctermfg) : 0xc0c0c0; /* white */ } if (bg == INVALCOLOR) { ctermbg = -1; if (id > 0) syn_id2cterm_bg(id, &ctermfg, &ctermbg); ! bg = ctermbg != -1 ? ctermtoxterm(ctermbg) : 0x000000; /* black */ } fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg); --- 7812,7827 ---- ctermfg = -1; if (id > 0) syn_id2cterm_bg(id, &ctermfg, &ctermbg); ! fg = ctermfg != -1 ? ctermtoxterm(ctermfg) : default_console_color_fg; ! cterm_normal_fg_gui_color = fg; } if (bg == INVALCOLOR) { ctermbg = -1; if (id > 0) syn_id2cterm_bg(id, &ctermfg, &ctermbg); ! bg = ctermbg != -1 ? ctermtoxterm(ctermbg) : default_console_color_bg; ! cterm_normal_bg_gui_color = bg; } fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg); *************** *** 7807,7814 **** csbi.cbSize = sizeof(csbi); csbi.srWindow.Right += 1; csbi.srWindow.Bottom += 1; ! csbi.ColorTable[0] = (COLORREF)bg; ! csbi.ColorTable[7] = (COLORREF)fg; if (has_csbiex) pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi); # endif --- 7833,7840 ---- csbi.cbSize = sizeof(csbi); csbi.srWindow.Right += 1; csbi.srWindow.Bottom += 1; ! csbi.ColorTable[g_color_index_bg] = (COLORREF)bg; ! csbi.ColorTable[g_color_index_fg] = (COLORREF)fg; if (has_csbiex) pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi); # endif *************** *** 7827,7834 **** csbi.cbSize = sizeof(csbi); csbi.srWindow.Right += 1; csbi.srWindow.Bottom += 1; ! csbi.ColorTable[0] = (COLORREF)save_console_bg_rgb; ! csbi.ColorTable[7] = (COLORREF)save_console_fg_rgb; if (has_csbiex) pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi); # endif --- 7853,7860 ---- csbi.cbSize = sizeof(csbi); csbi.srWindow.Right += 1; csbi.srWindow.Bottom += 1; ! csbi.ColorTable[g_color_index_bg] = (COLORREF)save_console_bg_rgb; ! csbi.ColorTable[g_color_index_fg] = (COLORREF)save_console_fg_rgb; if (has_csbiex) pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi); # endif *** ../vim-8.1.0337/src/version.c 2018-08-30 15:58:23.248944510 +0200 --- src/version.c 2018-08-30 17:45:48.250391370 +0200 *************** *** 796,797 **** --- 796,799 ---- { /* Add new patch number below this line */ + /**/ + 338, /**/ -- The average life of an organization chart is six months. You can safely ignore any order from your boss that would take six months to complete. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///