Changed atrtab, trace_on, and _getch_win_ to pdc_atrtab, pdc_trace_on

and pdc_getch_win; made c_gindex etc. private to getch.c; moved
flushinp() to getch.c. (Not its "traditional" home, but who cares?)
This commit is contained in:
William McBrine
2006-08-12 22:22:05 +00:00
parent 16b4c7113f
commit 763fdb304f
18 changed files with 102 additions and 105 deletions

View File

@@ -15,7 +15,7 @@
* See the file maintain.er for details of the current maintainer. *
************************************************************************/
/* $Id: curspriv.h,v 1.116 2006/08/12 20:28:59 wmcbrine Exp $ */
/* $Id: curspriv.h,v 1.117 2006/08/12 22:22:05 wmcbrine Exp $ */
/* CURSPRIV.H
@@ -35,16 +35,14 @@
/*----------------------------------------------------------------------*/
/* Miscellaneous */
#define _INBUFSIZ 512 /* size of terminal input buffer */
#define _NO_CHANGE -1 /* flags line edge unchanged */
#define _ECHAR 0x08 /* Erase char (^H) */
#define _DWCHAR 0x17 /* Delete Word char (^W) */
#define _DLCHAR 0x15 /* Delete Line char (^U) */
#define NUNGETCH 256 /* max # chars to ungetch() */
/* tracing flag */
extern bool trace_on;
extern bool pdc_trace_on;
/* Monitor (terminal) type information */
enum
@@ -57,16 +55,12 @@ enum
_UNIX_COLOR = 0x40, _UNIX_MONO
};
extern int c_pindex; /* putter index */
extern int c_gindex; /* getter index */
extern int c_ungind; /* ungetch() push index */
extern int c_ungch[NUNGETCH]; /* array of ungotten chars */
extern WINDOW *_getch_win_;
extern WINDOW *pdc_getch_win;
extern unsigned long pdc_key_modifiers;
extern MOUSE_STATUS Trapped_Mouse_status;
extern unsigned char *atrtab;
extern unsigned char *pdc_atrtab;
/*----------------------------------------------------------------------
* ANSI C prototypes.
@@ -103,7 +97,7 @@ int PDC_validchar(int);
#ifdef PDCDEBUG
void PDC_debug(const char *, ...);
# define PDC_LOG(x) if (trace_on) PDC_debug x
# define PDC_LOG(x) if (pdc_trace_on) PDC_debug x
# define RCSID(x) static const char *rcsid = x
#else
# define PDC_LOG(x)
@@ -121,7 +115,7 @@ void PDC_debug(const char *, ...);
# define PDC_OFFSET 8
#endif
#define chtype_attr(ch) (atrtab[(chtype)(ch) >> PDC_ATTR_SHIFT])
#define chtype_attr(ch) (pdc_atrtab[(chtype)(ch) >> PDC_ATTR_SHIFT])
#define MAX_ATRTAB (PDC_COLOR_PAIRS * PDC_OFFSET)

View File

@@ -192,8 +192,8 @@ The virtual keypad is arranged like this:
FUNCTIONS
The following table lists each curses routine and the name of the
manual page on which it is described. This list is based on
X/Open and System V R4 curses:
manual page on which it is described. This list is based mainly
on X/Open and System V R4 curses:
Curses Function Manual Page Name
@@ -243,7 +243,7 @@ FUNCTIONS
erasechar termattr
filter util
flash beep
flushinp util
flushinp getch
getbegyx getyx
getattrs attr
getch getch
@@ -409,7 +409,8 @@ FUNCTIONS
touchwin touch
tparm terminfo
tputs terminfo
trace_on pdcdebug
traceoff pdcdebug
traceon pdcdebug
typeahead inopts
unctrl util
ungetch getch

View File

@@ -23,7 +23,7 @@
#include "pdcdos.h"
RCSID("$Id: pdckbd.c,v 1.33 2006/08/11 22:19:45 wmcbrine Exp $");
RCSID("$Id: pdckbd.c,v 1.34 2006/08/12 22:22:05 wmcbrine Exp $");
/************************************************************************
* Table for key code translation of function keys in keypad mode *
@@ -392,7 +392,7 @@ int PDC_validchar(int c)
PDC_LOG(("PDC_validchar() - called\n"));
if (_getch_win_ == (WINDOW *)NULL)
if (pdc_getch_win == (WINDOW *)NULL)
return -1;
/* normal character */
@@ -402,7 +402,7 @@ int PDC_validchar(int c)
/* skip if keys if !keypad mode */
if (!(_getch_win_->_use_keypad))
if (!(pdc_getch_win->_use_keypad))
return -1;
/* Under DOS, extended keys are in the upper byte. Shift down

View File

@@ -24,7 +24,7 @@
# include <sys/movedata.h>
#endif
RCSID("$Id: pdcscrn.c,v 1.47 2006/08/12 21:13:45 wmcbrine Exp $");
RCSID("$Id: pdcscrn.c,v 1.48 2006/08/12 22:22:05 wmcbrine Exp $");
union REGS regs; /* used in various other modules */
@@ -109,8 +109,8 @@ void PDC_scr_exit(void)
{
if (SP)
free(SP);
if (atrtab)
free(atrtab);
if (pdc_atrtab)
free(pdc_atrtab);
}
/*man-start**************************************************************
@@ -142,9 +142,9 @@ int PDC_scr_open(int argc, char **argv)
PDC_LOG(("PDC_scr_open() - called\n"));
SP = calloc(1, sizeof(SCREEN));
atrtab = calloc(MAX_ATRTAB, 1);
pdc_atrtab = calloc(MAX_ATRTAB, 1);
if (!SP || !atrtab)
if (!SP || !pdc_atrtab)
return ERR;
SP->orig_attr = FALSE;

View File

@@ -33,7 +33,7 @@ static int tahead = -1;
static KBDINFO kbdinfo; /* default keyboard mode */
#endif
RCSID("$Id: pdckbd.c,v 1.33 2006/08/11 07:25:40 wmcbrine Exp $");
RCSID("$Id: pdckbd.c,v 1.34 2006/08/12 22:22:05 wmcbrine Exp $");
/************************************************************************
* Table for key code translation of function keys in keypad mode *
@@ -505,7 +505,7 @@ int PDC_validchar(int c)
PDC_LOG(("PDC_validchar() - called. c: %d\n", c));
if (_getch_win_ == (WINDOW *)NULL)
if (pdc_getch_win == (WINDOW *)NULL)
return -1;
/* normal character */
@@ -515,7 +515,7 @@ int PDC_validchar(int c)
/* skip if keys if !keypad mode */
if (!_getch_win_->_use_keypad)
if (!pdc_getch_win->_use_keypad)
return -1;
/* Under DOS, extended keys are in the upper byte. Shift down

View File

@@ -20,7 +20,7 @@
#include <curses.h>
#include <stdlib.h>
RCSID("$Id: pdcscrn.c,v 1.42 2006/08/12 21:13:45 wmcbrine Exp $");
RCSID("$Id: pdcscrn.c,v 1.43 2006/08/12 22:22:05 wmcbrine Exp $");
#ifdef EMXVIDEO
static unsigned char *saved_screen = NULL;
@@ -135,8 +135,8 @@ void PDC_scr_exit(void)
{
if (SP)
free(SP);
if (atrtab)
free(atrtab);
if (pdc_atrtab)
free(pdc_atrtab);
}
/*man-start**************************************************************
@@ -168,9 +168,9 @@ int PDC_scr_open(int argc, char **argv)
PDC_LOG(("PDC_scr_open() - called\n"));
SP = calloc(1, sizeof(SCREEN));
atrtab = calloc(MAX_ATRTAB, 1);
pdc_atrtab = calloc(MAX_ATRTAB, 1);
if (!SP || !atrtab)
if (!SP || !pdc_atrtab)
return ERR;
#ifdef EMXVIDEO

View File

@@ -23,7 +23,8 @@ EXPORTS
PDC_set_title
stdscr
curscr
trace_on
traceoff
traceon
baudrate
beep
border

View File

@@ -34,7 +34,7 @@
static void PDC_init_pair(short, short, short);
RCSID("$Id: color.c,v 1.52 2006/08/11 20:23:13 wmcbrine Exp $");
RCSID("$Id: color.c,v 1.53 2006/08/12 22:22:05 wmcbrine Exp $");
/*man-start**************************************************************
@@ -118,7 +118,7 @@ static bool colorstarted = FALSE;
/* COLOR_PAIR to attribute encoding table. */
unsigned char *atrtab = (unsigned char *)NULL;
unsigned char *pdc_atrtab = (unsigned char *)NULL;
static unsigned char colorset[PDC_COLOR_PAIRS];
@@ -227,8 +227,8 @@ int pair_content(short colorpair, short *foreground, short *background)
(!foreground || !background))
return ERR;
*foreground = (short)(atrtab[colorpair * PDC_OFFSET] & 0x0F);
*background = (short)((atrtab[colorpair * PDC_OFFSET] & 0xF0) >> 4);
*foreground = (short)(pdc_atrtab[colorpair * PDC_OFFSET] & 0x0F);
*background = (short)((pdc_atrtab[colorpair * PDC_OFFSET] & 0xF0) >> 4);
return OK;
}
@@ -280,6 +280,6 @@ static void PDC_init_pair(short pairnum, short fg, short bg)
if (i & (A_BLINK >> PDC_ATTR_SHIFT))
att |= 128;
atrtab[(pairnum * PDC_OFFSET) + i] = att;
pdc_atrtab[(pairnum * PDC_OFFSET) + i] = att;
}
}

