Skip to content

Commit

Permalink
Avoid dirty hack
Browse files Browse the repository at this point in the history
  • Loading branch information
Nobuhiro Takasaki committed Oct 23, 2017
1 parent c4eea13 commit dad2c92
Showing 1 changed file with 20 additions and 33 deletions.
53 changes: 20 additions & 33 deletions src/os_win32.c
Expand Up @@ -20,21 +20,8 @@
* Roger Knobbe <rogerk@wonderware.com> did the initial port of Vim 3.0.
*/

/* Avoid _WIN32_WINNT_VISTA */
#define _CONSOLE_SCREEN_BUFFER_INFOEX _CONSOLE_SCREEN_BUFFER_INFOEX_TAG
#define CONSOLE_SCREEN_BUFFER_INFOEX CONSOLE_SCREEN_BUFFER_INFOEX_TAG
#define PCONSOLE_SCREEN_BUFFER_INFOEX PCONSOLE_SCREEN_BUFFER_INFOEX_TAG
#define GetConsoleScreenBufferInfoEx GetConsoleScreenBufferInfoEx_
#define SetConsoleScreenBufferInfoEx SetConsoleScreenBufferInfoEx_

#include "vim.h"

#undef _CONSOLE_SCREEN_BUFFER_INFOEX
#undef CONSOLE_SCREEN_BUFFER_INFOEX
#undef PCONSOLE_SCREEN_BUFFER_INFOEX
#undef GetConsoleScreenBufferInfoEx
#undef SetConsoleScreenBufferInfoEx

#ifdef FEAT_MZSCHEME
# include "if_mzsch.h"
#endif
Expand Down Expand Up @@ -285,7 +272,7 @@ static BOOL win8_or_later = FALSE;

#ifndef FEAT_GUI
/* Dynamic loading for portability */
typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX
typedef struct _DYN_CONSOLE_SCREEN_BUFFER_INFOEX
{
ULONG cbSize;
COORD dwSize;
Expand All @@ -296,11 +283,11 @@ typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX
WORD wPopupAttributes;
BOOL bFullscreenSupported;
COLORREF ColorTable[16];
} CONSOLE_SCREEN_BUFFER_INFOEX, *PCONSOLE_SCREEN_BUFFER_INFOEX;
typedef BOOL (WINAPI *PfnGetConsoleScreenBufferInfoEx)(HANDLE, PCONSOLE_SCREEN_BUFFER_INFOEX);
static PfnGetConsoleScreenBufferInfoEx pGetConsoleScreenBufferInfoEx;
typedef BOOL (WINAPI *PfnSetConsoleScreenBufferInfoEx)(HANDLE, PCONSOLE_SCREEN_BUFFER_INFOEX);
static PfnSetConsoleScreenBufferInfoEx pSetConsoleScreenBufferInfoEx;
} DYN_CONSOLE_SCREEN_BUFFER_INFOEX, *PDYN_CONSOLE_SCREEN_BUFFER_INFOEX;
typedef BOOL (WINAPI *PfnDynGetConsoleScreenBufferInfoEx)(HANDLE, PDYN_CONSOLE_SCREEN_BUFFER_INFOEX);
static PfnDynGetConsoleScreenBufferInfoEx pDynGetConsoleScreenBufferInfoEx;
typedef BOOL (WINAPI *PfnDynSetConsoleScreenBufferInfoEx)(HANDLE, PDYN_CONSOLE_SCREEN_BUFFER_INFOEX);
static PfnDynSetConsoleScreenBufferInfoEx pDynSetConsoleScreenBufferInfoEx;
static BOOL has_csbiex = FALSE;
#endif

Expand Down Expand Up @@ -7441,7 +7428,7 @@ vcon_init(
{
DWORD ver, mode;
HMODULE hKerneldll;
CONSOLE_SCREEN_BUFFER_INFOEX csbi;
DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;

ver = get_build_number();
has_vcon = (ver >= VTP_FIRST_SUPPORT_BUILD) ? 1 : 0;
Expand All @@ -7454,20 +7441,20 @@ vcon_init(
hKerneldll = GetModuleHandle("kernel32.dll");
if (hKerneldll != NULL)
{
pGetConsoleScreenBufferInfoEx =
(PfnGetConsoleScreenBufferInfoEx)GetProcAddress(
pDynGetConsoleScreenBufferInfoEx =
(PfnDynGetConsoleScreenBufferInfoEx)GetProcAddress(
hKerneldll, "GetConsoleScreenBufferInfoEx");
pSetConsoleScreenBufferInfoEx =
(PfnSetConsoleScreenBufferInfoEx)GetProcAddress(
pDynSetConsoleScreenBufferInfoEx =
(PfnDynSetConsoleScreenBufferInfoEx)GetProcAddress(
hKerneldll, "SetConsoleScreenBufferInfoEx");
if (pGetConsoleScreenBufferInfoEx != NULL
&& pSetConsoleScreenBufferInfoEx != NULL)
if (pDynGetConsoleScreenBufferInfoEx != NULL
&& pDynSetConsoleScreenBufferInfoEx != NULL)
has_csbiex = TRUE;
}

csbi.cbSize = sizeof(csbi);
if (has_csbiex)
pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
pDynGetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
save_console_bg_rgb = (guicolor_T)csbi.ColorTable[0];
save_console_fg_rgb = (guicolor_T)csbi.ColorTable[7];

Expand Down Expand Up @@ -7880,7 +7867,7 @@ set_console_color_rgb(
void)
{
# ifdef FEAT_TERMGUICOLORS
CONSOLE_SCREEN_BUFFER_INFOEX csbi;
DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;
int id;
guicolor_T fg = INVALCOLOR;
guicolor_T bg = INVALCOLOR;
Expand All @@ -7897,15 +7884,15 @@ set_console_color_rgb(

csbi.cbSize = sizeof(csbi);
if (has_csbiex)
pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
pDynGetConsoleScreenBufferInfoEx(g_hConOut, &csbi);

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);
pDynSetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
# endif
}

Expand All @@ -7914,19 +7901,19 @@ reset_console_color_rgb(
void)
{
# ifdef FEAT_TERMGUICOLORS
CONSOLE_SCREEN_BUFFER_INFOEX csbi;
DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;

csbi.cbSize = sizeof(csbi);
if (has_csbiex)
pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
pDynGetConsoleScreenBufferInfoEx(g_hConOut, &csbi);

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);
pDynSetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
# endif
}

Expand Down

0 comments on commit dad2c92

Please sign in to comment.