1*7a656419SBaptiste Daroussin /**************************************************************************** 2*7a656419SBaptiste Daroussin * Copyright 2018-2019,2020 Thomas E. Dickey * 3*7a656419SBaptiste Daroussin * Copyright 2008-2010,2017 Free Software Foundation, Inc. * 4*7a656419SBaptiste Daroussin * * 5*7a656419SBaptiste Daroussin * Permission is hereby granted, free of charge, to any person obtaining a * 6*7a656419SBaptiste Daroussin * copy of this software and associated documentation files (the * 7*7a656419SBaptiste Daroussin * "Software"), to deal in the Software without restriction, including * 8*7a656419SBaptiste Daroussin * without limitation the rights to use, copy, modify, merge, publish, * 9*7a656419SBaptiste Daroussin * distribute, distribute with modifications, sublicense, and/or sell * 10*7a656419SBaptiste Daroussin * copies of the Software, and to permit persons to whom the Software is * 11*7a656419SBaptiste Daroussin * furnished to do so, subject to the following conditions: * 12*7a656419SBaptiste Daroussin * * 13*7a656419SBaptiste Daroussin * The above copyright notice and this permission notice shall be included * 14*7a656419SBaptiste Daroussin * in all copies or substantial portions of the Software. * 15*7a656419SBaptiste Daroussin * * 16*7a656419SBaptiste Daroussin * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 17*7a656419SBaptiste Daroussin * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 18*7a656419SBaptiste Daroussin * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 19*7a656419SBaptiste Daroussin * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 20*7a656419SBaptiste Daroussin * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 21*7a656419SBaptiste Daroussin * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 22*7a656419SBaptiste Daroussin * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 23*7a656419SBaptiste Daroussin * * 24*7a656419SBaptiste Daroussin * Except as contained in this notice, the name(s) of the above copyright * 25*7a656419SBaptiste Daroussin * holders shall not be used in advertising or otherwise to promote the * 26*7a656419SBaptiste Daroussin * sale, use or other dealings in this Software without prior written * 27*7a656419SBaptiste Daroussin * authorization. * 28*7a656419SBaptiste Daroussin ****************************************************************************/ 29*7a656419SBaptiste Daroussin 30*7a656419SBaptiste Daroussin /**************************************************************************** 31*7a656419SBaptiste Daroussin * Author: Thomas Dickey, 2008-on * 32*7a656419SBaptiste Daroussin ****************************************************************************/ 33*7a656419SBaptiste Daroussin 34*7a656419SBaptiste Daroussin /* $Id: nc_win32.h,v 1.9 2020/09/13 00:17:30 tom Exp $ */ 35*7a656419SBaptiste Daroussin 36*7a656419SBaptiste Daroussin #ifndef NC_WIN32_H 37*7a656419SBaptiste Daroussin #define NC_WIN32_H 1 38*7a656419SBaptiste Daroussin 39*7a656419SBaptiste Daroussin #if defined(_WIN32) || defined(_WIN64) 40*7a656419SBaptiste Daroussin 41*7a656419SBaptiste Daroussin #ifndef _NC_WINDOWS 42*7a656419SBaptiste Daroussin #define _NC_WINDOWS 43*7a656419SBaptiste Daroussin #endif 44*7a656419SBaptiste Daroussin 45*7a656419SBaptiste Daroussin #ifdef TERMIOS 46*7a656419SBaptiste Daroussin #error TERMIOS must not be defined on Windows 47*7a656419SBaptiste Daroussin #endif 48*7a656419SBaptiste Daroussin 49*7a656419SBaptiste Daroussin /* We no longer support WindowsXP. 50*7a656419SBaptiste Daroussin Minimum requirement is Windows Vista or Server2008, 51*7a656419SBaptiste Daroussin aka Windows NT 6.0 52*7a656419SBaptiste Daroussin */ 53*7a656419SBaptiste Daroussin #ifdef WINVER 54*7a656419SBaptiste Daroussin # if WINVER < 0x0600 55*7a656419SBaptiste Daroussin # error WINVER must at least be 0x0600 56*7a656419SBaptiste Daroussin # endif 57*7a656419SBaptiste Daroussin #else 58*7a656419SBaptiste Daroussin # define WINVER 0x0600 59*7a656419SBaptiste Daroussin #endif 60*7a656419SBaptiste Daroussin 61*7a656419SBaptiste Daroussin #undef _NC_CHECK_MINTTY 62*7a656419SBaptiste Daroussin #if WINVER >= 0x0600 63*7a656419SBaptiste Daroussin #define _NC_CHECK_MINTTY 64*7a656419SBaptiste Daroussin #endif 65*7a656419SBaptiste Daroussin 66*7a656419SBaptiste Daroussin #include <windows.h> 67*7a656419SBaptiste Daroussin 68*7a656419SBaptiste Daroussin #if HAVE_SYS_TIME_H 69*7a656419SBaptiste Daroussin #include <sys/time.h> /* for struct timeval */ 70*7a656419SBaptiste Daroussin #endif 71*7a656419SBaptiste Daroussin 72*7a656419SBaptiste Daroussin #ifdef _NC_MSC 73*7a656419SBaptiste Daroussin #include <winsock2.h> /* for struct timeval */ 74*7a656419SBaptiste Daroussin #endif 75*7a656419SBaptiste Daroussin 76*7a656419SBaptiste Daroussin #ifdef __cplusplus 77*7a656419SBaptiste Daroussin extern "C" { 78*7a656419SBaptiste Daroussin #endif 79*7a656419SBaptiste Daroussin 80*7a656419SBaptiste Daroussin #include <ncurses_dll.h> 81*7a656419SBaptiste Daroussin 82*7a656419SBaptiste Daroussin #undef HAVE_GETTIMEOFDAY 83*7a656419SBaptiste Daroussin #define HAVE_GETTIMEOFDAY 1 84*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(int) _nc_gettimeofday(struct timeval *, void *); 85*7a656419SBaptiste Daroussin 86*7a656419SBaptiste Daroussin #undef wcwidth 87*7a656419SBaptiste Daroussin #define wcwidth(ucs) _nc_wcwidth((wchar_t)(ucs)) 88*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(int) _nc_wcwidth(wchar_t); 89*7a656419SBaptiste Daroussin 90*7a656419SBaptiste Daroussin #ifdef EVENTLIST_2nd /* test.priv.h just needs the preceding */ 91*7a656419SBaptiste Daroussin 92*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(void) _nc_console_size(int* Lines, int* Cols); 93*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(HANDLE) _nc_console_handle(int fd); 94*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(int) _nc_console_isatty(int fd); 95*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(int) _nc_console_test(int fd); 96*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(int) _nc_console_read(SCREEN *sp,HANDLE hdl,int *buf); 97*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(int) _nc_console_twait(SCREEN *, HANDLE,int,int,int * EVENTLIST_2nd(_nc_eventlist * evl)); 98*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(WORD) _nc_console_MapColor(bool fore, int color); 99*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(void) _nc_console_selectActiveHandle(void); 100*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(bool) _nc_console_get_SBI(void); 101*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(void) _nc_console_set_scrollback(bool normal, CONSOLE_SCREEN_BUFFER_INFO * info); 102*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(int) _nc_console_testmouse(SCREEN *,HANDLE,int EVENTLIST_2nd(_nc_eventlist*)); 103*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(int) _nc_console_keyok(int keycode,int flag); 104*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(bool) _nc_console_keyExist(int keycode); 105*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(bool) _nc_console_checkinit(bool initFlag, bool assumeTermInfo); 106*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(int) _nc_console_vt_supported(void); 107*7a656419SBaptiste Daroussin 108*7a656419SBaptiste Daroussin #ifdef _NC_CHECK_MINTTY 109*7a656419SBaptiste Daroussin extern NCURSES_EXPORT(int) _nc_console_checkmintty(int fd, LPHANDLE pMinTTY); 110*7a656419SBaptiste Daroussin #endif 111*7a656419SBaptiste Daroussin 112*7a656419SBaptiste Daroussin #undef VALID_TERM_ENV 113*7a656419SBaptiste Daroussin #define MS_TERMINAL "ms-terminal" 114*7a656419SBaptiste Daroussin #define VALID_TERM_ENV(term_env, no_terminal) \ 115*7a656419SBaptiste Daroussin (term_env = (NonEmpty(term_env) \ 116*7a656419SBaptiste Daroussin ? term_env \ 117*7a656419SBaptiste Daroussin : (_nc_console_vt_supported() \ 118*7a656419SBaptiste Daroussin ? MS_TERMINAL \ 119*7a656419SBaptiste Daroussin : no_terminal)), \ 120*7a656419SBaptiste Daroussin NonEmpty(term_env)) 121*7a656419SBaptiste Daroussin 122*7a656419SBaptiste Daroussin /* 123*7a656419SBaptiste Daroussin * Various Console mode definitions 124*7a656419SBaptiste Daroussin */ 125*7a656419SBaptiste Daroussin 126*7a656419SBaptiste Daroussin /* Flags to enable virtual Terminal processing */ 127*7a656419SBaptiste Daroussin #define VT_FLAG_OUT ENABLE_VIRTUAL_TERMINAL_PROCESSING 128*7a656419SBaptiste Daroussin #define VT_FLAG_IN ENABLE_VIRTUAL_TERMINAL_INPUT 129*7a656419SBaptiste Daroussin 130*7a656419SBaptiste Daroussin /* Default flags for input/output modes */ 131*7a656419SBaptiste Daroussin #define CONMODE_IN_DEFAULT (ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT) 132*7a656419SBaptiste Daroussin #define CONMODE_OUT_DEFAULT (ENABLE_PROCESSED_OUTPUT | DISABLE_NEWLINE_AUTO_RETURN | ENABLE_LVB_GRID_WORLDWIDE) 133*7a656419SBaptiste Daroussin 134*7a656419SBaptiste Daroussin /* Flags to reset from RAW/CBREAK */ 135*7a656419SBaptiste Daroussin #define CONMODE_NORAW (ENABLE_PROCESSED_INPUT|ENABLE_LINE_INPUT) 136*7a656419SBaptiste Daroussin #define CONMODE_NOCBREAK (ENABLE_LINE_INPUT) 137*7a656419SBaptiste Daroussin 138*7a656419SBaptiste Daroussin 139*7a656419SBaptiste Daroussin #if defined(USE_TERM_DRIVER) && defined(USE_WIN32CON_DRIVER) 140*7a656419SBaptiste Daroussin extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_WIN_DRIVER; 141*7a656419SBaptiste Daroussin #endif 142*7a656419SBaptiste Daroussin 143*7a656419SBaptiste Daroussin #define CON_NUMPAIRS 64 144*7a656419SBaptiste Daroussin typedef struct { 145*7a656419SBaptiste Daroussin BOOL initialized; 146*7a656419SBaptiste Daroussin BOOL buffered; 147*7a656419SBaptiste Daroussin BOOL window_only; 148*7a656419SBaptiste Daroussin BOOL progMode; 149*7a656419SBaptiste Daroussin BOOL isMinTTY; 150*7a656419SBaptiste Daroussin BOOL isTermInfoConsole; 151*7a656419SBaptiste Daroussin HANDLE out; 152*7a656419SBaptiste Daroussin HANDLE inp; 153*7a656419SBaptiste Daroussin HANDLE hdl; 154*7a656419SBaptiste Daroussin HANDLE lastOut; 155*7a656419SBaptiste Daroussin int numButtons; 156*7a656419SBaptiste Daroussin LPDWORD ansi_map; 157*7a656419SBaptiste Daroussin LPDWORD map; 158*7a656419SBaptiste Daroussin LPDWORD rmap; 159*7a656419SBaptiste Daroussin WORD pairs[CON_NUMPAIRS]; 160*7a656419SBaptiste Daroussin COORD origin; 161*7a656419SBaptiste Daroussin CHAR_INFO *save_screen; 162*7a656419SBaptiste Daroussin COORD save_size; 163*7a656419SBaptiste Daroussin SMALL_RECT save_region; 164*7a656419SBaptiste Daroussin CONSOLE_SCREEN_BUFFER_INFO SBI; 165*7a656419SBaptiste Daroussin CONSOLE_SCREEN_BUFFER_INFO save_SBI; 166*7a656419SBaptiste Daroussin CONSOLE_CURSOR_INFO save_CI; 167*7a656419SBaptiste Daroussin TTY originalMode; 168*7a656419SBaptiste Daroussin } ConsoleInfo; 169*7a656419SBaptiste Daroussin 170*7a656419SBaptiste Daroussin extern NCURSES_EXPORT_VAR(ConsoleInfo) _nc_CONSOLE; 171*7a656419SBaptiste Daroussin #define WINCONSOLE _nc_CONSOLE 172*7a656419SBaptiste Daroussin 173*7a656419SBaptiste Daroussin #define TypeAlloca(type,count)(type*) _alloca(sizeof(type)*(size_t)(count)) 174*7a656419SBaptiste Daroussin 175*7a656419SBaptiste Daroussin #endif /* EVENTLIST_2nd */ 176*7a656419SBaptiste Daroussin 177*7a656419SBaptiste Daroussin #ifdef __cplusplus 178*7a656419SBaptiste Daroussin } 179*7a656419SBaptiste Daroussin #endif 180*7a656419SBaptiste Daroussin 181*7a656419SBaptiste Daroussin #endif /* _WIN32 || _WIN64 */ 182*7a656419SBaptiste Daroussin 183*7a656419SBaptiste Daroussin #endif /* NC_WIN32_H */ 184