View File

@@ -24,6 +24,7 @@
#undef mvgetch
#undef mvwgetch
#undef ungetch
#undef flushinp
/* undefine any macros for functions called by this module if in debug mode */
#ifdef PDCDEBUG
@@ -33,7 +34,15 @@
# undef wmove
#endif
RCSID("$Id: getch.c,v 1.32 2006/08/01 03:16:17 wmcbrine Exp $");
#define _INBUFSIZ 512 /* size of terminal input buffer */
#define NUNGETCH 256 /* max # chars to ungetch() */
RCSID("$Id: getch.c,v 1.33 2006/08/12 22:22:05 wmcbrine Exp $");
static int c_pindex = 0; /* putter index */
static int c_gindex = 1; /* getter index */
static int c_ungind = 0; /* wungetch() push index */
static int c_ungch[NUNGETCH]; /* array of ungotten chars */
/*man-start**************************************************************
@@ -45,6 +54,7 @@ RCSID("$Id: getch.c,v 1.32 2006/08/01 03:16:17 wmcbrine Exp $");
int mvgetch(int y, int x);
int mvwgetch(WINDOW *win, int y, int x);
int ungetch(int ch);
int flushinp(void);
X/Open Description:
With the getch(), wgetch(), mvgetch(), and mvwgetch() functions,
@@ -75,6 +85,9 @@ RCSID("$Id: getch.c,v 1.32 2006/08/01 03:16:17 wmcbrine Exp $");
The ungetch() function places ch back onto the input queue to be
returned by the next call to wgetch().
The flushinp() routine throws away any type-ahead that has been
typed by the user and has not yet been read by the program.
NOTE: getch(), mvgetch() and mvwgetch() are implemented as macros.
PDCurses Description:
@@ -104,7 +117,7 @@ RCSID("$Id: getch.c,v 1.32 2006/08/01 03:16:17 wmcbrine Exp $");
#define getch PDC_getch
#define ungetch PDC_ungetch
WINDOW *_getch_win_ = NULL;
WINDOW *pdc_getch_win = NULL;
/*man-start**************************************************************
@@ -169,11 +182,11 @@ static int PDC_rawgetch(void)
PDC_LOG(("PDC_rawgetch() - called\n"));
if (_getch_win_ == (WINDOW *)NULL)
if (pdc_getch_win == (WINDOW *)NULL)
return -1;
if ((SP->delaytenths || _getch_win_->_delayms || _getch_win_->_nodelay)
&& !PDC_breakout())
if ((SP->delaytenths || pdc_getch_win->_delayms ||
pdc_getch_win->_nodelay) && !PDC_breakout())
return -1;
for (;;)
@@ -186,7 +199,7 @@ static int PDC_rawgetch(void)
if (c != KEY_MOUSE && (c = PDC_validchar(c)) >= 0)
return c;
if (_getch_win_->_use_keypad)
if (pdc_getch_win->_use_keypad)
return oldc;
}
}
@@ -219,11 +232,11 @@ static int PDC_sysgetch(void)
PDC_LOG(("PDC_sysgetch() - called\n"));
if (_getch_win_ == (WINDOW *)NULL)
if (pdc_getch_win == (WINDOW *)NULL)
return -1;
if ((SP->delaytenths || _getch_win_->_delayms || _getch_win_->_nodelay)
&& !PDC_breakout())
if ((SP->delaytenths || pdc_getch_win->_delayms ||
pdc_getch_win->_nodelay) && !PDC_breakout())
return -1;
for (;;)
@@ -312,7 +325,7 @@ int wgetch(WINDOW *win)
if (!(win->_flags & _PAD) && is_wintouched(win))
wrefresh(win);
_getch_win_ = win;
pdc_getch_win = win;
/* if ungotten char exists, remove and return it */
@@ -427,3 +440,16 @@ int PDC_ungetch(int ch)
return OK;
}
int flushinp(void)
{
PDC_LOG(("flushinp() - called\n"));
PDC_flushinp();
c_gindex = 1; /* set indices to kill buffer */
c_pindex = 0;
c_ungind = 0; /* clear c_ungch array */
return OK;
}

