save_key_modifiers isn't useful -- they can always be saved. A pseudo-

prototype is retained for backwards compatibility.
This commit is contained in:
William McBrine
2019-08-05 02:26:52 -04:00
parent f5886b69c7
commit c18d86d4a2
11 changed files with 65 additions and 100 deletions

View File

@@ -28,7 +28,7 @@ Defined by this header:
**man-end****************************************************************/
#define PDCURSES 1
#define PDC_BUILD 3811
#define PDC_BUILD 3812
#define PDC_VER_MAJOR 3
#define PDC_VER_MINOR 8
#define PDC_VERDOT "3.8"
@@ -342,8 +342,6 @@ typedef struct
to be restored, and how */
unsigned long key_modifiers; /* key modifiers (SHIFT, CONTROL, etc.)
on last key press */
bool save_key_modifiers; /* TRUE if each key modifiers saved
with each key press */
bool return_key_modifiers; /* TRUE if modifier keys are
returned as "real" keys */
bool key_code; /* TRUE if last key is a special key;
@@ -1335,7 +1333,6 @@ PDCEX int PDC_setclipboard(const char *, long);
PDCEX unsigned long PDC_get_input_fd(void);
PDCEX unsigned long PDC_get_key_modifiers(void);
PDCEX int PDC_return_key_modifiers(bool);
PDCEX int PDC_save_key_modifiers(bool);
#ifdef XCURSES
PDCEX WINDOW *Xinitscr(int, char **);
@@ -1380,6 +1377,10 @@ PDCEX int wunderscore(WINDOW *);
# define getmouse(x) nc_getmouse(x)
#endif
/* Deprecated */
#define PDC_save_key_modifiers(x) (OK)
/* return codes from PDC_getclipboard() and PDC_setclipboard() calls */
#define PDC_CLIP_SUCCESS 0

View File

@@ -376,7 +376,6 @@ void inputTest(WINDOW *win)
#ifdef PDCURSES
mouse_set(ALL_MOUSE_EVENTS);
PDC_save_key_modifiers(TRUE);
PDC_return_key_modifiers(TRUE);
#endif
curs_set(0); /* turn cursor off */
@@ -494,7 +493,6 @@ void inputTest(WINDOW *win)
#ifdef PDCURSES
mouse_set(0L);
PDC_save_key_modifiers(FALSE);
PDC_return_key_modifiers(FALSE);
#endif
wclear(win);

View File

@@ -364,20 +364,17 @@ int PDC_get_key(void)
key = regs.h.al;
scan = regs.h.ah;
if (SP->save_key_modifiers)
{
if (shift_status & 3)
SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
if (shift_status & 3)
SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
if (shift_status & 4)
SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
if (shift_status & 4)
SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
if (shift_status & 8)
SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
if (shift_status & 8)
SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
if (shift_status & 0x20)
SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
}
if (shift_status & 0x20)
SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
if (scan == 0x1c && key == 0x0a) /* ^Enter */
key = CTL_ENTER;

View File

@@ -882,7 +882,6 @@ getch
int unget_wch(const wchar_t wch);
unsigned long PDC_get_key_modifiers(void);
int PDC_save_key_modifiers(bool flag);
int PDC_return_key_modifiers(bool flag);
### Description
@@ -921,8 +920,7 @@ getch
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
call. 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.

View File

@@ -329,20 +329,17 @@ int PDC_get_key(void)
key = keyInfo.chChar;
scan = keyInfo.chScan;
if (SP->save_key_modifiers)
{
if (keyInfo.fsState & KBDSTF_ALT)
SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
if (keyInfo.fsState & KBDSTF_ALT)
SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
if (keyInfo.fsState & KBDSTF_CONTROL)
SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
if (keyInfo.fsState & KBDSTF_CONTROL)
SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
if (keyInfo.fsState & KBDSTF_NUMLOCK_ON)
SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
if (keyInfo.fsState & KBDSTF_NUMLOCK_ON)
SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
if (keyInfo.fsState & (KBDSTF_LEFTSHIFT|KBDSTF_RIGHTSHIFT))
SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
}
if (keyInfo.fsState & (KBDSTF_LEFTSHIFT|KBDSTF_RIGHTSHIFT))
SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
if (scan == 0x1c && key == 0x0a) /* ^Enter */
key = CTL_ENTER;

View File

