and even this

This commit is contained in:
William McBrine
2019-08-04 00:16:36 -04:00
parent 74dba12aef
commit 9ce10d9a16
13 changed files with 43 additions and 54 deletions

View File

@@ -28,7 +28,7 @@ Defined by this header:
**man-end****************************************************************/
#define PDCURSES 1 /* PDCurses-only routines */
#define PDC_BUILD 3808
#define PDC_BUILD 3809
#define PDC_VER_MAJOR 3
#define PDC_VER_MINOR 8
#define PDC_VERDOT "3.8"
@@ -339,6 +339,8 @@ typedef struct
to be preserved */
int _restore; /* specifies if screen background
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

View File

@@ -43,7 +43,6 @@ typedef struct /* structure for ripped off lines */
#define _DLCHAR 0x15 /* Delete Line char (^U) */
extern FILE *pdc_dbfp; /* tracing file pointer (NULL = off) */
extern unsigned long pdc_key_modifiers;
extern MOUSE_STATUS pdc_mouse_status;
/*----------------------------------------------------------------------*/

View File

@@ -79,8 +79,6 @@ static short key_table[] =
ALT_PADSLASH, ALT_TAB, ALT_PADENTER, -1
};
unsigned long pdc_key_modifiers = 0L;
static struct {unsigned short pressed, released;} button[3];
static bool mouse_avail = FALSE, mouse_vis = FALSE, mouse_moved = FALSE,
@@ -314,7 +312,7 @@ int PDC_get_key(void)
PDCREGS regs;
int key, scan;
pdc_key_modifiers = 0;
SP->key_modifiers = 0;
if (mouse_vis && (mouse_scroll || mouse_button || mouse_moved))
return _process_mouse_events();
@@ -369,16 +367,16 @@ int PDC_get_key(void)
if (SP->save_key_modifiers)
{
if (shift_status & 3)
pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
if (shift_status & 4)
pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
if (shift_status & 8)
pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
if (shift_status & 0x20)
pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
}
if (scan == 0x1c && key == 0x0a) /* ^Enter */

View File