View File

@@ -38,7 +38,7 @@
# undef wnoutrefresh
#endif
RCSID("$Id: initscr.c,v 1.70 2006/08/12 20:28:59 wmcbrine Exp $");
RCSID("$Id: initscr.c,v 1.71 2006/08/12 22:22:05 wmcbrine Exp $");
const char *_curses_notice = "PDCurses 3.0 - Public Domain 2006";
@@ -52,13 +52,6 @@ int TABSIZE = 8;
MOUSE_STATUS Mouse_status;
/* Global definitions for charget routines */
int c_pindex = 0; /* putter index */
int c_gindex = 1; /* getter index */
int c_ungind = 0; /* wungetch() push index */
int c_ungch[NUNGETCH]; /* array of ungotten chars */
#ifdef PDC_WIDE
cchar_t _wacs_map[] = {
ACS_ULCORNER, ACS_LLCORNER, ACS_URCORNER, ACS_LRCORNER,
@@ -325,7 +318,7 @@ void delscreen(SCREEN *sp)
PDC_scr_exit();
SP = (SCREEN *)NULL;
atrtab = (unsigned char *)NULL;
pdc_atrtab = (unsigned char *)NULL;
}
int resize_term(int nlines, int ncols)

View File

@@ -23,9 +23,9 @@
#undef PDC_debug
RCSID("$Id: pdcdebug.c,v 1.20 2006/07/15 15:38:24 wmcbrine Exp $");
RCSID("$Id: pdcdebug.c,v 1.21 2006/08/12 22:22:05 wmcbrine Exp $");
bool trace_on = FALSE;
bool pdc_trace_on = FALSE;
/*man-start**************************************************************
@@ -46,7 +46,7 @@ void PDC_debug(const char *fmt, ...)
char hms[9];
time_t now;
if (!trace_on)
if (!pdc_trace_on)
return;
/* open debug log file append */

