/****************************************************************************
- * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. *
+ * Copyright 2018-2020,2021 Thomas E. Dickey *
+ * Copyright 2008-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#include <curses.priv.h>
-#ifdef __MINGW32__
+#ifdef _WIN32
#include <tchar.h>
#else
#include <windows.h>
#define CUR TerminalType(my_term).
-MODULE_ID("$Id: win_driver.c,v 1.59 2017/07/22 21:10:28 tom Exp $")
+MODULE_ID("$Id: win_driver.c,v 1.67 2021/09/04 10:54:35 tom Exp $")
-#ifndef __GNUC__
-# error We need GCC to compile for MinGW
-#endif
+#define TypeAlloca(type,count) (type*) _alloca(sizeof(type) * (size_t) (count))
#define WINMAGIC NCDRV_MAGIC(NCDRV_WINCONSOLE)
#define MAPSIZE (FKEYS + N_INI)
#define NUMPAIRS 64
-/* A process can only have a single console, so it's safe
+/* A process can only have a single console, so it is safe
to maintain all the information about it in a single
static structure.
*/
con_write16(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, cchar_t *str, int limit)
{
int actual = 0;
- CHAR_INFO ci[limit];
+ CHAR_INFO *ci = TypeAlloca(CHAR_INFO, limit);
COORD loc, siz;
SMALL_RECT rec;
int i;
static BOOL
con_write8(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, chtype *str, int n)
{
- CHAR_INFO ci[n];
+ CHAR_INFO *ci = TypeAlloca(CHAR_INFO, n);
COORD loc, siz;
SMALL_RECT rec;
int i;
if ((CurScreen(sp)->_clear || NewScreen(sp)->_clear)) {
int x;
#if USE_WIDEC_SUPPORT
- cchar_t empty[Width];
+ cchar_t *empty = TypeAlloca(cchar_t, Width);
wchar_t blank[2] =
{
L' ', L'\0'
for (x = 0; x < Width; x++)
setcchar(&empty[x], blank, 0, 0, 0);
#else
- chtype empty[Width];
+ chtype *empty = TypeAlloca(chtype, Width);
for (x = 0; x < Width; x++)
empty[x] = ' ';
int max_cells = (high * wide);
int i;
- CHAR_INFO this_screen[max_cells];
- CHAR_INFO that_screen[max_cells];
+ CHAR_INFO *this_screen = TypeAlloca(CHAR_INFO, max_cells);
+ CHAR_INFO *that_screen = TypeAlloca(CHAR_INFO, max_cells);
COORD this_size;
SMALL_RECT this_region;
COORD bufferCoord;
bufferCoord,
&this_region)) {
- memcpy(that_screen, this_screen, sizeof(that_screen));
+ memcpy(that_screen,
+ this_screen,
+ sizeof(CHAR_INFO) * (size_t) max_cells);
for (i = 0; i < max_cells; i++) {
that_screen[i].Attributes = RevAttr(that_screen[i].Attributes);
}
static int
-wcon_testmouse(TERMINAL_CONTROL_BLOCK * TCB, int delay)
+wcon_testmouse(TERMINAL_CONTROL_BLOCK * TCB,
+ int delay
+ EVENTLIST_2nd(_nc_eventlist * evl))
{
int rc = 0;
SCREEN *sp;
int diff;
bool isImmed = (milliseconds == 0);
+#ifdef NCURSES_WGETCH_EVENTS
+ (void) evl; /* TODO: implement wgetch-events */
+#endif
+
#define CONSUME() ReadConsoleInput(fd,&inp_rec,1,&nRead)
assert(sp);
CON.inp,
mode,
milliseconds,
- timeleft EVENTLIST_2nd(_nc_eventlist * evl));
+ timeleft EVENTLIST_2nd(evl));
}
return code;
}
#if WINVER >= 0x0600
/* This function tests, whether or not the ncurses application
is running as a descendant of MSYS2/cygwin mintty terminal
- application. mintty doesn't use Windows Console for it's screen
+ application. mintty doesn't use Windows Console for its screen
I/O, so the native Windows _isatty doesn't recognize it as
character device. But we can discover we are at the end of an
Pipe and can query to server side of the pipe, looking whether
/* This is used when running in terminfo mode to discover,
whether or not the "terminal" is actually a Windows
- Console. It's the responsibilty of the console to deal
+ Console. It is the responsibility of the console to deal
with the terminal escape sequences that are sent by
terminfo.
*/
_nc_mingw_testmouse(
SCREEN *sp,
HANDLE fd,
- int delay)
+ int delay
+ EVENTLIST_2nd(_nc_eventlist * evl))
{
int rc = 0;
static bool
InitConsole(void)
{
- /* initalize once, or not at all */
+ /* initialize once, or not at all */
if (!console_initialized) {
int i;
DWORD num_buttons;