comparison src/os_win32.c @ 30320:0763cb330a65 v9.0.0496

patch 9.0.0496: no good reason to keep supporting Windows-XP Commit: https://github.com/vim/vim/commit/27b53be3a6a340f1858bcd31233fe2efc86f8e15 Author: K.Takata <kentkt@csc.jp> Date: Sun Sep 18 12:25:49 2022 +0100 patch 9.0.0496: no good reason to keep supporting Windows-XP Problem: No good reason to keep supporting Windows-XP. Solution: Drop Windows-XP support. (Ken Takata, closes https://github.com/vim/vim/issues/11089)
author Bram Moolenaar <Bram@vim.org>
date Sun, 18 Sep 2022 13:30:05 +0200
parents 499c766d0c14
children ae1113e53ce3
comparison
equal deleted inserted replaced
30319:54c55ede50e5 30320:0763cb330a65
240 #endif 240 #endif
241 241
242 static char_u *exe_path = NULL; 242 static char_u *exe_path = NULL;
243 243
244 static BOOL win8_or_later = FALSE; 244 static BOOL win8_or_later = FALSE;
245
246 #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL)
247 // Dynamic loading for portability
248 typedef struct _DYN_CONSOLE_SCREEN_BUFFER_INFOEX
249 {
250 ULONG cbSize;
251 COORD dwSize;
252 COORD dwCursorPosition;
253 WORD wAttributes;
254 SMALL_RECT srWindow;
255 COORD dwMaximumWindowSize;
256 WORD wPopupAttributes;
257 BOOL bFullscreenSupported;
258 COLORREF ColorTable[16];
259 } DYN_CONSOLE_SCREEN_BUFFER_INFOEX, *PDYN_CONSOLE_SCREEN_BUFFER_INFOEX;
260 typedef BOOL (WINAPI *PfnGetConsoleScreenBufferInfoEx)(HANDLE, PDYN_CONSOLE_SCREEN_BUFFER_INFOEX);
261 static PfnGetConsoleScreenBufferInfoEx pGetConsoleScreenBufferInfoEx;
262 typedef BOOL (WINAPI *PfnSetConsoleScreenBufferInfoEx)(HANDLE, PDYN_CONSOLE_SCREEN_BUFFER_INFOEX);
263 static PfnSetConsoleScreenBufferInfoEx pSetConsoleScreenBufferInfoEx;
264 static BOOL has_csbiex = FALSE;
265 #endif
266 245
267 /* 246 /*
268 * Get version number including build number 247 * Get version number including build number
269 */ 248 */
270 typedef BOOL (WINAPI *PfnRtlGetVersion)(LPOSVERSIONINFOW); 249 typedef BOOL (WINAPI *PfnRtlGetVersion)(LPOSVERSIONINFOW);
7880 #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) || defined(PROTO) 7859 #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) || defined(PROTO)
7881 7860
7882 static void 7861 static void
7883 vtp_init(void) 7862 vtp_init(void)
7884 { 7863 {
7885 HMODULE hKerneldll; 7864 CONSOLE_SCREEN_BUFFER_INFOEX csbi;
7886 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;
7887 # ifdef FEAT_TERMGUICOLORS 7865 # ifdef FEAT_TERMGUICOLORS
7888 COLORREF fg; 7866 COLORREF fg;
7889 # endif 7867 # endif
7890 7868
7891 // Use functions supported from Vista
7892 hKerneldll = GetModuleHandle("kernel32.dll");
7893 if (hKerneldll != NULL)
7894 {
7895 pGetConsoleScreenBufferInfoEx =
7896 (PfnGetConsoleScreenBufferInfoEx)GetProcAddress(
7897 hKerneldll, "GetConsoleScreenBufferInfoEx");
7898 pSetConsoleScreenBufferInfoEx =
7899 (PfnSetConsoleScreenBufferInfoEx)GetProcAddress(
7900 hKerneldll, "SetConsoleScreenBufferInfoEx");
7901 if (pGetConsoleScreenBufferInfoEx != NULL
7902 && pSetConsoleScreenBufferInfoEx != NULL)
7903 has_csbiex = TRUE;
7904 }
7905
7906 csbi.cbSize = sizeof(csbi); 7869 csbi.cbSize = sizeof(csbi);
7907 if (has_csbiex) 7870 GetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
7908 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
7909 save_console_bg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_bg]; 7871 save_console_bg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_bg];
7910 save_console_fg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_fg]; 7872 save_console_fg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_fg];
7911 store_console_bg_rgb = save_console_bg_rgb; 7873 store_console_bg_rgb = save_console_bg_rgb;
7912 store_console_fg_rgb = save_console_fg_rgb; 7874 store_console_fg_rgb = save_console_fg_rgb;
7913 7875
8132 8094
8133 static void 8095 static void
8134 set_console_color_rgb(void) 8096 set_console_color_rgb(void)
8135 { 8097 {
8136 # ifdef FEAT_TERMGUICOLORS 8098 # ifdef FEAT_TERMGUICOLORS
8137 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi; 8099 CONSOLE_SCREEN_BUFFER_INFOEX csbi;
8138 guicolor_T fg, bg; 8100 guicolor_T fg, bg;
8139 int ctermfg, ctermbg; 8101 int ctermfg, ctermbg;
8140 8102
8141 if (!USE_VTP) 8103 if (!USE_VTP)
8142 return; 8104 return;
8152 8114
8153 fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); 8115 fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg);
8154 bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg); 8116 bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg);
8155 8117
8156 csbi.cbSize = sizeof(csbi); 8118 csbi.cbSize = sizeof(csbi);
8157 if (has_csbiex) 8119 GetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
8158 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
8159 8120
8160 csbi.cbSize = sizeof(csbi); 8121 csbi.cbSize = sizeof(csbi);
8161 csbi.srWindow.Right += 1; 8122 csbi.srWindow.Right += 1;
8162 csbi.srWindow.Bottom += 1; 8123 csbi.srWindow.Bottom += 1;
8163 store_console_bg_rgb = csbi.ColorTable[g_color_index_bg]; 8124 store_console_bg_rgb = csbi.ColorTable[g_color_index_bg];
8164 store_console_fg_rgb = csbi.ColorTable[g_color_index_fg]; 8125 store_console_fg_rgb = csbi.ColorTable[g_color_index_fg];
8165 csbi.ColorTable[g_color_index_bg] = (COLORREF)bg; 8126 csbi.ColorTable[g_color_index_bg] = (COLORREF)bg;
8166 csbi.ColorTable[g_color_index_fg] = (COLORREF)fg; 8127 csbi.ColorTable[g_color_index_fg] = (COLORREF)fg;
8167 if (has_csbiex) 8128 SetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
8168 pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
8169 # endif 8129 # endif
8170 } 8130 }
8171 8131
8172 # if defined(FEAT_TERMGUICOLORS) || defined(PROTO) 8132 # if defined(FEAT_TERMGUICOLORS) || defined(PROTO)
8173 void 8133 void
8229 */ 8189 */
8230 static void 8190 static void
8231 reset_console_color_rgb(void) 8191 reset_console_color_rgb(void)
8232 { 8192 {
8233 # ifdef FEAT_TERMGUICOLORS 8193 # ifdef FEAT_TERMGUICOLORS
8234 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi; 8194 CONSOLE_SCREEN_BUFFER_INFOEX csbi;
8235 8195
8236 if (USE_WT) 8196 if (USE_WT)
8237 return; 8197 return;
8238 8198
8239 csbi.cbSize = sizeof(csbi); 8199 csbi.cbSize = sizeof(csbi);
8240 if (has_csbiex) 8200 GetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
8241 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
8242 8201
8243 csbi.cbSize = sizeof(csbi); 8202 csbi.cbSize = sizeof(csbi);
8244 csbi.srWindow.Right += 1; 8203 csbi.srWindow.Right += 1;
8245 csbi.srWindow.Bottom += 1; 8204 csbi.srWindow.Bottom += 1;
8246 csbi.ColorTable[g_color_index_bg] = (COLORREF)store_console_bg_rgb; 8205 csbi.ColorTable[g_color_index_bg] = (COLORREF)store_console_bg_rgb;
8247 csbi.ColorTable[g_color_index_fg] = (COLORREF)store_console_fg_rgb; 8206 csbi.ColorTable[g_color_index_fg] = (COLORREF)store_console_fg_rgb;
8248 if (has_csbiex) 8207 SetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
8249 pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
8250 # endif 8208 # endif
8251 } 8209 }
8252 8210
8253 /* 8211 /*
8254 * Set the console colors to the original colors. 8212 * Set the console colors to the original colors.
8255 */ 8213 */
8256 static void 8214 static void
8257 restore_console_color_rgb(void) 8215 restore_console_color_rgb(void)
8258 { 8216 {
8259 # ifdef FEAT_TERMGUICOLORS 8217 # ifdef FEAT_TERMGUICOLORS
8260 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi; 8218 CONSOLE_SCREEN_BUFFER_INFOEX csbi;
8261 8219
8262 csbi.cbSize = sizeof(csbi); 8220 csbi.cbSize = sizeof(csbi);
8263 if (has_csbiex) 8221 GetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
8264 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
8265 8222
8266 csbi.cbSize = sizeof(csbi); 8223 csbi.cbSize = sizeof(csbi);
8267 csbi.srWindow.Right += 1; 8224 csbi.srWindow.Right += 1;
8268 csbi.srWindow.Bottom += 1; 8225 csbi.srWindow.Bottom += 1;
8269 csbi.ColorTable[g_color_index_bg] = (COLORREF)save_console_bg_rgb; 8226 csbi.ColorTable[g_color_index_bg] = (COLORREF)save_console_bg_rgb;
8270 csbi.ColorTable[g_color_index_fg] = (COLORREF)save_console_fg_rgb; 8227 csbi.ColorTable[g_color_index_fg] = (COLORREF)save_console_fg_rgb;
8271 if (has_csbiex) 8228 SetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
8272 pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
8273 # endif 8229 # endif
8274 } 8230 }
8275 8231
8276 void 8232 void
8277 control_console_color_rgb(void) 8233 control_console_color_rgb(void)