From bd4104d17a4e39f400cd8710fbbc399a2ae407dd Mon Sep 17 00:00:00 2001 From: William McBrine Date: Wed, 15 Nov 2006 16:26:45 +0000 Subject: [PATCH] Functional implementations of PDC_save_key_modifiers() and PDC_return_key_modifers(); added PDC_modifiers_set(), similar to PDC_mouse_set(). --- curses.h | 7 ++++--- curspriv.h | 3 ++- dos/pdckbd.c | 7 ++++++- os2/pdckbd.c | 7 ++++++- pdcurses/getch.c | 34 +++++++++++++++++++++++++++------- win32/pdckbd.c | 7 ++++++- x11/pdckbd.c | 7 ++++++- 7 files changed, 57 insertions(+), 15 deletions(-) diff --git a/curses.h b/curses.h index 442b25f9..2e347018 100644 --- a/curses.h +++ b/curses.h @@ -11,7 +11,7 @@ * See the file maintain.er for details of the current maintainer. * ************************************************************************/ -/* $Id: curses.h,v 1.244 2006/11/09 08:52:36 wmcbrine Exp $ */ +/* $Id: curses.h,v 1.245 2006/11/15 16:26:44 wmcbrine Exp $ */ /*----------------------------------------------------------------------* * PDCurses * @@ -1477,6 +1477,9 @@ int PDC_setclipboard(const char *, long); unsigned long PDC_get_input_fd(void); unsigned long PDC_get_key_modifiers(void); +int PDC_save_key_modifiers(bool); +int PDC_return_key_modifiers(bool); + /*** Functions defined as macros ***/ @@ -1520,8 +1523,6 @@ unsigned long PDC_get_key_modifiers(void); #define addrawch(c) waddrawch(stdscr, c) #define insrawch(c) winsrawch(stdscr, c) #define mvwaddrawch(w,y,x,c) (wmove(w, y, x)==ERR?ERR:waddrawch(w, c)) -#define PDC_save_key_modifiers(flag) (SP->save_key_modifiers = flag) -#define PDC_return_key_modifiers(flag) (SP->return_key_modifiers = flag) /* return codes from PDC_getclipboard() and PDC_setclipboard() calls */ diff --git a/curspriv.h b/curspriv.h index 87915585..53e83264 100644 --- a/curspriv.h +++ b/curspriv.h @@ -11,7 +11,7 @@ * See the file maintain.er for details of the current maintainer. * ************************************************************************/ -/* $Id: curspriv.h,v 1.139 2006/11/11 20:24:36 wmcbrine Exp $ */ +/* $Id: curspriv.h,v 1.140 2006/11/15 16:26:44 wmcbrine Exp $ */ /* CURSPRIV.H @@ -80,6 +80,7 @@ int PDC_get_rows(void); void PDC_gotoyx(int, int); void PDC_init_atrtab(void); int PDC_init_color(short, short, short, short); +int PDC_modifiers_set(void); int PDC_mouse_set(void); void PDC_napms(int); void PDC_reset_prog_mode(void); diff --git a/dos/pdckbd.c b/dos/pdckbd.c index 337e964f..d33698de 100644 --- a/dos/pdckbd.c +++ b/dos/pdckbd.c @@ -19,7 +19,7 @@ #include "pdcdos.h" -RCSID("$Id: pdckbd.c,v 1.50 2006/11/13 00:07:24 wmcbrine Exp $"); +RCSID("$Id: pdckbd.c,v 1.51 2006/11/15 16:26:45 wmcbrine Exp $"); /************************************************************************ * Table for key code translation of function keys in keypad mode * @@ -395,3 +395,8 @@ int PDC_mouse_set(void) SP->_trap_mbe = 0; return old_mbe ? ERR : OK; } + +int PDC_modifiers_set(void) +{ + return SP->return_key_modifers ? ERR : OK; +} diff --git a/os2/pdckbd.c b/os2/pdckbd.c index d3ea39d7..15c63e9e 100644 --- a/os2/pdckbd.c +++ b/os2/pdckbd.c @@ -32,7 +32,7 @@ static HMOU mouse_handle = 0; static MOUSE_STATUS old_mouse_status; #endif -RCSID("$Id: pdckbd.c,v 1.54 2006/11/15 01:09:31 wmcbrine Exp $"); +RCSID("$Id: pdckbd.c,v 1.55 2006/11/15 16:26:45 wmcbrine Exp $"); /************************************************************************ * Table for key code translation of function keys in keypad mode * @@ -622,3 +622,8 @@ int PDC_mouse_set(void) #endif return OK; } + +int PDC_modifiers_set(void) +{ + return SP->return_key_modifers ? ERR : OK; +} diff --git a/pdcurses/getch.c b/pdcurses/getch.c index 54d6a9c8..9b8c19d2 100644 --- a/pdcurses/getch.c +++ b/pdcurses/getch.c @@ -16,7 +16,7 @@ #define _INBUFSIZ 512 /* size of terminal input buffer */ #define NUNGETCH 256 /* max # chars to ungetch() */ -RCSID("$Id: getch.c,v 1.56 2006/11/14 14:51:57 wmcbrine Exp $"); +RCSID("$Id: getch.c,v 1.57 2006/11/15 16:26:45 wmcbrine Exp $"); static int c_pindex = 0; /* putter index */ static int c_gindex = 1; /* getter index */ @@ -41,7 +41,9 @@ static int c_ungch[NUNGETCH]; /* array of ungotten chars */ int mvwget_wch(WINDOW *win, int y, int x, wint_t *wch); int unget_wch(const wchar_t wch); - int PDC_get_key_modifiers(void); + unsigned long PDC_get_key_modifiers(void); + int PDC_save_key_modifiers(bool flag); + int PDC_return_key_modifiers(bool flag); X/Open Description: With the getch(), wgetch(), mvgetch(), and mvwgetch() functions, @@ -85,11 +87,13 @@ static int c_ungch[NUNGETCH]; /* array of ungotten chars */ Also, note that the getch() definition will conflict with many DOS compiler's runtime libraries. - PDC_get_key_modifiers() returns the keyboard modifiers effective - at the time of the last getch() call, only 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_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. X/Open Return Value: These functions return ERR or the value of the character, meta @@ -388,6 +392,22 @@ unsigned long PDC_get_key_modifiers(void) return pdc_key_modifiers; } +int PDC_save_key_modifiers(bool flag) +{ + PDC_LOG(("PDC_save_key_modifiers() - called\n")); + + SP->save_key_modifiers = flag; + return OK; +} + +int PDC_return_key_modifiers(bool flag) +{ + PDC_LOG(("PDC_return_key_modifiers() - called\n")); + + SP->return_key_modifiers = flag; + return PDC_modifiers_set(); +} + #ifdef PDC_WIDE int wget_wch(WINDOW *win, wint_t *wch) { diff --git a/win32/pdckbd.c b/win32/pdckbd.c index c1817ad7..1b761d2f 100644 --- a/win32/pdckbd.c +++ b/win32/pdckbd.c @@ -13,7 +13,7 @@ #include "pdcwin.h" -RCSID("$Id: pdckbd.c,v 1.79 2006/11/14 14:51:57 wmcbrine Exp $"); +RCSID("$Id: pdckbd.c,v 1.80 2006/11/15 16:26:45 wmcbrine Exp $"); #define ACTUAL_MOUSE_MOVED (actual_mouse_status.changes & 8) #define ACTUAL_BUTTON_STATUS(x) (actual_mouse_status.button[(x) - 1]) @@ -999,3 +999,8 @@ int PDC_mouse_set(void) return OK; } + +int PDC_modifiers_set(void) +{ + return OK; +} diff --git a/x11/pdckbd.c b/x11/pdckbd.c index a57b01ca..1ebb56d9 100644 --- a/x11/pdckbd.c +++ b/x11/pdckbd.c @@ -13,7 +13,7 @@ #include "pdcx11.h" -RCSID("$Id: pdckbd.c,v 1.49 2006/11/13 17:50:08 wmcbrine Exp $"); +RCSID("$Id: pdckbd.c,v 1.50 2006/11/15 16:26:45 wmcbrine Exp $"); /*man-start************************************************************** @@ -196,3 +196,8 @@ int PDC_mouse_set(void) { return OK; } + +int PDC_modifiers_set(void) +{ + return OK; +}