From 35513e0d702dab12cb7cd29795c06ef55d4fd0c4 Mon Sep 17 00:00:00 2001 From: Mark Hessling Date: Sat, 12 Jan 2002 04:04:18 +0000 Subject: [PATCH] Allow "special" characters like Ctrl-S to be returned by OS/2 keyboard handler. --- curses.h | 3 +- curspriv.h | 19 +- os2/gccos2.mak | 18 +- os2/pdcgetsc.c | 440 +++++++++++-------------- os2/pdckbd.c | 783 +++++++++++++++++++++++---------------------- os2/pdcscrn.c | 373 +++++++++++---------- os2/pdcsetsc.c | 353 +++++++++----------- pdcurses/initscr.c | 747 +++++++++++++++++++++--------------------- pdcurses/kernel.c | 497 ++++++++++++++-------------- 9 files changed, 1592 insertions(+), 1641 deletions(-) diff --git a/curses.h b/curses.h index 7bead9f8..7db5b70a 100644 --- a/curses.h +++ b/curses.h @@ -18,7 +18,7 @@ *************************************************************************** */ /* -$Id: curses.h,v 1.8 2002/01/12 03:37:57 mark Exp $ +$Id: curses.h,v 1.9 2002/01/12 04:04:18 mark Exp $ */ /* *---------------------------------------------------------------------- @@ -937,6 +937,7 @@ typedef struct # else VIOMODEINFO scrnmode; /* default screen mode */ VIOCONFIGINFO adapter; /* Screen type */ + KBDINFO kbdinfo; /* keyboard info */ # endif #else int adapter; /* Screen type */ diff --git a/curspriv.h b/curspriv.h index 268e2537..949d607a 100644 --- a/curspriv.h +++ b/curspriv.h @@ -18,7 +18,7 @@ *************************************************************************** */ /* -$Id: curspriv.h,v 1.3 2001/01/10 08:31:37 mark Exp $ +$Id: curspriv.h,v 1.4 2002/01/12 04:04:18 mark Exp $ */ /* * @@ -337,17 +337,24 @@ void PDC_usleep( long ); int PDC_validchar( int ); int PDC_vsscanf( char *, const char *, va_list); -int PDC_query_adapter_type( void ); -int PDC_get_scrn_mode( void ); void PDC_slk_calc( void ); # if defined( OS2 ) && !defined( EMXVIDEO ) int PDC_set_scrn_mode( VIOMODEINFO); bool PDC_scrn_modes_equal (VIOMODEINFO, VIOMODEINFO); +int PDC_get_scrn_mode( VIOMODEINFO *); +int PDC_query_adapter_type( VIOCONFIGINFO * ); +int PDC_get_keyboard_info( KBDINFO * ); +int PDC_set_keyboard_binary( void ); +int PDC_set_keyboard_default( void ); +int PDC_reset_shell_mode( void ); +int PDC_reset_prog_mode( void ); # else int PDC_set_scrn_mode( int ); bool PDC_scrn_modes_equal (int, int); +int PDC_get_scrn_mode( void ); +int PDC_query_adapter_type( void ); # endif # ifdef FLEXOS @@ -456,17 +463,19 @@ void PDC_usleep( /* long */ ); int PDC_validchar( /* int */ ); int PDC_vsscanf( /* char *, const char *, ... */); -int PDC_query_adapter_type( /* void */ ); -int PDC_get_scrn_mode( /* void */ ); void PDC_slk_calc( /* void */ ); # if defined( OS2 ) && !defined( EMXVIDEO ) int PDC_set_scrn_mode( /* VIOMODEINFO*/ ); bool PDC_scrn_modes_equal ( /*VIOMODEINFO, VIOMODEINFO*/ ); +int PDC_get_scrn_mode( /* VIOMODEINFO * */ ); +int PDC_query_adapter_type( /* VIOCONFIGINFO * */ ); # else int PDC_set_scrn_mode( /* int */ ); bool PDC_scrn_modes_equal ( /*int, int*/ ); +int PDC_get_scrn_mode( /* void */ ); +int PDC_query_adapter_type( /* void */ ); # endif # ifdef FLEXOS diff --git a/os2/gccos2.mak b/os2/gccos2.mak index e3d69767..acf9d24d 100644 --- a/os2/gccos2.mak +++ b/os2/gccos2.mak @@ -12,8 +12,7 @@ # ################################################################################ # -# This makefile requires the following environment variables with values like: -# PDCURSES_SRCDIR=c:\pdcurses +# Change these for your environment... # ################################################################################ PDCURSES_HOME =$(PDCURSES_SRCDIR) @@ -44,11 +43,13 @@ ifeq ($(EMXVIDEO),Y) VIDLIB = -lvideo BINDFLAGS = -acm DLLTARGET = + DISTTARGETS = pdcurses.a pdcurses.lib panel.a panel.lib else EMXVID = VIDLIB = BINDFLAGS = DLLTARGET = curses.dll + DISTTARGETS = curses.a curses.dll curses.lib pdcurses.a pdcurses.lib panel.a panel.lib endif ifeq ($(DEBUG),Y) @@ -206,6 +207,7 @@ pdcurses.a : $(LIBOBJS) $(PDCOBJS) curses.dll : $(DLLOBJS) $(PDCDLOS) $(LINK) $(DLLFLAGS) -o curses.dll $(DLLOBJS) $(PDCDLOS) $(osdir)\pdcurses.def + lxlite curses.dll emximp -o curses.lib $(osdir)\pdcurses.def emximp -o curses.a curses.lib @@ -529,7 +531,7 @@ xmas.exe: xmas.o $(LIBCURSES) $(EMXBIND) xmas $(BINDFLAGS) -testcurs_dyn.exe: testcurs.obj pdcurses.dll +testcurs_dyn.exe: testcurs.obj curses.dll $(LINK) $(LDFLAGS) $(DLLFLAGS) -o testcurs_dyn testcurs.obj $(DLLCURSES) -L$(CCLIBDIR) $(CCLIBS) $(EMXBIND) testcurs_dyn $(BINDFLAGS) @@ -550,23 +552,23 @@ testcurs.obj: $(demodir)\testcurs.c $(PDCURSES_CURSES_H) tui.o: $(demodir)\tui.c $(demodir)\tui.h $(PDCURSES_CURSES_H) $(CC) $(CCFLAGS) -I$(demodir) -o $@ $(demodir)\tui.c - + tuidemo.o: $(demodir)\tuidemo.c $(PDCURSES_CURSES_H) $(CC) $(CCFLAGS) -I$(demodir) -o $@ $(demodir)\tuidemo.c xmas.o: $(demodir)\xmas.c $(PDCURSES_CURSES_H) $(CC) $(CCFLAGS) -o$@ $(demodir)\xmas.c -dist: curses.a curses.dll curses.lib pdcurses.a pdcurses.lib panel.a panel.lib +dist: $(DISTTARGETS) -mkdir tmp copy $(PDCURSES_HOME)\README tmp\README copy $(PDCURSES_HOME)\readme.?? tmp copy $(PDCURSES_HOME)\curses.h tmp copy $(PDCURSES_HOME)\curspriv.h tmp copy $(PDCURSES_HOME)\maintain.er tmp - copy curses.dll tmp - copy curses.lib tmp - copy curses.a tmp + -copy curses.dll tmp + -copy curses.lib tmp + -copy curses.a tmp copy pdcurses.a tmp copy pdcurses.lib tmp copy panel.a tmp diff --git a/os2/pdcgetsc.c b/os2/pdcgetsc.c index c138ed93..c3bb0377 100644 --- a/os2/pdcgetsc.c +++ b/os2/pdcgetsc.c @@ -17,538 +17,480 @@ * See the file maintain.er for details of the current maintainer. *************************************************************************** */ -#define CURSES_LIBRARY 1 +#define CURSES_LIBRARY 1 #ifdef HAVE_CONFIG_H # include #endif #include #ifdef PDCDEBUG -char *rcsid_PDCgetsc = "$Id: pdcgetsc.c,v 1.2 2001/01/10 08:29:33 mark Exp $"; -#endif - -#if !defined( EMXVIDEO ) - VIOCONFIGINFO configInfo={0}; - VIOMODEINFO modeInfo={0}; +char *rcsid_PDCgetsc = "$Id: pdcgetsc.c,v 1.3 2002/01/12 04:04:18 mark Exp $"; #endif /*man-start********************************************************************* - PDC_get_cursor_pos() - return current cursor position + PDC_get_cursor_pos() - return current cursor position PDCurses Description: - This is a private PDCurses function + This is a private PDCurses function - Gets the cursor position in video page 0. 'row' and 'column' - are the cursor address. At this time, there is no support for - use of multiple screen pages. + Gets the cursor position in video page 0. 'row' and 'column' + are the cursor address. At this time, there is no support for + use of multiple screen pages. PDCurses Return Value: - This routine will return OK upon success and otherwise ERR will be - returned. + This routine will return OK upon success and otherwise ERR will be + returned. PDCurses Errors: - There are no defined errors for this routine. + There are no defined errors for this routine. Portability: - PDCurses int PDC_get_cursor_pos( int* row, int* col ); + PDCurses int PDC_get_cursor_pos( int* row, int* col ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_get_cursor_pos(int *row, int *col) -#else -int PDC_get_cursor_pos(row,col) -int *row; -int *col; -#endif +int PDC_get_cursor_pos(int *row, int *col) /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_cursor_pos() - called\n"); + if (trace_on) PDC_debug("PDC_get_cursor_pos() - called\n"); #endif #ifdef EMXVIDEO - v_getxy (col, row); + v_getxy (col, row); #else - VioGetCurPos((PUSHORT)row,(PUSHORT)col,0); + VioGetCurPos((PUSHORT)row,(PUSHORT)col,0); #endif - return( OK ); + return( OK ); } /*man-start********************************************************************* - PDC_get_cur_col() - get current column position of cursor + PDC_get_cur_col() - get current column position of cursor PDCurses Description: - This is a private PDCurses function + This is a private PDCurses function - This routine returns the current column position of the cursor on - screen. + This routine returns the current column position of the cursor on + screen. PDCurses Return Value: - This routine returns the current column position of the cursor. No - error is returned. + This routine returns the current column position of the cursor. No + error is returned. PDCurses Errors: - There are no defined errors for this routine. + There are no defined errors for this routine. Portability: - PDCurses int PDC_get_cur_col( void ); + PDCurses int PDC_get_cur_col( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_get_cur_col(void) -#else -int PDC_get_cur_col() -#endif +int PDC_get_cur_col(void) /***********************************************************************/ { #ifdef EMXVIDEO - int curCol=0, curRow=0; + int curCol=0, curRow=0; #else - USHORT curCol=0, curRow=0; + USHORT curCol=0, curRow=0; #endif - #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_cur_col() - called\n"); + if (trace_on) PDC_debug("PDC_get_cur_col() - called\n"); #endif - /* find the current cursor position */ + /* find the current cursor position */ #ifdef EMXVIDEO - v_getxy (&curCol, &curRow); + v_getxy (&curCol, &curRow); #else - VioGetCurPos ((PUSHORT) &curRow, (PUSHORT) &curCol, 0); + VioGetCurPos ((PUSHORT) &curRow, (PUSHORT) &curCol, 0); #endif - return (curCol); - + return (curCol); } /*man-start********************************************************************* - PDC_get_cur_row() - get current row position of cursor + PDC_get_cur_row() - get current row position of cursor PDCurses Description: - This is a private PDCurses function + This is a private PDCurses function - This routine returns the current row position of the cursor on - screen. + This routine returns the current row position of the cursor on + screen. PDCurses Return Value: - This routine returns the current row position of the cursor. No - error is returned. + This routine returns the current row position of the cursor. No + error is returned. PDCurses Errors: - There are no defined errors for this routine. + There are no defined errors for this routine. Portability: - PDCurses int PDC_get_cur_row( void ); + PDCurses int PDC_get_cur_row( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_get_cur_row(void) -#else -int PDC_get_cur_row() -#endif +int PDC_get_cur_row(void) /***********************************************************************/ { #ifdef EMXVIDEO - int curCol=0, curRow=0; + int curCol=0, curRow=0; #else - USHORT curCol=0, curRow=0; + USHORT curCol=0, curRow=0; #endif - #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_cur_row() - called\n"); + if (trace_on) PDC_debug("PDC_get_cur_row() - called\n"); #endif - /* find the current cursor position */ + /* find the current cursor position */ #ifdef EMXVIDEO - v_getxy (&curCol, &curRow); + v_getxy (&curCol, &curRow); #else - VioGetCurPos ((PUSHORT) &curRow, (PUSHORT) &curCol, 0); + VioGetCurPos ((PUSHORT) &curRow, (PUSHORT) &curCol, 0); #endif - return (curRow); - + return (curRow); } /*man-start********************************************************************* - PDC_get_attribute() - Get attribute at current cursor + PDC_get_attribute() - Get attribute at current cursor PDCurses Description: - This is a private PDCurses function + This is a private PDCurses function - Return the current attr at current cursor position on the screen. + Return the current attr at current cursor position on the screen. PDCurses Return Value: - This routine will return OK upon success and otherwise ERR will be - returned. + This routine will return OK upon success and otherwise ERR will be + returned. PDCurses Errors: - There are no defined errors for this routine. + There are no defined errors for this routine. Portability: - PDCurses int PDC_get_attribute( void ); + PDCurses int PDC_get_attribute( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_get_attribute(void) -#else -int PDC_get_attribute() -#endif +int PDC_get_attribute(void) /***********************************************************************/ { #ifndef EMXVIDEO - USHORT cellLen = 2; + USHORT cellLen = 2; #endif - int curRow=0, curCol=0; - char Cell[4]; - + int curRow=0, curCol=0; + char Cell[4]; #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_attribute() - called\n"); + if (trace_on) PDC_debug("PDC_get_attribute() - called\n"); #endif - PDC_get_cursor_pos(&curRow, &curCol); + PDC_get_cursor_pos(&curRow, &curCol); #ifdef EMXVIDEO - v_getline (Cell, curCol, curRow, 1); + v_getline (Cell, curCol, curRow, 1); #else - VioReadCellStr((PCH)&Cell, (PUSHORT)&cellLen, (USHORT)curRow, (USHORT)curCol, 0); + VioReadCellStr((PCH)&Cell, (PUSHORT)&cellLen, (USHORT)curRow, (USHORT)curCol, 0); #endif - return ((int) Cell[1]); - + return ((int) Cell[1]); } /*man-start********************************************************************* - PDC_get_columns() - return width of screen/viewport. + PDC_get_columns() - return width of screen/viewport. PDCurses Description: - This is a private PDCurses function + This is a private PDCurses function - This function will return the width of the current screen. + This function will return the width of the current screen. PDCurses Return Value: - This routine will return OK upon success and otherwise ERR will be - returned. + This routine will return OK upon success and otherwise ERR will be + returned. PDCurses Errors: - There are no defined errors for this routine. + There are no defined errors for this routine. Portability: - PDCurses int PDC_get_columns( void ); + PDCurses int PDC_get_columns( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_get_columns(void) -#else -int PDC_get_columns() -#endif +int PDC_get_columns(void) /***********************************************************************/ { #ifdef EMXVIDEO - int rows=0; + int rows=0; #else - VIOMODEINFO modeInfo={0}; + VIOMODEINFO modeInfo={0}; #endif - int cols=0; - char *env_cols=NULL; - - + int cols=0; + char *env_cols=NULL; #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_columns() - called\n"); + if (trace_on) PDC_debug("PDC_get_columns() - called\n"); #endif #ifdef EMXVIDEO - v_dimen (&cols, &rows); + v_dimen (&cols, &rows); #else - modeInfo.cb = sizeof(modeInfo); - VioGetMode(&modeInfo, 0); - cols = modeInfo.col; + modeInfo.cb = sizeof(modeInfo); + VioGetMode(&modeInfo, 0); + cols = modeInfo.col; #endif - env_cols = (char *)getenv("COLS"); - if (env_cols != (char *)NULL) - { - cols = min(atoi(env_cols),cols); - } + env_cols = (char *)getenv("COLS"); + if (env_cols != (char *)NULL) + { + cols = min(atoi(env_cols),cols); + } #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_columns() - returned: cols %d\n",cols); + if (trace_on) PDC_debug("PDC_get_columns() - returned: cols %d\n",cols); #endif - return(cols); - + return(cols); } /*man-start********************************************************************* - PDC_get_cursor_mode() - Get the cursor start and stop scan lines. + PDC_get_cursor_mode() - Get the cursor start and stop scan lines. PDCurses Description: - Gets the cursor type to begin in scan line startrow and end in - scan line endrow. Both values should be 0-31. + Gets the cursor type to begin in scan line startrow and end in + scan line endrow. Both values should be 0-31. PDCurses Return Value: - This function returns OK on success and ERR on error. + This function returns OK on success and ERR on error. PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses int PDC_get_cursor_mode( void ); + PDCurses int PDC_get_cursor_mode( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_get_cursor_mode(void) -#else -int PDC_get_cursor_mode() -#endif +int PDC_get_cursor_mode(void) /***********************************************************************/ { #ifdef EMXVIDEO - int curstart=0, curend=0; + int curstart=0, curend=0; #else - VIOCURSORINFO cursorInfo; + VIOCURSORINFO cursorInfo; #endif - short cmode=0; + short cmode=0; #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_cursor_mode() - called\n"); + if (trace_on) PDC_debug("PDC_get_cursor_mode() - called\n"); #endif #ifdef EMXVIDEO - v_getctype (&curstart, &curend); - cmode = ((curstart << 8) | (curend)); + v_getctype (&curstart, &curend); + cmode = ((curstart << 8) | (curend)); #else - VioGetCurType (&cursorInfo, 0); + VioGetCurType (&cursorInfo, 0); /* I am not sure about this JGB */ - cmode = ((cursorInfo.yStart << 8) | (cursorInfo.cEnd)); + cmode = ((cursorInfo.yStart << 8) | (cursorInfo.cEnd)); #endif - return(cmode); - + return(cmode); } /*man-start********************************************************************* - PDC_get_font() - Get the current font size + PDC_get_font() - Get the current font size PDCurses Description: - This is a private PDCurses routine. + This is a private PDCurses routine. - This function returns the current font size. This function only - works if the #define FAST_VIDEO is true. + This function returns the current font size. This function only + works if the #define FAST_VIDEO is true. PDCurses Return Value: - This function returns OK on success and ERR on error. + This function returns OK on success and ERR on error. PDCurses Errors: - An ERR will be returned if FAST_VIDEO is not true. + An ERR will be returned if FAST_VIDEO is not true. Portability: - PDCurses int PDC_get_font( void ); + PDCurses int PDC_get_font( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_get_font(void) -#else -int PDC_get_font() -#endif +int PDC_get_font(void) /***********************************************************************/ { #ifdef EMXVIDEO - int retval=0; + int retval=0; #else - VIOMODEINFO modeInfo={0}; + VIOMODEINFO modeInfo={0}; #endif #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_font() - called\n"); + if (trace_on) PDC_debug("PDC_get_font() - called\n"); #endif #ifdef EMXVIDEO - retval = v_hardware(); - return (retval == V_MONOCHROME) ? 14 : (retval == V_COLOR_8) ? 8 : 12; + retval = v_hardware(); + return (retval == V_MONOCHROME) ? 14 : (retval == V_COLOR_8) ? 8 : 12; #else - modeInfo.cb = sizeof(modeInfo); - /* set most parameters of modeInfo */ - VioGetMode(&modeInfo, 0); - return ( modeInfo.vres / modeInfo.row); + modeInfo.cb = sizeof(modeInfo); + /* set most parameters of modeInfo */ + VioGetMode(&modeInfo, 0); + return ( modeInfo.vres / modeInfo.row); #endif } /*man-start********************************************************************* - PDC_get_rows() - Return number of screen rows. + PDC_get_rows() - Return number of screen rows. PDCurses Description: - This is a private PDCurses routine. + This is a private PDCurses routine. - Returns the maximum number of rows supported by the display. - e.g. 25, 28, 43, 50, 60, 66... + Returns the maximum number of rows supported by the display. + e.g. 25, 28, 43, 50, 60, 66... PDCurses Return Value: - This function returns OK on success and ERR on error. + This function returns OK on success and ERR on error. PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses int PDC_get_rows( void ); + PDCurses int PDC_get_rows( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_get_rows(void) -#else -int PDC_get_rows() -#endif +int PDC_get_rows(void) /***********************************************************************/ { - #ifdef EMXVIDEO - int cols=0; + int cols=0; #else - VIOMODEINFO modeInfo={0}; + VIOMODEINFO modeInfo={0}; #endif - int rows=0; - char *env_rows=NULL; + int rows=0; + char *env_rows=NULL; #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_rows() - called\n"); + if (trace_on) PDC_debug("PDC_get_rows() - called\n"); #endif /* use the value from LINES environment variable, if set. MH 10-Jun-92 */ /* and use the minimum of LINES and *ROWS. MH 18-Jun-92 */ #ifdef EMXVIDEO - v_dimen (&cols, &rows); + v_dimen (&cols, &rows); #else - modeInfo.cb = sizeof(modeInfo); - VioGetMode(&modeInfo, 0); - rows = modeInfo.row; + modeInfo.cb = sizeof(modeInfo); + VioGetMode(&modeInfo, 0); + rows = modeInfo.row; #endif - env_rows = (char *)getenv("LINES"); - if (env_rows != (char *)NULL) - rows = min(atoi(env_rows),rows); + env_rows = (char *)getenv("LINES"); + if (env_rows != (char *)NULL) + rows = min(atoi(env_rows),rows); #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_rows() - returned: rows %d\n",rows); + if (trace_on) PDC_debug("PDC_get_rows() - returned: rows %d\n",rows); #endif - return(rows); - + return(rows); } /*man-start********************************************************************* - PDC_get_scrn_mode() - Return the current BIOS video mode + PDC_get_scrn_mode() - Return the current BIOS video mode PDCurses Description: - This is a private PDCurses routine. + This is a private PDCurses routine. PDCurses Return Value: - Returns the current BIOS Video Mode Number. + Returns the current BIOS Video Mode Number. PDCurses Errors: - The FLEXOS version of this routine returns an ERR. - The UNIX version of this routine returns an ERR. - The EMXVIDEO version of this routine returns an ERR. + The FLEXOS version of this routine returns an ERR. + The UNIX version of this routine returns an ERR. + The EMXVIDEO version of this routine returns an ERR. Portability: - PDCurses int PDC_get_scrn_mode( void ); + PDCurses int PDC_get_scrn_mode( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_get_scrn_mode(void) +#if defined(EMXVIDEO) +int PDC_get_scrn_mode( void ) #else -int PDC_get_scrn_mode() +int PDC_get_scrn_mode( VIOMODEINFO *modeinfo ) #endif /***********************************************************************/ { - +#ifndef EMXVIDEO + VIOMODEINFO amodeinfo; +#endif #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_scrn_mode() - called\n"); + if (trace_on) PDC_debug("PDC_get_scrn_mode() - called\n"); #endif - #ifdef EMXVIDEO - return(ERR); + return(ERR); #else - VioGetMode (&modeInfo, 0); - return(OK); + VioGetMode ( &amodeinfo, 0 ); + *modeinfo = amodeinfo; + return(OK); #endif - } /*man-start********************************************************************* - PDC_query_adapter_type() - Determine PC video adapter type + PDC_query_adapter_type() - Determine PC video adapter type PDCurses Description: - This is a private PDCurses routine. + This is a private PDCurses routine. - Thanks to Jeff Duntemann, K16RA for providing the impetus - (through the Dr. Dobbs Journal, March 1989 issue) for getting - the routines below merged into Bjorn Larsson's PDCurses 1.3... - -- frotz@dri.com 900730 + Thanks to Jeff Duntemann, K16RA for providing the impetus + (through the Dr. Dobbs Journal, March 1989 issue) for getting + the routines below merged into Bjorn Larsson's PDCurses 1.3... + -- frotz@dri.com 900730 PDCurses Return Value: - This function returns a macro identifier indicating the adapter - type. See the list of adapter types in CURSPRIV.H. + This function returns a macro identifier indicating the adapter + type. See the list of adapter types in CURSPRIV.H. PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses int PDC_query_adapter_type( void ); + PDCurses int PDC_query_adapter_type( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_query_adapter_type(void) +#if defined(EMXVIDEO) +int PDC_query_adapter_type( void ) #else -int PDC_query_adapter_type() +int PDC_query_adapter_type( VIOCONFIGINFO *configinfo ) #endif /***********************************************************************/ { - int retval = _NONE; - -#ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_query_adapter_type() - called\n"); -#endif - -#ifdef EMXVIDEO - SP->adapter = v_hardware(); - if (SP->adapter == V_MONOCHROME) - { - SP->mono = TRUE; - retval = _UNIX_MONO; - } - else - { - SP->mono = FALSE; - retval = _UNIX_COLOR; - } - SP->sizeable = TRUE; - SP->bogus_adapter = FALSE; - return(retval); +#ifndef EMXVIDEO + VIOCONFIGINFO aconfiginfo; #else - VioGetConfig(0, &configInfo, 0); - SP->sizeable = TRUE; - return(OK); + int retval = _NONE; +#endif +#ifdef PDCDEBUG + if (trace_on) PDC_debug("PDC_query_adapter_type() - called\n"); +#endif +#ifdef EMXVIDEO + if (v_hardware() == V_MONOCHROME) + retval = _UNIX_MONO; + else + retval = _UNIX_COLOR; + return(retval); +#else + VioGetConfig( 0, &aconfiginfo, 0 ); + *configinfo = aconfiginfo; + return(OK); #endif - } diff --git a/os2/pdckbd.c b/os2/pdckbd.c index 714cd360..907ad37e 100644 --- a/os2/pdckbd.c +++ b/os2/pdckbd.c @@ -18,75 +18,74 @@ *************************************************************************** */ -#define CURSES_LIBRARY 1 +#define CURSES_LIBRARY 1 #ifdef HAVE_CONFIG_H -# include +# include #endif #include #if defined (CURSES__32BIT__) || defined(CSET2) || defined(TC) -# include +# include #else -# define INCL_DOSSIGNALS -# define INCL_NOCOMMON -# include +# define INCL_DOSSIGNALS +# define INCL_NOCOMMON +# include #endif #ifdef PDCDEBUG -char *rcsid_PDCkbd = "$Id: pdckbd.c,v 1.3 2001/04/22 05:53:53 mark Exp $"; +char *rcsid_PDCkbd = "$Id: pdckbd.c,v 1.4 2002/01/12 04:04:18 mark Exp $"; #endif /******************************************************************************* -* Table for key code translation of function keys in keypad mode -* These values are for strict IBM keyboard compatibles only +* Table for key code translation of function keys in keypad mode +* These values are for strict IBM keyboard compatibles only *******************************************************************************/ - static int kptab[] = { - /* Normal Function Keys */ + /* Normal Function Keys */ 0x3b, KEY_F(1), 0x3c, KEY_F(2), 0x3d, KEY_F(3), 0x3e, KEY_F(4), 0x3f, KEY_F(5), 0x40, KEY_F(6), 0x41, KEY_F(7), 0x42, KEY_F(8), 0x43, KEY_F(9), 0x44, KEY_F(10), - /* Normal Keypad */ + /* Normal Keypad */ 0x47, KEY_HOME, 0x48, KEY_UP, 0x49, KEY_PPAGE, 0x4b, KEY_LEFT, 0x4c, KEY_B2, 0x4d, KEY_RIGHT, 0x4f, KEY_END, 0x50, KEY_DOWN, 0x51, KEY_NPAGE, 0x52, KEY_IC, 0x53, KEY_DC, - /* Shifted Keypad */ + /* Shifted Keypad */ 0xb0, KEY_SHOME, 0xb1, KEY_SUP, 0xb2, KEY_SPREVIOUS, 0xb3, KEY_SLEFT, 0xb4, KEY_SRIGHT, 0xb5, KEY_SEND, 0xb6, KEY_SDOWN, 0xb7, KEY_SNEXT, 0xb8, KEY_SIC, 0xb9, KEY_SDC, - /* Shft-Function Keys */ + /* Shft-Function Keys */ 0x54, KEY_F(13), 0x55, KEY_F(14), 0x56, KEY_F(15), 0x57, KEY_F(16), 0x58, KEY_F(17), 0x59, KEY_F(18), 0x5a, KEY_F(19), 0x5b, KEY_F(20), 0x5c, KEY_F(21), 0x5d, KEY_F(22), - /* Ctl-Function Keys */ + /* Ctl-Function Keys */ 0x5e, KEY_F(25), 0x5f, KEY_F(26), 0x60, KEY_F(27), 0x61, KEY_F(28), 0x62, KEY_F(29), 0x63, KEY_F(30), 0x64, KEY_F(31), 0x65, KEY_F(32), 0x66, KEY_F(33), 0x67, KEY_F(34), - /* Alt-Function Keys */ + /* Alt-Function Keys */ 0x68, KEY_F(37), 0x69, KEY_F(38), 0x6a, KEY_F(39), 0x6b, KEY_F(40), 0x6c, KEY_F(41), 0x6d, KEY_F(42), 0x6e, KEY_F(43), 0x6f, KEY_F(44), 0x70, KEY_F(45), 0x71, KEY_F(46), - /* Control-Keypad */ + /* Control-Keypad */ 0x77, CTL_HOME, 0x84, CTL_PGUP, 0x73, CTL_LEFT, 0x74, CTL_RIGHT, 0x75, CTL_END, 0x76, CTL_PGDN, - /* Alt-Numbers */ + /* Alt-Numbers */ 0x78, ALT_1, 0x79, ALT_2, 0x7a, ALT_3, 0x7b, ALT_4, 0x7c, ALT_5, 0x7d, ALT_6, 0x7e, ALT_7, 0x7f, ALT_8, 0x80, ALT_9, 0x81, ALT_0, - /* Extended codes */ + /* Extended codes */ 0x85, KEY_F(11), 0x86, KEY_F(12), 0x87, KEY_F(23), 0x88, KEY_F(24), 0x89, KEY_F(35), 0x8a, KEY_F(36), 0x8b, KEY_F(47), 0x8c, KEY_F(48), 0x03, 0, /* NULL */ @@ -115,7 +114,7 @@ static int kptab[] = 0x27, ALT_SEMICOLON,0x28, ALT_FQUOTE, 0x33, ALT_COMMA, 0x34, ALT_STOP, 0x35, ALT_FSLASH, 0x2b, ALT_BSLASH, - /* Alt-Alphabet */ + /* Alt-Alphabet */ 0x1e, ALT_A, 0x30, ALT_B, 0x2e, ALT_C, 0x20, ALT_D, 0x12, ALT_E, 0x21, ALT_F, 0x22, ALT_G, 0x23, ALT_H, 0x17, ALT_I, 0x24, ALT_J, 0x25, ALT_K, 0x26, ALT_L, @@ -126,155 +125,211 @@ static int kptab[] = 0x0f, KEY_BTAB, 0x100, (-1) }; - /* End of kptab[] */ + /* End of kptab[] */ static unsigned long pdc_key_modifiers=0L; MOUSE_STATUS Trapped_Mouse_status; /*man-start********************************************************************* - PDC_breakout() - check for type-ahead + PDC_breakout() - check for type-ahead X/Open Description: - The curses package does the "line-breakout optimisation" by - looking for type-ahead periodically while updating the screen. - If input is found, the current update will be postponed until - refresh() or doupdate() are called again. This allows faster - response to commands typed in advance. Normally, the input FILE - pointer passed to newterm(), or stdin in the case when initscr() - was called, will be used to do this type-ahead checking. This routine - will do the actual check for PDcurses to see if input is pending. + The curses package does the "line-breakout optimisation" by + looking for type-ahead periodically while updating the screen. + If input is found, the current update will be postponed until + refresh() or doupdate() are called again. This allows faster + response to commands typed in advance. Normally, the input FILE + pointer passed to newterm(), or stdin in the case when initscr() + was called, will be used to do this type-ahead checking. This routine + will do the actual check for PDcurses to see if input is pending. PDCurses Description: - This routine does what the PDcurses typeahead routine used to do. But - to make that routine consistent with its System V counterpart, all it - does now is set whether or not typeahead checking is performed. + This routine does what the PDcurses typeahead routine used to do. But + to make that routine consistent with its System V counterpart, all it + does now is set whether or not typeahead checking is performed. X/Open Return Value: - The PDC_breakout() routine returns TRUE if keyboard input is pending - otherwise FALSE is returned. + The PDC_breakout() routine returns TRUE if keyboard input is pending + otherwise FALSE is returned. Portability: - PDCurses bool PD_breakout( void ); + PDCurses bool PD_breakout( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -bool PDC_breakout( void ) -#else -bool PDC_breakout() -#endif +bool PDC_breakout( void ) /***********************************************************************/ { -extern int c_pindex; /* putter index */ -extern int c_gindex; /* getter index */ -extern int c_ungind; /* wungetch() push index */ -#ifdef TC -# pragma argsused +extern int c_pindex; /* putter index */ +extern int c_gindex; /* getter index */ +extern int c_ungind; /* wungetch() push index */ +#ifdef TC +# pragma argsused #endif - #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_breakout() - called\n"); + if (trace_on) PDC_debug("PDC_breakout() - called\n"); #endif + if (c_ungind) + return (TRUE); /* ungotten char */ + if (c_pindex > c_gindex) + return (TRUE); /* buffered char */ + if (SP->raw_inp) + return((bool)PDC_check_bios_key());/* raw mode test */ - if (c_ungind) - return (TRUE); /* ungotten char */ - if (c_pindex > c_gindex) - return (TRUE); /* buffered char */ - if (SP->raw_inp) - return((bool)PDC_check_bios_key());/* raw mode test */ - - return((bool)PDC_check_bios_key()); /* normal mode test */ + return((bool)PDC_check_bios_key()); /* normal mode test */ } /*man-start********************************************************************* - PDC_get_input_fd() - Get file descriptor used for PDCurses input + PDC_get_input_fd() - Get file descriptor used for PDCurses input PDCurses Description: - This is a private PDCurses routine. + This is a private PDCurses routine. - This routine will return the file descriptor that PDCurses reads - its input from. It can be used for select(). + This routine will return the file descriptor that PDCurses reads + its input from. It can be used for select(). PDCurses Return Value: - Returns a file descriptor. + Returns a file descriptor. PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses int PDC_get_input_fd( void ); + PDCurses int PDC_get_input_fd( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO int PDC_get_input_fd(void) -#else -int PDC_get_input_fd() -#endif /***********************************************************************/ { - #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_input_fd() - called\n"); + if (trace_on) PDC_debug("PDC_get_input_fd() - called\n"); #endif - - return fileno(stdin); + return fileno(stdin); } +#ifndef EMXVIDEO +/***********************************************************************/ +int PDC_get_keyboard_info( KBDINFO *kbdinfo ) +/***********************************************************************/ +{ + KBDINFO akbdinfo; +#ifdef PDCDEBUG + if (trace_on) PDC_debug("PDC_get_keyboard_info() - called\n"); +#endif + akbdinfo.cb = sizeof(akbdinfo); + KbdGetStatus( &akbdinfo, 0 ); + *kbdinfo = akbdinfo; +#ifdef PDCDEBUG + if (trace_on) PDC_debug("PDC_get_keyboard_info(). cb: %x, fsMask: %x, chTurnAround: %x, fsInterim: %x, fsState: %x\n", + kbdinfo->cb, + kbdinfo->fsMask, + kbdinfo->chTurnAround, + kbdinfo->fsInterim, + kbdinfo->fsState); +#endif + return OK; +} + +/***********************************************************************/ +int PDC_set_keyboard_binary( void ) +/***********************************************************************/ +{ + KBDINFO kbdinfo; +#ifdef PDCDEBUG + if (trace_on) PDC_debug("PDC_set_keyboard_binary() - called\n"); +#endif + kbdinfo.cb = sizeof(kbdinfo); + KbdGetStatus( &kbdinfo, 0); +#ifdef PDCDEBUG + if (trace_on) PDC_debug("PDC_set_keyboard_binary() - before. cb: %x, fsMask: %x, chTurnAround: %x, fsInterim: %x, fsState: %x\n", + kbdinfo.cb, + kbdinfo.fsMask, + kbdinfo.chTurnAround, + kbdinfo.fsInterim, + kbdinfo.fsState); +#endif + kbdinfo.fsMask = (kbdinfo.fsMask & ~KEYBOARD_ASCII_MODE) | KEYBOARD_BINARY_MODE; + KbdSetStatus( &kbdinfo, 0 ); +#ifdef PDCDEBUG + if (trace_on) PDC_debug("PDC_set_keyboard_binary() - after. cb: %x, fsMask: %x, chTurnAround: %x, fsInterim: %x, fsState: %x\n", + kbdinfo.cb, + kbdinfo.fsMask, + kbdinfo.chTurnAround, + kbdinfo.fsInterim, + kbdinfo.fsState); +#endif + return OK; +} + +/***********************************************************************/ +int PDC_set_keyboard_default( void ) +/***********************************************************************/ +{ +#ifdef PDCDEBUG + if (trace_on) PDC_debug("PDC_set_keyboard_default() - called\n"); +#endif +#ifdef PDCDEBUG + if (trace_on) PDC_debug("PDC_set_keyboard_default(). cb: %x, fsMask: %x, chTurnAround: %x, fsInterim: %x, fsState: %x\n", + SP->kbdinfo.cb, + SP->kbdinfo.fsMask, + SP->kbdinfo.chTurnAround, + SP->kbdinfo.fsInterim, + SP->kbdinfo.fsState); +#endif + KbdSetStatus( &SP->kbdinfo, 0 ); + return OK; +} +#endif + /*man-start********************************************************************* - PDC_check_bios_key() - Check BIOS key data area for input + PDC_check_bios_key() - Check BIOS key data area for input PDCurses Description: - This is a private PDCurses routine. + This is a private PDCurses routine. - This routine will check the BIOS for any indication that - keystrokes are pending. + This routine will check the BIOS for any indication that + keystrokes are pending. PDCurses Return Value: - Returns 1 if a keyboard character is available, 0 otherwise. + Returns 1 if a keyboard character is available, 0 otherwise. PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses bool PDC_check_bios_key( void ); + PDCurses bool PDC_check_bios_key( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO bool PDC_check_bios_key(void) -#else -bool PDC_check_bios_key() -#endif /***********************************************************************/ { #if !defined(MSC) && !defined(EMXVIDEO) - KBDKEYINFO keyInfo={0}; + KBDKEYINFO keyInfo={0}; #endif - #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_check_bios_key() - called\n"); + if (trace_on) PDC_debug("PDC_check_bios_key() - called\n"); #endif #ifdef EMXVIDEO - if (SP->tahead == -1) /* Nothing typed yet */ - { /* See if there's anything */ - SP->tahead = _read_kbd (0, 0, 0); - if (SP->tahead == 0) /* Read additional */ - SP->tahead = (_read_kbd (0, 1, 0) << 8); - } - return(SP->tahead != -1) ? 1 : 0; + if (SP->tahead == -1) /* Nothing typed yet */ + { /* See if there's anything */ + SP->tahead = _read_kbd (0, 0, 0); + if (SP->tahead == 0) /* Read additional */ + SP->tahead = (_read_kbd (0, 1, 0) << 8); + } + return(SP->tahead != -1) ? 1 : 0; #else # if !defined(MSC) -/* KbdCharIn(&keyInfo, IO_NOWAIT, 0);*/ /* get a character */ - KbdPeek(&keyInfo, 0); /* peek at keyboard */ - return (keyInfo.fbStatus != 0); + KbdPeek(&keyInfo, 0); /* peek at keyboard */ + return (keyInfo.fbStatus != 0); # else return(kbhit()); # endif @@ -284,471 +339,439 @@ bool PDC_check_bios_key() /*man-start********************************************************************* - PDC_get_bios_key() - Returns the next key available from the BIOS. + PDC_get_bios_key() - Returns the next key available from the BIOS. PDCurses Description: - This is a private PDCurses routine. + This is a private PDCurses routine. - Returns the next key code struck at the keyboard. If the low 8 - bits are 0, the upper bits contain the extended character - code. If bit 0-7 are non-zero, the upper bits = 0. + Returns the next key code struck at the keyboard. If the low 8 + bits are 0, the upper bits contain the extended character + code. If bit 0-7 are non-zero, the upper bits = 0. PDCurses Return Value: - This function returns OK on success and ERR on error. + This function returns OK on success and ERR on error. PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses int PDC_get_bios_key( void ); + PDCurses int PDC_get_bios_key( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_get_bios_key(void) -#else -int PDC_get_bios_key() -#endif +int PDC_get_bios_key(void) /***********************************************************************/ { - int ascii=0,scan=0; + int ascii=0,scan=0,key; #ifndef EMXVIDEO - KBDKEYINFO keyInfo={0}; + KBDKEYINFO keyInfo={0}; #endif - #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_bios_key() - called\n"); + if (trace_on) PDC_debug("PDC_get_bios_key() - called\n"); #endif - #ifdef EMXVIDEO - if (SP->tahead == -1) - { - SP->tahead = _read_kbd (0, 1, 0); - if (SP->tahead == 0) /* Read additional */ - SP->tahead = (_read_kbd (0, 1, 0) << 8); - } - ascii = SP->tahead & 0xff; - scan = SP->tahead >> 8; - pdc_key_modifiers = 0L; - SP->tahead = -1; + if (SP->tahead == -1) + { + SP->tahead = _read_kbd (0, 1, 0); + if (SP->tahead == 0) /* Read additional */ + SP->tahead = (_read_kbd (0, 1, 0) << 8); + } + ascii = SP->tahead & 0xff; + scan = SP->tahead >> 8; + pdc_key_modifiers = 0L; + SP->tahead = -1; #else - KbdCharIn(&keyInfo, IO_WAIT, 0); /* get a character */ - ascii = keyInfo.chChar; - scan = keyInfo.chScan; - pdc_key_modifiers = 0L; - if (SP->save_key_modifiers) - { - if (keyInfo.fsState & KBDSTF_ALT) - pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT; - if (keyInfo.fsState & KBDSTF_CONTROL) - pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL; - if (keyInfo.fsState & KBDSTF_NUMLOCK_ON) - pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK; - if (keyInfo.fsState & KBDSTF_LEFTSHIFT - || keyInfo.fsState & KBDSTF_RIGHTSHIFT) - pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT; - } +/* PDC_get_keyboard_info( &SP->kbdinfo ); + PDC_set_keyboard_binary(); */ + KbdCharIn(&keyInfo, IO_WAIT, 0); /* get a character */ +/* PDC_set_keyboard_default(); */ + ascii = keyInfo.chChar; + scan = keyInfo.chScan; + pdc_key_modifiers = 0L; + if (SP->save_key_modifiers) + { + if (keyInfo.fsState & KBDSTF_ALT) + pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT; + if (keyInfo.fsState & KBDSTF_CONTROL) + pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL; + if (keyInfo.fsState & KBDSTF_NUMLOCK_ON) + pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK; + if (keyInfo.fsState & KBDSTF_LEFTSHIFT + || keyInfo.fsState & KBDSTF_RIGHTSHIFT) + pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT; + } #endif - - if (scan == 0x1c && ascii == 0x0a) /* ^Enter */ - return ((int) (0xfc00)); - if ((scan == 0x03 && ascii == 0x00) /* ^@ - Null */ - || (scan == 0xe0 && ascii == 0x0d) /* PadEnter */ - || (scan == 0xe0 && ascii == 0x0a)) /* ^PadEnter */ - return ((int) (ascii << 8)); - if ((scan == 0x37 && ascii == 0x2a) /* Star */ - || (scan == 0x4a && ascii == 0x2d) /* Minus */ - || (scan == 0x4e && ascii == 0x2b) /* Plus */ - || (scan == 0xe0 && ascii == 0x2f)) /* Slash */ - return ((int) ((ascii & 0x0f) | 0xf0) << 8); - if (ascii == 0xe0 && scan == 0x47 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Home */ - return ((int) (0xb0 << 8)); - if (ascii == 0xe0 && scan == 0x48 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Up */ - return ((int) (0xb1 << 8)); - if (ascii == 0xe0 && scan == 0x49 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift PgUp */ - return ((int) (0xb2 << 8)); - if (ascii == 0xe0 && scan == 0x4b && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Left */ - return ((int) (0xb3 << 8)); - if (ascii == 0xe0 && scan == 0x4d && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Right */ - return ((int) (0xb4 << 8)); - if (ascii == 0xe0 && scan == 0x4f && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift End */ - return ((int) (0xb5 << 8)); - if (ascii == 0xe0 && scan == 0x50 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Down */ - return ((int) (0xb6 << 8)); - if (ascii == 0xe0 && scan == 0x51 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift PgDn */ - return ((int) (0xb7 << 8)); - if (ascii == 0xe0 && scan == 0x52 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Ins */ - return ((int) (0xb8 << 8)); - if (ascii == 0xe0 && scan == 0x53 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Del */ - return ((int) (0xb9 << 8)); - if (ascii == 0x00 || ascii == 0xe0) - return ((int) (scan << 8)); - return ((int) (ascii)); + if (scan == 0x1c && ascii == 0x0a) /* ^Enter */ + key = ((int) (0xfc00)); + else if ((scan == 0x03 && ascii == 0x00) /* ^@ - Null */ + || (scan == 0xe0 && ascii == 0x0d) /* PadEnter */ + || (scan == 0xe0 && ascii == 0x0a)) /* ^PadEnter */ + key = ((int) (ascii << 8)); + else if ((scan == 0x37 && ascii == 0x2a) /* Star */ + || (scan == 0x4a && ascii == 0x2d) /* Minus */ + || (scan == 0x4e && ascii == 0x2b) /* Plus */ + || (scan == 0xe0 && ascii == 0x2f)) /* Slash */ + key = ((int) ((ascii & 0x0f) | 0xf0) << 8); + else if (ascii == 0xe0 && scan == 0x47 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Home */ + key = ((int) (0xb0 << 8)); + else if (ascii == 0xe0 && scan == 0x48 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Up */ + key = ((int) (0xb1 << 8)); + else if (ascii == 0xe0 && scan == 0x49 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift PgUp */ + key = ((int) (0xb2 << 8)); + else if (ascii == 0xe0 && scan == 0x4b && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Left */ + key = ((int) (0xb3 << 8)); + else if (ascii == 0xe0 && scan == 0x4d && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Right */ + key = ((int) (0xb4 << 8)); + else if (ascii == 0xe0 && scan == 0x4f && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift End */ + key = ((int) (0xb5 << 8)); + else if (ascii == 0xe0 && scan == 0x50 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Down */ + key = ((int) (0xb6 << 8)); + else if (ascii == 0xe0 && scan == 0x51 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift PgDn */ + key = ((int) (0xb7 << 8)); + else if (ascii == 0xe0 && scan == 0x52 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Ins */ + key = ((int) (0xb8 << 8)); + else if (ascii == 0xe0 && scan == 0x53 && pdc_key_modifiers & PDC_KEY_MODIFIER_SHIFT) /* Shift Del */ + key = ((int) (0xb9 << 8)); + else if (ascii == 0x00 || ascii == 0xe0) + key = ((int) (scan << 8)); + else + key = ((int) (ascii)); +#ifdef PDCDEBUG + if (trace_on) PDC_debug("PDC_get_bios_key() - returned: %d(0x%x), ascii: %d(0x%x) scan: %d(0x%x)\n", key, key, ascii, ascii, scan, scan); +#endif + return key; } /*man-start********************************************************************* - PDC_get_ctrl_break() - return OS control break state + PDC_get_ctrl_break() - return OS control break state PDCurses Description: - This is a private PDCurses routine. + This is a private PDCurses routine. - Returns the current OS Control Break Check state. + Returns the current OS Control Break Check state. PDCurses Return Value: - DOS: - This function returns TRUE on if the Control Break - Check is enabled otherwise FALSE is returned. + DOS: + This function returns TRUE on if the Control Break + Check is enabled otherwise FALSE is returned. - FLEXOS: - This function returns TRUE on if the Keyboard Mode - allows a break to bre reported otherwise FALSE is returned. + FLEXOS: + This function returns TRUE on if the Keyboard Mode + allows a break to bre reported otherwise FALSE is returned. PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses bool PDC_get_ctrl_break( void ); + PDCurses bool PDC_get_ctrl_break( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -bool PDC_get_ctrl_break(void) -#else -bool PDC_get_ctrl_break() -#endif +bool PDC_get_ctrl_break(void) /***********************************************************************/ { #if defined(CURSES__32BIT__) || defined(CSET2) || defined(TC) # if defined(TC) - void __cdecl (*oldAction) (int); + void __cdecl (*oldAction) (int); # else - void (*oldAction) (int); + void (*oldAction) (int); # endif #endif #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_ctrl_break() - called\n"); + if (trace_on) PDC_debug("PDC_get_ctrl_break() - called\n"); #endif #if defined(CURSES__32BIT__) || defined(CSET2) || defined(TC) - oldAction = signal (SIGINT, SIG_DFL); - if (oldAction == SIG_ERR) return FALSE; - else signal (SIGINT, oldAction); - return (oldAction != SIG_IGN); + oldAction = signal (SIGINT, SIG_DFL); + if (oldAction == SIG_ERR) return FALSE; + else signal (SIGINT, oldAction); + return (oldAction != SIG_IGN); #else - PFNSIGHANDLER oldHandler, oldHandler1; - USHORT oldAction, oldAction1; - /* get the current state, and set to ignore */ - DosSetSigHandler((PFNSIGHANDLER) NULL, &oldHandler, &oldAction, - SIGA_IGNORE, SIG_CTRLBREAK); - /* restore the previous state */ - DosSetSigHandler(oldHandler, &oldHandler1, &oldAction1, - oldAction, SIG_CTRLBREAK); - return(oldAction != SIGA_IGNORE); + PFNSIGHANDLER oldHandler, oldHandler1; + USHORT oldAction, oldAction1; + /* get the current state, and set to ignore */ + DosSetSigHandler((PFNSIGHANDLER) NULL, &oldHandler, &oldAction, + SIGA_IGNORE, SIG_CTRLBREAK); + /* restore the previous state */ + DosSetSigHandler(oldHandler, &oldHandler1, &oldAction1, + oldAction, SIG_CTRLBREAK); + return(oldAction != SIGA_IGNORE); #endif } /*man-start********************************************************************* - PDC_rawgetch() - Returns the next uninterpreted character (if available). + PDC_rawgetch() - Returns the next uninterpreted character (if available). PDCurses Description: - Gets a character without any interpretation at all and returns - it. If keypad mode is active for the designated window, - function key translation will be performed. Otherwise, - function keys are ignored. If nodelay mode is active in the - window, then PDC_rawgetch() returns -1 if no character is - available. + Gets a character without any interpretation at all and returns + it. If keypad mode is active for the designated window, + function key translation will be performed. Otherwise, + function keys are ignored. If nodelay mode is active in the + window, then PDC_rawgetch() returns -1 if no character is + available. - WARNING: It is unknown whether the FUNCTION key translation - is performed at this level. --Frotz 911130 BUG + WARNING: It is unknown whether the FUNCTION key translation + is performed at this level. --Frotz 911130 BUG PDCurses Return Value: - This function returns OK on success and ERR on error. + This function returns OK on success and ERR on error. PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses int PDC_rawgetch( void ); + PDCurses int PDC_rawgetch( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_rawgetch(void) -#else -int PDC_rawgetch() -#endif +int PDC_rawgetch(void) /***********************************************************************/ { -extern WINDOW* _getch_win_; -/* extern WINDOW* w;*/ /* w defined in wgetch() as static - _getch_win_ */ +extern WINDOW* _getch_win_; +/* extern WINDOW* w;*/ /* w defined in wgetch() as static - _getch_win_ */ /* is the same window - all references to w changed*/ /* to _getch_win_ - marked with @@ */ - int c=0; - int oldc=0; - + int c=0; + int oldc=0; #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_rawgetch() - called\n"); + if (trace_on) PDC_debug("PDC_rawgetch() - called\n"); #endif + if (_getch_win_ == (WINDOW *)NULL) /* @@ */ + return( -1 ); - if (_getch_win_ == (WINDOW *)NULL) /* @@ */ - return( -1 ); + if (_getch_win_->_nodelay && !PDC_breakout()) /* @@ */ + return( -1 ); - if (_getch_win_->_nodelay && !PDC_breakout()) /* @@ */ - return( -1 ); - - while (1) /* loop to get valid char */ - { - c = PDC_get_bios_key(); - oldc = c; - /* - * Return the key if it is not a special key. - */ - if ((c = PDC_validchar(c)) >= 0) - { /* get & check next char */ - return( c ); - } - if (_getch_win_->_use_keypad) - return( oldc ); - } + while (1) /* loop to get valid char */ + { + c = PDC_get_bios_key(); + oldc = c; + /* + * Return the key if it is not a special key. + */ + if ((c = PDC_validchar(c)) >= 0) + { /* get & check next char */ + return( c ); + } + if (_getch_win_->_use_keypad) + return( oldc ); + } } /*man-start********************************************************************* - PDC_set_ctrl_break() - Enables/Disables the host OS BREAK key check. + PDC_set_ctrl_break() - Enables/Disables the host OS BREAK key check. PDCurses Description: - This is a private PDCurses routine. + This is a private PDCurses routine. - Enables/Disables the host OS BREAK key check. If the supplied setting - is TRUE, this enables CTRL/C and CTRL/BREAK to abort the process. - If FALSE, CTRL/C and CTRL/BREAK are ignored. + Enables/Disables the host OS BREAK key check. If the supplied setting + is TRUE, this enables CTRL/C and CTRL/BREAK to abort the process. + If FALSE, CTRL/C and CTRL/BREAK are ignored. PDCurses Return Value: - This function returns OK on success and ERR on error. + This function returns OK on success and ERR on error. PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses int PDC_set_ctrl_break( bool setting ); + PDCurses int PDC_set_ctrl_break( bool setting ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_set_ctrl_break(bool setting) -#else -int PDC_set_ctrl_break(setting) -bool setting; -#endif +int PDC_set_ctrl_break(bool setting) /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_set_ctrl_break() - called\n"); + if (trace_on) PDC_debug("PDC_set_ctrl_break() - called. Setting: %d\n",setting); #endif - #if defined (CURSES__32BIT__) || defined (CSET2) || defined(TC) - signal (SIGINT, (setting?SIG_DFL:SIG_IGN)); - signal (SIGBREAK, (setting?SIG_DFL:SIG_IGN)); - return( OK ); + signal (SIGINT, (setting?SIG_DFL:SIG_IGN)); + signal (SIGBREAK, (setting?SIG_DFL:SIG_IGN)); + return( OK ); #else - PFNSIGHANDLER oldHandler; - USHORT oldAction, Action; + PFNSIGHANDLER oldHandler; + USHORT oldAction, Action; - /* turn off control C checking */ - if (setting) - Action = SIGA_KILL; - else - Action = SIGA_IGNORE; - DosSetSigHandler((PFNSIGHANDLER) NULL, &oldHandler, &oldAction, - Action, SIG_CTRLBREAK); - DosSetSigHandler((PFNSIGHANDLER) NULL, &oldHandler, &oldAction, - Action, SIG_CTRLC); - return( OK ); + /* turn off control C checking */ + if (setting) + Action = SIGA_KILL; + else + Action = SIGA_IGNORE; + DosSetSigHandler((PFNSIGHANDLER) NULL, &oldHandler, &oldAction, + Action, SIG_CTRLBREAK); + DosSetSigHandler((PFNSIGHANDLER) NULL, &oldHandler, &oldAction, + Action, SIG_CTRLC); + return( OK ); #endif } /*man-start********************************************************************* - PDC_sysgetch() - Return a character using default system routines. + PDC_sysgetch() - Return a character using default system routines. PDCurses Description: - This is a private PDCurses function. + This is a private PDCurses function. - Gets a character without normal ^S, ^Q, ^P and ^C interpretation - and returns it. If keypad mode is active for the designated - window, function key translation will be performed. Otherwise, - function keys are ignored. If nodelay mode is active in the - window, then sysgetch() returns -1 if no character is - available. + Gets a character without normal ^S, ^Q, ^P and ^C interpretation + and returns it. If keypad mode is active for the designated + window, function key translation will be performed. Otherwise, + function keys are ignored. If nodelay mode is active in the + window, then sysgetch() returns -1 if no character is + available. PDCurses Return Value: - This function returns OK upon success otherwise ERR is returned. + This function returns OK upon success otherwise ERR is returned. PDCurses Errors: - No errors are defined for this routine. + No errors are defined for this routine. Portability: - PDCurses int PDC_sysgetch( void ); + PDCurses int PDC_sysgetch( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_sysgetch(void) -#else -int PDC_sysgetch() -#endif +int PDC_sysgetch(void) /***********************************************************************/ { -extern WINDOW* _getch_win_; -/* extern WINDOW* w;*/ /* w defined in wgetch() as static - _getch_win_ */ +extern WINDOW* _getch_win_; +/* extern WINDOW* w;*/ /* w defined in wgetch() as static - _getch_win_ */ /* is the same window - all references to w changed*/ /* to _getch_win_ - marked with @@ */ - int c=0; - + int c=0; #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_sysgetch() - called\n"); + if (trace_on) PDC_debug("PDC_sysgetch() - called\n"); #endif + if (_getch_win_ == (WINDOW *)NULL) /* @@ */ + return (-1); - if (_getch_win_ == (WINDOW *)NULL) /* @@ */ - return (-1); + if (_getch_win_->_nodelay && !PDC_breakout()) + return (-1); - if (_getch_win_->_nodelay && !PDC_breakout()) - return (-1); - - while (1) - { - c = PDC_get_bios_key(); - /* - * Return the key if it is not a special key. - */ - if ((unsigned int)c < 256) - return(c); - if ((c = PDC_validchar(c)) >= 0) - { - return (c); /* get & check next char */ - } - } + while (1) + { + c = PDC_get_bios_key(); + /* + * Return the key if it is not a special key. + */ + if ((unsigned int)c < 256) + return(c); + if ((c = PDC_validchar(c)) >= 0) + { + return (c); /* get & check next char */ + } + } } /*man-start********************************************************************* - PDC_validchar() - validate/translate passed character + PDC_validchar() - validate/translate passed character PDCurses Description: - This is a private PDCurses function. + This is a private PDCurses function. - Checks that 'c' is a valid character, and if so returns it, - with function key translation applied if 'w' has keypad mode - set. If char is invalid, returns -1. + Checks that 'c' is a valid character, and if so returns it, + with function key translation applied if 'w' has keypad mode + set. If char is invalid, returns -1. PDCurses Return Value: - This function returns -1 if the passed character is invalid, or - the WINDOW* 'w' is NULL, or 'w's keypad is not active. + This function returns -1 if the passed character is invalid, or + the WINDOW* 'w' is NULL, or 'w's keypad is not active. - This function returns 0 under Flexos if the passed character - is 0x0300. (-:Forget why. --Frotz 911130:-) + This function returns 0 under Flexos if the passed character + is 0x0300. (-:Forget why. --Frotz 911130:-) - Otherwise, this function returns the PDCurses equivalent of the - passed character. See the function key and key macros in - + Otherwise, this function returns the PDCurses equivalent of the + passed character. See the function key and key macros in + PDCurses Errors: - There are no errors defined for this routine. + There are no errors defined for this routine. Portability: - PDCurses int PDC_validchar( int c ); + PDCurses int PDC_validchar( int c ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_validchar(int c) -#else -int PDC_validchar(c) -int c; -#endif +int PDC_validchar(int c) /***********************************************************************/ { -extern WINDOW* _getch_win_; -/* extern WINDOW* w;*/ /* w defined in wgetch() as static - _getch_win_ */ +extern WINDOW* _getch_win_; +/* extern WINDOW* w;*/ /* w defined in wgetch() as static - _getch_win_ */ /* is the same window - all references to w changed*/ /* to _getch_win_ - marked with @@ */ - int *scanp=NULL; - + int *scanp=NULL; #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_validchar() - called\n"); + if (trace_on) PDC_debug("PDC_validchar() - called. c: %d\n",c); #endif + if (_getch_win_ == (WINDOW *)NULL) + return (-1); /* bad window pointer */ - if (_getch_win_ == (WINDOW *)NULL) - return (-1); /* bad window pointer */ + if ((unsigned int)c < 256) return (c); /* normal character */ + if (!(_getch_win_->_use_keypad)) return (-1); /* skip if keys if !keypad mode */ - if ((unsigned int)c < 256) return (c); /* normal character */ - if (!(_getch_win_->_use_keypad)) return (-1); /* skip if keys if !keypad mode */ + /* + * Under DOS, extended keys are in the upper byte. Shift down for a + * comparison. + */ + c = (c >> 8) & 0xFF; - /* - * Under DOS, extended keys are in the upper byte. Shift down for a - * comparison. - */ - c = (c >> 8) & 0xFF; - - scanp = kptab; - while (*scanp > 0) /* search for value */ - { /* (stops on table entry 0x100) */ - if (*scanp++ == c) - { - return (*scanp); /* found, return it */ - } - scanp++; - } - return( -1 ); /* not found, invalid */ + scanp = kptab; + while (*scanp > 0) /* search for value */ + { /* (stops on table entry 0x100) */ + if (*scanp++ == c) + { + return (*scanp); /* found, return it */ + } + scanp++; + } + return( -1 ); /* not found, invalid */ } /*man-start********************************************************************* - PDC_get_key_modifiers() - Returns the keyboard modifier(s) at time of last getch() + PDC_get_key_modifiers() - Returns the keyboard modifier(s) at time of last getch() PDCurses Description: - This is a private PDCurses routine. + This is a private PDCurses routine. - 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. + 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. PDCurses Return Value: - This function returns the modifiers. + This function returns the modifiers. PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses int PDC_get_key_modifiers( void ); + PDCurses int PDC_get_key_modifiers( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -unsigned long PDC_get_key_modifiers(void) -#else -unsigned long PDC_get_key_modifiers() -#endif +unsigned long PDC_get_key_modifiers(void) /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_get_key_modifiers() - called\n"); + if (trace_on) PDC_debug("PDC_get_key_modifiers() - called\n"); #endif - return(pdc_key_modifiers); + return(pdc_key_modifiers); } diff --git a/os2/pdcscrn.c b/os2/pdcscrn.c index 339bd0b1..31fab36b 100644 --- a/os2/pdcscrn.c +++ b/os2/pdcscrn.c @@ -17,303 +17,328 @@ * See the file maintain.er for details of the current maintainer. *************************************************************************** */ -#define CURSES_LIBRARY 1 +#define CURSES_LIBRARY 1 #ifdef HAVE_CONFIG_H # include #endif +#define INCL_DOSMISC #include #ifdef PDCDEBUG -char *rcsid_PDCscrn = "$Id: pdcscrn.c,v 1.2 2001/01/10 08:29:40 mark Exp $"; +char *rcsid_PDCscrn = "$Id: pdcscrn.c,v 1.3 2002/01/12 04:04:18 mark Exp $"; #endif #ifdef EMXVIDEO - static unsigned char *saved_screen = NULL; - static int saved_lines = 0; - static int saved_cols = 0; + static unsigned char *saved_screen = NULL; + static int saved_lines = 0; + static int saved_cols = 0; #else - static PCH saved_screen = NULL; - static USHORT saved_lines = 0; - static USHORT saved_cols = 0; + static PCH saved_screen = NULL; + static USHORT saved_lines = 0; + static USHORT saved_cols = 0; #endif /*man-start********************************************************************* - PDC_scr_close() - Internal low-level binding to close the physical screen + PDC_scr_close() - Internal low-level binding to close the physical screen PDCurses Description: - This function provides a low-level binding for the Flexos - platform which must close the screen before writing to it. - This is a nop for the DOS platform. + This function provides a low-level binding for the Flexos + platform which must close the screen before writing to it. + This is a nop for the DOS platform. - This function is provided in order to reset the FlexOS 16 bit - character set for input rather than the limited input - character set associated with the VT52. + This function is provided in order to reset the FlexOS 16 bit + character set for input rather than the limited input + character set associated with the VT52. PDCurses Return Value: - This function returns OK on success, otherwise an ERR is returned. + This function returns OK on success, otherwise an ERR is returned. PDCurses Errors: - The DOS platform will never fail. The Flexos platform may fail - depending on the ability to close the current virtual console in - 8 (as opposed to 16) bit mode. + The DOS platform will never fail. The Flexos platform may fail + depending on the ability to close the current virtual console in + 8 (as opposed to 16) bit mode. Portability: - PDCurses int PDC_scr_close( void ); + PDCurses int PDC_scr_close( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_scr_close(void) -#else -int PDC_scr_close() -#endif +int PDC_scr_close(void) /***********************************************************************/ { + char *ptr; #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_scr_close() - called\n"); + if (trace_on) PDC_debug("PDC_scr_close() - called\n"); #endif - if (getenv("PDC_RESTORE_SCREEN") != NULL) - { - if (saved_screen == NULL) - return( OK ); #ifdef EMXVIDEO - v_putline(saved_screen,0,0,saved_lines*saved_cols); + ptr = getenv("PDC_RESTORE_SCREEN"); #else - VioWrtCellStr(saved_screen,saved_lines*saved_cols*2,0,0,(HVIO)NULL); + if ( DosScanEnv( "PDC_RESTORE_SCREEN", (PSZ *)&ptr ) ) + ptr = NULL; #endif - free(saved_screen); - saved_screen = NULL; - } - return( OK ); + if (ptr != NULL) + { + if (saved_screen == NULL) + return( OK ); +#ifdef EMXVIDEO + v_putline(saved_screen,0,0,saved_lines*saved_cols); +#else + VioWrtCellStr(saved_screen,saved_lines*saved_cols*2,0,0,(HVIO)NULL); +#endif + free(saved_screen); + saved_screen = NULL; + } + return( OK ); } /*man-start********************************************************************* - PDC_scrn_modes_equal() - Decide if two screen modes are equal + PDC_scrn_modes_equal() - Decide if two screen modes are equal PDCurses Description: - Mainly required for OS/2. It decides if two screen modes + Mainly required for OS/2. It decides if two screen modes (VIOMODEINFO structure) are equal. Under DOS it just compares two integers PDCurses Return Value: - This function returns TRUE if equal else FALSe. + This function returns TRUE if equal else FALSe. PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses int PDC_scrn_modes_equal( int mode1, int mode2 ); - OS2 PDCurses int PDC_scrn_modes_equal( VIOMODEINFO mode1, VIOMODEINFO mode2 ); + PDCurses int PDC_scrn_modes_equal( int mode1, int mode2 ); + OS2 PDCurses int PDC_scrn_modes_equal( VIOMODEINFO mode1, VIOMODEINFO mode2 ); **man-end**********************************************************************/ /***********************************************************************/ #if !defined( EMXVIDEO ) -bool PDC_scrn_modes_equal(VIOMODEINFO mode1, VIOMODEINFO mode2) +bool PDC_scrn_modes_equal(VIOMODEINFO mode1, VIOMODEINFO mode2) #else -# ifdef HAVE_PROTO -bool PDC_scrn_modes_equal(int mode1, int mode2) -# else -bool PDC_scrn_modes_equal(mode1,mode2) -int mode1; -int mode2; -# endif +bool PDC_scrn_modes_equal(int mode1, int mode2) #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_scrn_modes_equal() - called\n"); + if (trace_on) PDC_debug("PDC_scrn_modes_equal() - called\n"); #endif #if !defined( EMXVIDEO ) - return ((mode1.cb == mode2.cb) && (mode1.fbType == mode2.fbType) - && (mode1.color == mode2.color) && (mode1.col == mode2.col) - && (mode1.row == mode2.row) && (mode1.hres == mode2.vres) - && (mode1.vres == mode2.vres) ); + return ((mode1.cb == mode2.cb) && (mode1.fbType == mode2.fbType) + && (mode1.color == mode2.color) && (mode1.col == mode2.col) + && (mode1.row == mode2.row) && (mode1.hres == mode2.vres) + && (mode1.vres == mode2.vres) ); #else - return (mode1 == mode2); + return (mode1 == mode2); #endif } /*man-start********************************************************************* - PDC_scr_open() - Internal low-level binding to open the physical screen + PDC_scr_open() - Internal low-level binding to open the physical screen PDCurses Description: - This function provides a low-level binding for the Flexos - platform which must open the screen before writing to it. + This function provides a low-level binding for the Flexos + platform which must open the screen before writing to it. - This function is provided in order to access the FlexOS 16 bit - character set for input rather than the limited input - character set associated with the VT52. + This function is provided in order to access the FlexOS 16 bit + character set for input rather than the limited input + character set associated with the VT52. PDCurses Return Value: - This function returns OK on success, otherwise an ERR is returned. + This function returns OK on success, otherwise an ERR is returned. PDCurses Errors: - The DOS platform will never fail. The Flexos platform may fail - depending on the ability to open the current virtual console in - 8 (as opposed to 16) bit mode. + The DOS platform will never fail. The Flexos platform may fail + depending on the ability to open the current virtual console in + 8 (as opposed to 16) bit mode. Portability: - PDCurses int PDC_scr_open( SCREEN* internal, bool echo ); + PDCurses int PDC_scr_open( SCREEN* internal, bool echo ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_scr_open(SCREEN *internal, bool echo) -#else -int PDC_scr_open(internal,echo) -SCREEN *internal; -bool echo; -#endif +int PDC_scr_open(SCREEN *internal, bool echo) /***********************************************************************/ { + char *ptr; #if !defined( EMXVIDEO ) - extern VIOCONFIGINFO configInfo; - extern VIOMODEINFO modeInfo; - USHORT totchars=0; + USHORT totchars=0; #endif - #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_scr_open() - called\n"); + if (trace_on) PDC_debug("PDC_scr_open() - called. internal: %x, echo: %d\n", internal, echo); #endif - - internal->orig_attr = 0; - internal->orig_emulation = 0; - PDC_get_cursor_pos(&internal->cursrow, &internal->curscol); - internal->direct_video = TRUE; /* Assume that we can */ - internal->autocr = TRUE; /* lf -> crlf by default */ - internal->raw_out = FALSE; /* tty I/O modes */ - internal->raw_inp = FALSE; /* tty I/O modes */ - internal->cbreak = TRUE; - internal->save_key_modifiers = FALSE; - internal->return_key_modifiers = FALSE; - internal->echo = echo; + internal->orig_attr = 0; + internal->orig_emulation = 0; + PDC_get_cursor_pos(&internal->cursrow, &internal->curscol); + internal->direct_video = TRUE; /* Assume that we can */ + internal->autocr = TRUE; /* lf -> crlf by default */ + internal->raw_out = FALSE; /* tty I/O modes */ + internal->raw_inp = FALSE; /* tty I/O modes */ + internal->cbreak = TRUE; + internal->save_key_modifiers = FALSE; + internal->return_key_modifiers = FALSE; + internal->echo = echo; /* under System V Curses, typeahead checking is enabled by default */ - internal->refrbrk = TRUE; /* allow premature end of refresh*/ - internal->video_page = 0; /* Current Video Page */ - internal->visible_cursor= TRUE; /* Assume that it is visible */ - internal->cursor = PDC_get_cursor_mode(); + internal->refrbrk = TRUE; /* allow premature end of refresh*/ + internal->video_page = 0; /* Current Video Page */ + internal->visible_cursor= TRUE; /* Assume that it is visible */ + internal->cursor = PDC_get_cursor_mode(); #if defined(EMXVIDEO) - internal->tahead = -1; + internal->tahead = -1; #endif #if !defined(EMXVIDEO) - (void)PDC_query_adapter_type(); - memcpy((char *)&internal->adapter,(char *)&configInfo,sizeof(VIOCONFIGINFO)); - (void)PDC_get_scrn_mode(); - memcpy((char *)&internal->scrnmode,(char *)&modeInfo,sizeof(VIOMODEINFO)); + (void)PDC_query_adapter_type( &internal->adapter ); + (void)PDC_get_scrn_mode( &internal->scrnmode ); + (void)PDC_get_keyboard_info( &internal->kbdinfo ); +# ifdef PDCDEBUG1 + if (trace_on) PDC_debug("PDC_scr_open() - after PDC_get_keyboard_info(). cb: %x, fsMask: %x, chTurnAround: %x, fsInterim: %x, fsState: %x\n", + SP->kbdinfo.cb, + SP->kbdinfo.fsMask, + SP->kbdinfo.chTurnAround, + SP->kbdinfo.fsInterim, + SP->kbdinfo.fsState); +# endif + /* + * Now set the keyboard into binary mode + */ + (void)PDC_set_keyboard_binary(); #else - internal->adapter = PDC_query_adapter_type(); + internal->adapter = PDC_query_adapter_type(); + if ( internal->adapter == _UNIX_MONO ) + internal->mono = TRUE; #endif - internal->orig_font = internal->font = PDC_get_font(); - internal->lines = PDC_get_rows(); - internal->cols = PDC_get_columns(); - internal->audible = TRUE; - internal->visibility = 1; - internal->orig_cursor = internal->cursor; - internal->orgcbr = PDC_get_ctrl_break(); - internal->blank = ' '; - internal->resized = FALSE; - internal->shell = FALSE; - internal->_trap_mbe = 0L; - internal->_map_mbe_to_key = 0L; - internal->linesrippedoff = 0; - internal->linesrippedoffontop = 0; - internal->delaytenths = 0; -/* - * This code for preserving the current screen... - */ - if (getenv("PDC_RESTORE_SCREEN") != NULL) - { - saved_lines = internal->lines; - saved_cols = internal->cols; + internal->orig_font = internal->font = PDC_get_font(); + internal->lines = PDC_get_rows(); + internal->cols = PDC_get_columns(); + internal->audible = TRUE; + internal->visibility = 1; + internal->orig_cursor = internal->cursor; + internal->orgcbr = PDC_get_ctrl_break(); + internal->blank = ' '; + internal->resized = FALSE; + internal->shell = FALSE; + internal->_trap_mbe = 0L; + internal->_map_mbe_to_key = 0L; + internal->linesrippedoff = 0; + internal->linesrippedoffontop = 0; + internal->delaytenths = 0; + internal->sizeable = TRUE; + /* + * This code for preserving the current screen... + */ #ifdef EMXVIDEO - if ((saved_screen = (unsigned char*)malloc(2*saved_lines*saved_cols*sizeof(unsigned char))) == NULL) - return(ERR); - v_getline(saved_screen,0,0,saved_lines*saved_cols); + ptr = getenv("PDC_RESTORE_SCREEN"); #else - if ((saved_screen = (PCH)malloc(2*saved_lines*saved_cols*sizeof(unsigned char))) == NULL) - return(ERR); - totchars = saved_lines*saved_cols*2; - VioReadCellStr((PCH)saved_screen,&totchars,0,0,(HVIO)NULL); + if ( DosScanEnv( "PDC_RESTORE_SCREEN", (PSZ *)&ptr ) ) + ptr = NULL; #endif - } + if (ptr != NULL) + { + saved_lines = internal->lines; + saved_cols = internal->cols; +#ifdef EMXVIDEO + if ((saved_screen = (unsigned char*)malloc(2*saved_lines*saved_cols*sizeof(unsigned char))) == NULL) + return(ERR); + v_getline(saved_screen,0,0,saved_lines*saved_cols); +#else + if ((saved_screen = (PCH)malloc(2*saved_lines*saved_cols*sizeof(unsigned char))) == NULL) + return(ERR); + totchars = saved_lines*saved_cols*2; + VioReadCellStr((PCH)saved_screen,&totchars,0,0,(HVIO)NULL); +#endif + } - if (getenv("PDC_PRESERVE_SCREEN") != NULL) - internal->_preserve = TRUE; - else - internal->_preserve = FALSE; +#ifdef EMXVIDEO + ptr = getenv("PDC_PRESERVE_SCREEN"); +#else + if ( DosScanEnv( "PDC_PRESERVE_SCREEN", (PSZ *)&ptr ) ) + ptr = NULL; +#endif + if (ptr != NULL) + internal->_preserve = TRUE; + else + internal->_preserve = FALSE; - return( OK ); + return( OK ); } /*man-start********************************************************************* - PDC_resize_screen() - Internal low-level function to resize screen + PDC_resize_screen() - Internal low-level function to resize screen PDCurses Description: - This function provides a means for the application program to - resize the overall dimensions of the screen. Under DOS and OS/2 - the application can tell PDCurses what size to make the screen; - under X11, resizing is done by the user and this function simply - adjusts its internal structures to fit the new size. + This function provides a means for the application program to + resize the overall dimensions of the screen. Under DOS and OS/2 + the application can tell PDCurses what size to make the screen; + under X11, resizing is done by the user and this function simply + adjusts its internal structures to fit the new size. PDCurses Return Value: - This function returns OK on success, otherwise an ERR is returned. + This function returns OK on success, otherwise an ERR is returned. PDCurses Errors: Portability: - PDCurses int PDC_resize_screen( int, int ); + PDCurses int PDC_resize_screen( int, int ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_resize_screen(int nlines, int ncols) -#else -int PDC_resize_screen(nlines, ncols) -int nlines,ncols; -#endif +int PDC_resize_screen(int nlines, int ncols) /***********************************************************************/ { - int rc=OK; #ifndef EMXVIDEO - VIOMODEINFO modeInfo={0}; - USHORT result=0; + VIOMODEINFO modeInfo={0}; + USHORT result=0; #endif #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_resize_screen() - called. Lines: %d Cols: %d\n",nlines,ncols); + if (trace_on) PDC_debug("PDC_resize_screen() - called. Lines: %d Cols: %d\n",nlines,ncols); #endif -#if 0 - if (nlines >= 43) PDC_set_font(_FONT8); - else if (nlines > 25) PDC_set_font(_FONT14); - else PDC_set_80x25(); - return ( rc ); +#ifdef EMXVIDEO + return (ERR); #else - -# ifdef EMXVIDEO - return (ERR); -# else - modeInfo.cb = sizeof(modeInfo); - /* set most parameters of modeInfo */ - VioGetMode(&modeInfo, 0); - modeInfo.fbType = 1; - modeInfo.row = nlines; - modeInfo.col = ncols; - result = VioSetMode(&modeInfo, 0); - LINES = PDC_get_rows(); - COLS = PDC_get_columns(); - return ((result == 0) ? OK : ERR); -# endif + modeInfo.cb = sizeof(modeInfo); + /* set most parameters of modeInfo */ + VioGetMode(&modeInfo, 0); + modeInfo.fbType = 1; + modeInfo.row = nlines; + modeInfo.col = ncols; + result = VioSetMode(&modeInfo, 0); + LINES = PDC_get_rows(); + COLS = PDC_get_columns(); + return ((result == 0) ? OK : ERR); #endif } + +#if !defined(EMXVIDEO) +/***********************************************************************/ +int PDC_reset_shell_mode( void ) +/***********************************************************************/ +{ +#ifdef PDCDEBUG + if (trace_on) PDC_debug("PDC_reset_shell_mode() - called.\n"); +#endif + PDC_set_keyboard_default(); + return OK; +} + +/***********************************************************************/ +int PDC_reset_prog_mode( void ) +/***********************************************************************/ +{ +#ifdef PDCDEBUG + if (trace_on) PDC_debug("PDC_reset_prog_mode() - called.\n"); +#endif + PDC_set_keyboard_binary(); + return OK; +} +#endif diff --git a/os2/pdcsetsc.c b/os2/pdcsetsc.c index 1409c201..0d4d75f4 100644 --- a/os2/pdcsetsc.c +++ b/os2/pdcsetsc.c @@ -17,301 +17,265 @@ * See the file maintain.er for details of the current maintainer. *************************************************************************** */ -#define CURSES_LIBRARY 1 +#define CURSES_LIBRARY 1 #ifdef HAVE_CONFIG_H # include #endif #include #ifdef PDCDEBUG -char *rcsid_PDCsetsc = "$Id: pdcsetsc.c,v 1.2 2001/01/10 08:29:42 mark Exp $"; +char *rcsid_PDCsetsc = "$Id: pdcsetsc.c,v 1.3 2002/01/12 04:04:18 mark Exp $"; #endif /*man-start********************************************************************* - PDC_set_80x25() - force a known screen state: 80x25 text mode. + PDC_set_80x25() - force a known screen state: 80x25 text mode. PDCurses Description: - This is a private PDCurses function. + This is a private PDCurses function. - Forces the appropriate 80x25 alpha mode given the display adapter. + Forces the appropriate 80x25 alpha mode given the display adapter. - Since we currently do not support changing the virtual console size, - this routine is a NOP under Flexos. + Since we currently do not support changing the virtual console size, + this routine is a NOP under Flexos. PDCurses Return Value: - This function returns OK upon success otherwise ERR is returned. + This function returns OK upon success otherwise ERR is returned. PDCurses Errors: - No errors are defined for this routine. + No errors are defined for this routine. Portability: - PDCurses int PDC_set_80x25( void ); + PDCurses int PDC_set_80x25( void ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_set_80x25(void) -#else -int PDC_set_80x25() -#endif +int PDC_set_80x25(void) /***********************************************************************/ { #ifndef EMXVIDEO - VIOMODEINFO modeInfo={0}; + VIOMODEINFO modeInfo={0}; #endif - #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_set_80x25() - called\n"); + if (trace_on) PDC_debug("PDC_set_80x25() - called\n"); #endif #ifndef EMXVIDEO - modeInfo.cb = sizeof(modeInfo); - /* set most parameters of modeInfo */ - VioGetMode(&modeInfo, 0); - modeInfo.fbType = 1; - VioSetMode(&modeInfo, 0); + modeInfo.cb = sizeof(modeInfo); + /* set most parameters of modeInfo */ + VioGetMode(&modeInfo, 0); + modeInfo.fbType = 1; + VioSetMode(&modeInfo, 0); #endif - return( OK ); + return( OK ); } /*man-start********************************************************************* - PDC_set_cursor_mode() - Set the cursor start and stop scan lines. + PDC_set_cursor_mode() - Set the cursor start and stop scan lines. PDCurses Description: - Sets the cursor type to begin in scan line startrow and end in - scan line endrow. Both values should be 0-31. + Sets the cursor type to begin in scan line startrow and end in + scan line endrow. Both values should be 0-31. PDCurses Return Value: - This function returns OK on success and ERR on error. + This function returns OK on success and ERR on error. PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses int PDC_set_cursor_mode( int startrow, int endrow ); + PDCurses int PDC_set_cursor_mode( int startrow, int endrow ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_set_cursor_mode( int startrow, int endrow ) -#else -int PDC_set_cursor_mode(startrow,endrow) -int startrow; -int endrow; -#endif +int PDC_set_cursor_mode( int startrow, int endrow ) /***********************************************************************/ { #ifndef EMXVIDEO - VIOCURSORINFO cursorInfo={0}; + VIOCURSORINFO cursorInfo={0}; #endif - #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_set_cursor_mode() - called: startrow %d endrow %d\n",startrow,endrow); + if (trace_on) PDC_debug("PDC_set_cursor_mode() - called: startrow %d endrow %d\n",startrow,endrow); #endif #ifdef EMXVIDEO - if (endrow <= startrow) - v_hidecursor(); - else - v_ctype (startrow, endrow); - return( OK ); + if (endrow <= startrow) + v_hidecursor(); + else + v_ctype (startrow, endrow); + return( OK ); #else - cursorInfo.yStart = startrow; - cursorInfo.cEnd = endrow; - cursorInfo.cx = 1; - cursorInfo.attr = 0; - return (VioSetCurType (&cursorInfo, 0) == 0); + cursorInfo.yStart = startrow; + cursorInfo.cEnd = endrow; + cursorInfo.cx = 1; + cursorInfo.attr = 0; + return (VioSetCurType (&cursorInfo, 0) == 0); #endif } /*man-start********************************************************************* - PDC_set_font() - sets the current font size + PDC_set_font() - sets the current font size PDCurses Description: - This is a private PDCurses function. + This is a private PDCurses function. - This routine sets the current font size, if the adapter allows - such a change. + 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. + 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. + 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. - It is also an error to attempt to change the size of the Flexos - console (as there is currently no support for that). + It is also an error to attempt to change the size of the Flexos + console (as there is currently no support for that). Portability: - PDCurses int PDC_set_font( int size ); + PDCurses int PDC_set_font( int size ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_set_font(int size) -#else -int PDC_set_font(size) -int size; -#endif +int PDC_set_font(int size) /***********************************************************************/ { #ifndef EMXVIDEO - VIOMODEINFO modeInfo={0}; + VIOMODEINFO modeInfo={0}; #endif - #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_set_font() - called\n"); + if (trace_on) PDC_debug("PDC_set_font() - called\n"); #endif #ifndef EMXVIDEO - if (SP->sizeable && (SP->font != size)) - { - modeInfo.cb = sizeof(modeInfo); - /* set most parameters of modeInfo */ - VioGetMode(&modeInfo, 0); - modeInfo.cb = 8; /* ignore horiz an vert resolution */ - modeInfo.row = modeInfo.vres / size; - VioSetMode(&modeInfo, 0); - } - if (SP->visible_cursor) - PDC_cursor_on(); - else - PDC_cursor_off(); - SP->font = PDC_get_font(); + if (SP->sizeable && (SP->font != size)) + { + modeInfo.cb = sizeof(modeInfo); + /* set most parameters of modeInfo */ + VioGetMode(&modeInfo, 0); + modeInfo.cb = 8; /* ignore horiz an vert resolution */ + modeInfo.row = modeInfo.vres / size; + VioSetMode(&modeInfo, 0); + } + if (SP->visible_cursor) + PDC_cursor_on(); + else + PDC_cursor_off(); + SP->font = PDC_get_font(); #endif - return( OK ); - + return( OK ); } /*man-start********************************************************************* - PDC_set_rows() - sets the physical number of rows on screen + PDC_set_rows() - sets the physical number of rows on screen PDCurses Description: - This is a private PDCurses function. + This is a private PDCurses function. - This routine attempts to set the number of rows on the physical - screen to the passed value. + This routine attempts to set the number of rows on the physical + screen to the passed value. PDCurses Return Value: - This function returns OK upon success otherwise ERR is returned. + This function returns OK upon success otherwise ERR is returned. PDCurses Errors: - It is an error to attempt to change the screen 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. + It is an error to attempt to change the screen 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. - It is also an error to attempt to change the size of the Flexos - console (as there is currently no support for that). + It is also an error to attempt to change the size of the Flexos + console (as there is currently no support for that). Portability: - PDCurses int PDC_set_rows( int rows ); + PDCurses int PDC_set_rows( int rows ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_set_rows(int rows) -#else -int PDC_set_rows(rows) -int rows; -#endif +int PDC_set_rows(int rows) /***********************************************************************/ { #ifndef EMXVIDEO - VIOMODEINFO modeInfo={0}; - USHORT result=0; + VIOMODEINFO modeInfo={0}; + USHORT result=0; #endif - #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_set_rows() - called\n"); + if (trace_on) PDC_debug("PDC_set_rows() - called\n"); #endif #ifdef EMXVIDEO - return (ERR); + return (ERR); #else - modeInfo.cb = sizeof(modeInfo); - /* set most parameters of modeInfo */ - VioGetMode(&modeInfo, 0); - modeInfo.fbType = 1; - modeInfo.row = rows; - result = VioSetMode(&modeInfo, 0); - SP->font = PDC_get_font(); - LINES = PDC_get_rows(); - COLS = PDC_get_columns(); - return ((result == 0) ? OK : ERR); + modeInfo.cb = sizeof(modeInfo); + /* set most parameters of modeInfo */ + VioGetMode(&modeInfo, 0); + modeInfo.fbType = 1; + modeInfo.row = rows; + result = VioSetMode(&modeInfo, 0); + SP->font = PDC_get_font(); + LINES = PDC_get_rows(); + COLS = PDC_get_columns(); + return ((result == 0) ? OK : ERR); #endif } /*man-start********************************************************************* - PDC_set_scrn_mode() - Set BIOS Video Mode + PDC_set_scrn_mode() - Set BIOS Video Mode PDCurses Description: - Sets the BIOS Video Mode Number ONLY if it is different from - the current video mode. This routine is for DOS systems only. + Sets the BIOS Video Mode Number ONLY if it is different from + the current video mode. This routine is for DOS systems only. PDCurses Return Value: - This function returns OK on success and ERR on error. + This function returns OK on success and ERR on error. PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses int PDC_set_scrn_mode( int new_mode ); + PDCurses int PDC_set_scrn_mode( int new_mode ); **man-end**********************************************************************/ /***********************************************************************/ #if !defined( EMXVIDEO ) -int PDC_set_scrn_mode(VIOMODEINFO new_mode) +int PDC_set_scrn_mode(VIOMODEINFO new_mode) #else -# ifdef HAVE_PROTO -int PDC_set_scrn_mode(int new_mode) -# else -int PDC_set_scrn_mode(new_mode) -int new_mode; -# endif +int PDC_set_scrn_mode(int new_mode) #endif /***********************************************************************/ { - #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_set_scrn_mode() - called\n"); + if (trace_on) PDC_debug("PDC_set_scrn_mode() - called\n"); #endif #ifdef EMXVIDEO - return ( OK ); + return ( OK ); #else - if (VioSetMode (&new_mode, 0) != 0) - { - SP->font = PDC_get_font(); - memcpy((char *)&SP->scrnmode,(char *)&new_mode,sizeof(VIOMODEINFO)); - LINES = PDC_get_rows(); - COLS = PDC_get_columns(); - return( OK ); - } - else - return (ERR); + if (VioSetMode (&new_mode, 0) != 0) + { + SP->font = PDC_get_font(); + memcpy((char *)&SP->scrnmode,(char *)&new_mode,sizeof(VIOMODEINFO)); + LINES = PDC_get_rows(); + COLS = PDC_get_columns(); + return( OK ); + } + else + return (ERR); #endif } /***********************************************************************/ -#ifdef HAVE_PROTO -int PDC_curs_set(int visibility) -#else -int PDC_curs_set(visibility) -int visibility; -#endif +int PDC_curs_set(int visibility) /***********************************************************************/ { #ifndef EMXVIDEO @@ -321,79 +285,72 @@ int visibility; int ret_vis=0,hidden=0; #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_curs_set() - called: visibility=%d\n",visibility); + if (trace_on) PDC_debug("PDC_curs_set() - called: visibility=%d\n",visibility); #endif - ret_vis = SP->visibility; - SP->visibility = visibility; + ret_vis = SP->visibility; + SP->visibility = visibility; - switch(visibility) - { - case 0: /* invisible */ + switch(visibility) + { + case 0: /* invisible */ #ifdef EMXVIDEO - start = end = 0; + start = end = 0; #else - start = SP->font / 4; - end = SP->font; + start = SP->font / 4; + end = SP->font; #endif - hidden = (-1); - break; - case 2: /* highly visible */ - start = 2; /* almost full-height block */ - end = SP->font-1; - break; - default: /* normal visibility */ - start = SP->font - (SP->font / 4); - end = SP->font-1; - break; - } + hidden = (-1); + break; + case 2: /* highly visible */ + start = 2; /* almost full-height block */ + end = SP->font-1; + break; + default: /* normal visibility */ + start = SP->font - (SP->font / 4); + end = SP->font-1; + break; + } #ifdef EMXVIDEO - if (!visibility) - v_hidecursor(); - else - v_ctype (start, end); + if (!visibility) + v_hidecursor(); + else + v_ctype (start, end); #else - pvioCursorInfo.yStart = (USHORT)start; - pvioCursorInfo.cEnd = (USHORT)end; - pvioCursorInfo.cx = (USHORT)1; - pvioCursorInfo.attr = hidden; - VioSetCurType((PVIOCURSORINFO)&pvioCursorInfo,0); + pvioCursorInfo.yStart = (USHORT)start; + pvioCursorInfo.cEnd = (USHORT)end; + pvioCursorInfo.cx = (USHORT)1; + pvioCursorInfo.attr = hidden; + VioSetCurType((PVIOCURSORINFO)&pvioCursorInfo,0); #endif - - return( ret_vis ); + return( ret_vis ); } /*man-start********************************************************************* - PDC_set_title() - Set window title + PDC_set_title() - Set window title PDCurses Description: - Sets the title of the window in which the curses program is running. - This function may not do anything on some platforms. + Sets the title of the window in which the curses program is running. + This function may not do anything on some platforms. PDCurses Return Value: - N/A + N/A PDCurses Errors: - No errors are defined for this function. + No errors are defined for this function. Portability: - PDCurses void PDC_set_title( char *title ); + PDCurses void PDC_set_title( char *title ); **man-end**********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PROTO -void PDC_set_title(char *title) -#else -void PDC_set_title(title) -char *title; -#endif +void PDC_set_title(char *title) /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("PDC_set_title() - called:<%s>\n",title); + if (trace_on) PDC_debug("PDC_set_title() - called:<%s>\n",title); #endif - - return; + return; } diff --git a/pdcurses/initscr.c b/pdcurses/initscr.c index a5e044bd..5226c430 100644 --- a/pdcurses/initscr.c +++ b/pdcurses/initscr.c @@ -17,7 +17,7 @@ * See the file maintain.er for details of the current maintainer. *************************************************************************** */ -#define CURSES_LIBRARY 1 +#define CURSES_LIBRARY 1 #ifdef HAVE_CONFIG_H # include #endif @@ -34,22 +34,22 @@ #endif /* undefine any macros for functions defined in this module */ -#undef initscr -#undef endwin -#undef isendwin -#undef newterm -#undef set_term -#undef delscreen -#undef resize_term -#undef is_termresized +#undef initscr +#undef endwin +#undef isendwin +#undef newterm +#undef set_term +#undef delscreen +#undef resize_term +#undef is_termresized /* undefine any macros for functions called by this module if in debug mode */ #ifdef PDCDEBUG -# undef move -# undef wmove -# undef resize_term -# undef touchwin -# undef wnoutrefresh +# undef move +# undef wmove +# undef resize_term +# undef touchwin +# undef wnoutrefresh #endif #ifdef UNIX @@ -61,72 +61,72 @@ #endif #ifdef PDCDEBUG -char *rcsid_initscr = "$Id: initscr.c,v 1.2 2001/01/10 08:27:08 mark Exp $"; +char *rcsid_initscr = "$Id: initscr.c,v 1.3 2002/01/12 04:04:18 mark Exp $"; #else -char* _curses_notice = "PDCurses 2.2 - Public Domain 1994"; +char* _curses_notice = "PDCurses 2.2 - Public Domain 1994"; #endif -int _default_lines = 25; /* default terminal height */ +int _default_lines = 25; /* default terminal height */ -SCREEN *SP = (SCREEN*)NULL; /* curses variables */ -WINDOW* curscr=NULL; /* the current screen image */ -WINDOW* stdscr=NULL; /* the default screen window */ -int LINES=0; /* current terminal height */ -int COLS=0; /* current terminal width */ +SCREEN *SP = (SCREEN*)NULL; /* curses variables */ +WINDOW* curscr=NULL; /* the current screen image */ +WINDOW* stdscr=NULL; /* the default screen window */ +int LINES=0; /* current terminal height */ +int COLS=0; /* current terminal width */ MOUSE_STATUS Mouse_status; int use_emalloc = FALSE; -#if defined DOS +#if defined DOS Regs regs; #endif /* * 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 */ -WINDOW* _getch_win_=NULL; +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 */ +WINDOW* _getch_win_=NULL; /* * Global definitions for setmode routines */ -struct cttyset c_sh_tty = {0}; /* tty modes for def_shell_mode */ -struct cttyset c_pr_tty = {0}; /* tty modes for def_prog_mode */ +struct cttyset c_sh_tty = {0}; /* tty modes for def_shell_mode */ +struct cttyset c_pr_tty = {0}; /* tty modes for def_prog_mode */ struct cttyset c_save_tty = {0}; struct cttyset c_save_trm = {0}; /* * Global definitions for printscan routines */ -char c_printscanbuf[513]; /* buffer used during I/O */ +char c_printscanbuf[513]; /* buffer used during I/O */ /* * Global definitions for strget routines */ char *c_strbeg; -#if EMALLOC -void* emalloc( size_t ); -void* ecalloc( size_t, size_t ); -void efree( void* ); - -extern void* emalloc(); /* user's emalloc(size) */ -extern void* ecalloc(); /* user's ecalloc(num,size) */ -extern void efree(); /* user's efree(ptr) */ +#if EMALLOC +void* emalloc( size_t ); +void* ecalloc( size_t, size_t ); +void efree( void* ); + +extern void* emalloc(); /* user's emalloc(size) */ +extern void* ecalloc(); /* user's ecalloc(num,size) */ +extern void efree(); /* user's efree(ptr) */ #endif #if !defined(UNIX) && !defined(XCURSES) -extern void* malloc(); /* runtime's malloc(size) */ -extern void* calloc(); /* runtime's calloc(num,size) */ -extern void free(); /* runtime's free(ptr) */ +extern void* malloc(); /* runtime's malloc(size) */ +extern void* calloc(); /* runtime's calloc(num,size) */ +extern void free(); /* runtime's free(ptr) */ #endif -void* (*mallc)(); /* ptr to some malloc(size) */ -void* (*callc)(); /* ptr to some ecalloc(num,size)*/ -void (*fre)(); /* ptr to some free(ptr) */ -void* (*reallc)(); /* ptr to some realloc(ptr,size) */ +void* (*mallc)(); /* ptr to some malloc(size) */ +void* (*callc)(); /* ptr to some ecalloc(num,size)*/ +void (*fre)(); /* ptr to some free(ptr) */ +void* (*reallc)(); /* ptr to some realloc(ptr,size) */ #ifdef XCURSES chtype *acs_map; @@ -146,69 +146,69 @@ extern void (*PDC_initial_slk)(); Name: initscr Synopsis: - WINDOW *initscr(void); - WINDOW *Xinitscr(int argc, char *argv[]); - int endwin(void); - int isendwin(void); - *** SCREEN *newterm(char *type, FILE *outfd, FILE *infd); - SCREEN *set_term(SCREEN *new); - *** void delscreen(SCREEN *sp); + WINDOW *initscr(void); + WINDOW *Xinitscr(int argc, char *argv[]); + int endwin(void); + int isendwin(void); + *** SCREEN *newterm(char *type, FILE *outfd, FILE *infd); + SCREEN *set_term(SCREEN *new); + *** void delscreen(SCREEN *sp); - int resize_term(int nlines, int ncols); - bool is_termresized(void); + int resize_term(int nlines, int ncols); + bool is_termresized(void); X/Open Description: - The first curses routine called should be initscr(). This will - determine the terminal type and initialize all curses data - structures. The initscr() function also arranges that the - first call to refresh() will clear the screen. If errors - occur, initscr() will write an appropriate error message to - standard error and exit. If the program wants an indication - of error conditions, newterm() should be used instead of - initscr(). + The first curses routine called should be initscr(). This will + determine the terminal type and initialize all curses data + structures. The initscr() function also arranges that the + first call to refresh() will clear the screen. If errors + occur, initscr() will write an appropriate error message to + standard error and exit. If the program wants an indication + of error conditions, newterm() should be used instead of + initscr(). - A program should always call endwin() before exiting or - escaping from curses mode temporarily. This routine will - restore tty modes, move the cursor to the lower left corner - of the screen and reset the terminal into the proper non-visual - mode. To resume curses after a temporary escape, refresh() or - doupdate() should be called. + A program should always call endwin() before exiting or + escaping from curses mode temporarily. This routine will + restore tty modes, move the cursor to the lower left corner + of the screen and reset the terminal into the proper non-visual + mode. To resume curses after a temporary escape, refresh() or + doupdate() should be called. - The isendwin() function returns TRUE if endwin() has been called - without any subsequent calls to wrefresh(), and FALSE otherwise. + The isendwin() function returns TRUE if endwin() has been called + without any subsequent calls to wrefresh(), and FALSE otherwise. - A program which outputs to more than one terminal should use - newterm() for each terminal instead of initscr(). The newterm() - function should be called once for each terminal. It returns a - value of type SCREEN* which should be saved as a reference to that - terminal. The arguments are the type of of terminal to be used - in place of TERM (environment variable), a file pointer for output - to the terminal and another file pointer for input from the terminal. - The program must also call endwin() for each terminal no longer being - used. + A program which outputs to more than one terminal should use + newterm() for each terminal instead of initscr(). The newterm() + function should be called once for each terminal. It returns a + value of type SCREEN* which should be saved as a reference to that + terminal. The arguments are the type of of terminal to be used + in place of TERM (environment variable), a file pointer for output + to the terminal and another file pointer for input from the terminal. + The program must also call endwin() for each terminal no longer being + used. - The set_term() function is used to switch between different terminals. - The screen reference 'new' becomes the new current terminal. - The previous terminal is returned by the routine. This is the - only routine which manipulates SCREEN pointers; all other routines - affect only the current terminal. + The set_term() function is used to switch between different terminals. + The screen reference 'new' becomes the new current terminal. + The previous terminal is returned by the routine. This is the + only routine which manipulates SCREEN pointers; all other routines + affect only the current terminal. PDCurses Description: - The resize_term() function is used to have PDCurses change its - internal structures to the new, specified size. + The resize_term() function is used to have PDCurses change its + internal structures to the new, specified size. - The is_termresized() function returns TRUE if the Curses screen has - been resized by external means, and requires a call to resize_term(). + The is_termresized() function returns TRUE if the Curses screen has + been resized by external means, and requires a call to resize_term(). - Due to the fact that newterm() does not yet exist in PDCurses, - there is no way to recover from an error in initscr(). + Due to the fact that newterm() does not yet exist in PDCurses, + there is no way to recover from an error in initscr(). X/Open Return Value: - All functions return NULL on error, except endwin(), which - returns ERR on error. + All functions return NULL on error, except endwin(), which + returns ERR on error. X/Open Errors: - No errors are defined for this function. + No errors are defined for this function. Portability X/Open BSD SYS V Dec '88 @@ -225,9 +225,9 @@ extern void (*PDC_initial_slk)(); /***********************************************************************/ #ifdef HAVE_PROTO -WINDOW* PDC_CDECL Xinitscr(int argc, char *argv[]) +WINDOW* PDC_CDECL Xinitscr(int argc, char *argv[]) #else -WINDOW* PDC_CDECL Xinitscr(argc,argv) +WINDOW* PDC_CDECL Xinitscr(argc,argv) int argc; char *argv[]; #endif @@ -236,269 +236,268 @@ char *argv[]; register int i=0; #ifdef PDCDEBUG - if (trace_on) PDC_debug("Xinitscr() - called\n"); + if (trace_on) PDC_debug("Xinitscr() - called\n"); #endif - if (SP != (SCREEN *)NULL - && SP->alive) - return( NULL); + if (SP != (SCREEN *)NULL + && SP->alive) + return( NULL); #ifdef EMXVIDEO - v_init(); + v_init(); #endif - if (use_emalloc == EMALLOC_MAGIC) - { -#if EMALLOC - use_emalloc = TRUE; - mallc = emalloc; - callc = ecalloc; - fre = efree; - reallc = erealloc; + if (use_emalloc == EMALLOC_MAGIC) + { +#if EMALLOC + use_emalloc = TRUE; + mallc = emalloc; + callc = ecalloc; + fre = efree; + reallc = erealloc; #endif - } - else - { - mallc = malloc; - callc = calloc; - fre = free; - reallc = realloc; - } + } + else + { + mallc = malloc; + callc = calloc; + fre = free; + reallc = realloc; + } #ifdef UNIX - setupterm((char *)0,1,(int *)0); - if (enter_ca_mode != NULL) - putp(enter_ca_mode); + setupterm((char *)0,1,(int *)0); + if (enter_ca_mode != NULL) + putp(enter_ca_mode); #endif #if defined (XCURSES) - if (XCursesInitscr(NULL,argc,argv) == ERR) - exit(7); + if (XCursesInitscr(NULL,argc,argv) == ERR) + exit(7); #endif #if defined (XCURSES) - if (SP == (SCREEN*)NULL) /* SP already attached in XCursesInitscr() */ + if (SP == (SCREEN*)NULL) /* SP already attached in XCursesInitscr() */ #else - if ((SP = (SCREEN*)callc(1,sizeof(SCREEN))) == (SCREEN*)NULL) + if ((SP = (SCREEN*)callc(1,sizeof(SCREEN))) == (SCREEN*)NULL) #endif - { - fprintf( stderr, "initscr(): Unable to create SP\n" ); - exit(8); - } + { + fprintf( stderr, "initscr(): Unable to create SP\n" ); + exit(8); + } - PDC_scr_open(SP, 0); + PDC_scr_open(SP, 0); -#ifdef FLEXOS - _flexos_16bitmode(); +#ifdef FLEXOS + _flexos_16bitmode(); #endif - LINES = SP->lines; - COLS = SP->cols; + LINES = SP->lines; + COLS = SP->cols; - if (LINES < 2 || COLS < 2) - { - fprintf( stderr, "initscr(): LINES=%d COLS=%d: too small.\n",LINES,COLS ); - exit( 4 ); - } + if (LINES < 2 || COLS < 2) + { + fprintf( stderr, "initscr(): LINES=%d COLS=%d: too small.\n",LINES,COLS ); + exit( 4 ); + } - if ((curscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *) NULL) - { - fprintf( stderr, "initscr(): Unable to create curscr.\n" ); - exit( 2 ); - } + if ((curscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *) NULL) + { + fprintf( stderr, "initscr(): Unable to create curscr.\n" ); + exit( 2 ); + } #ifdef XCURSES - if ((acs_map = (chtype *)(*mallc)(128*sizeof(chtype))) == (chtype *)NULL) - { - fprintf( stderr, "initscr(): Unable to create acs_map.\n" ); - exit( 5 ); - } - for (i=0;i<128;i++) - { - acs_map[i] = '#' | A_ALTCHARSET; - } -ACS_BSSB = (chtype)13|A_ALTCHARSET; -ACS_SSBB = (chtype)14|A_ALTCHARSET; -ACS_BBSS = (chtype)12|A_ALTCHARSET; -ACS_SBBS = (chtype)11|A_ALTCHARSET; -ACS_SBSS = (chtype)22|A_ALTCHARSET; -ACS_SSSB = (chtype)21|A_ALTCHARSET; -ACS_SSBS = (chtype)23|A_ALTCHARSET; -ACS_BSSS = (chtype)24|A_ALTCHARSET; -ACS_BSBS = (chtype)18|A_ALTCHARSET; -ACS_SBSB = (chtype)25|A_ALTCHARSET; -ACS_SSSS = (chtype)15|A_ALTCHARSET; -ACS_S1 = (chtype)16|A_ALTCHARSET; -ACS_S9 = (chtype)20|A_ALTCHARSET; -ACS_DIAMOND = (chtype)1|A_ALTCHARSET; -ACS_CKBOARD = (chtype)2|A_ALTCHARSET; -ACS_DEGREE = (chtype)7|A_ALTCHARSET; -ACS_PLMINUS = (chtype)8|A_ALTCHARSET; -ACS_BULLET = (chtype)'*'|A_ALTCHARSET; -ACS_LARROW = (chtype)'<'|A_ALTCHARSET; -ACS_RARROW = (chtype)'>'|A_ALTCHARSET; -ACS_DARROW = (chtype)'v'|A_ALTCHARSET; -ACS_UARROW = (chtype)'^'|A_ALTCHARSET; -ACS_BOARD = (chtype)'#'|A_ALTCHARSET; -ACS_LANTERN = (chtype)'#'|A_ALTCHARSET; -ACS_BLOCK = (chtype)0|A_ALTCHARSET; -/* extra, non-standard symbols */ -ACS_S3 = (chtype)17|A_ALTCHARSET; -ACS_S7 = (chtype)19|A_ALTCHARSET; -ACS_LEQUAL = (chtype)26|A_ALTCHARSET; -ACS_GEQUAL = (chtype)27|A_ALTCHARSET; -ACS_PI = (chtype)28|A_ALTCHARSET; -ACS_NEQUAL = (chtype)29|A_ALTCHARSET; -ACS_STERLING= (chtype)30|A_ALTCHARSET; + if ((acs_map = (chtype *)(*mallc)(128*sizeof(chtype))) == (chtype *)NULL) + { + fprintf( stderr, "initscr(): Unable to create acs_map.\n" ); + exit( 5 ); + } + for (i=0;i<128;i++) + { + acs_map[i] = '#' | A_ALTCHARSET; + } + ACS_BSSB = (chtype)13|A_ALTCHARSET; + ACS_SSBB = (chtype)14|A_ALTCHARSET; + ACS_BBSS = (chtype)12|A_ALTCHARSET; + ACS_SBBS = (chtype)11|A_ALTCHARSET; + ACS_SBSS = (chtype)22|A_ALTCHARSET; + ACS_SSSB = (chtype)21|A_ALTCHARSET; + ACS_SSBS = (chtype)23|A_ALTCHARSET; + ACS_BSSS = (chtype)24|A_ALTCHARSET; + ACS_BSBS = (chtype)18|A_ALTCHARSET; + ACS_SBSB = (chtype)25|A_ALTCHARSET; + ACS_SSSS = (chtype)15|A_ALTCHARSET; + ACS_S1 = (chtype)16|A_ALTCHARSET; + ACS_S9 = (chtype)20|A_ALTCHARSET; + ACS_DIAMOND = (chtype)1|A_ALTCHARSET; + ACS_CKBOARD = (chtype)2|A_ALTCHARSET; + ACS_DEGREE = (chtype)7|A_ALTCHARSET; + ACS_PLMINUS = (chtype)8|A_ALTCHARSET; + ACS_BULLET = (chtype)'*'|A_ALTCHARSET; + ACS_LARROW = (chtype)'<'|A_ALTCHARSET; + ACS_RARROW = (chtype)'>'|A_ALTCHARSET; + ACS_DARROW = (chtype)'v'|A_ALTCHARSET; + ACS_UARROW = (chtype)'^'|A_ALTCHARSET; + ACS_BOARD = (chtype)'#'|A_ALTCHARSET; + ACS_LANTERN = (chtype)'#'|A_ALTCHARSET; + ACS_BLOCK = (chtype)0|A_ALTCHARSET; + /* extra, non-standard symbols */ + ACS_S3 = (chtype)17|A_ALTCHARSET; + ACS_S7 = (chtype)19|A_ALTCHARSET; + ACS_LEQUAL = (chtype)26|A_ALTCHARSET; + ACS_GEQUAL = (chtype)27|A_ALTCHARSET; + ACS_PI = (chtype)28|A_ALTCHARSET; + ACS_NEQUAL = (chtype)29|A_ALTCHARSET; + ACS_STERLING= (chtype)30|A_ALTCHARSET; #endif - if (PDC_initial_slk) - { - (*PDC_initial_slk)(); - LINES -= SP->slklines; - } + if (PDC_initial_slk) + { + (*PDC_initial_slk)(); + LINES -= SP->slklines; + } /* * We have to sort out ripped off lines here and reduce the height * of stdscr by the number of lines ripped off */ - for (i=0;ilinesrippedoffontop++,0),COLS); - SP->linesrippedoff++; - LINES--; - } - linesrippedoff = 0; + for (i=0;ilinesrippedoffontop++,0),COLS); + SP->linesrippedoff++; + LINES--; + } + linesrippedoff = 0; - if ((stdscr = newwin(LINES, COLS, SP->linesrippedoffontop, 0)) == (WINDOW *) NULL) - { - fprintf( stderr, "initscr(): Unable to create stdscr.\n" ); - exit( 1 ); - } + if ((stdscr = newwin(LINES, COLS, SP->linesrippedoffontop, 0)) == (WINDOW *) NULL) + { + fprintf( stderr, "initscr(): Unable to create stdscr.\n" ); + exit( 1 ); + } - wclrtobot(stdscr); + wclrtobot(stdscr); /* * If preserving the existing screen don't allow a screen clear... */ if (SP->_preserve) - { - untouchwin(curscr); - untouchwin(stdscr); - stdscr->_clear = FALSE; - } + { + untouchwin(curscr); + untouchwin(stdscr); + stdscr->_clear = FALSE; + } - curscr->_clear = FALSE; + curscr->_clear = FALSE; -#ifdef REGISTERWINDOWS - SP->refreshall = FALSE; - _inswin(stdscr, (WINDOW *)NULL); +#ifdef REGISTERWINDOWS + SP->refreshall = FALSE; + _inswin(stdscr, (WINDOW *)NULL); #endif #if defined(CHTYPE_LONG) - PDC_init_atrtab(); /* set up default (BLACK on WHITE colours */ + PDC_init_atrtab(); /* set up default (BLACK on WHITE colours */ #endif #ifdef EMXVIDEO - SP->tahead = -1; + SP->tahead = -1; #endif - MOUSE_X_POS = MOUSE_Y_POS = (-1); - BUTTON_STATUS(1) = BUTTON_RELEASED; - BUTTON_STATUS(2) = BUTTON_RELEASED; - BUTTON_STATUS(3) = BUTTON_RELEASED; - Mouse_status.changes = 0; + MOUSE_X_POS = MOUSE_Y_POS = (-1); + BUTTON_STATUS(1) = BUTTON_RELEASED; + BUTTON_STATUS(2) = BUTTON_RELEASED; + BUTTON_STATUS(3) = BUTTON_RELEASED; + Mouse_status.changes = 0; - SP->alive = TRUE; + SP->alive = TRUE; #ifdef UNIX - PDC_setup_keys(); + PDC_setup_keys(); #else - def_shell_mode(); /* don't do this for UNIX as scropen has already changed things */ + def_shell_mode(); /* don't do this for UNIX as scropen has already changed things */ #endif - return( stdscr ); + return( stdscr ); } /***********************************************************************/ #ifdef HAVE_PROTO -WINDOW* PDC_CDECL initscr(void) +WINDOW* PDC_CDECL initscr(void) #else -WINDOW* PDC_CDECL initscr() +WINDOW* PDC_CDECL initscr() #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("initscr() - called\n"); + if (trace_on) PDC_debug("initscr() - called\n"); #endif - return (Xinitscr( 0, NULL ) ); + return (Xinitscr( 0, NULL ) ); } /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL endwin(void) +int PDC_CDECL endwin(void) #else -int PDC_CDECL endwin() +int PDC_CDECL endwin() #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("endwin() - called\n"); + if (trace_on) PDC_debug("endwin() - called\n"); #endif #ifdef ORIGINAL_PDCURSES_BEHAVIOUR - PDC_scr_close(); -/* 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()); - } + PDC_scr_close(); +/* 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()); + } - SP->visible_cursor = FALSE; /* Force the visible cursor */ - SP->cursor = SP->orig_cursor; - PDC_cursor_on(); - /* - * Position cursor so that the screen will not scroll until they hit - * a carriage return. Do this BEFORE delwin(curscr) as PDC_gotoxy() uses - * curscr. - */ - PDC_gotoxy(PDC_get_rows() - 2, 0); - delwin(stdscr); - delwin(curscr); - stdscr = (WINDOW *)NULL; - curscr = (WINDOW *)NULL; - SP->alive = FALSE; + SP->visible_cursor = FALSE; /* Force the visible cursor */ + SP->cursor = SP->orig_cursor; + PDC_cursor_on(); + /* + * Position cursor so that the screen will not scroll until they hit + * a carriage return. Do this BEFORE delwin(curscr) as PDC_gotoxy() uses + * curscr. + */ + PDC_gotoxy(PDC_get_rows() - 2, 0); + delwin(stdscr); + delwin(curscr); + stdscr = (WINDOW *)NULL; + curscr = (WINDOW *)NULL; + SP->alive = FALSE; # if !defined (XCURSES) - if (SP) - { - fre(SP); - SP = (SCREEN *)NULL; - } + if (SP) + { + fre(SP); + SP = (SCREEN *)NULL; + } # endif -# ifdef FLEXOS - _flexos_8bitmode(); +# ifdef FLEXOS + _flexos_8bitmode(); # endif -/* PDC_fix_cursor(SP->orig_emulation);*/ +/* PDC_fix_cursor(SP->orig_emulation);*/ # ifdef UNIX - if (exit_ca_mode != NULL) - putp(exit_ca_mode); + if (exit_ca_mode != NULL) + putp(exit_ca_mode); # endif # if defined(DOS) || defined(OS2) - if (SP->orig_font != SP->font) /* screen has not been resized */ - reset_shell_mode(); + reset_shell_mode(); # endif # if DONOTKILLXFROMHERE # if defined (XCURSES) - XCursesInstruct(CURSES_EXIT); - XCursesCleanupCursesProcess(0); + XCursesInstruct(CURSES_EXIT); + XCursesCleanupCursesProcess(0); # endif # endif @@ -509,200 +508,200 @@ int PDC_CDECL endwin() * using endwin(). */ - PDC_scr_close(); + PDC_scr_close(); -# ifdef FLEXOS - _flexos_8bitmode(); +# ifdef FLEXOS + _flexos_8bitmode(); # endif # if defined(DOS) || defined(OS2) - reset_shell_mode(); + reset_shell_mode(); # endif - curs_set(1); - /* - * Position cursor to the bottom left of the screen. - */ + curs_set(1); + /* + * Position cursor to the bottom left of the screen. + */ #if defined(WIN32) - PDC_gotoxy(PDC_get_buffer_rows() - 2, 0); + PDC_gotoxy(PDC_get_buffer_rows() - 2, 0); #else - PDC_gotoxy(PDC_get_rows() - 2, 0); + PDC_gotoxy(PDC_get_rows() - 2, 0); #endif - SP->alive = FALSE; + SP->alive = FALSE; #endif - return( OK ); + return( OK ); } /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL isendwin(void) +int PDC_CDECL isendwin(void) #else -int PDC_CDECL isendwin() +int PDC_CDECL isendwin() #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("isendwin() - called\n"); + if (trace_on) PDC_debug("isendwin() - called\n"); #endif - return((SP->alive) ? FALSE : TRUE); + return((SP->alive) ? FALSE : TRUE); } /***********************************************************************/ #ifdef HAVE_PROTO -SCREEN*PDC_CDECL newterm( char *type, FILE *outfd, FILE *infd ) +SCREEN*PDC_CDECL newterm( char *type, FILE *outfd, FILE *infd ) #else -SCREEN*PDC_CDECL newterm(type,outfd,infd) +SCREEN*PDC_CDECL newterm(type,outfd,infd) char *type; FILE *outfd; FILE *infd; #endif /***********************************************************************/ { -#ifdef TC +#ifdef TC # pragma argsused #endif #if 0 -extern void* mallc(); /* malloc(size) */ -extern void* callc(); /* calloc(num,size) */ -extern void fre(); /* free(ptr) */ +extern void* mallc(); /* malloc(size) */ +extern void* callc(); /* calloc(num,size) */ +extern void fre(); /* free(ptr) */ -extern void* malloc(); -extern void* calloc(); -extern void free(); +extern void* malloc(); +extern void* calloc(); +extern void free(); #ifdef PDCDEBUG - if (trace_on) PDC_debug("newterm() - called\n"); + if (trace_on) PDC_debug("newterm() - called\n"); #endif - if (SP->alive) - return( ERR ); + if (SP->alive) + return( ERR ); - if (use_emalloc == EMALLOC_MAGIC) - { -#if EMALLOC - memset(SP, 0, sizeof(SCREEN)); - use_emalloc = TRUE; - mallc = emalloc; - callc = ecalloc; - fre = efree; - reallc = erealloc; + if (use_emalloc == EMALLOC_MAGIC) + { +#if EMALLOC + memset(SP, 0, sizeof(SCREEN)); + use_emalloc = TRUE; + mallc = emalloc; + callc = ecalloc; + fre = efree; + reallc = erealloc; #endif - } - else - { - memset(SP, 0, sizeof(SCREEN)); - mallc = malloc; - callc = calloc; - fre = free; - reallc = realloc; - } - PDC_scr_open(SP, 0); - SP->orig_cursor = SP->cursor; - SP->orig_font = PDC_get_font(); - SP->orgcbr = PDC_get_ctrl_break(); - SP->blank = ' '; -#ifdef FLEXOS - _flexos_16bitmode(); + } + else + { + memset(SP, 0, sizeof(SCREEN)); + mallc = malloc; + callc = calloc; + fre = free; + reallc = realloc; + } + PDC_scr_open(SP, 0); + SP->orig_cursor = SP->cursor; + SP->orig_font = PDC_get_font(); + SP->orgcbr = PDC_get_ctrl_break(); + SP->blank = ' '; +#ifdef FLEXOS + _flexos_16bitmode(); #endif - savetty(); - LINES = PDC_get_rows(); - COLS = PDC_get_columns(); + savetty(); + LINES = PDC_get_rows(); + COLS = PDC_get_columns(); - if ((curscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *) ERR) - { - return( ERR ); - } - if ((stdscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *) ERR) - { - return( ERR ); - } - curscr->_clear = FALSE; -#ifdef REGISTERWINDOWS - SP->refreshall = FALSE; - _inswin(stdscr, (WINDOW *)NULL); + if ((curscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *) ERR) + { + return( ERR ); + } + if ((stdscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *) ERR) + { + return( ERR ); + } + curscr->_clear = FALSE; +#ifdef REGISTERWINDOWS + SP->refreshall = FALSE; + _inswin(stdscr, (WINDOW *)NULL); #endif - SP->alive = TRUE; - return( SP ); + SP->alive = TRUE; + return( SP ); #endif - return(NULL); + return(NULL); } /***********************************************************************/ #ifdef HAVE_PROTO -SCREEN* PDC_CDECL set_term( SCREEN *new ) +SCREEN* PDC_CDECL set_term( SCREEN *new ) #else -SCREEN* PDC_CDECL set_term(new) +SCREEN* PDC_CDECL set_term(new) SCREEN *new; #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("set_term() - called\n"); + if (trace_on) PDC_debug("set_term() - called\n"); #endif -#ifdef TC +#ifdef TC # pragma argsused #endif - return( SP ); /* We only have one screen supported right now */ + return( SP ); /* We only have one screen supported right now */ } /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL resize_term(int nlines, int ncols) +int PDC_CDECL resize_term(int nlines, int ncols) #else -int PDC_CDECL resize_term(nlines,ncols) +int PDC_CDECL resize_term(nlines,ncols) int nlines,ncols; #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("resize_term() - called: nlines %d\n",nlines); + if (trace_on) PDC_debug("resize_term() - called: nlines %d\n",nlines); #endif - if (stdscr == (WINDOW *)NULL) - return(ERR); + if (stdscr == (WINDOW *)NULL) + return(ERR); - if (PDC_resize_screen(nlines,ncols) == ERR) - return ( ERR ); + if (PDC_resize_screen(nlines,ncols) == ERR) + return ( ERR ); - SP->lines = PDC_get_rows(); - LINES = SP->lines - SP->linesrippedoff - SP->slklines; - SP->cols = COLS = PDC_get_columns(); + SP->lines = PDC_get_rows(); + LINES = SP->lines - SP->linesrippedoff - SP->slklines; + SP->cols = COLS = PDC_get_columns(); - if ((curscr = resize_window(curscr, SP->lines, SP->cols)) == NULL) - return (ERR); + if ((curscr = resize_window(curscr, SP->lines, SP->cols)) == NULL) + return (ERR); - if ((stdscr = resize_window(stdscr, LINES, COLS)) == NULL) - return (ERR); + if ((stdscr = resize_window(stdscr, LINES, COLS)) == NULL) + return (ERR); - if (SP->slk_winptr) - { - if ((SP->slk_winptr = resize_window(SP->slk_winptr,SP->slklines, COLS)) == NULL) - return (ERR); - wmove(SP->slk_winptr, 0, 0); - wclrtobot(SP->slk_winptr); - (*PDC_initial_slk)(); - slk_noutrefresh(); - } + if (SP->slk_winptr) + { + if ((SP->slk_winptr = resize_window(SP->slk_winptr,SP->slklines, COLS)) == NULL) + return (ERR); + wmove(SP->slk_winptr, 0, 0); + wclrtobot(SP->slk_winptr); + (*PDC_initial_slk)(); + slk_noutrefresh(); + } - touchwin(stdscr); - wnoutrefresh(stdscr); + touchwin(stdscr); + wnoutrefresh(stdscr); - return (OK); + return (OK); } /***********************************************************************/ #ifdef HAVE_PROTO -bool PDC_CDECL is_termresized(void) +bool PDC_CDECL is_termresized(void) #else -bool PDC_CDECL is_termresized() +bool PDC_CDECL is_termresized() #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("is_termresized() - called\n"); + if (trace_on) PDC_debug("is_termresized() - called\n"); #endif - return( SP->resized ); + return( SP->resized ); } diff --git a/pdcurses/kernel.c b/pdcurses/kernel.c index 4b22b239..f8e056d8 100644 --- a/pdcurses/kernel.c +++ b/pdcurses/kernel.c @@ -17,7 +17,7 @@ * See the file maintain.er for details of the current maintainer. *************************************************************************** */ -#define CURSES_LIBRARY 1 +#define CURSES_LIBRARY 1 #ifdef HAVE_CONFIG_H # include #endif @@ -33,27 +33,27 @@ #endif /* undefine any macros for functions defined in this module */ -#undef def_prog_mode -#undef def_shell_mode -#undef reset_prog_mode -#undef reset_shell_mode -#undef resetty -#undef savetty -#undef getsyx -#undef setsyx -#undef ripoffline -#undef curs_set -#undef napms -#undef draino +#undef def_prog_mode +#undef def_shell_mode +#undef reset_prog_mode +#undef reset_shell_mode +#undef resetty +#undef savetty +#undef getsyx +#undef setsyx +#undef ripoffline +#undef curs_set +#undef napms +#undef draino /* undefine any macros for functions called by this module if in debug mode */ #ifdef PDCDEBUG -# undef move -# undef wmove +# undef move +# undef wmove #endif #ifdef PDCDEBUG -char *rcsid_kernel = "$Id: kernel.c,v 1.1 2001/01/10 08:27:13 mark Exp $"; +char *rcsid_kernel = "$Id: kernel.c,v 1.2 2002/01/12 04:04:18 mark Exp $"; #endif RIPPEDOFFLINE linesripped[5]; @@ -64,85 +64,85 @@ char linesrippedoff=0; Name: kernel Synopsis: - int def_prog_mode(void); - int def_shell_mode(void); - int reset_prog_mode(void); - int reset_shell_mode(void); - int resetty(void); - int savetty(void); - int getsyx(int *y, int *x); - int setsyx(int y, int x); - int ripoffline(int line, int (*init)(WINDOW *,int)); - int curs_set(int visibility); - int napms(int ms); - int draino(int ms); + int def_prog_mode(void); + int def_shell_mode(void); + int reset_prog_mode(void); + int reset_shell_mode(void); + int resetty(void); + int savetty(void); + int getsyx(int *y, int *x); + int setsyx(int y, int x); + int ripoffline(int line, int (*init)(WINDOW *,int)); + int curs_set(int visibility); + int napms(int ms); + int draino(int ms); X/Open Description: - The def_prog_mode() and def_shell_mode() functions save the - current terminal modes as the "program" (in curses) or - "shell" (not in curses) state for use by the reset_prog_mode() - and reset_shell_mode() functions. This is done automatically by - initscr(). + The def_prog_mode() and def_shell_mode() functions save the + current terminal modes as the "program" (in curses) or + "shell" (not in curses) state for use by the reset_prog_mode() + and reset_shell_mode() functions. This is done automatically by + initscr(). - The reset_prog_mode() and reset_shell_mode() functions restore - the terminal to "program" (in curses) or "shell" (not in curses) - state. These are done automatically by endwin() - and doupdate() after an endwin(), so they would normally not - be called before these functions. + The reset_prog_mode() and reset_shell_mode() functions restore + the terminal to "program" (in curses) or "shell" (not in curses) + state. These are done automatically by endwin() + and doupdate() after an endwin(), so they would normally not + be called before these functions. - The savetty() and resetty() routines save and restore the state of - the terminal modes. The savetty() function saves the current state - in a buffer and resetty() restores the state to what it was at the - last call to savetty(). + The savetty() and resetty() routines save and restore the state of + the terminal modes. The savetty() function saves the current state + in a buffer and resetty() restores the state to what it was at the + last call to savetty(). - The getsyx() routine obtains the coordinates of the virtual screen - cursor. If leaveok() is currently TRUE, then -1, -1 is returned. If - lines have been removed from the top of the screen with ripoffline() - then getsyx() includes those lines, so y and x should only be used - by setyx(). - The setyx() routine sets the cursor position of the virtual screen - to the y,x coordinates. If y,x are -1,-1, leaveok() is set TRUE. - The getsyx() and setsyx() routines are designed to be used by a - library routine that manipulates curses windows, but does not want - to change the position of the cursor. + The getsyx() routine obtains the coordinates of the virtual screen + cursor. If leaveok() is currently TRUE, then -1, -1 is returned. If + lines have been removed from the top of the screen with ripoffline() + then getsyx() includes those lines, so y and x should only be used + by setyx(). + The setyx() routine sets the cursor position of the virtual screen + to the y,x coordinates. If y,x are -1,-1, leaveok() is set TRUE. + The getsyx() and setsyx() routines are designed to be used by a + library routine that manipulates curses windows, but does not want + to change the position of the cursor. - The curs_set() function enables the appearance of the text cursor - to be altered. A value of 0 for visibility makes the cursor - disappear; a value of 1 makes the cursor appear "normal" (usually - an underline) and 2 makes the cursor "highly visible"; a block. + The curs_set() function enables the appearance of the text cursor + to be altered. A value of 0 for visibility makes the cursor + disappear; a value of 1 makes the cursor appear "normal" (usually + an underline) and 2 makes the cursor "highly visible"; a block. - The ripoffline() function allows the user to reduce the size of - stdscr by 1 line. If the value of line is positive, the line is - removed from the top of the screen; negative from the bottom. Up to - 5 lines can be ripped off stdscr by calling ripoffline() - consecutively. - The function argument, init, is called from within initscr() or - newterm(), so ripoffline() must be called before either of these - functions. The init function is passed a pointer to a 1 line - WINDOW and the width of the window. Calling ripoffline() with a - NULL initialise function pointer is not advisable! + The ripoffline() function allows the user to reduce the size of + stdscr by 1 line. If the value of line is positive, the line is + removed from the top of the screen; negative from the bottom. Up to + 5 lines can be ripped off stdscr by calling ripoffline() + consecutively. + The function argument, init, is called from within initscr() or + newterm(), so ripoffline() must be called before either of these + functions. The init function is passed a pointer to a 1 line + WINDOW and the width of the window. Calling ripoffline() with a + NULL initialise function pointer is not advisable! - The napms() and draino() functions, suspends the program for the - specified number of milliseconds. + The napms() and draino() functions, suspends the program for the + specified number of milliseconds. PDCurses Description: - FYI: It is very unclear whether savetty() and resetty() functions - are a duplication of the reset_prog_mode() and reset_shell_mode() - functions or whether this is a backing store type of operation. - At this time, they are implemented similar to the reset_*_mode() - routines. + FYI: It is very unclear whether savetty() and resetty() functions + are a duplication of the reset_prog_mode() and reset_shell_mode() + functions or whether this is a backing store type of operation. + At this time, they are implemented similar to the reset_*_mode() + routines. - The curs_set() routine is used to set the visibility of the cursor. - The cursor can be made invisible, normal or highly visible by setting - the parameter to 0, 1 or 2 respectively. If an invalid value is passed - the function will set the cursor to "normal". + The curs_set() routine is used to set the visibility of the cursor. + The cursor can be made invisible, normal or highly visible by setting + the parameter to 0, 1 or 2 respectively. If an invalid value is passed + the function will set the cursor to "normal". X/Open Return Value: - All functions return OK on success and ERR on error except curs_set() - which returns the previous visibility. + All functions return OK on success and ERR on error except curs_set() + which returns the previous visibility. X/Open Errors: - No errors are defined for this function. + No errors are defined for this function. Portability X/Open BSD SYS V Dec '88 @@ -163,348 +163,341 @@ char linesrippedoff=0; #ifndef UNIX /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL def_prog_mode(void) +int PDC_CDECL def_prog_mode(void) #else -int PDC_CDECL def_prog_mode() +int PDC_CDECL def_prog_mode() #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("def_prog_mode() - called\n"); + if (trace_on) PDC_debug("def_prog_mode() - called\n"); #endif -#ifdef FLEXOS - _flexos_16bitmode(); +#ifdef FLEXOS + _flexos_16bitmode(); #endif - c_pr_tty.been_set = TRUE; + c_pr_tty.been_set = TRUE; - memcpy(&c_pr_tty.saved, SP, sizeof(SCREEN)); + memcpy(&c_pr_tty.saved, SP, sizeof(SCREEN)); - return( OK ); + return( OK ); } #endif #ifndef UNIX /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL def_shell_mode(void) +int PDC_CDECL def_shell_mode(void) #else -int PDC_CDECL def_shell_mode() +int PDC_CDECL def_shell_mode() #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("def_shell_mode() - called\n"); + if (trace_on) PDC_debug("def_shell_mode() - called\n"); #endif -#ifdef FLEXOS - _flexos_8bitmode(); +#ifdef FLEXOS + _flexos_8bitmode(); #endif - c_sh_tty.been_set = TRUE; + c_sh_tty.been_set = TRUE; - memcpy(&c_sh_tty.saved, SP, sizeof(SCREEN)); + memcpy(&c_sh_tty.saved, SP, sizeof(SCREEN)); - return( OK ); + return( OK ); } #endif #ifndef UNIX /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL reset_prog_mode(void) +int PDC_CDECL reset_prog_mode(void) #else -int PDC_CDECL reset_prog_mode() +int PDC_CDECL reset_prog_mode() #endif /***********************************************************************/ { #if defined(OS2) && !defined(EMXVIDEO) - extern VIOMODEINFO modeInfo; + VIOMODEINFO modeInfo; #endif #ifdef PDCDEBUG - if (trace_on) PDC_debug("reset_prog_mode() - called\n"); + if (trace_on) PDC_debug("reset_prog_mode() - called\n"); #endif + if (c_pr_tty.been_set == TRUE) + { + memcpy(SP, &c_pr_tty.saved, sizeof(SCREEN)); - if (c_pr_tty.been_set == TRUE) - { - - memcpy(SP, &c_pr_tty.saved, sizeof(SCREEN)); - - mvcur(0, 0, c_pr_tty.saved.cursrow, c_pr_tty.saved.curscol); - if (PDC_get_ctrl_break() != c_pr_tty.saved.orgcbr) - PDC_set_ctrl_break(c_pr_tty.saved.orgcbr); - if (c_pr_tty.saved.raw_out) - raw(); - if (c_pr_tty.saved.visible_cursor) - PDC_cursor_on(); - SP->font = PDC_get_font(); - PDC_set_font(c_pr_tty.saved.font); + mvcur(0, 0, c_pr_tty.saved.cursrow, c_pr_tty.saved.curscol); + if (PDC_get_ctrl_break() != c_pr_tty.saved.orgcbr) + PDC_set_ctrl_break(c_pr_tty.saved.orgcbr); + if (c_pr_tty.saved.raw_out) + raw(); + if (c_pr_tty.saved.visible_cursor) + PDC_cursor_on(); + SP->font = PDC_get_font(); + PDC_set_font(c_pr_tty.saved.font); #if !defined (XCURSES) -# if !defined(EMXVIDEO) -# if defined(OS2) - (void)PDC_get_scrn_mode(); - if (!PDC_scrn_modes_equal (modeInfo, c_pr_tty.saved.scrnmode)) - PDC_set_scrn_mode(c_pr_tty.saved.scrnmode); -# else - if (!PDC_scrn_modes_equal (PDC_get_scrn_mode(), c_pr_tty.saved.scrnmode)) - PDC_set_scrn_mode(c_pr_tty.saved.scrnmode); -# endif +# if !defined(EMXVIDEO) +# if defined(OS2) + (void)PDC_get_scrn_mode( &modeInfo ); + if ( !PDC_scrn_modes_equal( modeInfo, c_pr_tty.saved.scrnmode ) ) + PDC_set_scrn_mode( c_pr_tty.saved.scrnmode ); +# else + if ( !PDC_scrn_modes_equal( PDC_get_scrn_mode(), c_pr_tty.saved.scrnmode ) ) + PDC_set_scrn_mode( c_pr_tty.saved.scrnmode ); # endif +# endif #endif - PDC_set_rows(c_pr_tty.saved.lines); - } - -#ifdef FLEXOS - _flexos_16bitmode(); + PDC_set_rows(c_pr_tty.saved.lines); + } +#ifdef FLEXOS + _flexos_16bitmode(); #endif -#ifdef WIN32 - PDC_reset_prog_mode(); +#if defined(WIN32) || (defined(OS2) && !defined(EMXVIDEO)) + PDC_reset_prog_mode(); #endif - - return( OK ); + return( OK ); } #endif #ifndef UNIX /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL reset_shell_mode(void) +int PDC_CDECL reset_shell_mode(void) #else -int PDC_CDECL reset_shell_mode() +int PDC_CDECL reset_shell_mode() #endif /***********************************************************************/ { #if defined(OS2) && !defined(EMXVIDEO) - extern VIOMODEINFO modeInfo; + VIOMODEINFO modeInfo; #endif #ifdef PDCDEBUG - if (trace_on) PDC_debug("reset_shell_mode() - called\n"); + if (trace_on) PDC_debug("reset_shell_mode() - called\n"); #endif - #ifndef WIN32 - if (c_sh_tty.been_set == TRUE) - { + if (c_sh_tty.been_set == TRUE) + { + memcpy(SP, &c_sh_tty.saved, sizeof(SCREEN)); - memcpy(SP, &c_sh_tty.saved, sizeof(SCREEN)); - - mvcur(0, 0, c_sh_tty.saved.cursrow, c_sh_tty.saved.curscol); - if (PDC_get_ctrl_break() != c_sh_tty.saved.orgcbr) - PDC_set_ctrl_break(c_sh_tty.saved.orgcbr); - if (c_sh_tty.saved.raw_out) - raw(); - if (c_sh_tty.saved.visible_cursor) - PDC_cursor_on(); - SP->font = PDC_get_font(); - PDC_set_font(c_sh_tty.saved.font); + mvcur(0, 0, c_sh_tty.saved.cursrow, c_sh_tty.saved.curscol); + if (PDC_get_ctrl_break() != c_sh_tty.saved.orgcbr) + PDC_set_ctrl_break(c_sh_tty.saved.orgcbr); + if (c_sh_tty.saved.raw_out) + raw(); + if (c_sh_tty.saved.visible_cursor) + PDC_cursor_on(); + SP->font = PDC_get_font(); + PDC_set_font(c_sh_tty.saved.font); #if !defined (XCURSES) -# if !defined(EMXVIDEO) -# if defined(OS2) - (void)PDC_get_scrn_mode(); - if (!PDC_scrn_modes_equal (modeInfo, c_sh_tty.saved.scrnmode)) - PDC_set_scrn_mode(c_sh_tty.saved.scrnmode); -# else - if (!PDC_scrn_modes_equal (PDC_get_scrn_mode(), c_sh_tty.saved.scrnmode)) - PDC_set_scrn_mode(c_sh_tty.saved.scrnmode); -# endif +# if !defined(EMXVIDEO) +# if defined(OS2) + (void)PDC_get_scrn_mode( &modeInfo ); + if ( !PDC_scrn_modes_equal( modeInfo, c_sh_tty.saved.scrnmode ) ) + PDC_set_scrn_mode( c_sh_tty.saved.scrnmode ); +# else + if ( !PDC_scrn_modes_equal( PDC_get_scrn_mode(), c_sh_tty.saved.scrnmode ) ) + PDC_set_scrn_mode( c_sh_tty.saved.scrnmode ); # endif +# endif #endif #if defined(OS2) || defined(WIN32) - PDC_resize_screen(c_sh_tty.saved.lines,c_sh_tty.saved.cols); + PDC_resize_screen(c_sh_tty.saved.lines,c_sh_tty.saved.cols); #else - PDC_set_rows(c_sh_tty.saved.lines); + PDC_set_rows(c_sh_tty.saved.lines); #endif - } + } #endif -#ifdef FLEXOS - _flexos_8bitmode(); +#ifdef FLEXOS + _flexos_8bitmode(); #endif -#ifdef WIN32 - PDC_reset_shell_mode(); +#if defined(WIN32) || (defined(OS2) && !defined(EMXVIDEO)) + PDC_reset_shell_mode(); #endif - return( OK ); + return( OK ); } #endif /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL resetty(void) +int PDC_CDECL resetty(void) #else -int PDC_CDECL resetty() +int PDC_CDECL resetty() #endif /***********************************************************************/ { #if defined(OS2) && !defined(EMXVIDEO) - extern VIOMODEINFO modeInfo; + VIOMODEINFO modeInfo; #endif #ifdef PDCDEBUG - if (trace_on) PDC_debug("resetty() - called\n"); + if (trace_on) PDC_debug("resetty() - called\n"); #endif #ifndef UNIX - if (c_save_tty.been_set == TRUE) - { - memcpy(SP, &c_save_tty.saved, sizeof(SCREEN)); - - mvcur(0, 0, c_save_tty.saved.cursrow, c_save_tty.saved.curscol); - if (PDC_get_ctrl_break() != c_save_tty.saved.orgcbr) - PDC_set_ctrl_break(c_save_tty.saved.orgcbr); - if (c_save_tty.saved.raw_out) - raw(); - if (c_save_tty.saved.visible_cursor) - PDC_cursor_on(); - SP->font = PDC_get_font(); - PDC_set_font(c_save_tty.saved.font); -#if !defined (XCURSES) + if (c_save_tty.been_set == TRUE) + { + memcpy(SP, &c_save_tty.saved, sizeof(SCREEN)); + mvcur(0, 0, c_save_tty.saved.cursrow, c_save_tty.saved.curscol); + if (PDC_get_ctrl_break() != c_save_tty.saved.orgcbr) + PDC_set_ctrl_break(c_save_tty.saved.orgcbr); + if (c_save_tty.saved.raw_out) + raw(); + if (c_save_tty.saved.visible_cursor) + PDC_cursor_on(); + SP->font = PDC_get_font(); + PDC_set_font(c_save_tty.saved.font); +# if !defined (XCURSES) # if !defined(EMXVIDEO) -# if defined(OS2) - (void)PDC_get_scrn_mode(); - if (!PDC_scrn_modes_equal (modeInfo, c_save_tty.saved.scrnmode)) - PDC_set_scrn_mode(c_save_tty.saved.scrnmode); -# else - if (!PDC_scrn_modes_equal (PDC_get_scrn_mode(), c_save_tty.saved.scrnmode)) - PDC_set_scrn_mode(c_save_tty.saved.scrnmode); -# endif +# if defined(OS2) + (void)PDC_get_scrn_mode( &modeInfo ); + if ( !PDC_scrn_modes_equal( modeInfo, c_save_tty.saved.scrnmode ) ) + PDC_set_scrn_mode( c_save_tty.saved.scrnmode ); +# else + if ( !PDC_scrn_modes_equal( PDC_get_scrn_mode(), c_save_tty.saved.scrnmode ) ) + PDC_set_scrn_mode( c_save_tty.saved.scrnmode ); +# endif # endif +# endif +# if defined(OS2) + PDC_resize_screen(c_save_tty.saved.lines,c_save_tty.saved.cols); +# else + PDC_set_rows(c_save_tty.saved.lines); +# endif + } #endif -#if defined(OS2) - PDC_resize_screen(c_save_tty.saved.lines,c_save_tty.saved.cols); -#else - PDC_set_rows(c_save_tty.saved.lines); -#endif - } -#endif - return( c_save_tty.been_set ? OK : ERR ); + return( c_save_tty.been_set ? OK : ERR ); } /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL savetty(void) +int PDC_CDECL savetty(void) #else -int PDC_CDECL savetty() +int PDC_CDECL savetty() #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("savetty() - called\n"); + if (trace_on) PDC_debug("savetty() - called\n"); #endif - c_save_tty.been_set = TRUE; - memcpy(&c_save_tty.saved, SP, sizeof(SCREEN)); - return( OK ); + c_save_tty.been_set = TRUE; + memcpy(&c_save_tty.saved, SP, sizeof(SCREEN)); + return( OK ); } /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL getsyx(int *y, int *x) +int PDC_CDECL getsyx(int *y, int *x) #else -int PDC_CDECL getsyx(y,x) +int PDC_CDECL getsyx(y,x) int *y,*x; #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("getsyx() - called\n"); + if (trace_on) PDC_debug("getsyx() - called\n"); #endif - if (curscr->_leaveit) - *y = *x = (-1); - else - { - *y = curscr->_cury - SP->linesrippedoffontop; - *x = curscr->_curx; - } - return( OK ); + if (curscr->_leaveit) + *y = *x = (-1); + else + { + *y = curscr->_cury - SP->linesrippedoffontop; + *x = curscr->_curx; + } + return( OK ); } /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL setsyx(int y, int x) +int PDC_CDECL setsyx(int y, int x) #else -int PDC_CDECL setsyx(y,x) +int PDC_CDECL setsyx(y,x) int y,x; #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("setsyx() - called\n"); + if (trace_on) PDC_debug("setsyx() - called\n"); #endif - if (y < 0 && x < 0) - curscr->_leaveit = TRUE; - else - { - curscr->_cury = y + SP->linesrippedoffontop; - curscr->_curx = x; - curscr->_leaveit = FALSE; - } - return( OK ); + if (y < 0 && x < 0) + curscr->_leaveit = TRUE; + else + { + curscr->_cury = y + SP->linesrippedoffontop; + curscr->_curx = x; + curscr->_leaveit = FALSE; + } + return( OK ); } /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL curs_set(int visibility) +int PDC_CDECL curs_set(int visibility) #else -int PDC_CDECL curs_set(visibility) +int PDC_CDECL curs_set(visibility) int visibility; #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("curs_set() - called: visibility=%d\n",visibility); + if (trace_on) PDC_debug("curs_set() - called: visibility=%d\n",visibility); #endif - return(PDC_curs_set(visibility)); + return(PDC_curs_set(visibility)); } /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL ripoffline(int line, int (*init)(WINDOW *,int)) +int PDC_CDECL ripoffline(int line, int (*init)(WINDOW *,int)) #else -int PDC_CDECL ripoffline(line, init) +int PDC_CDECL ripoffline(line, init) int line; int (*init)(); #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("ripoffline() - called: line=%d\n",line); + if (trace_on) PDC_debug("ripoffline() - called: line=%d\n",line); #endif - if (linesrippedoff < 5 - && line != 0) - { - linesripped[(int)linesrippedoff].line = line; - linesripped[(int)linesrippedoff++].init = init; - } - return(OK); + if (linesrippedoff < 5 + && line != 0) + { + linesripped[(int)linesrippedoff].line = line; + linesripped[(int)linesrippedoff++].init = init; + } + return(OK); } /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL napms(int ms) +int PDC_CDECL napms(int ms) #else -int PDC_CDECL napms(ms) +int PDC_CDECL napms(ms) int ms; #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("napms() - called: ms=%d\n",ms); + if (trace_on) PDC_debug("napms() - called: ms=%d\n",ms); #endif - return(delay_output(ms)); + return(delay_output(ms)); } /***********************************************************************/ #ifdef HAVE_PROTO -int PDC_CDECL draino(int ms) +int PDC_CDECL draino(int ms) #else -int PDC_CDECL draino(ms) +int PDC_CDECL draino(ms) int ms; #endif /***********************************************************************/ { #ifdef PDCDEBUG - if (trace_on) PDC_debug("draino() - called: ms=%d\n",ms); + if (trace_on) PDC_debug("draino() - called: ms=%d\n",ms); #endif - return(delay_output(ms)); + return(delay_output(ms)); }