diff --git a/curspriv.h b/curspriv.h index 7c90ce97..bb8fb3b8 100644 --- a/curspriv.h +++ b/curspriv.h @@ -15,7 +15,7 @@ * See the file maintain.er for details of the current maintainer. * ************************************************************************/ -/* $Id: curspriv.h,v 1.111 2006/08/11 07:04:31 wmcbrine Exp $ */ +/* $Id: curspriv.h,v 1.112 2006/08/11 19:50:51 wmcbrine Exp $ */ /* CURSPRIV.H @@ -52,7 +52,7 @@ struct cttyset SCREEN saved; }; -extern struct cttyset ctty[3]; +extern struct cttyset *ctty; /* tracing flag */ extern bool trace_on; @@ -78,6 +78,8 @@ extern unsigned long pdc_key_modifiers; extern MOUSE_STATUS Trapped_Mouse_status; +extern unsigned char *atrtab; + /*---------------------------------------------------------------------- * ANSI C prototypes. */ @@ -104,20 +106,14 @@ void PDC_reset_shell_mode(void); int PDC_resize_screen(int, int); void PDC_restore_screen_mode(int); int PDC_scr_close(void); +void PDC_scr_exit(void); int PDC_scr_open(int, char **); int PDC_set_ctrl_break(bool); -int PDC_set_font(int); void PDC_set_keyboard_binary(bool); void PDC_sync(WINDOW *); void PDC_transform_line(int, int, int, const chtype *); int PDC_validchar(int); -#ifdef XCURSES -# define PDC_scr_exit() XCursesExit() -#else -# define PDC_scr_exit() if (SP) free(SP) -#endif - #ifdef PDCDEBUG void PDC_debug(const char *, ...); # define PDC_LOG(x) if (trace_on) PDC_debug x diff --git a/dos/pdcdisp.c b/dos/pdcdisp.c index 95bb3757..0dc4a9c3 100644 --- a/dos/pdcdisp.c +++ b/dos/pdcdisp.c @@ -19,9 +19,7 @@ #include -RCSID("$Id: pdcdisp.c,v 1.48 2006/07/30 03:55:46 wmcbrine Exp $"); - -extern unsigned char atrtab[MAX_ATRTAB]; +RCSID("$Id: pdcdisp.c,v 1.49 2006/08/11 19:50:51 wmcbrine Exp $"); #ifdef __PACIFIC__ void movedata(unsigned sseg, unsigned soff, unsigned dseg, diff --git a/dos/pdcdos.h b/dos/pdcdos.h index 0227896a..ad40b4e5 100644 --- a/dos/pdcdos.h +++ b/dos/pdcdos.h @@ -15,7 +15,7 @@ * See the file maintain.er for details of the current maintainer. * ************************************************************************/ -/* $Id: pdcdos.h,v 1.6 2006/08/11 07:04:31 wmcbrine Exp $ */ +/* $Id: pdcdos.h,v 1.7 2006/08/11 19:50:51 wmcbrine Exp $ */ #define CURSES_LIBRARY 1 #include @@ -120,4 +120,5 @@ int PDC_get_scrn_mode(void); void PDC_putctty(chtype); int PDC_query_adapter_type(void); int PDC_set_80x25(void); +int PDC_set_font(int); int PDC_set_scrn_mode(int); diff --git a/dos/pdcscrn.c b/dos/pdcscrn.c index c8f3dadf..45b7866c 100644 --- a/dos/pdcscrn.c +++ b/dos/pdcscrn.c @@ -24,7 +24,7 @@ # include #endif -RCSID("$Id: pdcscrn.c,v 1.40 2006/08/11 06:17:48 wmcbrine Exp $"); +RCSID("$Id: pdcscrn.c,v 1.41 2006/08/11 19:50:51 wmcbrine Exp $"); Regs regs; /* used in various other modules */ @@ -89,6 +89,14 @@ int PDC_scr_close(void) return OK; } +void PDC_scr_exit(void) +{ + if (SP) + free(SP); + if (atrtab) + free(atrtab); +} + /*man-start************************************************************** PDC_scr_open() - Internal low-level binding to open the @@ -117,7 +125,8 @@ int PDC_scr_open(int argc, char **argv) #endif PDC_LOG(("PDC_scr_open() - called\n")); - if ((SP = (SCREEN *)calloc(1, sizeof(SCREEN))) == (SCREEN *)NULL) + if (!(SP = (SCREEN *)calloc(1, sizeof(SCREEN))) + || !(atrtab = (unsigned char *)calloc(MAX_ATRTAB, 1)) ) return ERR; SP->orig_attr = FALSE; diff --git a/os2/pdcdisp.c b/os2/pdcdisp.c index 0d88ccbd..a1709e68 100644 --- a/os2/pdcdisp.c +++ b/os2/pdcdisp.c @@ -19,9 +19,7 @@ #include #include -RCSID("$Id: pdcdisp.c,v 1.33 2006/07/30 03:55:46 wmcbrine Exp $"); - -extern unsigned char atrtab[MAX_ATRTAB]; +RCSID("$Id: pdcdisp.c,v 1.34 2006/08/11 19:50:51 wmcbrine Exp $"); /*man-start************************************************************** diff --git a/os2/pdcscrn.c b/os2/pdcscrn.c index c5be16a1..2b05d5ba 100644 --- a/os2/pdcscrn.c +++ b/os2/pdcscrn.c @@ -20,7 +20,7 @@ #include #include -RCSID("$Id: pdcscrn.c,v 1.37 2006/08/11 07:25:40 wmcbrine Exp $"); +RCSID("$Id: pdcscrn.c,v 1.38 2006/08/11 19:50:51 wmcbrine Exp $"); #ifdef EMXVIDEO static unsigned char *saved_screen = NULL; @@ -39,6 +39,7 @@ extern int PDC_query_adapter_type(VIOCONFIGINFO *); extern void PDC_set_keyboard_default(void); extern int PDC_set_scrn_mode(VIOMODEINFO); #endif +extern int PDC_set_font(int); /*man-start************************************************************** @@ -118,6 +119,14 @@ static bool PDC_scrn_modes_equal(VIOMODEINFO mode1, VIOMODEINFO mode2) #endif +void PDC_scr_exit(void) +{ + if (SP) + free(SP); + if (atrtab) + free(atrtab); +} + /*man-start************************************************************** PDC_scr_open() - Internal low-level binding to open the physical screen @@ -146,7 +155,8 @@ int PDC_scr_open(int argc, char **argv) #endif PDC_LOG(("PDC_scr_open() - called\n")); - if ((SP = (SCREEN *)calloc(1, sizeof(SCREEN))) == (SCREEN *)NULL) + if (!(SP = (SCREEN *)calloc(1, sizeof(SCREEN))) + || !(atrtab = (unsigned char *)calloc(MAX_ATRTAB, 1)) ) return ERR; #ifdef EMXVIDEO diff --git a/pdcurses/color.c b/pdcurses/color.c index 0ee08877..6424fc55 100644 --- a/pdcurses/color.c +++ b/pdcurses/color.c @@ -34,7 +34,7 @@ static void PDC_init_pair(short, short, short); -RCSID("$Id: color.c,v 1.50 2006/07/31 22:27:12 wmcbrine Exp $"); +RCSID("$Id: color.c,v 1.51 2006/08/11 19:50:51 wmcbrine Exp $"); /*man-start************************************************************** @@ -118,11 +118,7 @@ static bool colorstarted = FALSE; /* COLOR_PAIR to attribute encoding table. */ -#ifdef XCURSES unsigned char *atrtab = NULL; -#else -unsigned char atrtab[MAX_ATRTAB]; -#endif static unsigned char colorset[PDC_COLOR_PAIRS]; diff --git a/pdcurses/initscr.c b/pdcurses/initscr.c index 29d52050..b41e6202 100644 --- a/pdcurses/initscr.c +++ b/pdcurses/initscr.c @@ -38,7 +38,7 @@ # undef wnoutrefresh #endif -RCSID("$Id: initscr.c,v 1.67 2006/08/11 07:08:22 wmcbrine Exp $"); +RCSID("$Id: initscr.c,v 1.68 2006/08/11 19:50:51 wmcbrine Exp $"); const char *_curses_notice = "PDCurses 3.0 - Public Domain 2006"; @@ -61,7 +61,7 @@ int c_ungch[NUNGETCH]; /* array of ungotten chars */ /* Global definitions for setmode routines */ -struct cttyset ctty[3] = {{0}, {0}, {0}}; +struct cttyset *ctty; #ifdef PDC_WIDE cchar_t _wacs_map[] = { @@ -173,6 +173,12 @@ WINDOW *Xinitscr(int argc, char *argv[]) exit(8); } + if (!(ctty = calloc(3, sizeof(struct cttyset)))) + { + fprintf(stderr, "initscr(): Unable to allocate ctty\n"); + exit(9); + } + SP->autocr = TRUE; /* cr -> lf by default */ SP->raw_out = FALSE; /* tty I/O modes */ SP->raw_inp = FALSE; /* tty I/O modes */ @@ -280,15 +286,6 @@ int endwin(void) PDC_scr_close(); -#if 0 - /* resetty(); */ - if (SP->orig_font != SP->font) /* screen has not been resized */ - { - PDC_set_font(SP->orig_font); - resize_term(PDC_get_rows(), PDC_get_columns()); - } -#endif - #if defined(DOS) || defined(OS2) reset_shell_mode(); #endif @@ -347,11 +344,16 @@ void delscreen(SCREEN *sp) delwin(curscr); stdscr = (WINDOW *)NULL; curscr = (WINDOW *)NULL; + SP->alive = FALSE; + free(ctty); + ctty = NULL; + PDC_scr_exit(); SP = (SCREEN *)NULL; + atrtab = (unsigned char *)NULL; } int resize_term(int nlines, int ncols) diff --git a/win32/pdcdisp.c b/win32/pdcdisp.c index a17be03e..9b6ca9dc 100644 --- a/win32/pdcdisp.c +++ b/win32/pdcdisp.c @@ -27,9 +27,8 @@ #include extern HANDLE hConOut; -extern unsigned char atrtab[MAX_ATRTAB]; -RCSID("$Id: pdcdisp.c,v 1.34 2006/08/10 08:43:36 wmcbrine Exp $"); +RCSID("$Id: pdcdisp.c,v 1.35 2006/08/11 19:50:51 wmcbrine Exp $"); /*man-start************************************************************** diff --git a/win32/pdcscrn.c b/win32/pdcscrn.c index 8c0aa7ce..307df07f 100644 --- a/win32/pdcscrn.c +++ b/win32/pdcscrn.c @@ -24,7 +24,7 @@ #define CURSES_LIBRARY 1 #include -RCSID("$Id: pdcscrn.c,v 1.50 2006/08/11 07:04:31 wmcbrine Exp $"); +RCSID("$Id: pdcscrn.c,v 1.51 2006/08/11 19:50:51 wmcbrine Exp $"); #define PDC_RESTORE_NONE 0 #define PDC_RESTORE_BUFFER 1 @@ -98,6 +98,14 @@ int PDC_scr_close(void) return OK; } +void PDC_scr_exit(void) +{ + if (SP) + free(SP); + if (atrtab) + free(atrtab); +} + /*man-start************************************************************** PDC_scr_open() - Internal low-level binding to open the physical screen @@ -124,7 +132,8 @@ int PDC_scr_open(int argc, char **argv) PDC_LOG(("PDC_scr_open() - called\n")); - if ((SP = (SCREEN *)calloc(1, sizeof(SCREEN))) == (SCREEN *)NULL) + if (!(SP = (SCREEN *)calloc(1, sizeof(SCREEN))) + || !(atrtab = (unsigned char *)calloc(MAX_ATRTAB, 1)) ) return ERR; hConOut = GetStdHandle(STD_OUTPUT_HANDLE); diff --git a/win32/pdcsetsc.c b/win32/pdcsetsc.c index 830afc57..c526bdc2 100644 --- a/win32/pdcsetsc.c +++ b/win32/pdcsetsc.c @@ -24,41 +24,10 @@ #define CURSES_LIBRARY 1 #include -RCSID("$Id: pdcsetsc.c,v 1.25 2006/08/10 08:43:36 wmcbrine Exp $"); +RCSID("$Id: pdcsetsc.c,v 1.26 2006/08/11 19:50:51 wmcbrine Exp $"); extern HANDLE hConOut; -/*man-start************************************************************** - - PDC_set_font() - sets the current font size - - PDCurses Description: - This is a private PDCurses function. - - This routine sets the current font size, if the adapter allows - such a change. - - PDCurses Return Value: - This function returns OK upon success otherwise ERR is returned. - - PDCurses Errors: - It is an error to attempt to change the font size on a "bogus" - adapter. The reason for this is that we have a known video - adapter identity problem. e.g. Two adapters report the same - identifying characteristics. - - Portability: - PDCurses int PDC_set_font(int size); - -**man-end****************************************************************/ - -int PDC_set_font(int size) -{ - PDC_LOG(("PDC_set_font() - called\n")); - - return OK; -} - int PDC_curs_set(int visibility) { CONSOLE_CURSOR_INFO cci; diff --git a/x11/pdcscrn.c b/x11/pdcscrn.c index 6551ec56..13e5b44e 100644 --- a/x11/pdcscrn.c +++ b/x11/pdcscrn.c @@ -17,7 +17,7 @@ #include "pdcx11.h" -RCSID("$Id: pdcscrn.c,v 1.34 2006/08/11 07:04:31 wmcbrine Exp $"); +RCSID("$Id: pdcscrn.c,v 1.35 2006/08/11 19:50:51 wmcbrine Exp $"); /*man-start************************************************************** @@ -43,6 +43,11 @@ int PDC_scr_close(void) return OK; } +void PDC_scr_exit(void) +{ + XCursesExit(); +} + /*man-start************************************************************** PDC_scr_open() - Internal low-level binding to open the physical diff --git a/x11/pdcsetsc.c b/x11/pdcsetsc.c index 2f164d74..dde4f680 100644 --- a/x11/pdcsetsc.c +++ b/x11/pdcsetsc.c @@ -19,38 +19,7 @@ #include -RCSID("$Id: pdcsetsc.c,v 1.22 2006/07/30 23:57:04 wmcbrine Exp $"); - -/*man-start************************************************************** - - PDC_set_font() - sets the current font size - - PDCurses Description: - This is a private PDCurses function. - - This routine sets the current font size, if the adapter allows - such a change. - - PDCurses Return Value: - This function returns OK upon success otherwise ERR is returned. - - PDCurses Errors: - It is an error to attempt to change the font size on a "bogus" - adapter. The reason for this is that we have a known video - adapter identity problem. e.g. Two adapters report the same - identifying characteristics. - - Portability: - PDCurses int PDC_set_font(int size); - -**man-end****************************************************************/ - -int PDC_set_font(int size) -{ - PDC_LOG(("PDC_set_font() - called\n")); - - return OK; -} +RCSID("$Id: pdcsetsc.c,v 1.23 2006/08/11 19:50:51 wmcbrine Exp $"); int PDC_curs_set(int visibility) { diff --git a/x11/pdcx11.h b/x11/pdcx11.h index 167ed8f8..b630194e 100644 --- a/x11/pdcx11.h +++ b/x11/pdcx11.h @@ -15,7 +15,7 @@ * See the file maintain.er for details of the current maintainer. * ************************************************************************/ -/* $Id: pdcx11.h,v 1.47 2006/07/30 23:57:04 wmcbrine Exp $ */ +/* $Id: pdcx11.h,v 1.48 2006/08/11 19:50:51 wmcbrine Exp $ */ #define CURSES_LIBRARY 1 #ifdef HAVE_CONFIG_H @@ -179,7 +179,6 @@ extern int shmkey_Xcurscr; extern int otherpid; extern int XCursesLINES; extern int XCursesCOLS; -extern unsigned char *atrtab; extern int XC_display_sock; extern int XC_key_sock; extern int display_sockets[2];