View File

@@ -25,9 +25,8 @@
#undef filter
#undef use_env
#undef delay_output
#undef flushinp
RCSID("$Id: util.c,v 1.46 2006/07/15 15:38:24 wmcbrine Exp $");
RCSID("$Id: util.c,v 1.47 2006/08/12 22:22:05 wmcbrine Exp $");
/*man-start**************************************************************
@@ -39,7 +38,6 @@ RCSID("$Id: util.c,v 1.46 2006/07/15 15:38:24 wmcbrine Exp $");
void filter(void);
void use_env(bool x);
int delay_output(int ms);
int flushinp(void);
X/Open Description:
The unctrl() routine expands the character c into a character
@@ -54,9 +52,6 @@ RCSID("$Id: util.c,v 1.46 2006/07/15 15:38:24 wmcbrine Exp $");
The delay_output() function inserts ms millisecond pause in output.
On some systems, this has no effect.
The flushinp() routine throws away any type-ahead that has been
typed by the user and has not yet been read by the program.
PDCurses Description:
The conversion from a control character to a two-character
sequence is done by the unctrl() function. In the BSD version
@@ -219,19 +214,6 @@ int delay_output(int ms)
return napms(ms);
}
int flushinp(void)
{
PDC_LOG(("flushinp() - called\n"));
PDC_flushinp();
c_gindex = 1; /* set indices to kill buffer */
c_pindex = 0;
c_ungind = 0; /* clear c_ungch array */
return OK;
}
#ifdef PDC_WIDE
int getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs,
short *color_pair, void *opts)
@@ -310,12 +292,12 @@ void traceon(void)
{
PDC_LOG(("traceon() - called\n"));
trace_on = TRUE;
pdc_trace_on = TRUE;
}
void traceoff(void)
{
PDC_LOG(("traceoff() - called\n"));
trace_on = FALSE;
pdc_trace_on = FALSE;
}

