From 72996797a02093522e87158a3105f7af237702f6 Mon Sep 17 00:00:00 2001 From: casey langen Date: Sun, 1 Sep 2019 21:53:20 -0700 Subject: [PATCH] Upgraded PDCurses --- src/3rdparty/bin | 2 +- src/3rdparty/win32_include/curses.h | 15 ++-- src/3rdparty/win32_include/curspriv.h | 1 + src/3rdparty/win32_src/pdcurses/README.md | 88 +++++++++++++++++--- src/3rdparty/win32_src/pdcurses/addch.c | 6 +- src/3rdparty/win32_src/pdcurses/addchstr.c | 4 +- src/3rdparty/win32_src/pdcurses/addstr.c | 2 +- src/3rdparty/win32_src/pdcurses/attr.c | 2 +- src/3rdparty/win32_src/pdcurses/beep.c | 2 +- src/3rdparty/win32_src/pdcurses/bkgd.c | 14 ++-- src/3rdparty/win32_src/pdcurses/border.c | 24 +++--- src/3rdparty/win32_src/pdcurses/clear.c | 2 +- src/3rdparty/win32_src/pdcurses/color.c | 2 +- src/3rdparty/win32_src/pdcurses/debug.c | 2 +- src/3rdparty/win32_src/pdcurses/delch.c | 2 +- src/3rdparty/win32_src/pdcurses/deleteln.c | 4 +- src/3rdparty/win32_src/pdcurses/deprec.c | 6 +- src/3rdparty/win32_src/pdcurses/getch.c | 94 +++++++++++----------- src/3rdparty/win32_src/pdcurses/getstr.c | 2 +- src/3rdparty/win32_src/pdcurses/getyx.c | 2 +- src/3rdparty/win32_src/pdcurses/inch.c | 2 +- src/3rdparty/win32_src/pdcurses/initscr.c | 2 +- src/3rdparty/win32_src/pdcurses/inopts.c | 10 +-- src/3rdparty/win32_src/pdcurses/insch.c | 2 +- src/3rdparty/win32_src/pdcurses/insstr.c | 2 +- src/3rdparty/win32_src/pdcurses/instr.c | 2 +- src/3rdparty/win32_src/pdcurses/kernel.c | 2 +- src/3rdparty/win32_src/pdcurses/keyname.c | 2 +- src/3rdparty/win32_src/pdcurses/mouse.c | 25 ++++-- src/3rdparty/win32_src/pdcurses/move.c | 2 +- src/3rdparty/win32_src/pdcurses/outopts.c | 2 +- src/3rdparty/win32_src/pdcurses/overlay.c | 2 +- src/3rdparty/win32_src/pdcurses/pad.c | 2 +- src/3rdparty/win32_src/pdcurses/panel.c | 4 +- src/3rdparty/win32_src/pdcurses/pdckbd.c | 5 ++ src/3rdparty/win32_src/pdcurses/printw.c | 2 +- src/3rdparty/win32_src/pdcurses/refresh.c | 6 +- src/3rdparty/win32_src/pdcurses/scanw.c | 16 ++-- src/3rdparty/win32_src/pdcurses/scr_dump.c | 2 +- src/3rdparty/win32_src/pdcurses/scroll.c | 8 +- src/3rdparty/win32_src/pdcurses/slk.c | 7 +- src/3rdparty/win32_src/pdcurses/termattr.c | 2 +- src/3rdparty/win32_src/pdcurses/terminfo.c | 2 +- src/3rdparty/win32_src/pdcurses/touch.c | 4 +- src/3rdparty/win32_src/pdcurses/util.c | 2 +- src/3rdparty/win32_src/pdcurses/window.c | 2 +- 46 files changed, 241 insertions(+), 154 deletions(-) diff --git a/src/3rdparty/bin b/src/3rdparty/bin index f77857c24..31cd71097 160000 --- a/src/3rdparty/bin +++ b/src/3rdparty/bin @@ -1 +1 @@ -Subproject commit f77857c24dec5e4d6d900995ed3d140088657eb6 +Subproject commit 31cd7109785075fc18ddb6319440c5cbb305e702 diff --git a/src/3rdparty/win32_include/curses.h b/src/3rdparty/win32_include/curses.h index e99585fa0..942e007f8 100755 --- a/src/3rdparty/win32_include/curses.h +++ b/src/3rdparty/win32_include/curses.h @@ -42,7 +42,7 @@ PDCurses portable platform definitions list: /*----------------------------------------------------------------------*/ #ifdef NO_STDINT_H - #define uint64_t unsigned long long + #define uint64_t unsigned __int64 #define uint32_t unsigned long #define uint16_t unsigned short #else @@ -56,7 +56,7 @@ PDCurses portable platform definitions list: # include #endif -#if defined(__STDC_VERSION__) && __STDC_VERSION >= 199901L && \ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \ !defined(__bool_true_false_are_defined) # include #endif @@ -116,11 +116,11 @@ typedef chtype attr_t; /* Don't forget to update 'version.mif' if MAJOR/MINOR changes! */ #define PDC_VER_MAJOR 4 -#define PDC_VER_MINOR 0 -#define PDC_VER_CHANGE 4 +#define PDC_VER_MINOR 1 +#define PDC_VER_CHANGE 0 #define PDC_VER_YEAR 2019 -#define PDC_VER_MONTH 1 -#define PDC_VER_DAY 20 +#define PDC_VER_MONTH 5 +#define PDC_VER_DAY 8 #define PDC_BUILD (PDC_VER_MAJOR*1000 + PDC_VER_MINOR *100 + PDC_VER_CHANGE) @@ -1725,6 +1725,7 @@ PDCEX bool has_key(int); PDCEX int use_default_colors(void); PDCEX int wresize(WINDOW *, int, int); +PDCEX bool has_mouse(void); PDCEX int mouseinterval(int); PDCEX mmask_t mousemask(mmask_t, mmask_t *); PDCEX bool mouse_trafo(int *, int *, bool); @@ -1789,8 +1790,8 @@ PDCEX int PDC_set_function_key( const unsigned function, const int new_key); PDCEX int PDC_set_preferred_fontface( const wchar_t* fontface); -PDCEX void PDC_set_default_menu_visibility( int visible); PDCEX void PDC_set_color_intensify_enabled( bool enabled); +PDCEX void PDC_set_default_menu_visibility(int visible); PDCEX WINDOW *Xinitscr(int, char **); #ifdef XCURSES diff --git a/src/3rdparty/win32_include/curspriv.h b/src/3rdparty/win32_include/curspriv.h index b5edcc173..741526ce4 100644 --- a/src/3rdparty/win32_include/curspriv.h +++ b/src/3rdparty/win32_include/curspriv.h @@ -71,6 +71,7 @@ int PDC_get_cursor_mode(void); int PDC_get_key(void); int PDC_get_rows(void); void PDC_gotoyx(int, int); +bool PDC_has_mouse(void); int PDC_init_color(short, short, short, short); void PDC_init_pair(short, short, short); int PDC_modifiers_set(void); diff --git a/src/3rdparty/win32_src/pdcurses/README.md b/src/3rdparty/win32_src/pdcurses/README.md index bef1c4c46..4b58370aa 100644 --- a/src/3rdparty/win32_src/pdcurses/README.md +++ b/src/3rdparty/win32_src/pdcurses/README.md @@ -1,25 +1,93 @@ -PDCurses Portable Core -====================== - -This directory contains core PDCurses source code files common to all -platforms. +PDCurses for WinGUI +================== +This directory contains PDCurses source code files specific to Win32 +graphics mode (Win95 and all subsequent forks of Windows). Building -------- -These modules are built by the platform-specific makefiles, in the -platform directories. + (Note that the following is almost identical to the instructions + for the Win32 console flavor of PDCurses.) +- Choose the appropriate makefile for your compiler: + + Makefile.bcc - Borland C++ 4.0.2+ + Makefile.dmc - Digital Mars + Makefile.lcc - LCC-Win32 + Makefile.mng - MinGW, Cygnus GNU Compiler + Makefile.vc - Microsoft Visual C++ 2.0+ or later & Intel(R) compiler + Makefile.wcc - Watcom 10.6+ or OpenWATCOM + +- Optionally, you can build in a different directory than the platform + directory by setting PDCURSES_SRCDIR to point to the directory where + you unpacked PDCurses, and changing to your target directory: + + set PDCURSES_SRCDIR=c:\pdcurses + + This won't work with the LCC or Digital Mars makefiles, nor will the + options described below. + +- Build it: + + make -f makefilename + + (For Watcom, use "wmake" instead of "make"; for MSVC, "nmake".) You'll + get the libraries (pdcurses.lib or .a, depending on your compiler; and + panel.lib or .a), the demos (*.exe), and a lot of object files. Note + that the panel library is just a copy of the main library, provided + for convenience; both panel and curses functions are in the main + library. + + You can also give the optional parameter "WIDE=Y", to build the + library with wide-character (Unicode) support: + + make -f Makefile.mng WIDE=Y + + When built this way, the library is not compatible with Windows 9x, + unless you also link with the Microsoft Layer for Unicode (not + tested). + + For the Intel(R) compiler, use Makefile.vc and add ICC=Y. + + By default, Makefile.vc results in 64-bit code for both VC and Intel(R). + Add IX86=Y to generate 32-bit code. (Other builds are 32-bit only.) + + Another option, "UTF8=Y", makes PDCurses ignore the system locale, and + treat all narrow-character strings as UTF-8. This option has no effect + unless WIDE=Y is also set. This was originally provided to get around + poor support for UTF-8 in the Win32 console: + + make -f Makefile.mng WIDE=Y UTF8=Y + + WinGUI doesn't have the same limitations as the Win32 console flavor, + but UTF-8 and non-UTF-8 versions are still available. If nothing else, + this means that if you've built a Win32 console PDCurses DLL with any + configuration, you can build a matching WinGUI DLL and swap between + console or GUI PDCurses just by swapping DLLs. + + You can also use the optional parameter "DLL=Y" with Visual C++, + MinGW or Cygwin, to build the library as a DLL: + + nmake -f Makefile.vc WIDE=Y DLL=Y + + When you build the library as a Windows DLL, you must always define + PDC_DLL_BUILD when linking against it. (Or, if you only want to use + the DLL, you could add this definition to your curses.h.) + + If cross-compiling from Linux, add the parameter `_w64=1` to get + 64-bit code (default will be 32-bit). + + make -f Makefile.mng _w64=1 [WIDE=Y UTF8=Y DLL=Y] Distribution Status ------------------- The files in this directory are released to the Public Domain. - Acknowledgements ---------------- -The panel library was originally provided by -Warren Tucker +Based heavily on the Win32 console flavor of PDCurses by Chris Szurgot +, ported to Win32 GUI by Bill Gray +. diff --git a/src/3rdparty/win32_src/pdcurses/addch.c b/src/3rdparty/win32_src/pdcurses/addch.c index f4bd4e0c8..8d5af51f8 100644 --- a/src/3rdparty/win32_src/pdcurses/addch.c +++ b/src/3rdparty/win32_src/pdcurses/addch.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -362,7 +362,7 @@ int PDC_expand_combined_characters( const cchar_t c, cchar_t *added) combos = NULL; return( 0); } - assert( c >= COMBINED_CHAR_START && c < COMBINED_CHAR_START + n_combos); + assert( (int)c >= COMBINED_CHAR_START && (int)c < COMBINED_CHAR_START + n_combos); *added = combos[c - COMBINED_CHAR_START].added; return( combos[c - COMBINED_CHAR_START].root); } @@ -435,6 +435,8 @@ int waddch( WINDOW *win, const chtype ch) if (!SP->raw_out) x = 0; + /* Had this commented out. I think it matters in */ + /* wide, non-UTF8 mode on some platforms. */ wclrtoeol(win); if (++y > win->_bmarg) diff --git a/src/3rdparty/win32_src/pdcurses/addchstr.c b/src/3rdparty/win32_src/pdcurses/addchstr.c index c1a0f1124..0369f8d7c 100644 --- a/src/3rdparty/win32_src/pdcurses/addchstr.c +++ b/src/3rdparty/win32_src/pdcurses/addchstr.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -100,7 +100,7 @@ int waddchnstr(WINDOW *win, const chtype *ch, int n) PDC_LOG(("y %d x %d minx %d maxx %d *ptr %x *ch" " %x firstch: %d lastch: %d\n", - y, x, minx, maxx, *ptr, *ch, + y, x, minx, maxx, *ptr, *ch, win->_firstch[y], win->_lastch[y])); *ptr = *ch; diff --git a/src/3rdparty/win32_src/pdcurses/addstr.c b/src/3rdparty/win32_src/pdcurses/addstr.c index a2a9465cb..cf2be8fac 100644 --- a/src/3rdparty/win32_src/pdcurses/addstr.c +++ b/src/3rdparty/win32_src/pdcurses/addstr.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/attr.c b/src/3rdparty/win32_src/pdcurses/attr.c index c80e84a9c..0cd64da8d 100644 --- a/src/3rdparty/win32_src/pdcurses/attr.c +++ b/src/3rdparty/win32_src/pdcurses/attr.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/beep.c b/src/3rdparty/win32_src/pdcurses/beep.c index 857706ccb..c6e5a35e6 100644 --- a/src/3rdparty/win32_src/pdcurses/beep.c +++ b/src/3rdparty/win32_src/pdcurses/beep.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/bkgd.c b/src/3rdparty/win32_src/pdcurses/bkgd.c index e0864471f..5c6ef200b 100644 --- a/src/3rdparty/win32_src/pdcurses/bkgd.c +++ b/src/3rdparty/win32_src/pdcurses/bkgd.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -89,7 +89,7 @@ int wbkgd(WINDOW *win, chtype ch) newch = win->_bkgd & A_CHARTEXT; - /* what follows is what seems to occur in the System V + /* what follows is what seems to occur in the System V implementation of this routine */ for (y = 0; y < win->_maxy; y++) @@ -100,26 +100,26 @@ int wbkgd(WINDOW *win, chtype ch) ch = *winptr; - /* determine the colors and attributes of the character read + /* determine the colors and attributes of the character read from the window */ colr = ch & A_COLOR; attr = ch & (A_ATTRIBUTES ^ A_COLOR); - /* if the color is the same as the old background color, + /* if the color is the same as the old background color, then make it the new background color, otherwise leave it */ if (colr == oldcolr) colr = newcolr; - /* remove any attributes (non color) from the character that - were part of the old background, then combine the + /* remove any attributes (non color) from the character that + were part of the old background, then combine the remaining ones with the new background */ attr ^= oldattr; attr |= newattr; - /* change character if it is there because it was the old + /* change character if it is there because it was the old background character */ ch &= A_CHARTEXT; diff --git a/src/3rdparty/win32_src/pdcurses/border.c b/src/3rdparty/win32_src/pdcurses/border.c index 66ed41be3..23975c476 100644 --- a/src/3rdparty/win32_src/pdcurses/border.c +++ b/src/3rdparty/win32_src/pdcurses/border.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -97,28 +97,28 @@ border **man-end****************************************************************/ -/* _attr_passthru() -- Takes a single chtype 'ch' and checks if the - current attribute of window 'win', as set by wattrset(), and/or the - current background of win, as set by wbkgd(), should by combined with +/* _attr_passthru() -- Takes a single chtype 'ch' and checks if the + current attribute of window 'win', as set by wattrset(), and/or the + current background of win, as set by wbkgd(), should by combined with it. Attributes set explicitly in ch take precedence. */ static chtype _attr_passthru(WINDOW *win, chtype ch) { chtype attr; - /* If the incoming character doesn't have its own attribute, then - use the current attributes for the window. If the incoming - character has attributes, but not a color component, OR the - attributes to the current attributes for the window. If the - incoming character has a color component, use only the attributes + /* If the incoming character doesn't have its own attribute, then + use the current attributes for the window. If the incoming + character has attributes, but not a color component, OR the + attributes to the current attributes for the window. If the + incoming character has a color component, use only the attributes from the incoming character. */ attr = ch & A_ATTRIBUTES; if (!(attr & A_COLOR)) attr |= win->_attrs; - /* wrs (4/10/93) -- Apply the same sort of logic for the window - background, in that it only takes precedence if other color + /* wrs (4/10/93) -- Apply the same sort of logic for the window + background, in that it only takes precedence if other color attributes are not there. */ if (!(attr & A_COLOR)) @@ -131,7 +131,7 @@ static chtype _attr_passthru(WINDOW *win, chtype ch) return ch; } -int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, +int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br) { int i, ymax, xmax; diff --git a/src/3rdparty/win32_src/pdcurses/clear.c b/src/3rdparty/win32_src/pdcurses/clear.c index 7e14b2658..6f46c6252 100644 --- a/src/3rdparty/win32_src/pdcurses/clear.c +++ b/src/3rdparty/win32_src/pdcurses/clear.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/color.c b/src/3rdparty/win32_src/pdcurses/color.c index e0745fb36..d2e9da7ce 100644 --- a/src/3rdparty/win32_src/pdcurses/color.c +++ b/src/3rdparty/win32_src/pdcurses/color.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/debug.c b/src/3rdparty/win32_src/pdcurses/debug.c index 3c0e28feb..ed6b4b28d 100644 --- a/src/3rdparty/win32_src/pdcurses/debug.c +++ b/src/3rdparty/win32_src/pdcurses/debug.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/delch.c b/src/3rdparty/win32_src/pdcurses/delch.c index 2dfc43712..f55a28e7d 100644 --- a/src/3rdparty/win32_src/pdcurses/delch.c +++ b/src/3rdparty/win32_src/pdcurses/delch.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/deleteln.c b/src/3rdparty/win32_src/pdcurses/deleteln.c index f94b49254..8274fc917 100644 --- a/src/3rdparty/win32_src/pdcurses/deleteln.c +++ b/src/3rdparty/win32_src/pdcurses/deleteln.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -79,7 +79,7 @@ int wdeleteln(WINDOW *win) for (ptr = temp; (ptr - temp < win->_maxx); ptr++) *ptr = blank; /* make a blank line */ - if (win->_cury <= win->_bmarg) + if (win->_cury <= win->_bmarg) { win->_firstch[win->_bmarg] = 0; win->_lastch[win->_bmarg] = win->_maxx - 1; diff --git a/src/3rdparty/win32_src/pdcurses/deprec.c b/src/3rdparty/win32_src/pdcurses/deprec.c index 561c1511a..a7c9a82bc 100644 --- a/src/3rdparty/win32_src/pdcurses/deprec.c +++ b/src/3rdparty/win32_src/pdcurses/deprec.c @@ -1,9 +1,9 @@ -/* Public Domain Curses */ +/* PDCurses */ #include -/* Deprecated functions. These should not be used, and will eventually - be removed. They're here solely for the benefit of applications that +/* Deprecated functions. These should not be used, and will eventually + be removed. They're here solely for the benefit of applications that linked to them in older versions of PDCurses. */ bool PDC_check_bios_key(void) diff --git a/src/3rdparty/win32_src/pdcurses/getch.c b/src/3rdparty/win32_src/pdcurses/getch.c index 5534c3dfd..5ea48140d 100644 --- a/src/3rdparty/win32_src/pdcurses/getch.c +++ b/src/3rdparty/win32_src/pdcurses/getch.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -28,36 +28,45 @@ getch ### Description - With the getch(), wgetch(), mvgetch(), and mvwgetch() functions, - a character is read from the terminal associated with the window. - In nodelay mode, if there is no input waiting, the value ERR is + With the getch(), wgetch(), mvgetch(), and mvwgetch() functions, a + character is read from the terminal associated with the window. In + nodelay mode, if there is no input waiting, the value ERR is returned. In delay mode, the program will hang until the system passes text through to the program. Depending on the setting of cbreak(), this will be after one character or after the first - newline. Unless noecho() has been set, the character will also - be echoed into the designated window. + newline. Unless noecho() has been set, the character will also be + echoed into the designated window. If keypad() is TRUE, and a function key is pressed, the token for that function key will be returned instead of the raw characters. Possible function keys are defined in with integers beginning with 0401, whose names begin with KEY_. - If nodelay(win, TRUE) has been called on the window and no input - is waiting, the value ERR is returned. + If nodelay(win, TRUE) has been called on the window and no input is + waiting, the value ERR is returned. - ungetch() places ch back onto the input queue to be returned by - the next call to wgetch(). + ungetch() places ch back onto the input queue to be returned by the + next call to wgetch(). - flushinp() throws away any type-ahead that has been typed by the - user and has not yet been read by the program. + flushinp() throws away any type-ahead that has been typed by the user + and has not yet been read by the program. + + wget_wch() is the wide-character version of wgetch(), available when + PDCurses is built with the PDC_WIDE option. It takes a pointer to a + wint_t rather than returning the key as an int, and instead returns + KEY_CODE_YES if the key is a function key. Otherwise, it returns OK + or ERR. It's important to check for KEY_CODE_YES, since regular wide + characters can have the same values as function key codes. + + unget_wch() puts a wide character on the input queue. PDC_get_key_modifiers() returns the keyboard modifiers (shift, control, alt, numlock) effective at the time of the last getch() call, if PDC_save_key_modifiers(TRUE) has been called before the getch(). Use the macros PDC_KEY_MODIFIER_* to determine which - modifier(s) were set. PDC_return_key_modifiers() tells getch() - to return modifier keys pressed alone as keystrokes (KEY_ALT_L, - etc.). These may not work on all platforms. + modifier(s) were set. PDC_return_key_modifiers() tells getch() to + return modifier keys pressed alone as keystrokes (KEY_ALT_L, etc.). + These may not work on all platforms. NOTE: getch() and ungetch() are implemented as macros, to avoid conflict with many DOS compiler's runtime libraries. @@ -68,18 +77,18 @@ getch character or function key token. ### Portability - X/Open BSD SYS V + X/Open ncurses NetBSD getch Y Y Y wgetch Y Y Y mvgetch Y Y Y mvwgetch Y Y Y ungetch Y Y Y flushinp Y Y Y - get_wch Y - wget_wch Y - mvget_wch Y - mvwget_wch Y - unget_wch Y + get_wch Y Y Y + wget_wch Y Y Y + mvget_wch Y Y Y + mvwget_wch Y Y Y + unget_wch Y Y Y PDC_get_key_modifiers - - - **man-end****************************************************************/ @@ -92,7 +101,7 @@ static int c_gindex = 1; /* getter index */ static int c_ungind = 0; /* ungetch() push index */ static int c_ungch[NUNGETCH]; /* array of ungotten chars */ -static int _mouse_key(WINDOW *win) +static int _mouse_key(void) { int i, key = KEY_MOUSE; unsigned long mbe = SP->_trap_mbe; @@ -161,32 +170,24 @@ static int _mouse_key(WINDOW *win) return key; } +#define WAIT_FOREVER -1 + int wgetch(WINDOW *win) { static int buffer[_INBUFSIZ]; /* character buffer */ - int key, waitcount; + int key, remaining_millisecs; PDC_LOG(("wgetch() - called\n")); if (!win) return ERR; - waitcount = 0; - - /* set the number of 1/20th second napms() calls */ - if (SP->delaytenths) - waitcount = 2 * SP->delaytenths; + remaining_millisecs = 100 * SP->delaytenths; else - if (win->_delayms) - { - /* Can't really do millisecond intervals, so delay in - 1/20ths of a second (50ms) */ - - waitcount = win->_delayms / 50; - if (!waitcount) - waitcount = 1; - } + remaining_millisecs = win->_delayms; + if( !remaining_millisecs && !win->_nodelay) + remaining_millisecs = WAIT_FOREVER; /* refresh window when wgetch is called if there have been changes to it and it is not a pad */ @@ -215,24 +216,23 @@ int wgetch(WINDOW *win) for (;;) /* loop for any buffering */ { + /* is there a keystroke ready? */ if (!PDC_check_key()) { /* if not, handle timeout() and halfdelay() */ + int nap_time = 50; - if (SP->delaytenths || win->_delayms) + if (remaining_millisecs != WAIT_FOREVER) { - if (!waitcount) + if (!remaining_millisecs) return ERR; - - waitcount--; + if( nap_time > remaining_millisecs) + nap_time = remaining_millisecs; + remaining_millisecs -= nap_time; } - else - if (win->_nodelay) - return ERR; - - napms(50); /* sleep for 1/20th second */ + napms( nap_time); continue; /* then check again */ } @@ -251,7 +251,7 @@ int wgetch(WINDOW *win) area to function keys */ else if (key == KEY_MOUSE) - key = _mouse_key(win); + key = _mouse_key(); } /* unwanted key? loop back */ diff --git a/src/3rdparty/win32_src/pdcurses/getstr.c b/src/3rdparty/win32_src/pdcurses/getstr.c index 6e3d3a028..828241916 100644 --- a/src/3rdparty/win32_src/pdcurses/getstr.c +++ b/src/3rdparty/win32_src/pdcurses/getstr.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/getyx.c b/src/3rdparty/win32_src/pdcurses/getyx.c index 804f7e8ef..268186570 100644 --- a/src/3rdparty/win32_src/pdcurses/getyx.c +++ b/src/3rdparty/win32_src/pdcurses/getyx.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/inch.c b/src/3rdparty/win32_src/pdcurses/inch.c index 97259b952..47c16362d 100644 --- a/src/3rdparty/win32_src/pdcurses/inch.c +++ b/src/3rdparty/win32_src/pdcurses/inch.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/initscr.c b/src/3rdparty/win32_src/pdcurses/initscr.c index dee1a609b..0d63e9d2c 100644 --- a/src/3rdparty/win32_src/pdcurses/initscr.c +++ b/src/3rdparty/win32_src/pdcurses/initscr.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/inopts.c b/src/3rdparty/win32_src/pdcurses/inopts.c index 166cb470f..6c730c829 100644 --- a/src/3rdparty/win32_src/pdcurses/inopts.c +++ b/src/3rdparty/win32_src/pdcurses/inopts.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -277,7 +277,7 @@ void wtimeout(WINDOW *win, int delay) if (delay < 0) { - /* This causes a blocking read on the window, so turn on delay + /* This causes a blocking read on the window, so turn on delay mode */ win->_nodelay = FALSE; @@ -285,7 +285,7 @@ void wtimeout(WINDOW *win, int delay) } else if (!delay) { - /* This causes a non-blocking read on the window, so turn off + /* This causes a non-blocking read on the window, so turn off delay mode */ win->_nodelay = TRUE; @@ -293,8 +293,8 @@ void wtimeout(WINDOW *win, int delay) } else { - /* This causes the read on the window to delay for the number of - milliseconds. Also forces the window into non-blocking read + /* This causes the read on the window to delay for the number of + milliseconds. Also forces the window into non-blocking read mode */ /*win->_nodelay = TRUE;*/ diff --git a/src/3rdparty/win32_src/pdcurses/insch.c b/src/3rdparty/win32_src/pdcurses/insch.c index f335fba1b..a6434bd36 100644 --- a/src/3rdparty/win32_src/pdcurses/insch.c +++ b/src/3rdparty/win32_src/pdcurses/insch.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/insstr.c b/src/3rdparty/win32_src/pdcurses/insstr.c index d8355b4b4..3c9c6e3b2 100644 --- a/src/3rdparty/win32_src/pdcurses/insstr.c +++ b/src/3rdparty/win32_src/pdcurses/insstr.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/instr.c b/src/3rdparty/win32_src/pdcurses/instr.c index 08e14b24e..23f8332ee 100644 --- a/src/3rdparty/win32_src/pdcurses/instr.c +++ b/src/3rdparty/win32_src/pdcurses/instr.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/kernel.c b/src/3rdparty/win32_src/pdcurses/kernel.c index 6eb5c3045..ab54b5125 100644 --- a/src/3rdparty/win32_src/pdcurses/kernel.c +++ b/src/3rdparty/win32_src/pdcurses/kernel.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/keyname.c b/src/3rdparty/win32_src/pdcurses/keyname.c index 581eb8647..0df91a898 100644 --- a/src/3rdparty/win32_src/pdcurses/keyname.c +++ b/src/3rdparty/win32_src/pdcurses/keyname.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/mouse.c b/src/3rdparty/win32_src/pdcurses/mouse.c index b0b33b3c0..37b074a8f 100644 --- a/src/3rdparty/win32_src/pdcurses/mouse.c +++ b/src/3rdparty/win32_src/pdcurses/mouse.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -25,6 +25,7 @@ mouse mmask_t mousemask(mmask_t mask, mmask_t *oldmask); int nc_getmouse(MEVENT *event); int ungetmouse(MEVENT *event); + bool has_mouse(void); ### Description @@ -72,13 +73,12 @@ mouse to map a mouse action to the Soft Label Keys as set by the map_button() function. - The ncurses interface: mouseinterval(), wenclose(), - wmouse_trafo(), mouse_trafo(), mousemask(), nc_getmouse(), and - ungetmouse(). A typical application using this interface would - start by calling mousemask() with a non-zero value, often - ALL_MOUSE_EVENTS. Then it would check for a KEY_MOUSE return - from getch(). If found, it would call nc_getmouse() to get the - current mouse status. + The ncurses interface: mouseinterval(), wenclose(), wmouse_traၱfo(), + mouse_trafo(), mousemask(), nc_getmouse(), ungetmouse(), and + has_mouse(). A typical application using this interface would start + by calling mousemask() with a non-zero value, often ALL_MOUSE_EVENTS. + Then it would check for a KEY_MOUSE return from getch(). If found, it + would call nc_getmouse() to get the current mouse status. mouseinterval() sets the timeout for a mouse click. On all current platforms, PDCurses receives mouse button press and @@ -131,6 +131,9 @@ mouse be pushed back, and it can overwrite or be overwritten by real mouse events. + has_mouse() reports whether the mouse is available at all on the + current platform. + ### Portability X/Open BSD SYS V mouse_set - - 4.0 @@ -148,6 +151,7 @@ mouse mousemask - - - nc_getmouse - - - ungetmouse - - - + has_mouse - - - **man-end****************************************************************/ @@ -436,3 +440,8 @@ int ungetmouse(MEVENT *event) return ungetch(KEY_MOUSE); } + +bool has_mouse(void) +{ + return PDC_has_mouse(); +} diff --git a/src/3rdparty/win32_src/pdcurses/move.c b/src/3rdparty/win32_src/pdcurses/move.c index 062f115ce..780ccce58 100644 --- a/src/3rdparty/win32_src/pdcurses/move.c +++ b/src/3rdparty/win32_src/pdcurses/move.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/outopts.c b/src/3rdparty/win32_src/pdcurses/outopts.c index 605e88729..87eafd99b 100644 --- a/src/3rdparty/win32_src/pdcurses/outopts.c +++ b/src/3rdparty/win32_src/pdcurses/outopts.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/overlay.c b/src/3rdparty/win32_src/pdcurses/overlay.c index 41e5e7f64..038eef939 100644 --- a/src/3rdparty/win32_src/pdcurses/overlay.c +++ b/src/3rdparty/win32_src/pdcurses/overlay.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/pad.c b/src/3rdparty/win32_src/pdcurses/pad.c index 77bdec4c4..178847f6b 100644 --- a/src/3rdparty/win32_src/pdcurses/pad.c +++ b/src/3rdparty/win32_src/pdcurses/pad.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/panel.c b/src/3rdparty/win32_src/pdcurses/panel.c index fbee054bf..6a735e959 100644 --- a/src/3rdparty/win32_src/pdcurses/panel.c +++ b/src/3rdparty/win32_src/pdcurses/panel.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -620,7 +620,7 @@ void update_panels(void) if (is_wintouched(stdscr)) Wnoutrefresh(&_stdscr_pseudo_panel); - + pan = _bottom_panel; while (pan) diff --git a/src/3rdparty/win32_src/pdcurses/pdckbd.c b/src/3rdparty/win32_src/pdcurses/pdckbd.c index 7255aa632..198ccfd41 100644 --- a/src/3rdparty/win32_src/pdcurses/pdckbd.c +++ b/src/3rdparty/win32_src/pdcurses/pdckbd.c @@ -127,6 +127,11 @@ void PDC_flushinp(void) } } +bool PDC_has_mouse( void) +{ + return TRUE; +} + int PDC_mouse_set(void) { /* If turning on mouse input: Set ENABLE_MOUSE_INPUT, and clear diff --git a/src/3rdparty/win32_src/pdcurses/printw.c b/src/3rdparty/win32_src/pdcurses/printw.c index 3961faa7e..ccdb5ad3f 100644 --- a/src/3rdparty/win32_src/pdcurses/printw.c +++ b/src/3rdparty/win32_src/pdcurses/printw.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/refresh.c b/src/3rdparty/win32_src/pdcurses/refresh.c index 7facd7d05..4ff9efd4b 100644 --- a/src/3rdparty/win32_src/pdcurses/refresh.c +++ b/src/3rdparty/win32_src/pdcurses/refresh.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -82,7 +82,7 @@ int wnoutrefresh(WINDOW *win) int first = win->_firstch[i]; /* first changed */ int last = win->_lastch[i]; /* last changed */ - /* ignore areas on the outside that are marked as changed, + /* ignore areas on the outside that are marked as changed, but really aren't */ while (first <= last && src[first] == dest[first]) @@ -98,7 +98,7 @@ int wnoutrefresh(WINDOW *win) memcpy(dest + first, src + first, (last - first + 1) * sizeof(chtype)); - first += begx; + first += begx; last += begx; if (first < curscr->_firstch[j] || diff --git a/src/3rdparty/win32_src/pdcurses/scanw.c b/src/3rdparty/win32_src/pdcurses/scanw.c index 7b974357d..ab6eace62 100644 --- a/src/3rdparty/win32_src/pdcurses/scanw.c +++ b/src/3rdparty/win32_src/pdcurses/scanw.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -133,17 +133,17 @@ int vw_scanw(WINDOW *win, const char *fmt, va_list varglist) #ifndef HAVE_VSSCANF -/* _pdc_vsscanf() - Internal routine to parse and format an input - buffer. It scans a series of input fields; each field is formatted - according to a supplied format string and the formatted input is - stored in the variable number of addresses passed. Returns the number +/* _pdc_vsscanf() - Internal routine to parse and format an input + buffer. It scans a series of input fields; each field is formatted + according to a supplied format string and the formatted input is + stored in the variable number of addresses passed. Returns the number of input fields or EOF on error. - Don't compile this unless required. Some compilers (at least Borland + Don't compile this unless required. Some compilers (at least Borland C++ 3.0) have to link with math libraries due to the use of floats. - Based on vsscanf.c and input.c from emx 0.8f library source, - Copyright (c) 1990-1992 by Eberhard Mattes, who has kindly agreed to + Based on vsscanf.c and input.c from emx 0.8f library source, + Copyright (c) 1990-1992 by Eberhard Mattes, who has kindly agreed to its inclusion in PDCurses. */ #define WHITE(x) ((x) == ' ' || (x) == '\t' || (x) == '\n') diff --git a/src/3rdparty/win32_src/pdcurses/scr_dump.c b/src/3rdparty/win32_src/pdcurses/scr_dump.c index 4411cbb13..91a004cf6 100644 --- a/src/3rdparty/win32_src/pdcurses/scr_dump.c +++ b/src/3rdparty/win32_src/pdcurses/scr_dump.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/scroll.c b/src/3rdparty/win32_src/pdcurses/scroll.c index 81c4aa659..a829e09c5 100644 --- a/src/3rdparty/win32_src/pdcurses/scroll.c +++ b/src/3rdparty/win32_src/pdcurses/scroll.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -17,11 +17,11 @@ scroll scroll() causes the window to scroll up one line. This involves moving the lines in the window data strcture. - + With a positive n, scrl() and wscrl() scroll the window up n lines (line i + n becomes i); otherwise they scroll the window down n lines. - + For these functions to work, scrolling must be enabled via scrollok(). Note also that scrolling is not allowed if the supplied window is a pad. @@ -63,7 +63,7 @@ int wscrl(WINDOW *win, int n) dir = -1; } - for (l = 0; l < (n * dir); l++) + for (l = 0; l < (n * dir); l++) { temp = win->_y[start]; diff --git a/src/3rdparty/win32_src/pdcurses/slk.c b/src/3rdparty/win32_src/pdcurses/slk.c index 7b383beab..0f066435d 100644 --- a/src/3rdparty/win32_src/pdcurses/slk.c +++ b/src/3rdparty/win32_src/pdcurses/slk.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -469,8 +469,9 @@ void PDC_slk_initialize(void) if (!SP->slk_winptr) { - if ( !(SP->slk_winptr = newwin(SP->slklines, COLS, - LINES - SP->slklines, 0)) ) + SP->slk_winptr = newwin(SP->slklines, COLS, + LINES - SP->slklines, 0); + if (!SP->slk_winptr) return; wattrset(SP->slk_winptr, A_REVERSE); diff --git a/src/3rdparty/win32_src/pdcurses/termattr.c b/src/3rdparty/win32_src/pdcurses/termattr.c index d01a2e43b..2ae7a79a1 100644 --- a/src/3rdparty/win32_src/pdcurses/termattr.c +++ b/src/3rdparty/win32_src/pdcurses/termattr.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/terminfo.c b/src/3rdparty/win32_src/pdcurses/terminfo.c index fadba2302..befb3d3b8 100644 --- a/src/3rdparty/win32_src/pdcurses/terminfo.c +++ b/src/3rdparty/win32_src/pdcurses/terminfo.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/touch.c b/src/3rdparty/win32_src/pdcurses/touch.c index 21111624c..4f3028d51 100644 --- a/src/3rdparty/win32_src/pdcurses/touch.c +++ b/src/3rdparty/win32_src/pdcurses/touch.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include @@ -128,7 +128,7 @@ int wtouchln(WINDOW *win, int y, int n, int changed) win->_firstch[i] = 0; win->_lastch[i] = win->_maxx - 1; } - else + else { win->_firstch[i] = _NO_CHANGE; win->_lastch[i] = _NO_CHANGE; diff --git a/src/3rdparty/win32_src/pdcurses/util.c b/src/3rdparty/win32_src/pdcurses/util.c index a5f826ede..35e60dc2d 100644 --- a/src/3rdparty/win32_src/pdcurses/util.c +++ b/src/3rdparty/win32_src/pdcurses/util.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include diff --git a/src/3rdparty/win32_src/pdcurses/window.c b/src/3rdparty/win32_src/pdcurses/window.c index 34ae0287a..0058252ab 100644 --- a/src/3rdparty/win32_src/pdcurses/window.c +++ b/src/3rdparty/win32_src/pdcurses/window.c @@ -1,4 +1,4 @@ -/* Public Domain Curses */ +/* PDCurses */ #include