@@ -23,7 +23,6 @@ getch
int unget_wch(const wchar_t wch);
unsigned long PDC_get_key_modifiers(void);
int PDC_save_key_modifiers(bool flag);
int PDC_return_key_modifiers(bool flag);
### Description
@@ -62,8 +61,7 @@ getch
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
call. 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.
@@ -355,17 +353,6 @@ unsigned long PDC_get_key_modifiers(void)
return SP->key_modifiers;
}
int PDC_save_key_modifiers(bool flag)
{
PDC_LOG(("PDC_save_key_modifiers() - called\n"));
if (!SP)
return ERR;
SP->save_key_modifiers = flag;
return OK;
}
int PDC_return_key_modifiers(bool flag)
{
PDC_LOG(("PDC_return_key_modifiers() - called\n"));

View File

@@ -139,7 +139,6 @@ WINDOW *Xinitscr(int argc, char *argv[])
SP->raw_inp = FALSE; /* tty I/O modes */
SP->cbreak = TRUE;
SP->key_modifiers = 0L;
SP->save_key_modifiers = FALSE;
SP->return_key_modifiers = FALSE;
SP->echo = TRUE;
SP->visibility = 1;

View File

@@ -160,20 +160,17 @@ static int _process_key_event(void)
oldkey = event.key.keysym.sym;
if (SP->save_key_modifiers)
{
if (event.key.keysym.mod & KMOD_NUM)
SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
if (event.key.keysym.mod & KMOD_NUM)
SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
if (event.key.keysym.mod & KMOD_SHIFT)
SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
if (event.key.keysym.mod & KMOD_SHIFT)
SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
if (event.key.keysym.mod & KMOD_CTRL)
SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
if (event.key.keysym.mod & KMOD_CTRL)
SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
if (event.key.keysym.mod & KMOD_ALT)
SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
}
if (event.key.keysym.mod & KMOD_ALT)
SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
for (i = 0; key_table[i].keycode; i++)
{

View File

@@ -361,23 +361,20 @@ static int _process_key_event(void)
SP->key_code = TRUE;
/* Save the key modifiers if required. Do this first to allow to
detect e.g. a pressed CTRL key after a hit of NUMLOCK. */
/* Save the key modifiers. Do this first to allow to detect e.g. a
pressed CTRL key after a hit of NUMLOCK. */
if (SP->save_key_modifiers)
{
if (state & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
if (state & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
if (state & SHIFT_PRESSED)
SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
if (state & SHIFT_PRESSED)
SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
if (state & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
if (state & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
if (state & NUMLOCK_ON)
SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
}
if (state & NUMLOCK_ON)
SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
/* Handle modifier keys hit by themselves */

View File

@@ -1038,28 +1038,25 @@ static void XCursesKeyPress(Widget w, XEvent *event, String *params,
PDC_LOG(("%s:Keysym %x %d\n", XCLOGMSG,
XKeycodeToKeysym(XCURSESDISPLAY, event->xkey.keycode, key), key));
if (SP->save_key_modifiers)
{
/* 0x10: usually, numlock modifier */
/* 0x10: usually, numlock modifier */
if (event->xkey.state & Mod2Mask)
modifier |= PDC_KEY_MODIFIER_NUMLOCK;
if (event->xkey.state & Mod2Mask)
modifier |= PDC_KEY_MODIFIER_NUMLOCK;
/* 0x01: shift modifier */
/* 0x01: shift modifier */
if (event->xkey.state & ShiftMask)
modifier |= PDC_KEY_MODIFIER_SHIFT;
if (event->xkey.state & ShiftMask)
modifier |= PDC_KEY_MODIFIER_SHIFT;
/* 0x04: control modifier */
/* 0x04: control modifier */
if (event->xkey.state & ControlMask)
modifier |= PDC_KEY_MODIFIER_CONTROL;
if (event->xkey.state & ControlMask)
modifier |= PDC_KEY_MODIFIER_CONTROL;
/* 0x08: usually, alt modifier */
/* 0x08: usually, alt modifier */
if (event->xkey.state & Mod1Mask)
modifier |= PDC_KEY_MODIFIER_ALT;
}
if (event->xkey.state & Mod1Mask)
modifier |= PDC_KEY_MODIFIER_ALT;
for (i = 0; key_table[i].keycode; i++)
{

View File

@@ -1037,28 +1037,25 @@ unsigned long XCursesKeyPress(XEvent *event)
PDC_LOG(("%s:Keysym %x %d\n", XCLOGMSG,
XKeycodeToKeysym(XCURSESDISPLAY, event->xkey.keycode, key), key));
if (SP->save_key_modifiers)
{
/* 0x10: usually, numlock modifier */
/* 0x10: usually, numlock modifier */
if (event->xkey.state & Mod2Mask)
modifier |= PDC_KEY_MODIFIER_NUMLOCK;
if (event->xkey.state & Mod2Mask)
modifier |= PDC_KEY_MODIFIER_NUMLOCK;
/* 0x01: shift modifier */
/* 0x01: shift modifier */
if (event->xkey.state & ShiftMask)
modifier |= PDC_KEY_MODIFIER_SHIFT;
if (event->xkey.state & ShiftMask)
modifier |= PDC_KEY_MODIFIER_SHIFT;
/* 0x04: control modifier */
/* 0x04: control modifier */
if (event->xkey.state & ControlMask)
modifier |= PDC_KEY_MODIFIER_CONTROL;
if (event->xkey.state & ControlMask)
modifier |= PDC_KEY_MODIFIER_CONTROL;
/* 0x08: usually, alt modifier */
/* 0x08: usually, alt modifier */
if (event->xkey.state & Mod1Mask)
modifier |= PDC_KEY_MODIFIER_ALT;
}
if (event->xkey.state & Mod1Mask)
modifier |= PDC_KEY_MODIFIER_ALT;
for (i = 0; key_table[i].keycode; i++)
{