View File

@@ -24,7 +24,7 @@
#define CURSES_LIBRARY 1
#include <curses.h>
RCSID("$Id: pdckbd.c,v 1.57 2006/08/11 05:43:37 wmcbrine Exp $");
RCSID("$Id: pdckbd.c,v 1.58 2006/08/12 22:22:05 wmcbrine Exp $");
#define ACTUAL_MOUSE_MOVED (Actual_Mouse_status.changes & 8)
#define ACTUAL_BUTTON_STATUS(x) (Actual_Mouse_status.button[(x) - 1])
@@ -860,8 +860,8 @@ int PDC_set_ctrl_break(bool setting)
PDCurses Return Value:
This function returns -1 if the passed character is invalid, or
the WINDOW *_getch_win_ is NULL, or _getch_win_'s keypad is not
active.
the WINDOW *pdc_getch_win is NULL, or pdc_getch_win's keypad is
not active.
Otherwise, this function returns the PDCurses equivalent of the
passed character. See the function key and key macros in
@@ -878,8 +878,8 @@ int PDC_validchar(int c)
/* skip special keys if !keypad mode */
if ((_getch_win_ == (WINDOW *)NULL) ||
((unsigned int)c >= 256 && !_getch_win_->_use_keypad))
if ((pdc_getch_win == (WINDOW *)NULL) ||
((unsigned int)c >= 256 && !pdc_getch_win->_use_keypad))
c = -1;
PDC_LOG(("PDC_validchar() - returned: %x\n", c));

View File

@@ -24,7 +24,7 @@
#define CURSES_LIBRARY 1
#include <curses.h>
RCSID("$Id: pdcscrn.c,v 1.55 2006/08/12 21:13:45 wmcbrine Exp $");
RCSID("$Id: pdcscrn.c,v 1.56 2006/08/12 22:22:05 wmcbrine Exp $");
#define PDC_RESTORE_NONE 0
#define PDC_RESTORE_BUFFER 1
@@ -109,8 +109,8 @@ void PDC_scr_exit(void)
{
if (SP)
free(SP);
if (atrtab)
free(atrtab);
if (pdc_atrtab)
free(pdc_atrtab);
}
/*man-start**************************************************************
@@ -140,9 +140,9 @@ int PDC_scr_open(int argc, char **argv)
PDC_LOG(("PDC_scr_open() - called\n"));
SP = calloc(1, sizeof(SCREEN));
atrtab = calloc(MAX_ATRTAB, 1);
pdc_atrtab = calloc(MAX_ATRTAB, 1);
if (!SP || !atrtab)
if (!SP || !pdc_atrtab)
return ERR;
hConOut = GetStdHandle(STD_OUTPUT_HANDLE);

View File

@@ -17,7 +17,7 @@
#include "pdcx11.h"
RCSID("$Id: pdckbd.c,v 1.34 2006/08/11 05:43:37 wmcbrine Exp $");
RCSID("$Id: pdckbd.c,v 1.35 2006/08/12 22:22:05 wmcbrine Exp $");
MOUSE_STATUS Trapped_Mouse_status;
@@ -223,8 +223,8 @@ int PDC_set_ctrl_break(bool setting)
PDCurses Return Value:
This function returns -1 if the passed character is invalid, or
the WINDOW *_getch_win_ is NULL, or _getch_win_'s keypad is not
active.
the WINDOW *pdc_getch_win is NULL, or pdc_getch_win's keypad is
not active.
Otherwise, this function returns the PDCurses equivalent of the
passed character. See the function key and key macros in
@@ -241,8 +241,8 @@ int PDC_validchar(int c)
/* skip special keys if !keypad mode */
if ((_getch_win_ == (WINDOW *)NULL) ||
((unsigned int)c >= 256 && !_getch_win_->_use_keypad))
if ((pdc_getch_win == (WINDOW *)NULL) ||
((unsigned int)c >= 256 && !pdc_getch_win->_use_keypad))
c = -1;
PDC_LOG(("PDC_validchar() - returned: %x\n", c));

