src/arch/mswin/mycurses.c
/* Win32 Stuff */
/* returns 0 if fails */
Win32 Stuff
returns 0 if fails
Win32 Stuff returns 0 if fails
static int mycur_init(int fullscreen)
{
	COORD cStartPos;
	DWORD dwLen;
	if(first)
	{
		CONSOLE_SCREEN_BUFFER_INFO ConScreenBuffer = {0};
		OSVERSIONINFO verinfo;
		verinfo.dwOSVersionInfoSize = sizeof(verinfo);
		if (GetVersionEx(&verinfo) && verinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
		{
			WindowsNt = 1;
			LibKernel32 = LoadLibrary("Kernel32.dll");
			ApiReadConsoleInput = (ApiFncReadConsoleInput)GetProcAddress(LibKernel32, "ReadConsoleInputW");
		}
		ACS_VLINE = (CHTYPE)179;
		ACS_HLINE = (CHTYPE)196;
		ACS_BTEE = (CHTYPE)193;
		ACS_TTEE = (CHTYPE)194;
		ACS_RTEE = (CHTYPE)180;
		ACS_LTEE = (CHTYPE)195;
		ACS_ULCORNER = (CHTYPE)218;
		ACS_LRCORNER = (CHTYPE)217;
		ACS_URCORNER = (CHTYPE)191;
		ACS_LLCORNER = (CHTYPE)192;
		first = FALSE;
		hStdin = GetStdHandle((DWORD)STD_INPUT_HANDLE);
		if(hStdin == INVALID_HANDLE_VALUE)
		{
			printf("Error opening console window for input\n");
			return 0;
		}
		if (!GetConsoleMode(hStdin, &dwModeIn))
			redirected_in = 1;
		dwModeIn &= ~(ENABLE_LINE_INPUT
			| ENABLE_ECHO_INPUT
			| ENABLE_MOUSE_INPUT
			| ENABLE_WINDOW_INPUT);
		dwModeIn |=	ENABLE_PROCESSED_INPUT;
		SetConsoleMode(hStdin, dwModeIn);
		hStdout = GetStdHandle((DWORD)STD_OUTPUT_HANDLE);
		if (hStdout == INVALID_HANDLE_VALUE)
		{
			printf("Error opening console window for output\n");
			return 0;
		}
		if (!GetConsoleScreenBufferInfo(hStdout, &ConScreenBuffer)) {
			redirected_out = 1;
			ConScreenBuffer.dwSize.X = 80;
			ConScreenBuffer.dwSize.Y = 25;
			ConScreenBuffer.srWindow.Bottom = 25;
			ConScreenBuffer.srWindow.Right = 80;
		}
		CurrentScreenWidth = ConScreenBuffer.dwSize.X;
		CurrentScreenHeight = ConScreenBuffer.dwSize.Y;
		GetConsoleCursorInfo(hStdout, &ConCursorInfo);
#ifdef DEBUG
		fprintf(errfp, "Screen buffer: (%d,%d) pos=(%d,%d)\n",
			ConScreenBuffer.dwSize.X, ConScreenBuffer.dwSize.Y,
			ConScreenBuffer.dwCursorPosition.X, ConScreenBuffer.dwCursorPosition.Y);
		fprintf(errfp, "Window: (%d-%d,%d-%d) max=(%d,%d)\n",
			ConScreenBuffer.srWindow.Left, ConScreenBuffer.srWindow.Right,
			ConScreenBuffer.srWindow.Top, ConScreenBuffer.srWindow.Bottom,
			ConScreenBuffer.dwMaximumWindowSize.X,
			ConScreenBuffer.dwMaximumWindowSize.Y);
#endif
		if (ConScreenBuffer.srWindow.Left || ConScreenBuffer.srWindow.Top)
		{
		}
		cStartPos.X = 0;
		cStartPos.Y = 0;
		FillConsoleOutputCharacter(hStdout, (TCHAR)' ',
			(DWORD)(ConScreenBuffer.dwSize.X*ConScreenBuffer.dwSize.Y),
			cStartPos, &dwLen);
		if (fullscreen)
		{
			LINES = ConScreenBuffer.dwSize.Y;
			COLS = ConScreenBuffer.dwSize.X;
		}
		else
		{
			LINES = ConScreenBuffer.srWindow.Bottom;
			COLS = ConScreenBuffer.srWindow.Right;
		}
		adjust_linescols();
		platform_postcurses_init();
	}
	return 1;
}
static int mycur_init ( int fullscreen ) { COORD cStartPos ; DWORD dwLen ; if ( first ) { CONSOLE_SCREEN_BUFFER_INFO ConScreenBuffer = { 0 } ; OSVERSIONINFO verinfo ; verinfo . dwOSVersionInfoSize = sizeof ( verinfo ) ; if ( GetVersionEx ( & verinfo ) && verinfo . dwPlatformId == VER_PLATFORM_WIN32_NT ) { WindowsNt = 1 ; LibKernel32 = LoadLibrary ( " " ) ; ApiReadConsoleInput = ( ApiFncReadConsoleInput ) GetProcAddress ( LibKernel32 , " " ) ; } ACS_VLINE = ( CHTYPE ) 179 ; ACS_HLINE = ( CHTYPE ) 196 ; ACS_BTEE = ( CHTYPE ) 193 ; ACS_TTEE = ( CHTYPE ) 194 ; ACS_RTEE = ( CHTYPE ) 180 ; ACS_LTEE = ( CHTYPE ) 195 ; ACS_ULCORNER = ( CHTYPE ) 218 ; ACS_LRCORNER = ( CHTYPE ) 217 ; ACS_URCORNER = ( CHTYPE ) 191 ; ACS_LLCORNER = ( CHTYPE ) 192 ; first = FALSE ; hStdin = GetStdHandle ( ( DWORD ) STD_INPUT_HANDLE ) ; if ( hStdin == INVALID_HANDLE_VALUE ) { printf ( " \n " ) ; return 0 ; } if ( ! GetConsoleMode ( hStdin , & dwModeIn ) ) redirected_in = 1 ; dwModeIn &= ~ ( ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT ) ; dwModeIn |= ENABLE_PROCESSED_INPUT ; SetConsoleMode ( hStdin , dwModeIn ) ; hStdout = GetStdHandle ( ( DWORD ) STD_OUTPUT_HANDLE ) ; if ( hStdout == INVALID_HANDLE_VALUE ) { printf ( " \n " ) ; return 0 ; } if ( ! GetConsoleScreenBufferInfo ( hStdout , & ConScreenBuffer ) ) { redirected_out = 1 ; ConScreenBuffer . dwSize . X = 80 ; ConScreenBuffer . dwSize . Y = 25 ; ConScreenBuffer . srWindow . Bottom = 25 ; ConScreenBuffer . srWindow . Right = 80 ; } CurrentScreenWidth = ConScreenBuffer . dwSize . X ; CurrentScreenHeight = ConScreenBuffer . dwSize . Y ; GetConsoleCursorInfo ( hStdout , & ConCursorInfo ) ; #ifdef DEBUG fprintf ( errfp , " \n " , ConScreenBuffer . dwSize . X , ConScreenBuffer . dwSize . Y , ConScreenBuffer . dwCursorPosition . X , ConScreenBuffer . dwCursorPosition . Y ) ; fprintf ( errfp , " \n " , ConScreenBuffer . srWindow . Left , ConScreenBuffer . srWindow . Right , ConScreenBuffer . srWindow . Top , ConScreenBuffer . srWindow . Bottom , ConScreenBuffer . dwMaximumWindowSize . X , ConScreenBuffer . dwMaximumWindowSize . Y ) ; #endif if ( ConScreenBuffer . srWindow . Left || ConScreenBuffer . srWindow . Top ) { } cStartPos . X = 0 ; cStartPos . Y = 0 ; FillConsoleOutputCharacter ( hStdout , ( TCHAR ) ' ' , ( DWORD ) ( ConScreenBuffer . dwSize . X * ConScreenBuffer . dwSize . Y ) , cStartPos , & dwLen ) ; if ( fullscreen ) { LINES = ConScreenBuffer . dwSize . Y ; COLS = ConScreenBuffer . dwSize . X ; } else { LINES = ConScreenBuffer . srWindow . Bottom ; COLS = ConScreenBuffer . srWindow . Right ; } adjust_linescols ( ) ; platform_postcurses_init ( ) ; } return 1 ; }
Win32 Stuff
returns 0 if fails
Win32 Stuff returns 0 if fails
/* set up alternate character set values */ /* set up console I/O */ /*
			TODO: What to do with console output functions when output redirected ?
			2002-10-19, Perry
			*/ /* get info on cursor */ /*
		TODO: What to do with console cursor functions when output redirected?
		2005-09-21, Matt
		*/ /* WARNING: this code will not work correctly with offset window */ /* clear console (fill with blanks) */ /* save size into curses globals LINES & COLS */