@@ -86,8 +86,6 @@ static short key_table[] =
ALT_PADSLASH, ALT_TAB, ALT_PADENTER, -1
};
unsigned long pdc_key_modifiers = 0L;
unsigned long PDC_get_input_fd(void)
{
PDC_LOG(("PDC_get_input_fd() - called\n"));
@@ -285,7 +283,7 @@ int PDC_get_key(void)
int key, scan;
KBDKEYINFO keyInfo = {0};
pdc_key_modifiers = 0L;
SP->key_modifiers = 0L;
if (mouse_handle && mouse_events)
return _process_mouse_events();
@@ -334,16 +332,16 @@ int PDC_get_key(void)
if (SP->save_key_modifiers)
{
if (keyInfo.fsState & KBDSTF_ALT)
pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
if (keyInfo.fsState & KBDSTF_CONTROL)
pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
if (keyInfo.fsState & KBDSTF_NUMLOCK_ON)
pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
if (keyInfo.fsState & (KBDSTF_LEFTSHIFT|KBDSTF_RIGHTSHIFT))
pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
}
if (scan == 0x1c && key == 0x0a) /* ^Enter */

View File

@@ -349,7 +349,10 @@ unsigned long PDC_get_key_modifiers(void)
{
PDC_LOG(("PDC_get_key_modifiers() - called\n"));
return pdc_key_modifiers;
if (!SP)
return ERR;
return SP->key_modifiers;
}
int PDC_save_key_modifiers(bool flag)

View File

@@ -138,6 +138,7 @@ WINDOW *Xinitscr(int argc, char *argv[])
SP->raw_out = FALSE; /* tty I/O modes */
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;

View File

@@ -24,8 +24,6 @@ pdckbd
#include <string.h>
unsigned long pdc_key_modifiers = 0L;
static SDL_Event event;
static SDLKey oldkey;
static MOUSE_STATUS old_mouse_status;
@@ -127,7 +125,7 @@ static int _process_key_event(void)
{
int i, key = 0;
pdc_key_modifiers = 0L;
SP->key_modifiers = 0L;
SP->key_code = FALSE;
if (event.type == SDL_KEYUP)
@@ -165,16 +163,16 @@ static int _process_key_event(void)
if (SP->save_key_modifiers)
{
if (event.key.keysym.mod & KMOD_NUM)
pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
if (event.key.keysym.mod & KMOD_SHIFT)
pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
if (event.key.keysym.mod & KMOD_CTRL)
pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
if (event.key.keysym.mod & KMOD_ALT)
pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
}
for (i = 0; key_table[i].keycode; i++)

View File

@@ -25,8 +25,6 @@ pdckbd
#include <ctype.h>
#include <string.h>
unsigned long pdc_key_modifiers = 0L;
static SDL_Event event;
static SDL_Keycode oldkey;
static MOUSE_STATUS old_mouse_status;
@@ -177,12 +175,12 @@ static int _handle_alt_keys(int key)
if (key > 0x7f)
return key;
if (pdc_key_modifiers & PDC_KEY_MODIFIER_CONTROL)
if (SP->key_modifiers & PDC_KEY_MODIFIER_CONTROL)
{
if (key >= 'A' && key <= 'Z') key -= 64;
if (key >= 'a' && key <= 'z') key -= 96;
}
else if (pdc_key_modifiers & PDC_KEY_MODIFIER_ALT)
else if (SP->key_modifiers & PDC_KEY_MODIFIER_ALT)
{
if (key >= 'A' && key <= 'Z')
{
@@ -218,20 +216,20 @@ static int _process_key_event(void)
{
case SDLK_LCTRL:
case SDLK_RCTRL:
pdc_key_modifiers &= ~PDC_KEY_MODIFIER_CONTROL;
SP->key_modifiers &= ~PDC_KEY_MODIFIER_CONTROL;
break;
case SDLK_LALT:
case SDLK_RALT:
pdc_key_modifiers &= ~PDC_KEY_MODIFIER_ALT;
SP->key_modifiers &= ~PDC_KEY_MODIFIER_ALT;
break;
case SDLK_LSHIFT:
case SDLK_RSHIFT:
pdc_key_modifiers &= ~PDC_KEY_MODIFIER_SHIFT;
SP->key_modifiers &= ~PDC_KEY_MODIFIER_SHIFT;
break;
}
if (!(SDL_GetModState() & KMOD_NUM))
pdc_key_modifiers &= ~PDC_KEY_MODIFIER_NUMLOCK;
SP->key_modifiers &= ~PDC_KEY_MODIFIER_NUMLOCK;
if (SP->return_key_modifiers && event.key.keysym.sym == oldkey)
{
@@ -281,21 +279,21 @@ static int _process_key_event(void)
oldkey = event.key.keysym.sym;
if (SDL_GetModState() & KMOD_NUM)
pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
switch (event.key.keysym.sym)
{
case SDLK_LCTRL:
case SDLK_RCTRL:
pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
break;
case SDLK_LALT:
case SDLK_RALT:
pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
break;
case SDLK_LSHIFT:
case SDLK_RSHIFT:
pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
break;
case SDLK_RETURN:
return 0x0d;
@@ -332,7 +330,7 @@ static int _process_key_event(void)
}
/* SDL with TextInput ignores keys with CTRL */
if (key && pdc_key_modifiers & PDC_KEY_MODIFIER_CONTROL)
if (key && SP->key_modifiers & PDC_KEY_MODIFIER_CONTROL)
return _handle_alt_keys(key);
return -1;
}

View File

@@ -22,8 +22,6 @@ pdckbd
**man-end****************************************************************/
unsigned long pdc_key_modifiers = 0L;
/* These variables are used to store information about the next
Input Event. */
@@ -369,16 +367,16 @@ static int _process_key_event(void)
if (SP->save_key_modifiers)
{
if (state & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
if (state & SHIFT_PRESSED)
pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
if (state & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
if (state & NUMLOCK_ON)
pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
}
/* Handle modifier keys hit by themselves */
@@ -606,7 +604,7 @@ static int _process_mouse_event(void)
int PDC_get_key(void)
{
pdc_key_modifiers = 0L;
SP->key_modifiers = 0L;
if (!key_count)
{

View File

@@ -56,8 +56,7 @@ int PDC_get_key(void)
if (XC_read_socket(xc_key_sock, &newkey, sizeof(unsigned long)) < 0)
XCursesExitCursesProcess(2, "exiting from PDC_get_key");
pdc_key_modifiers = (newkey >> 24) & 0xFF;
key = (int)(newkey & 0x00FFFFFF);
key = (int)newkey;
if (key == KEY_MOUSE && SP->key_code)
{

View File

@@ -203,8 +203,6 @@ static struct
#define BITMAPDEPTH 1
unsigned long pdc_key_modifiers = 0L;
static GC normal_gc, rect_cursor_gc, italic_gc, bold_gc, border_gc;
static int font_height, font_width, font_ascent, font_descent,
window_width, window_height;
@@ -1133,7 +1131,7 @@ static void XCursesKeyPress(Widget w, XEvent *event, String *params,
if (key)
{
key |= (modifier << 24);
SP->key_modifiers = modifier;
_send_key_to_curses(key, NULL, key_code);
}

View File

@@ -50,8 +50,7 @@ int PDC_get_key(void)
if ((unsigned long)(-1) == newkey)
return -1;
pdc_key_modifiers = (newkey >> 24) & 0xFF;
key = (int)(newkey & 0x00FFFFFF);
key = (int)newkey;
PDC_LOG(("%s:PDC_get_key() - key %d returned\n", XCLOGMSG, key));

View File

@@ -201,8 +201,6 @@ static struct
#define BITMAPDEPTH 1
unsigned long pdc_key_modifiers = 0L;
static GC normal_gc, rect_cursor_gc, italic_gc, bold_gc, border_gc;
static int font_height, font_width, font_ascent, font_descent,
window_width, window_height;
@@ -1132,7 +1130,7 @@ unsigned long XCursesKeyPress(XEvent *event)
if (key)
{
key |= (modifier << 24);
SP->key_modifiers = modifier;
SP->key_code = key_code;
return key;