View File

@@ -17,7 +17,7 @@
#include "pdcx11.h"
RCSID("$Id: pdcscrn.c,v 1.37 2006/08/12 20:11:36 wmcbrine Exp $");
RCSID("$Id: pdcscrn.c,v 1.38 2006/08/12 22:22:05 wmcbrine Exp $");
/*man-start**************************************************************
@@ -137,7 +137,7 @@ int PDC_resize_screen(int nlines, int ncols)
shmkey_Xcurscr, SP->lines, SP->cols));
Xcurscr = (unsigned char*)shmat(shmid_Xcurscr, 0, 0);
atrtab = (unsigned char *)(Xcurscr + XCURSCR_ATRTAB_OFF);
pdc_atrtab = (unsigned char *)(Xcurscr + XCURSCR_ATRTAB_OFF);
SP->resized = FALSE;

View File

@@ -19,7 +19,7 @@
#include <stdlib.h>
RCSID("$Id: pdcx11.c,v 1.81 2006/07/31 00:20:18 wmcbrine Exp $");
RCSID("$Id: pdcx11.c,v 1.82 2006/08/12 22:22:05 wmcbrine Exp $");
/*** Functions that are called by both processes ***/
@@ -221,7 +221,7 @@ static int XCursesSetupCurses(void)
XCLOGMSG, shmid_Xcurscr, shmkey_Xcurscr, LINES, COLS));
Xcurscr = (unsigned char *)shmat(shmid_Xcurscr, 0, 0);
atrtab = (unsigned char *)(Xcurscr + XCURSCR_ATRTAB_OFF);
pdc_atrtab = (unsigned char *)(Xcurscr + XCURSCR_ATRTAB_OFF);
XC_LOG(("cursesprocess exiting from Xinitscr\n"));

View File

@@ -32,7 +32,7 @@
#include <stdlib.h>
#include <string.h>
RCSID("$Id: x11.c,v 1.8 2006/08/12 21:13:45 wmcbrine Exp $");
RCSID("$Id: x11.c,v 1.9 2006/08/12 22:22:05 wmcbrine Exp $");
#ifndef XPOINTER_TYPEDEFED
typedef char * XPointer;
@@ -3176,7 +3176,7 @@ static void XCursesProcessRequestsFromCurses(XtPointer client_data, int *fid,
/* Detach and drop the current shared memory segment and
create and attach to a new segment */
memcpy(save_atrtab, atrtab, sizeof(save_atrtab));
memcpy(save_atrtab, pdc_atrtab, sizeof(save_atrtab));
SP->XcurscrSize = XCURSCR_SIZE;
shmdt((char *)Xcurscr);
@@ -3193,8 +3193,8 @@ static void XCursesProcessRequestsFromCurses(XtPointer client_data, int *fid,
Xcurscr = (unsigned char*)shmat(shmid_Xcurscr, 0, 0);
memset(Xcurscr, 0, SP->XcurscrSize);
atrtab = (unsigned char *)(Xcurscr + XCURSCR_ATRTAB_OFF);
memcpy(atrtab, save_atrtab, sizeof(save_atrtab));
pdc_atrtab = (unsigned char *)(Xcurscr + XCURSCR_ATRTAB_OFF);
memcpy(pdc_atrtab, save_atrtab, sizeof(save_atrtab));
XCursesContinue();
break;
@@ -3511,7 +3511,7 @@ int XCursesSetupX(int argc, char *argv[])
Xcurscr = (unsigned char *)shmat(shmid_Xcurscr, 0, 0);
memset(Xcurscr, 0, SP->XcurscrSize);
atrtab = (unsigned char *)(Xcurscr + XCURSCR_ATRTAB_OFF);
pdc_atrtab = (unsigned char *)(Xcurscr + XCURSCR_ATRTAB_OFF);
PDC_LOG(("%s:shmid_Xcurscr %d shmkey_Xcurscr %d LINES %d COLS %d\n",
XCLOGMSG, shmid_Xcurscr, shmkey_Xcurscr, LINES, COLS));