Formatting, cruft, dead code. More to do in this regard. Re: formatting,

my main aim is consistency. Several indenting styles were in use in
different sections of the code, depending on the author and the time it
was written. Also, I like my code to fit in 80 columns where practical.
This commit is contained in:
William McBrine
2006-01-08 11:53:43 +00:00
parent 3fde95d3f0
commit d5860c11a4
14 changed files with 3199 additions and 2967 deletions

View File

@@ -18,10 +18,9 @@
***************************************************************************
*/
#define CURSES_LIBRARY 1
#ifdef HAVE_CONFIG_H
# include <config.h>
# include <config.h>
#endif
#if !defined(EMXVIDEO)
# define INCL_DOS
@@ -32,185 +31,190 @@
#include <string.h>
#ifdef PDCDEBUG
char *rcsid_PDCclip = "$Id: pdcclip.c,v 1.6 2006/01/03 07:34:43 wmcbrine Exp $";
char *rcsid_PDCclip = "$Id: pdcclip.c,v 1.7 2006/01/08 11:53:42 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
PDC_getclipboard() - Gets the contents of the clipboard
PDCurses Description:
This is a PDCurses only routine.
This is a PDCurses only routine.
Gets the textual contents of the system's clipboard. This
function returns the contents of the clipboard in the contents
argument. It is the responsibilitiy of the caller to free the
memory returned with the PDC_freeclipboard() call. The length of the
clipboard contents is returned in the length argument.
Gets the textual contents of the system's clipboard. This
function returns the contents of the clipboard in the contents
argument. It is the responsibilitiy of the caller to free the
memory returned with the PDC_freeclipboard() call. The length
of the clipboard contents is returned in the length argument.
PDCurses Return Value:
indicator of success/failure of call.
PDC_CLIP_SUCCESS the call was successful
PDC_CLIP_ACCESS_ERROR an error occured while accessing the
clipboard
PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
the clipboard contents
PDC_CLIP_EMPTY the clipboard contains no text
indicator of success/failure of call.
PDC_CLIP_SUCCESS the call was successful
PDC_CLIP_ACCESS_ERROR an error occured while accessing the
clipboard
PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
the clipboard contents
PDC_CLIP_EMPTY the clipboard contains no text
Portability:
PDCurses int PDC_getclipboard( char **contents, long *length );
PDCurses int PDC_getclipboard(char **contents, long *length);
**man-end**********************************************************************/
int PDC_CDECL PDC_getclipboard(char **contents, long *length)
{
#if !defined(EMXVIDEO)
HMQ hmq;
HAB hab;
PTIB ptib;
PPIB ppib;
ULONG ulRet;
long len=0;
int rc=0;
HMQ hmq;
HAB hab;
PTIB ptib;
PPIB ppib;
ULONG ulRet;
long len;
int rc;
#endif
PDC_LOG(("PDC_getclipboard() - called\n"));
PDC_LOG(("PDC_getclipboard() - called\n"));
#if !defined(EMXVIDEO)
DosGetInfoBlocks( &ptib, &ppib );
ppib->pib_ultype = 3;
hab = WinInitialize( 0 );
hmq = WinCreateMsgQueue( hab, 0 );
DosGetInfoBlocks(&ptib, &ppib);
ppib->pib_ultype = 3;
hab = WinInitialize(0);
hmq = WinCreateMsgQueue(hab, 0);
if ( !WinOpenClipbrd( hab ) )
{
WinDestroyMsgQueue( hmq );
WinTerminate( hab );
return PDC_CLIP_ACCESS_ERROR;
}
ulRet = WinQueryClipbrdData( hab, CF_TEXT );
if ( !ulRet )
rc = PDC_CLIP_EMPTY;
else
{
len = strlen( (char *)ulRet );
*contents = (char *)malloc( len+1 );
if ( !*contents )
{
rc = PDC_CLIP_MEMORY_ERROR;
}
else
{
strcpy( (char *)*contents, (char *)ulRet );
*length = len;
rc = PDC_CLIP_SUCCESS;
}
}
WinCloseClipbrd( hab );
WinDestroyMsgQueue( hmq );
WinTerminate( hab );
return( rc );
if (!WinOpenClipbrd(hab))
{
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
return PDC_CLIP_ACCESS_ERROR;
}
rc = PDC_CLIP_EMPTY;
ulRet = WinQueryClipbrdData(hab, CF_TEXT);
if (ulRet)
{
len = strlen((char *)ulRet);
*contents = (char *)malloc(len + 1);
if (!*contents)
rc = PDC_CLIP_MEMORY_ERROR;
else
{
strcpy((char *)*contents, (char *)ulRet);
*length = len;
rc = PDC_CLIP_SUCCESS;
}
}
WinCloseClipbrd(hab);
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
return rc;
#else
return PDC_CLIP_ACCESS_ERROR;
return PDC_CLIP_ACCESS_ERROR;
#endif
}
/*man-start*********************************************************************
PDC_setclipboard() - Sets the contents of the clipboard
PDCurses Description:
This is a PDCurses only routine.
This is a PDCurses only routine.
Copies the supplied text into the system's clipboard, emptying
the clipboard prior to the copy.
Copies the supplied text into the system's clipboard, emptying
the clipboard prior to the copy.
PDCurses Return Value:
indicator of success/failure of call.
PDC_CLIP_SUCCESS the call was successful
PDC_CLIP_ACCESS_ERROR an error occured while accessing the
clipboard
indicator of success/failure of call.
PDC_CLIP_SUCCESS the call was successful
PDC_CLIP_ACCESS_ERROR an error occured while accessing the
clipboard
Portability:
PDCurses int PDC_getclipboard( char *contents, long length );
PDCurses int PDC_getclipboard(char *contents, long length);
**man-end**********************************************************************/
int PDC_CDECL PDC_setclipboard(char *contents, long length)
{
#if !defined(EMXVIDEO)
HAB hab;
PTIB ptib;
PPIB ppib;
ULONG ulRC;
PSZ szTextOut=NULL;
int rc=0;
HAB hab;
PTIB ptib;
PPIB ppib;
ULONG ulRC;
PSZ szTextOut = NULL;
int rc;
#endif
PDC_LOG(("PDC_setclipboard() - called\n"));
PDC_LOG(("PDC_setclipboard() - called\n"));
#if !defined(EMXVIDEO)
DosGetInfoBlocks( &ptib, &ppib );
ppib->pib_ultype = 3;
hab = WinInitialize( 0 );
DosGetInfoBlocks(&ptib, &ppib);
ppib->pib_ultype = 3;
hab = WinInitialize(0);
if ( !WinOpenClipbrd( hab ) )
{
WinTerminate( hab );
return PDC_CLIP_ACCESS_ERROR;
}
ulRC = DosAllocSharedMem( (PVOID) &szTextOut, NULL, length+1, PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE );
if (ulRC != 0)
{
rc = PDC_CLIP_MEMORY_ERROR;
}
else
{
strcpy( szTextOut, contents );
WinEmptyClipbrd( hab );
if ( WinSetClipbrdData( hab, (ULONG)szTextOut, CF_TEXT, CFI_POINTER ) )
{
rc = PDC_CLIP_SUCCESS;
}
else
{
DosFreeMem( szTextOut );
rc = PDC_CLIP_ACCESS_ERROR;
}
}
WinCloseClipbrd( hab );
WinTerminate( hab );
return( rc );
if (!WinOpenClipbrd(hab))
{
WinTerminate(hab);
return PDC_CLIP_ACCESS_ERROR;
}
rc = PDC_CLIP_MEMORY_ERROR;
ulRC = DosAllocSharedMem((PVOID)&szTextOut, NULL, length + 1,
PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE);
if (ulRC == 0)
{
strcpy(szTextOut, contents);
WinEmptyClipbrd(hab);
if (WinSetClipbrdData(hab, (ULONG)szTextOut,
CF_TEXT, CFI_POINTER))
rc = PDC_CLIP_SUCCESS;
else
{
DosFreeMem(szTextOut);
rc = PDC_CLIP_ACCESS_ERROR;
}
}
WinCloseClipbrd(hab);
WinTerminate(hab);
return rc;
#else
return PDC_CLIP_ACCESS_ERROR;
return PDC_CLIP_ACCESS_ERROR;
#endif
}
/*man-start*********************************************************************
PDC_freeclipboard() - Frees the memory associated with the contents of the clipboard
PDC_freeclipboard() - Frees the memory associated with the contents
of the clipboard
PDCurses Description:
This is a PDCurses only routine.
This is a PDCurses only routine.
Frees the memory allocated by PDC_getclipboard().
Frees the memory allocated by PDC_getclipboard().
PDCurses Return Value:
Always returns PDC_CLIP_SUCCESS
Always returns PDC_CLIP_SUCCESS
Portability:
PDCurses int PDC_freeclipboard( char *contents );
PDCurses int PDC_freeclipboard(char *contents);
**man-end**********************************************************************/
int PDC_CDECL PDC_freeclipboard(char *contents)
{
PDC_LOG(("PDC_freeclipboard() - called\n"));
PDC_LOG(("PDC_freeclipboard() - called\n"));
if ( contents) free(contents);
return PDC_CLIP_SUCCESS;
if (contents)
free(contents);
return PDC_CLIP_SUCCESS;
}
/*man-start*********************************************************************
@@ -218,39 +222,39 @@ int PDC_CDECL PDC_freeclipboard(char *contents)
PDC_clearclipboard() - Clears the contents of the clipboard
PDCurses Description:
This is a PDCurses only routine.
This is a PDCurses only routine.
Clears the internal clipboard.
Clears the internal clipboard.
PDCurses Return Value:
Always returns PDC_CLIP_SUCCESS
Always returns PDC_CLIP_SUCCESS
Portability:
PDCurses int PDC_clearclipboard( void );
PDCurses int PDC_clearclipboard(void);
**man-end**********************************************************************/
int PDC_CDECL PDC_clearclipboard( void )
int PDC_CDECL PDC_clearclipboard(void)
{
#if !defined(EMXVIDEO)
HAB hab;
PTIB ptib;
PPIB ppib;
HAB hab;
PTIB ptib;
PPIB ppib;
#endif
PDC_LOG(("PDC_clearclipboard() - called\n"));
PDC_LOG(("PDC_clearclipboard() - called\n"));
#if !defined(EMXVIDEO)
DosGetInfoBlocks( &ptib, &ppib );
ppib->pib_ultype = 3;
hab = WinInitialize( 0 );
DosGetInfoBlocks(&ptib, &ppib);
ppib->pib_ultype = 3;
hab = WinInitialize(0);
WinEmptyClipbrd( hab );
WinEmptyClipbrd(hab);
WinCloseClipbrd( hab );
WinTerminate( hab );
return PDC_CLIP_SUCCESS;
WinCloseClipbrd(hab);
WinTerminate(hab);
return PDC_CLIP_SUCCESS;
#else
return PDC_CLIP_ACCESS_ERROR;
return PDC_CLIP_ACCESS_ERROR;
#endif
}

View File

@@ -19,18 +19,18 @@
*/
#define CURSES_LIBRARY 1
#ifdef HAVE_CONFIG_H
# include <config.h>
# include <config.h>
#endif
#include <curses.h>
#include <string.h>
#ifdef HAVE_MEMORY_H
# include <memory.h>
# include <memory.h>
#endif
#ifdef PDCDEBUG
char *rcsid_PDCdisp = "$Id: pdcdisp.c,v 1.5 2006/01/03 19:54:29 wmcbrine Exp $";
char *rcsid_PDCdisp = "$Id: pdcdisp.c,v 1.6 2006/01/08 11:53:42 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
@@ -38,20 +38,20 @@ char *rcsid_PDCdisp = "$Id: pdcdisp.c,v 1.5 2006/01/03 19:54:29 wmcbrine Exp $"
PDC_clr_update() - Updates the screen with a full redraw.
PDCurses Description:
Updates the screen by clearing it and then redraw it in its
entirety. If SP->refrbrk is TRUE, and there is pending
input characters, the update will be prematurely terminated.
Updates the screen by clearing it and then redraw it in its
entirety. If SP->refrbrk is TRUE, and there is pending
input characters, the update will be prematurely terminated.
PDCurses Return Value:
This routine returns ERR if it is unable to accomplish its task.
This routine returns ERR if it is unable to accomplish its task.
The return value OK is returned if there were no errors.
The return value OK is returned if there were no errors.
PDCurses Errors:
No errors are defined for this function.
No errors are defined for this function.
Portability:
PDCurses int PDC_clr_update( WINDOW* s );
PDCurses int PDC_clr_update(WINDOW *s);
**man-end**********************************************************************/
@@ -64,68 +64,76 @@ WINDOW *s;
#endif
/***********************************************************************/
{
register int i=0,j=0;
WINDOW* w=NULL;
unsigned short* ch;
bool rc=FALSE;
int i, j;
unsigned short *ch;
extern unsigned char atrtab[MAX_ATRTAB];
/* the next two variables have been changed from chtype to unsigned short */
/* as this is the correct datatype for a physical character/attribute */
unsigned short temp_line[256]; /* this should be enough for the maximum width of a screen. MH-920715 */
/* the next two variables have been changed from chtype to
unsigned short as this is the correct datatype for a physical
character/attribute */
/* this should be enough for the maximum width of a screen. */
unsigned short temp_line[256];
unsigned short chr;
PDC_LOG(("PDC_clr_update() - called\n"));
w = curscr;
if (w == (WINDOW *)NULL)
return( ERR );
/* if (SP->full_redraw)
PDC_clr_scrn(s); *//* clear physical screen */
if (curscr == (WINDOW *)NULL)
return ERR;
#if 0
if (SP->full_redraw)
PDC_clr_scrn(s); /* clear physical screen */
#endif
s->_clear = FALSE;
for (i = 0; i < LINES; i++) /* update physical screen */
{
if (s != w) /* copy s to curscr */
memcpy(w->_y[i], s->_y[i], COLS * sizeof(chtype));
/* copy s to curscr -- must be same size */
ch = temp_line; /* now have ch pointing to area to contain real attributes. MH-920715 */
if (s != curscr)
memcpy(curscr->_y[i], s->_y[i], COLS * sizeof(chtype));
for (j=0;j<COLS;j++) /* for each chtype in the line... */
{
/* now have ch pointing to area to contain real
attributes. MH-920715 */
ch = temp_line;
/* for each chtype in the line... */
for (j = 0; j < COLS; j++)
{
chr = (unsigned short)(s->_y[i][j] & A_CHARTEXT);
temp_line[j] = chtype_attr(s->_y[i][j]) | chr;
}
}
if (SP->direct_video)
{
#ifdef EMXVIDEO
v_putline ((char *)ch, 0, i, COLS);
v_putline ((char *)ch, 0, i, COLS);
#else
VioWrtCellStr ((PCH)ch, (USHORT)(COLS * sizeof(unsigned short)), (USHORT)i, 0, 0);
VioWrtCellStr((PCH)ch,
(USHORT)(COLS * sizeof(unsigned short)),
(USHORT)i, 0, 0);
#endif
}
else
{
for (j = 0; j < COLS; j++)
{
PDC_gotoxy(i, j);
PDC_putc( (*ch & A_CHARTEXT), (*ch & A_ATTRIBUTES) >> 8 );
PDC_putc((*ch & A_CHARTEXT),
(*ch & A_ATTRIBUTES) >> 8);
ch++;
}
}
if (SP->refrbrk && (SP->cbreak || SP->raw_inp))
{
rc = PDC_breakout();
if(rc)
break;
}
w->_firstch[i] = _NO_CHANGE;
w->_lastch[i] = _NO_CHANGE;
if (SP->refrbrk && (SP->cbreak || SP->raw_inp)
&& PDC_breakout())
break;
curscr->_firstch[i] = _NO_CHANGE;
curscr->_lastch[i] = _NO_CHANGE;
}
return( OK );
return OK;
}
/*man-start*********************************************************************
@@ -133,13 +141,13 @@ register int i=0,j=0;
PDC_cursor_on() - Turns on the hardware cursor.
PDCurses Description:
Turns on the hardware curses, it does nothing if it is already on.
Turns on the hardware cursor; does nothing if it is already on.
PDCurses Return Value:
Returns OK upon success, ERR upon failure.
Returns OK upon success, ERR upon failure.
Portability:
PDCurses int PDC_cursor_on( void );
PDCurses int PDC_cursor_on(void);
**man-end**********************************************************************/
@@ -153,13 +161,14 @@ int PDC_cursor_on()
{
PDC_LOG(("PDC_cursor_on() - called\n"));
if (!SP->visible_cursor)
if (!SP->visible_cursor)
{
SP->visible_cursor = TRUE;
PDC_set_cursor_mode((SP->cursor & 0xff00) >> 8,
(SP->cursor & 0x00ff));
}
return( OK );
return OK;
}
/*man-start*********************************************************************
@@ -167,17 +176,16 @@ int PDC_cursor_on()
PDC_cursor_off() - Turns off the hardware cursor.
PDCurses Description:
Turns off the hardware curses, it does nothing if it is already off.
Turns off the hardware cursor; does nothing if it is already off.
PDCurses Return Value:
Returns OK upon success, ERR upon failure.
Returns OK upon success, ERR upon failure.
PDCurses Errors:
ERR will be returned if the hardware cursor
can not be disabled.
ERR will be returned if the hardware cursor can not be disabled.
Portability:
PDCurses int PDC_cursor_off( void );
PDCurses int PDC_cursor_off(void);
**man-end**********************************************************************/
@@ -191,39 +199,42 @@ int PDC_cursor_off()
{
PDC_LOG(("PDC_cursor_off() - called\n"));
if (SP->visible_cursor)
if (SP->visible_cursor)
{
SP->visible_cursor = FALSE;
PDC_set_cursor_mode(32, 33); /* turn it off */
}
return( OK );
return OK;
}
/*man-start*********************************************************************
PDC_fix_cursor() - Fix the cursor start and stop scan lines (if necessary)
PDC_fix_cursor() - Fix the cursor start and stop scan lines
(if necessary)
PDCurses Description:
This is a private PDCurses routine.
This is a private PDCurses routine.
This routine will fix the cursor shape for certain video adapters.
Normally, the values used are correct, but some adapters choke.
The most noticable choke is on a monochrome adapter. The "correct"
scan lines will result in the cursor being set in the middle of the
character cell, rather than at the bottom.
This routine will fix the cursor shape for certain video
adapters. Normally, the values used are correct, but some
adapters choke. The most noticable choke is on a monochrome
adapter. The "correct" scan lines will result in the cursor
being set in the middle of the character cell, rather than at
the bottom.
The passed flag indicates whether the cursor is visible or not.
The passed flag indicates whether the cursor is visible or not.
This only applies to the DOS platform.
This only applies to the DOS platform.
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_fix_cursor( int flag );
PDCurses int PDC_fix_cursor(int flag);
**man-end**********************************************************************/
@@ -236,7 +247,7 @@ int flag;
#endif
/***********************************************************************/
{
return( OK );
return OK;
}
/*man-start*********************************************************************
@@ -244,20 +255,20 @@ int flag;
PDC_gotoxy() - position hardware cursor at (x, y)
PDCurses Description:
This is a private PDCurses routine.
This is a private PDCurses routine.
Moves the physical cursor to the desired address on the
screen. We don't optimize here -- on a PC, it takes more time
to optimize than to do things directly.
Moves the physical cursor to the desired address on the screen.
We don't optimize here -- on a PC, it takes more time to
optimize than to do things directly.
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_gotoxy( int row, int col );
PDCurses int PDC_gotoxy(int row, int col);
**man-end**********************************************************************/
@@ -265,20 +276,20 @@ int flag;
#ifdef HAVE_PROTO
int PDC_gotoxy(int row, int col)
#else
int PDC_gotoxy(row,col)
int PDC_gotoxy(row, col)
int row;
int col;
#endif
/***********************************************************************/
{
PDC_LOG(("PDC_gotoxy() - called: row %d col %d\n",row,col));
PDC_LOG(("PDC_gotoxy() - called: row %d col %d\n", row, col));
#ifdef EMXVIDEO
v_gotoxy (col, row);
v_gotoxy(col, row);
#else
VioSetCurPos (row, col, 0);
VioSetCurPos(row, col, 0);
#endif
return(OK);
return OK;
}
/*man-start*********************************************************************
@@ -286,49 +297,50 @@ int col;
PDC_putc() - Output a character in the current attribute.
PDCurses Description:
This is a private PDCurses routine.
This is a private PDCurses routine.
Outputs character 'chr' to screen in tty fashion. If a colour
mode is active, the character is written with colour 'colour'.
Outputs character 'chr' to screen in tty fashion. If a colour
mode is active, the character is written with colour 'colour'.
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_putc( chtype character, chtype color );
PDCurses int PDC_putc(chtype character, chtype color);
**man-end**********************************************************************/
/***********************************************************************/
#ifdef HAVE_PROTO
int PDC_putc( chtype character, chtype color )
int PDC_putc(chtype character, chtype color)
#else
int PDC_putc(character,color)
int PDC_putc(character, color)
chtype character;
chtype color;
#endif
/***********************************************************************/
{
int curRow=0, curCol=0;
int curRow = 0, curCol = 0;
#ifdef EMXVIDEO
char Cell[2];
#endif
PDC_LOG(("PDC_putc() - called:char=%c attrib=0x%x color=0x%x\n",character & A_CHARTEXT,character & A_ATTRIBUTES,color));
PDC_LOG(("PDC_putc() - called: char=%c attrib=0x%x color=0x%x\n",
character & A_CHARTEXT, character & A_ATTRIBUTES, color));
PDC_get_cursor_pos (&curRow, &curCol);
PDC_get_cursor_pos(&curRow, &curCol);
#ifdef EMXVIDEO
Cell[0] = (char)character;
Cell[1] = (char)color;
v_putline (Cell, curCol, curRow, 1);
v_putline(Cell, curCol, curRow, 1);
#else
VioWrtTTY ((PCH)&character, 1, 0);
VioWrtNAttr ((PBYTE)&color, 1, (USHORT)curRow, (USHORT)curCol, 0);
PDC_gotoxy (curRow, curCol);
VioWrtTTY((PCH)&character, 1, 0);
VioWrtNAttr((PBYTE)&color, 1, (USHORT)curRow, (USHORT)curCol, 0);
PDC_gotoxy(curRow, curCol);
#endif
return( OK );
return OK;
}
/*man-start*********************************************************************
@@ -336,30 +348,30 @@ chtype color;
PDC_putctty() - Output a character and attribute in TTY fashion.
PDCurses Description:
This is a private PDCurses routine.
This is a private PDCurses routine.
Outputs character 'chr' to screen in tty fashion. If a colour
mode is active, the character is written with colour 'colour'.
Outputs character 'chr' to screen in tty fashion. If a colour
mode is active, the character is written with colour 'colour'.
This function moves the physical cursor after writing so the
screen will scroll if necessary.
This function moves the physical cursor after writing so the
screen will scroll if necessary.
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_putctty( chtype character, chtype color );
PDCurses int PDC_putctty(chtype character, chtype color);
**man-end**********************************************************************/
/***********************************************************************/
#ifdef HAVE_PROTO
int PDC_putctty( chtype character, chtype color )
int PDC_putctty(chtype character, chtype color)
#else
int PDC_putctty(character,color)
int PDC_putctty(character, color)
chtype character;
chtype color;
#endif
@@ -369,15 +381,15 @@ chtype color;
PDC_LOG(("PDC_putctty() - called\n"));
PDC_get_cursor_pos (&curRow, &curCol);
PDC_get_cursor_pos(&curRow, &curCol);
#ifdef EMXVIDEO
v_attrib (color);
v_putc (character);
v_attrib(color);
v_putc(character);
#else
VioWrtTTY ((PCH)&character, 1, 0);
VioWrtNAttr ((PBYTE)&color, 1, (USHORT)curRow, (USHORT)curCol, 0);
VioWrtTTY((PCH)&character, 1, 0);
VioWrtNAttr((PBYTE)&color, 1, (USHORT)curRow, (USHORT)curCol, 0);
#endif
return( OK );
return OK;
}
/*man-start*********************************************************************
@@ -385,27 +397,29 @@ chtype color;
PDC_scroll() - low level screen scroll
PDCurses Description:
Scrolls a window in the current page up or down. Urow, lcol,
lrow, rcol are the window coordinates. Lines is the number of
lines to scroll. If 0, clears the window, if < 0 scrolls down,
if > 0 scrolls up. Blanks areas that are left, and sets
character attributes to attr. If in a colour graphics mode,
fills them with the colour 'attr' instead.
Scrolls a window in the current page up or down. Urow, lcol,
lrow, rcol are the window coordinates. Lines is the number of
lines to scroll. If 0, clears the window, if < 0 scrolls down,
if > 0 scrolls up. Blanks areas that are left, and sets
character attributes to attr. If in a colour graphics mode,
fills them with the colour 'attr' instead.
PDCurses Return Value:
The PDC_scroll() function returns OK on success otherwise ERR is returned.
The PDC_scroll() function returns OK on success otherwise ERR is
returned.
Portability:
PDCurses int PDC_scroll( int urow, int lcol, int rcol,
int nlines, chtype attr );
PDCurses int PDC_scroll(int urow, int lcol, int rcol,
int nlines, chtype attr);
**man-end**********************************************************************/
/***********************************************************************/
#ifdef HAVE_PROTO
int PDC_scroll(int urow, int lcol, int lrow, int rcol, int nlines, chtype attr)
int PDC_scroll(int urow, int lcol, int lrow, int rcol,
int nlines, chtype attr)
#else
int PDC_scroll(urow,lcol,lrow,rcol,nlines,attr)
int PDC_scroll(urow, lcol, lrow, rcol, nlines, attr)
int urow;
int lcol;
int lrow;
@@ -416,34 +430,37 @@ chtype attr;
/***********************************************************************/
{
extern unsigned char atrtab[MAX_ATRTAB];
int phys_attr=chtype_attr(attr);
int phys_attr = chtype_attr(attr);
#ifndef EMXVIDEO
USHORT ch=(phys_attr | SP->blank);
USHORT ch = (phys_attr | SP->blank);
#endif
PDC_LOG(("PDC_scroll() - called: urow %d lcol %d lrow %d rcol %d nlines %d\n",urow,lcol,lrow,rcol,nlines));
PDC_LOG(("PDC_scroll() - called: urow %d lcol %d lrow %d rcol %d nlines %d\n",
urow, lcol, lrow, rcol, nlines));
#ifdef EMXVIDEO
v_attrib (phys_attr);
v_attrib(phys_attr);
if (nlines > 0)
v_scroll (lcol, urow, rcol, lrow, nlines, V_SCROLL_UP);
v_scroll(lcol, urow, rcol, lrow, nlines, V_SCROLL_UP);
else
if (nlines < 0)
v_scroll (lcol, urow, rcol, lrow, -nlines, V_SCROLL_DOWN);
v_scroll(lcol, urow, rcol, lrow, -nlines,
V_SCROLL_DOWN);
else /* this clears the whole screen */
v_scroll (lcol, urow, rcol, lrow, -1, V_SCROLL_CLEAR);
v_scroll(lcol, urow, rcol, lrow, -1, V_SCROLL_CLEAR);
#else
if (nlines > 0)
VioScrollUp(urow, lcol, lrow, rcol, nlines, (PBYTE)&ch, 0);
else
if (nlines < 0)
VioScrollDn(urow, lcol, lrow, rcol, nlines, (PBYTE)&ch, 0);
else
/* this clears the whole screen ?? */
VioScrollDn(urow, lcol, lrow, rcol, nlines,
(PBYTE)&ch, 0);
else /* this clears the whole screen ?? */
VioScrollUp(0, 0, -1, -1, -1, (PBYTE)&ch, 0);
#endif
return(OK);
return OK;
}
/*man-start*********************************************************************
@@ -451,95 +468,91 @@ chtype attr;
PDC_transform_line() - display a physical line of the screen
PDCurses Description:
This is a private PDCurses function.
This is a private PDCurses function.
Updates the given physical line to look like the corresponding
line in _curscr.
Updates the given physical line to look like the corresponding
line in _curscr.
PDCurses Return Value:
This routine returns TRUE if a premature refresh end
is allowed, and there is an input character pending. Otherwise,
FALSE is returned.
This routine returns TRUE if a premature refresh end is allowed,
and there is an input character pending. Otherwise, FALSE is
returned.
PDCurses Errors:
No errors are defined for this routine.
No errors are defined for this routine.
Portability:
PDCurses bool PDC_transform_line( int lineno );
PDCurses bool PDC_transform_line(int lineno);
**man-end**********************************************************************/
/***********************************************************************/
#ifdef HAVE_PROTO
bool PDC_transform_line(register int lineno)
bool PDC_transform_line(int lineno)
#else
bool PDC_transform_line(lineno)
register int lineno;
int lineno;
#endif
/***********************************************************************/
{
register chtype* dstp=NULL;
register chtype* srcp=NULL;
chtype *srcp;
int j, x, endx, len;
int x=0;
int endx=0;
int len=0;
extern unsigned char atrtab[MAX_ATRTAB];
unsigned short temp_line[256]; /* this should be enough for the maximum width of a screen. MH-920715 */
unsigned short chr=0;
unsigned short* ch=NULL;
/* this should be enough for the maximum width of a screen. */
register int j=0;
bool rc=FALSE;
unsigned short temp_line[256];
unsigned short chr;
unsigned short *ch;
PDC_LOG(("PDC_transform_line() - called: line %d\n",lineno));
PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno));
if (curscr == (WINDOW *)NULL)
return( FALSE );
return FALSE;
x = curscr->_firstch[lineno];
endx = curscr->_lastch[lineno];
dstp = curscr->_y[lineno] + x;
srcp = curscr->_y[lineno] + x;
len = endx-x+1;
len = endx - x + 1;
ch = temp_line; /* now have ch pointing to area to contain real attributes. MH-920715 */
/* now have ch pointing to area to contain real attributes.
MH-920715 */
/* replace the attribute part of the chtype with the actual colour value */
/* replacing the number that points to the actual colour value. */
ch = temp_line;
for (j=0;j<len;j++) /* for each chtype in the line... */
{
chr = *(srcp+j) & A_CHARTEXT;
temp_line[j] = chtype_attr(*(srcp+j)) | chr;
}
/* replace the attribute part of the chtype with the actual colour value */
/* replacing the number that points to the actual colour value. */
/* for each chtype in the line... */
for (j = 0; j < len; j++)
{
chr = srcp[j] & A_CHARTEXT;
temp_line[j] = chtype_attr(srcp[j]) | chr;
}
if (SP->direct_video)
{
#ifdef EMXVIDEO
v_putline ((char*)ch, x, lineno, len);
v_putline((char*)ch, x, lineno, len);
#else
VioWrtCellStr ((PCH)ch, (USHORT)(len*sizeof(unsigned short)), (USHORT)lineno, (USHORT)x, 0);
VioWrtCellStr((PCH)ch, (USHORT)(len * sizeof(unsigned short)),
(USHORT)lineno, (USHORT)x, 0);
#endif
}
else
{
for (; x <= endx; x++)
{
PDC_gotoxy(lineno, x);
PDC_putc( (*ch & A_CHARTEXT),(*ch & A_ATTRIBUTES) >> 8 );
PDC_putc((*ch & A_CHARTEXT),
(*ch & A_ATTRIBUTES) >> 8);
ch++;
}
}
curscr->_firstch[lineno] = _NO_CHANGE;
curscr->_lastch[lineno] = _NO_CHANGE;
if (SP->refrbrk && (SP->cbreak || SP->raw_inp))
{
rc = PDC_breakout();
if(rc)
return(TRUE);
}
return(FALSE);
if (SP->refrbrk && (SP->cbreak || SP->raw_inp) && PDC_breakout())
return TRUE;
return FALSE;
}

View File

@@ -19,12 +19,12 @@
*/
#define CURSES_LIBRARY 1
#ifdef HAVE_CONFIG_H
# include <config.h>
# include <config.h>
#endif
#include <curses.h>
#ifdef PDCDEBUG
char *rcsid_PDCgetsc = "$Id: pdcgetsc.c,v 1.7 2006/01/03 19:54:29 wmcbrine Exp $";
char *rcsid_PDCgetsc = "$Id: pdcgetsc.c,v 1.8 2006/01/08 11:53:42 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
@@ -32,21 +32,21 @@ char *rcsid_PDCgetsc = "$Id: pdcgetsc.c,v 1.7 2006/01/03 19:54:29 wmcbrine Exp
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**********************************************************************/
@@ -54,14 +54,14 @@ char *rcsid_PDCgetsc = "$Id: pdcgetsc.c,v 1.7 2006/01/03 19:54:29 wmcbrine Exp
int PDC_get_cursor_pos(int *row, int *col)
/***********************************************************************/
{
PDC_LOG(("PDC_get_cursor_pos() - called\n"));
PDC_LOG(("PDC_get_cursor_pos() - called\n"));
#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*********************************************************************
@@ -69,20 +69,20 @@ int PDC_get_cursor_pos(int *row, int *col)
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**********************************************************************/
@@ -91,19 +91,20 @@ 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
PDC_LOG(("PDC_get_cur_col() - called\n"));
PDC_LOG(("PDC_get_cur_col() - called\n"));
/* 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*********************************************************************
@@ -111,20 +112,20 @@ int PDC_get_cur_col(void)
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**********************************************************************/
@@ -133,19 +134,20 @@ 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
PDC_LOG(("PDC_get_cur_row() - called\n"));
PDC_LOG(("PDC_get_cur_row() - called\n"));
/* 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*********************************************************************
@@ -153,19 +155,20 @@ int PDC_get_cur_row(void)
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**********************************************************************/
@@ -174,20 +177,22 @@ 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];
PDC_LOG(("PDC_get_attribute() - called\n"));
PDC_LOG(("PDC_get_attribute() - called\n"));
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*********************************************************************
@@ -195,19 +200,19 @@ int PDC_get_attribute(void)
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**********************************************************************/
@@ -216,32 +221,30 @@ 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;
PDC_LOG(("PDC_get_columns() - called\n"));
PDC_LOG(("PDC_get_columns() - called\n"));
#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");
env_cols = (char *)getenv("COLS");
if (env_cols != (char *)NULL)
{
cols = min(atoi(env_cols),cols);
}
if (env_cols != (char *)NULL)
cols = min(atoi(env_cols), cols);
PDC_LOG(("PDC_get_columns() - returned: cols %d\n",cols));
PDC_LOG(("PDC_get_columns() - returned: cols %d\n", cols));
return(cols);
return cols;
}
/*man-start*********************************************************************
@@ -249,17 +252,18 @@ int PDC_get_columns(void)
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 in the range 0 through
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**********************************************************************/
@@ -268,23 +272,22 @@ 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;
PDC_LOG(("PDC_get_cursor_mode() - called\n"));
PDC_LOG(("PDC_get_cursor_mode() - called\n"));
#ifdef EMXVIDEO
v_getctype (&curstart, &curend);
cmode = ((curstart << 8) | (curend));
v_getctype(&curstart, &curend);
return (curstart << 8) | curend;
#else
VioGetCurType (&cursorInfo, 0);
/* I am not sure about this JGB */
cmode = ((cursorInfo.yStart << 8) | (cursorInfo.cEnd));
VioGetCurType (&cursorInfo, 0);
/* I am not sure about this JGB */
return (cursorInfo.yStart << 8) | cursorInfo.cEnd;
#endif
return(cmode);
}
/*man-start*********************************************************************
@@ -292,19 +295,19 @@ int PDC_get_cursor_mode(void)
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**********************************************************************/
@@ -313,21 +316,22 @@ int PDC_get_font(void)
/***********************************************************************/
{
#ifdef EMXVIDEO
int retval=0;
int retval;
#else
VIOMODEINFO modeInfo={0};
VIOMODEINFO modeInfo = {0};
#endif
PDC_LOG(("PDC_get_font() - called\n"));
PDC_LOG(("PDC_get_font() - called\n"));
#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
}
@@ -336,19 +340,19 @@ int PDC_get_font(void)
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**********************************************************************/
@@ -357,31 +361,33 @@ 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;
PDC_LOG(("PDC_get_rows() - called\n"));
PDC_LOG(("PDC_get_rows() - called\n"));
/* 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 */
/* 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");
PDC_LOG(("PDC_get_rows() - returned: rows %d\n",rows));
if (env_rows != (char *)NULL)
rows = min(atoi(env_rows), rows);
return(rows);
PDC_LOG(("PDC_get_rows() - returned: rows %d\n", rows));
return rows;
}
/*man-start*********************************************************************
@@ -389,34 +395,35 @@ int PDC_get_rows(void)
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 EMXVIDEO 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**********************************************************************/
/***********************************************************************/
#if defined(EMXVIDEO)
int PDC_get_scrn_mode( void )
int PDC_get_scrn_mode(void)
#else
int PDC_get_scrn_mode( VIOMODEINFO *modeinfo )
int PDC_get_scrn_mode(VIOMODEINFO *modeinfo)
#endif
/***********************************************************************/
{
PDC_LOG(("PDC_get_scrn_mode() - called\n"));
PDC_LOG(("PDC_get_scrn_mode() - called\n"));
#ifdef EMXVIDEO
return(ERR);
return ERR;
#else
VioGetMode ( modeinfo, 0 );
return(OK);
VioGetMode(modeinfo, 0);
return OK;
#endif
}
@@ -425,38 +432,38 @@ int PDC_get_scrn_mode( VIOMODEINFO *modeinfo )
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**********************************************************************/
/***********************************************************************/
#if defined(EMXVIDEO)
int PDC_query_adapter_type( void )
int PDC_query_adapter_type(void)
#else
int PDC_query_adapter_type( VIOCONFIGINFO *configinfo )
int PDC_query_adapter_type(VIOCONFIGINFO *configinfo)
#endif
/***********************************************************************/
{
PDC_LOG(("PDC_query_adapter_type() - called\n"));
PDC_LOG(("PDC_query_adapter_type() - called\n"));
#ifdef EMXVIDEO
return (v_hardware() == V_MONOCHROME) ? _UNIX_MONO : _UNIX_COLOR;
return (v_hardware() == V_MONOCHROME) ? _UNIX_MONO : _UNIX_COLOR;
#else
VioGetConfig( 0, configinfo, 0 );
return(OK);
VioGetConfig(0, configinfo, 0);
return OK;
#endif
}

File diff suppressed because it is too large Load Diff

View File

@@ -19,42 +19,42 @@
*/
#define CURSES_LIBRARY 1
#ifdef HAVE_CONFIG_H
# include <config.h>
# include <config.h>
#endif
#include <curses.h>
#ifdef PDCDEBUG
char *rcsid_PDCprint = "$Id: pdcprint.c,v 1.4 2006/01/03 07:34:43 wmcbrine Exp $";
char *rcsid_PDCprint = "$Id: pdcprint.c,v 1.5 2006/01/08 11:53:42 wmcbrine Exp $";
#endif
#if !defined (CURSES__32BIT__) && !defined(CSET2) && !defined(MSC) &&!defined(TC)
#define INCL_DOS
#include <bsedos.h>
#if !defined(CURSES__32BIT__) && !defined(CSET2) && !defined(MSC) &&!defined(TC)
# define INCL_DOS
# include <bsedos.h>
#endif
char Printer[]="LPT1:";
char Printer[] = "LPT1:";
/*man-start*********************************************************************
PDC_print() - Provides primitive access to the BIOS printer functions
PDCurses Description:
This is a private PDCurses routine.
This is a private PDCurses routine.
Implements write/init/read printer services at the BIOS level.
Implements write/init/read printer services at the BIOS level.
This provides the basic support that PDCurses needs to dump the
contents of windows or pads to the printer attached to the BIOS
printer port.
This provides the basic support that PDCurses needs to dump the
contents of windows or pads to the printer attached to the BIOS
printer port.
PDCurses Return Value:
See the BIOS INT 0x17 specifications.
See the BIOS INT 0x17 specifications.
PDCurses Errors:
See the BIOS INT 0x17 specifications.
See the BIOS INT 0x17 specifications.
Portability:
PDCurses int PDC_print( int cmd, int byte, int port );
PDCurses int PDC_print(int cmd, int byte, int port);
**man-end**********************************************************************/
@@ -62,27 +62,30 @@ char Printer[]="LPT1:";
#ifdef HAVE_PROTO
int PDC_print(int cmd, int byte, int port)
#else
int PDC_print(cmd,byte,port)
int PDC_print(cmd, byte, port)
int cmd;
int byte;
int port;
#endif
/***********************************************************************/
{
#if !defined (CURSES__32BIT__) && !defined(CSET2) && !defined(TC)
#if !defined(CURSES__32BIT__) && !defined(CSET2) && !defined(TC)
HFILE Lpt;
USHORT Action=0;
USHORT NoWritten=0;
USHORT Action = 0;
USHORT NoWritten = 0;
#endif
PDC_LOG(("PDC_print() - called\n"));
#if !defined (CURSES__32BIT__) && !defined(CSET2) && !defined(TC)
if (DosOpen((PSZ)Printer, &Lpt, &Action, 0,0,0,0,0) != 0)
return(ERR);
DosWrite(Lpt,&byte,1,&NoWritten);
if (DosOpen((PSZ)Printer, &Lpt, &Action, 0, 0, 0, 0, 0) != 0)
return ERR;
DosWrite(Lpt, &byte, 1, &NoWritten);
DosClose(Lpt);
return(NoWritten == 1);
return (NoWritten == 1);
#else
return (OK);
return OK;
#endif
}

View File

@@ -19,23 +19,23 @@
*/
#define CURSES_LIBRARY 1
#ifdef HAVE_CONFIG_H
# include <config.h>
# include <config.h>
#endif
#define INCL_DOSMISC
#include <curses.h>
#ifdef PDCDEBUG
char *rcsid_PDCscrn = "$Id: pdcscrn.c,v 1.6 2006/01/03 19:54:29 wmcbrine Exp $";
char *rcsid_PDCscrn = "$Id: pdcscrn.c,v 1.7 2006/01/08 11:53:42 wmcbrine 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*********************************************************************
@@ -43,16 +43,17 @@ char *rcsid_PDCscrn = "$Id: pdcscrn.c,v 1.6 2006/01/03 19:54:29 wmcbrine Exp $"
PDC_scr_close() - Internal low-level binding to close the physical screen
PDCurses Description:
This is a nop for the DOS platform.
This is a nop for the DOS platform.
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 DOS platform will never fail.
Portability:
PDCurses int PDC_scr_close( void );
PDCurses int PDC_scr_close(void);
**man-end**********************************************************************/
@@ -60,29 +61,31 @@ char *rcsid_PDCscrn = "$Id: pdcscrn.c,v 1.6 2006/01/03 19:54:29 wmcbrine Exp $"
int PDC_scr_close(void)
/***********************************************************************/
{
char *ptr;
char *ptr;
PDC_LOG(("PDC_scr_close() - called\n"));
PDC_LOG(("PDC_scr_close() - called\n"));
#ifdef EMXVIDEO
ptr = getenv("PDC_RESTORE_SCREEN");
ptr = getenv("PDC_RESTORE_SCREEN");
#else
if ( DosScanEnv( "PDC_RESTORE_SCREEN", (PSZ *)&ptr ) )
ptr = NULL;
if (DosScanEnv("PDC_RESTORE_SCREEN", (PSZ *)&ptr))
ptr = NULL;
#endif
if (ptr != NULL)
{
if (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);
v_putline(saved_screen, 0, 0, saved_lines * saved_cols);
#else
VioWrtCellStr(saved_screen,saved_lines*saved_cols*2,0,0,(HVIO)NULL);
VioWrtCellStr(saved_screen, saved_lines * saved_cols * 2,
0, 0, (HVIO)NULL);
#endif
free(saved_screen);
saved_screen = NULL;
}
return( OK );
free(saved_screen);
saved_screen = NULL;
}
return OK;
}
/*man-start*********************************************************************
@@ -90,39 +93,40 @@ int PDC_scr_close(void)
PDC_scrn_modes_equal() - Decide if two screen modes are equal
PDCurses Description:
Mainly required for OS/2. It decides if two screen modes
(VIOMODEINFO structure) are equal. Under DOS it just compares
two integers
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 )
#if !defined(EMXVIDEO)
bool PDC_scrn_modes_equal(VIOMODEINFO mode1, VIOMODEINFO mode2)
#else
bool PDC_scrn_modes_equal(int mode1, int mode2)
#endif
/***********************************************************************/
{
PDC_LOG(("PDC_scrn_modes_equal() - called\n"));
PDC_LOG(("PDC_scrn_modes_equal() - called\n"));
#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) );
#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));
#else
return (mode1 == mode2);
return (mode1 == mode2);
#endif
}
@@ -131,16 +135,17 @@ bool PDC_scrn_modes_equal(int mode1, int mode2)
PDC_scr_open() - Internal low-level binding to open the physical screen
PDCurses Description:
This is a NOP for the DOS platform.
This is a NOP for the DOS platform.
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 DOS platform will never fail.
Portability:
PDCurses int PDC_scr_open( SCREEN* internal, bool echo );
PDCurses int PDC_scr_open(SCREEN *internal, bool echo);
**man-end**********************************************************************/
@@ -148,102 +153,107 @@ bool PDC_scrn_modes_equal(int mode1, int mode2)
int PDC_scr_open(SCREEN *internal, bool echo)
/***********************************************************************/
{
char *ptr;
#if !defined( EMXVIDEO )
USHORT totchars=0;
char *ptr;
#if !defined(EMXVIDEO)
USHORT totchars;
#endif
PDC_LOG(("PDC_scr_open() - called. internal: %x, echo: %d\n", internal, echo));
PDC_LOG(("PDC_scr_open() - called. internal: %x, echo: %d\n",
internal, 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;
internal->refrbrk = FALSE; /* no 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->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->refrbrk = FALSE; /* no 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( &internal->adapter );
(void)PDC_get_scrn_mode( &internal->scrnmode );
(void)PDC_get_keyboard_info( &internal->kbdinfo );
PDC_query_adapter_type(&internal->adapter);
PDC_get_scrn_mode(&internal->scrnmode);
PDC_get_keyboard_info(&internal->kbdinfo);
PDC_LOG(("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));
PDC_LOG(("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));
/*
* Now set the keyboard into binary mode
*/
(void)PDC_set_keyboard_binary();
#else
internal->adapter = PDC_query_adapter_type();
if ( internal->adapter == _UNIX_MONO )
internal->mono = TRUE;
#endif
/* Now set the keyboard into binary mode */
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
ptr = getenv("PDC_RESTORE_SCREEN");
PDC_set_keyboard_binary();
#else
if ( DosScanEnv( "PDC_RESTORE_SCREEN", (PSZ *)&ptr ) )
ptr = NULL;
internal->adapter = PDC_query_adapter_type();
if (internal->adapter == _UNIX_MONO)
internal->mono = TRUE;
#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
}
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
ptr = getenv("PDC_PRESERVE_SCREEN");
ptr = getenv("PDC_RESTORE_SCREEN");
#else
if ( DosScanEnv( "PDC_PRESERVE_SCREEN", (PSZ *)&ptr ) )
ptr = NULL;
if (DosScanEnv("PDC_RESTORE_SCREEN", (PSZ *)&ptr))
ptr = NULL;
#endif
if (ptr != NULL)
internal->_preserve = TRUE;
else
internal->_preserve = FALSE;
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;
return( OK );
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
}
#ifdef EMXVIDEO
ptr = getenv("PDC_PRESERVE_SCREEN");
#else
if (DosScanEnv("PDC_PRESERVE_SCREEN", (PSZ *)&ptr))
ptr = NULL;
#endif
internal->_preserve = (ptr != NULL);
return OK;
}
/*man-start*********************************************************************
@@ -251,19 +261,20 @@ int PDC_scr_open(SCREEN *internal, bool echo)
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**********************************************************************/
@@ -272,46 +283,53 @@ int PDC_resize_screen(int nlines, int ncols)
/***********************************************************************/
{
#ifndef EMXVIDEO
VIOMODEINFO modeInfo={0};
USHORT result=0;
VIOMODEINFO modeInfo = {0};
USHORT result;
#endif
PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",nlines,ncols));
PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",
nlines, ncols));
#ifdef EMXVIDEO
return (ERR);
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);
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 )
int PDC_reset_shell_mode(void)
/***********************************************************************/
{
PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
PDC_set_keyboard_default();
return OK;
PDC_set_keyboard_default();
return OK;
}
/***********************************************************************/
int PDC_reset_prog_mode( void )
int PDC_reset_prog_mode(void)
/***********************************************************************/
{
PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
PDC_set_keyboard_binary();
return OK;
PDC_set_keyboard_binary();
return OK;
}
#endif

View File

@@ -19,16 +19,16 @@
*/
#define CURSES_LIBRARY 1
#ifdef HAVE_CONFIG_H
# include <config.h>
# include <config.h>
#endif
#include <curses.h>
#ifdef HAVE_STRING_H
# include <string.h>
# include <string.h>
#endif
#ifdef PDCDEBUG
char *rcsid_PDCsetsc = "$Id: pdcsetsc.c,v 1.6 2006/01/03 19:54:29 wmcbrine Exp $";
char *rcsid_PDCsetsc = "$Id: pdcsetsc.c,v 1.7 2006/01/08 11:53:42 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
@@ -36,18 +36,19 @@ char *rcsid_PDCsetsc = "$Id: pdcsetsc.c,v 1.6 2006/01/03 19:54:29 wmcbrine Exp
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.
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**********************************************************************/
@@ -56,18 +57,20 @@ int PDC_set_80x25(void)
/***********************************************************************/
{
#ifndef EMXVIDEO
VIOMODEINFO modeInfo={0};
VIOMODEINFO modeInfo = {0};
#endif
PDC_LOG(("PDC_set_80x25() - called\n"));
PDC_LOG(("PDC_set_80x25() - called\n"));
#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*********************************************************************
@@ -75,41 +78,44 @@ int PDC_set_80x25(void)
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**********************************************************************/
/***********************************************************************/
int PDC_set_cursor_mode( int startrow, int endrow )
int PDC_set_cursor_mode(int startrow, int endrow)
/***********************************************************************/
{
#ifndef EMXVIDEO
VIOCURSORINFO cursorInfo={0};
VIOCURSORINFO cursorInfo = {0};
#endif
PDC_LOG(("PDC_set_cursor_mode() - called: startrow %d endrow %d\n",startrow,endrow));
PDC_LOG(("PDC_set_cursor_mode() - called: startrow %d endrow %d\n",
startrow, endrow));
#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
}
@@ -118,22 +124,22 @@ int PDC_set_cursor_mode( int startrow, int endrow )
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.
Portability:
PDCurses int PDC_set_font( int size );
PDCurses int PDC_set_font(int size);
**man-end**********************************************************************/
@@ -142,27 +148,31 @@ int PDC_set_font(int size)
/***********************************************************************/
{
#ifndef EMXVIDEO
VIOMODEINFO modeInfo={0};
VIOMODEINFO modeInfo = {0};
#endif
PDC_LOG(("PDC_set_font() - called\n"));
PDC_LOG(("PDC_set_font() - called\n"));
#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*********************************************************************
@@ -170,22 +180,22 @@ int PDC_set_font(int size)
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.
Portability:
PDCurses int PDC_set_rows( int rows );
PDCurses int PDC_set_rows(int rows);
**man-end**********************************************************************/
@@ -194,24 +204,28 @@ int PDC_set_rows(int rows)
/***********************************************************************/
{
#ifndef EMXVIDEO
VIOMODEINFO modeInfo={0};
USHORT result=0;
VIOMODEINFO modeInfo = {0};
USHORT result;
#endif
PDC_LOG(("PDC_set_rows() - called\n"));
PDC_LOG(("PDC_set_rows() - called\n"));
#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
}
@@ -220,94 +234,97 @@ int PDC_set_rows(int rows)
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 )
#if !defined(EMXVIDEO)
int PDC_set_scrn_mode(VIOMODEINFO new_mode)
#else
int PDC_set_scrn_mode(int new_mode)
#endif
/***********************************************************************/
{
PDC_LOG(("PDC_set_scrn_mode() - called\n"));
PDC_LOG(("PDC_set_scrn_mode() - called\n"));
#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
}
/***********************************************************************/
int PDC_curs_set(int visibility)
/***********************************************************************/
{
#ifndef EMXVIDEO
VIOCURSORINFO pvioCursorInfo;
VIOCURSORINFO pvioCursorInfo;
#endif
int start=0,end=0;
int ret_vis=0,hidden=0;
int ret_vis, hidden = 0, start = 0, end = 0;
PDC_LOG(("PDC_curs_set() - called: visibility=%d\n",visibility));
PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
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;
}
#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*********************************************************************
@@ -315,24 +332,25 @@ int PDC_curs_set(int visibility)
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**********************************************************************/
/***********************************************************************/
void PDC_set_title(char *title)
/***********************************************************************/
{
PDC_LOG(("PDC_set_title() - called:<%s>\n",title));
PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
return;
return;
}

View File

@@ -22,145 +22,148 @@
#include <curses.h>
#ifdef PDCDEBUG
char *rcsid_PDCclip = "$Id: pdcclip.c,v 1.5 2006/01/03 07:34:43 wmcbrine Exp $";
char *rcsid_PDCclip = "$Id: pdcclip.c,v 1.6 2006/01/08 11:53:43 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
PDC_getclipboard() - Gets the contents of the clipboard
PDCurses Description:
This is a PDCurses only routine.
This is a PDCurses only routine.
Gets the textual contents of the system's clipboard. This
function returns the contents of the clipboard in the contents
argument. It is the responsibilitiy of the caller to free the
memory returned with the PDC_freeclipboard() call. The length of the
clipboard contents is returned in the length argument.
Gets the textual contents of the system's clipboard. This
function returns the contents of the clipboard in the contents
argument. It is the responsibilitiy of the caller to free the
memory returned with the PDC_freeclipboard() call. The length
of the clipboard contents is returned in the length argument.
PDCurses Return Value:
indicator of success/failure of call.
PDC_CLIP_SUCCESS the call was successful
PDC_CLIP_ACCESS_ERROR an error occured while accessing the
clipboard
PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
the clipboard contents
PDC_CLIP_EMPTY the clipboard contains no text
indicator of success/failure of call.
PDC_CLIP_SUCCESS the call was successful
PDC_CLIP_ACCESS_ERROR an error occured while accessing the
clipboard
PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
the clipboard contents
PDC_CLIP_EMPTY the clipboard contains no text
Portability:
PDCurses int PDC_getclipboard( char **contents, long *length );
PDCurses int PDC_getclipboard(char **contents, long *length);
**man-end**********************************************************************/
int PDC_CDECL PDC_getclipboard(char **contents, long *length)
int PDC_CDECL PDC_getclipboard(char **contents, long *length)
{
HANDLE handle;
long len;
HANDLE handle;
long len;
PDC_LOG(("PDC_getclipboard() - called\n"));
PDC_LOG(("PDC_getclipboard() - called\n"));
if (OpenClipboard(NULL) == 0)
{
return PDC_CLIP_ACCESS_ERROR;
}
handle = GetClipboardData( CF_TEXT );
if (handle == NULL)
{
CloseClipboard();
return PDC_CLIP_EMPTY;
}
if (OpenClipboard(NULL) == 0)
return PDC_CLIP_ACCESS_ERROR;
len = strlen((char *)handle);
*contents = (char *)GlobalAlloc(GMEM_FIXED,len+1);
if (!*contents)
{
CloseClipboard();
return PDC_CLIP_MEMORY_ERROR;
}
strcpy((char *)*contents,(char *)handle);
*length = len;
CloseClipboard();
handle = GetClipboardData(CF_TEXT);
if (handle == NULL)
{
CloseClipboard();
return PDC_CLIP_EMPTY;
}
return( PDC_CLIP_SUCCESS );
len = strlen((char *)handle);
*contents = (char *)GlobalAlloc(GMEM_FIXED, len + 1);
if (!*contents)
{
CloseClipboard();
return PDC_CLIP_MEMORY_ERROR;
}
strcpy((char *)*contents, (char *)handle);
*length = len;
CloseClipboard();
return PDC_CLIP_SUCCESS;
}
/*man-start*********************************************************************
PDC_setclipboard() - Sets the contents of the clipboard
PDCurses Description:
This is a PDCurses only routine.
This is a PDCurses-only routine.
Copies the supplied text into the system's clipboard, emptying
the clipboard prior to the copy.
Copies the supplied text into the system's clipboard, emptying
the clipboard prior to the copy.
PDCurses Return Value:
indicator of success/failure of call.
PDC_CLIP_SUCCESS the call was successful
PDC_CLIP_ACCESS_ERROR an error occured while accessing the
clipboard
indicator of success/failure of call.
PDC_CLIP_SUCCESS the call was successful
PDC_CLIP_ACCESS_ERROR an error occured while accessing the
clipboard
Portability:
PDCurses int PDC_getclipboard( char *contents, long length );
PDCurses int PDC_getclipboard(char *contents, long length);
**man-end**********************************************************************/
int PDC_CDECL PDC_setclipboard(char *contents, long length)
int PDC_CDECL PDC_setclipboard(char *contents, long length)
{
HGLOBAL ptr1;
LPTSTR ptr2;
HGLOBAL ptr1;
LPTSTR ptr2;
PDC_LOG(("PDC_setclipboard() - called\n"));
PDC_LOG(("PDC_setclipboard() - called\n"));
if (OpenClipboard(NULL) == 0)
{
return PDC_CLIP_ACCESS_ERROR;
}
ptr1 = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, (length+1)*sizeof(TCHAR) );
if (!ptr1)
{
return PDC_CLIP_MEMORY_ERROR;
}
if (OpenClipboard(NULL) == 0)
return PDC_CLIP_ACCESS_ERROR;
ptr2 = GlobalLock(ptr1);
memcpy((char *)ptr2, (char *)contents, length+1 );
GlobalUnlock(ptr1);
EmptyClipboard();
if (SetClipboardData(CF_TEXT, ptr1) == NULL)
{
GlobalFree(ptr1);
return PDC_CLIP_ACCESS_ERROR;
}
CloseClipboard();
GlobalFree(ptr1);
return PDC_CLIP_SUCCESS;
ptr1 = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
(length + 1) * sizeof(TCHAR));
if (!ptr1)
return PDC_CLIP_MEMORY_ERROR;
ptr2 = GlobalLock(ptr1);
memcpy((char *)ptr2, (char *)contents, length + 1);
GlobalUnlock(ptr1);
EmptyClipboard();
if (SetClipboardData(CF_TEXT, ptr1) == NULL)
{
GlobalFree(ptr1);
return PDC_CLIP_ACCESS_ERROR;
}
CloseClipboard();
GlobalFree(ptr1);
return PDC_CLIP_SUCCESS;
}
/*man-start*********************************************************************
PDC_freeclipboard() - Frees the memory associated with the contents of the clipboard
PDC_freeclipboard() - Frees the memory associated with the contents
of the clipboard
PDCurses Description:
This is a PDCurses only routine.
This is a PDCurses only routine.
Frees the memory allocated by PDC_getclipboard().
Frees the memory allocated by PDC_getclipboard().
PDCurses Return Value:
Always returns PDC_CLIP_SUCCESS
Always returns PDC_CLIP_SUCCESS
Portability:
PDCurses int PDC_freeclipboard( char *contents );
PDCurses int PDC_freeclipboard(char *contents);
**man-end**********************************************************************/
int PDC_CDECL PDC_freeclipboard(char *contents)
int PDC_CDECL PDC_freeclipboard(char *contents)
{
PDC_LOG(("PDC_freeclipboard() - called\n"));
PDC_LOG(("PDC_freeclipboard() - called\n"));
GlobalFree(contents);
return PDC_CLIP_SUCCESS;
GlobalFree(contents);
return PDC_CLIP_SUCCESS;
}
/*man-start*********************************************************************
@@ -168,24 +171,23 @@ int PDC_CDECL PDC_freeclipboard(char *contents)
PDC_clearclipboard() - Clears the contents of the clipboard
PDCurses Description:
This is a PDCurses only routine.
This is a PDCurses only routine.
Clears the internal clipboard.
Clears the internal clipboard.
PDCurses Return Value:
Always returns PDC_CLIP_SUCCESS
Always returns PDC_CLIP_SUCCESS
Portability:
PDCurses int PDC_clearclipboard( void );
PDCurses int PDC_clearclipboard(void);
**man-end**********************************************************************/
int PDC_CDECL PDC_clearclipboard( void )
int PDC_CDECL PDC_clearclipboard(void)
{
PDC_LOG(("PDC_clearclipboard() - called\n"));
PDC_LOG(("PDC_clearclipboard() - called\n"));
EmptyClipboard();
EmptyClipboard();
return PDC_CLIP_SUCCESS;
return PDC_CLIP_SUCCESS;
}

View File

@@ -29,89 +29,87 @@
extern HANDLE hConOut;
#ifdef PDCDEBUG
char *rcsid_PDCdisp = "$Id: pdcdisp.c,v 1.5 2006/01/03 19:54:29 wmcbrine Exp $";
char *rcsid_PDCdisp = "$Id: pdcdisp.c,v 1.6 2006/01/08 11:53:43 wmcbrine Exp $";
#endif
static CHAR_INFO ci[512];
/*man-start*********************************************************************
PDC_clr_update() - Updates the screen with a full redraw.
PDCurses Description:
Updates the screen by clearing it and then redraw it in its
entirety. If SP->refrbrk is TRUE, and there is pending
input characters, the update will be prematurely terminated.
Updates the screen by clearing it and then redraw it in its
entirety. If SP->refrbrk is TRUE, and there is pending
input characters, the update will be prematurely terminated.
PDCurses Return Value:
This routine returns ERR if it is unable to accomplish its task.
This routine returns ERR if it is unable to accomplish its task.
The return value OK is returned if there were no errors.
The return value OK is returned if there were no errors.
PDCurses Errors:
No errors are defined for this function.
No errors are defined for this function.
Portability:
PDCurses int PDC_clr_update( WINDOW* s );
PDCurses int PDC_clr_update(WINDOW *s);
**man-end**********************************************************************/
/***********************************************************************/
int PDC_clr_update(WINDOW *s)
int PDC_clr_update(WINDOW *s)
/***********************************************************************/
{
extern unsigned char atrtab[MAX_ATRTAB];
extern unsigned char atrtab[MAX_ATRTAB];
register int i, j;
register chtype *srcp;
WINDOW *w;
bool rc;
COORD bufSize, bufPos;
SMALL_RECT sr;
int i, j;
chtype *srcp;
COORD bufSize, bufPos;
SMALL_RECT sr;
PDC_LOG(("PDC_clr_update() - called\n"));
PDC_LOG(("PDC_clr_update() - called\n"));
w = curscr;
if (w == (WINDOW *)NULL)
return( ERR );
if (curscr == (WINDOW *)NULL)
return ERR;
#if 0
if (SP->full_redraw)
PDC_clr_scrn(s); /* clear physical screen */
if (SP->full_redraw)
PDC_clr_scrn(s); /* clear physical screen */
#endif
s->_clear = FALSE;
bufPos.X = bufPos.Y = 0;
bufSize.X = COLS;
bufSize.Y = 1;
sr.Left = 0;
sr.Right = COLS - 1;
s->_clear = FALSE;
bufPos.X = bufPos.Y = 0;
bufSize.X = COLS;
bufSize.Y = 1;
sr.Left = 0;
sr.Right = COLS - 1;
for (i = 0; i < LINES; i++) /* update physical screen */
{
if (s != w)
memcpy(w->_y[i], s->_y[i], COLS * sizeof(chtype));
for (i = 0; i < LINES; i++) /* update physical screen */
{
if (s != curscr)
memcpy(curscr->_y[i], s->_y[i], COLS * sizeof(chtype));
srcp = s->_y[i];
srcp = s->_y[i];
sr.Top = i;
sr.Bottom = i;
sr.Top = i;
sr.Bottom = i;
for (j = 0; j < COLS; j++)
{
ci[j].Char.AsciiChar = *(srcp+j) & A_CHARTEXT;
ci[j].Attributes = (chtype_attr(*(srcp+j)) & 0xFF00) >> 8 ;
for (j = 0; j < COLS; j++)
{
ci[j].Char.AsciiChar = srcp[j] & A_CHARTEXT;
ci[j].Attributes =
(chtype_attr(srcp[j]) & 0xFF00) >> 8;
#ifdef HIDE_ATTR
ci[j].Attributes = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
ci[j].Attributes = COLOR_WHITE;
#endif
}
WriteConsoleOutput(hConOut, ci, bufSize, bufPos, &sr);
}
if (SP->refrbrk && (SP->cbreak || SP->raw_inp))
{
rc = PDC_breakout();
if (rc)
break;
}
}
return( OK );
WriteConsoleOutput(hConOut, ci, bufSize, bufPos, &sr);
if (SP->refrbrk && (SP->cbreak || SP->raw_inp)
&& PDC_breakout())
break;
}
return OK;
}
/*man-start*********************************************************************
@@ -119,32 +117,33 @@ int PDC_clr_update(WINDOW *s)
PDC_cursor_on() - Turns on the hardware cursor.
PDCurses Description:
Turns on the hardware curses, it does nothing if it is already on.
Turns on the hardware cursor; does nothing if it is already on.
PDCurses Return Value:
Returns OK upon success, ERR upon failure.
Returns OK upon success, ERR upon failure.
Portability:
PDCurses int PDC_cursor_on( void );
PDCurses int PDC_cursor_on(void);
**man-end**********************************************************************/
/***********************************************************************/
int PDC_cursor_on(void)
int PDC_cursor_on(void)
/***********************************************************************/
{
CONSOLE_CURSOR_INFO cci;
CONSOLE_CURSOR_INFO cci;
PDC_LOG(("PDC_cursor_on() - called\n"));
PDC_LOG(("PDC_cursor_on() - called\n"));
if (!SP->visible_cursor)
{
SP->visible_cursor = TRUE;
GetConsoleCursorInfo(hConOut,&cci);
cci.bVisible = TRUE;
SetConsoleCursorInfo(hConOut,&cci);
}
return( OK );
if (!SP->visible_cursor)
{
SP->visible_cursor = TRUE;
GetConsoleCursorInfo(hConOut, &cci);
cci.bVisible = TRUE;
SetConsoleCursorInfo(hConOut, &cci);
}
return OK;
}
/*man-start*********************************************************************
@@ -152,37 +151,36 @@ int PDC_cursor_on(void)
PDC_cursor_off() - Turns off the hardware cursor.
PDCurses Description:
Turns off the hardware curses, it does nothing if it is already off.
Turns off the hardware cursor; does nothing if it is already off.
PDCurses Return Value:
Returns OK upon success, ERR upon failure.
Returns OK upon success, ERR upon failure.
PDCurses Errors:
ERR will be returned if the hardware cursor
can not be disabled.
ERR will be returned if the hardware cursor can not be disabled.
Portability:
PDCurses int PDC_cursor_off( void );
PDCurses int PDC_cursor_off(void);
**man-end**********************************************************************/
/***********************************************************************/
int PDC_cursor_off(void)
int PDC_cursor_off(void)
/***********************************************************************/
{
CONSOLE_CURSOR_INFO cci;
CONSOLE_CURSOR_INFO cci;
PDC_LOG(("PDC_cursor_off() - called\n"));
PDC_LOG(("PDC_cursor_off() - called\n"));
if (SP->visible_cursor)
{
SP->visible_cursor = FALSE;
GetConsoleCursorInfo(hConOut,&cci);
cci.bVisible = FALSE;
SetConsoleCursorInfo(hConOut,&cci);
}
if (SP->visible_cursor)
{
SP->visible_cursor = FALSE;
GetConsoleCursorInfo(hConOut, &cci);
cci.bVisible = FALSE;
SetConsoleCursorInfo(hConOut, &cci);
}
return( OK );
return OK;
}
/*man-start*********************************************************************
@@ -190,34 +188,35 @@ int PDC_cursor_off(void)
PDC_fix_cursor() - Fix the cursor start and stop scan lines (if necessary)
PDCurses Description:
This is a private PDCurses routine.
This is a private PDCurses routine.
This routine will fix the cursor shape for certain video adapters.
Normally, the values used are correct, but some adapters choke.
The most noticable choke is on a monochrome adapter. The "correct"
scan lines will result in the cursor being set in the middle of the
character cell, rather than at the bottom.
This routine will fix the cursor shape for certain video
adapters. Normally, the values used are correct, but some
adapters choke. The most noticable choke is on a monochrome
adapter. The "correct" scan lines will result in the cursor
being set in the middle of the character cell, rather than at
the bottom.
The passed flag indicates whether the cursor is visible or not.
The passed flag indicates whether the cursor is visible or not.
This only applies to the DOS platform.
This only applies to the DOS platform.
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_fix_cursor( int flag );
PDCurses int PDC_fix_cursor(int flag);
**man-end**********************************************************************/
/***********************************************************************/
int PDC_fix_cursor(int flag)
int PDC_fix_cursor(int flag)
/***********************************************************************/
{
return(OK);
return OK;
}
/*man-start*********************************************************************
@@ -225,36 +224,38 @@ int PDC_fix_cursor(int flag)
PDC_gotoxy() - position hardware cursor at (x, y)
PDCurses Description:
This is a private PDCurses routine.
This is a private PDCurses routine.
Moves the physical cursor to the desired address on the
screen. We don't optimize here -- on a PC, it takes more time
to optimize than to do things directly.
Moves the physical cursor to the desired address on the screen.
We don't optimize here -- on a PC, it takes more time to
optimize than to do things directly.
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_gotoxy( int row, int col );
PDCurses int PDC_gotoxy(int row, int col);
**man-end**********************************************************************/
/***********************************************************************/
int PDC_gotoxy(int row, int col)
int PDC_gotoxy(int row, int col)
/***********************************************************************/
{
COORD coord;
COORD coord;
PDC_LOG(("PDC_gotoxy() - called: row %d col %d from row %d col %d\n", row, col, SP->cursrow, SP->curscol ));
PDC_LOG(("PDC_gotoxy() - called: row %d col %d from row %d col %d\n",
row, col, SP->cursrow, SP->curscol));
coord.X = col;
coord.Y = row;
coord.X = col;
coord.Y = row;
SetConsoleCursorPosition(hConOut, coord);
return(OK);
SetConsoleCursorPosition(hConOut, coord);
return OK;
}
/*man-start*********************************************************************
@@ -262,44 +263,47 @@ int PDC_gotoxy(int row, int col)
PDC_putc() - Output a character in the current attribute.
PDCurses Description:
This is a private PDCurses routine.
This is a private PDCurses routine.
Outputs character 'chr' to screen in tty fashion. If a colour
mode is active, the character is written with colour 'colour'.
Outputs character 'chr' to screen in tty fashion. If a colour
mode is active, the character is written with colour 'colour'.
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_putc( chtype character, chtype color );
PDCurses int PDC_putc(chtype character, chtype color);
**man-end**********************************************************************/
/***********************************************************************/
int PDC_putc( chtype character, chtype color )
int PDC_putc(chtype character, chtype color)
/***********************************************************************/
{
int curRow, curCol;
WORD buffer[2];
COORD coord;
DWORD written;
int curRow, curCol;
WORD buffer[2];
COORD coord;
DWORD written;
PDC_LOG(("PDC_putc() - called:char=%c attrib=0x%x color=0x%x\n",character & A_CHARTEXT,character & A_ATTRIBUTES,color));
PDC_LOG(("PDC_putc() - called:char=%c attrib=0x%x color=0x%x\n",
character & A_CHARTEXT, character & A_ATTRIBUTES, color));
buffer[0] = color;
PDC_get_cursor_pos (&curRow, &curCol);
PDC_get_cursor_pos(&curRow, &curCol);
coord.X = curCol;
coord.Y = curRow;
// WriteConsoleOutputAttribute(hConOut, &buffer, 1, coord, &written);
coord.X = curCol;
coord.Y = curRow;
#if 0
buffer[0] = color;
WriteConsoleOutputAttribute(hConOut, &buffer, 1, coord, &written);
#endif
buffer[0] = character;
WriteConsoleOutputCharacter(hConOut, (char*)&buffer[0], 1,
coord, &written);
buffer[0] = character;
WriteConsoleOutputCharacter(hConOut, (char*)&buffer[0], 1, coord, &written);
return (OK);
return OK;
}
/*man-start*********************************************************************
@@ -307,46 +311,49 @@ int PDC_putc( chtype character, chtype color )
PDC_putctty() - Output a character and attribute in TTY fashion.
PDCurses Description:
This is a private PDCurses routine.
This is a private PDCurses routine.
Outputs character 'chr' to screen in tty fashion. If a colour
mode is active, the character is written with colour 'colour'.
Outputs character 'chr' to screen in tty fashion. If a colour
mode is active, the character is written with colour 'colour'.
This function moves the physical cursor after writing so the
screen will scroll if necessary.
This function moves the physical cursor after writing so the
screen will scroll if necessary.
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_putctty( chtype character, chtype color );
PDCurses int PDC_putctty(chtype character, chtype color);
**man-end**********************************************************************/
/***********************************************************************/
int PDC_putctty( chtype character, chtype color )
int PDC_putctty(chtype character, chtype color)
/***********************************************************************/
{
int curRow=0, curCol=0;
WORD buffer;
COORD coord;
DWORD written;
int curRow, curCol;
WORD buffer;
COORD coord;
DWORD written;
PDC_LOG(("PDC_putctty() - called\n"));
PDC_LOG(("PDC_putctty() - called\n"));
buffer = color;
PDC_get_cursor_pos (&curRow, &curCol);
coord.X = curCol;
coord.Y = curRow;
// WriteConsoleOutputAttribute(hConOut, &buffer, 1, coord, &written);
PDC_get_cursor_pos(&curRow, &curCol);
buffer = character;
WriteConsoleOutputCharacter(hConOut, (char*)&buffer, 1, coord, &written);
coord.X = curCol;
coord.Y = curRow;
#if 0
buffer = color;
WriteConsoleOutputAttribute(hConOut, &buffer, 1, coord, &written);
#endif
buffer = character;
WriteConsoleOutputCharacter(hConOut, (char*)&buffer, 1,
coord, &written);
return (OK);
return OK;
}
/*man-start*********************************************************************
@@ -354,29 +361,31 @@ int PDC_putctty( chtype character, chtype color )
PDC_scroll() - low level screen scroll
PDCurses Description:
Scrolls a window in the current page up or down. Urow, lcol,
lrow, rcol are the window coordinates. Lines is the number of
lines to scroll. If 0, clears the window, if < 0 scrolls down,
if > 0 scrolls up. Blanks areas that are left, and sets
character attributes to attr. If in a colour graphics mode,
fills them with the colour 'attr' instead.
Scrolls a window in the current page up or down. Urow, lcol,
lrow, rcol are the window coordinates. Lines is the number of
lines to scroll. If 0, clears the window, if < 0 scrolls down,
if > 0 scrolls up. Blanks areas that are left, and sets
character attributes to attr. If in a colour graphics mode,
fills them with the colour 'attr' instead.
PDCurses Return Value:
The PDC_scroll() function returns OK on success otherwise ERR is returned.
The PDC_scroll() function returns OK on success otherwise ERR is
returned.
Portability:
PDCurses int PDC_scroll( int urow, int lcol, int rcol,
int nlines, chtype attr );
PDCurses int PDC_scroll(int urow, int lcol, int rcol,
int nlines, chtype attr);
**man-end**********************************************************************/
/***********************************************************************/
int PDC_scroll(int urow, int lcol, int lrow, int rcol, int nlines, chtype attr)
int PDC_scroll(int urow, int lcol, int lrow, int rcol, int nlines, chtype attr)
/***********************************************************************/
{
PDC_LOG(("PDC_scroll() - called: urow %d lcol %d lrow %d rcol %d nlines %d\n",urow,lcol,lrow,rcol,nlines));
PDC_LOG(("PDC_scroll() - called: urow %d lcol %d lrow %d rcol %d nlines %d\n",
urow, lcol, lrow, rcol, nlines));
return( OK );
return OK;
}
/*man-start*********************************************************************
@@ -384,80 +393,74 @@ int PDC_scroll(int urow, int lcol, int lrow, int rcol, int nlines, chtype attr
PDC_transform_line() - display a physical line of the screen
PDCurses Description:
This is a private PDCurses function.
This is a private PDCurses function.
Updates the given physical line to look like the corresponding
line in _curscr.
Updates the given physical line to look like the corresponding
line in _curscr.
PDCurses Return Value:
This routine returns TRUE if a premature refresh end
is allowed, and there is an input character pending. Otherwise,
FALSE is returned.
This routine returns TRUE if a premature refresh end
is allowed, and there is an input character pending. Otherwise,
FALSE is returned.
PDCurses Errors:
No errors are defined for this routine.
No errors are defined for this routine.
Portability:
PDCurses bool PDC_transform_line( int lineno );
PDCurses bool PDC_transform_line(int lineno);
**man-end**********************************************************************/
/***********************************************************************/
bool PDC_transform_line(register int lineno)
bool PDC_transform_line(int lineno)
/***********************************************************************/
{
extern unsigned char atrtab[MAX_ATRTAB];
extern unsigned char atrtab[MAX_ATRTAB];
register int j;
register chtype *srcp;
int x;
int endx;
int len;
bool rc;
COORD bufSize, bufPos;
SMALL_RECT sr;
int j, x, endx, len;
chtype *srcp;
COORD bufSize, bufPos;
SMALL_RECT sr;
PDC_LOG(("PDC_transform_line() - called: lineno=%d\n",lineno));
PDC_LOG(("PDC_transform_line() - called: lineno=%d\n", lineno));
if (curscr == (WINDOW *)NULL)
return( FALSE );
if (curscr == (WINDOW *)NULL)
return FALSE;
x = curscr->_firstch[lineno];
endx = curscr->_lastch[lineno];
srcp = curscr->_y[lineno] + x;
len = endx-x+1;
x = curscr->_firstch[lineno];
endx = curscr->_lastch[lineno];
srcp = curscr->_y[lineno] + x;
len = endx - x + 1;
bufPos.X = bufPos.Y = 0;
bufPos.X = bufPos.Y = 0;
bufSize.X = len;
bufSize.Y = 1;
bufSize.X = len;
bufSize.Y = 1;
sr.Top = lineno;
sr.Bottom = lineno;
sr.Left = x;
sr.Right = endx;
sr.Top = lineno;
sr.Bottom = lineno;
sr.Left = x;
sr.Right = endx;
for (j = 0; j < len; j++)
{
ci[j].Char.AsciiChar = *(srcp+j) & A_CHARTEXT;
ci[j].Attributes = (chtype_attr(*(srcp+j)) & 0xFF00) >> 8 ;
for (j = 0; j < len; j++)
{
ci[j].Char.AsciiChar = srcp[j] & A_CHARTEXT;
ci[j].Attributes = (chtype_attr(srcp[j]) & 0xFF00) >> 8;
#ifdef HIDE_ATTR
ci[j].Attributes = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
ci[j].Attributes = COLOR_WHITE;
#endif
}
}
WriteConsoleOutput(hConOut, ci, bufSize, bufPos, &sr);
WriteConsoleOutput(hConOut, ci, bufSize, bufPos, &sr);
curscr->_firstch[lineno] = _NO_CHANGE;
curscr->_lastch[lineno] = _NO_CHANGE;
curscr->_firstch[lineno] = _NO_CHANGE;
curscr->_lastch[lineno] = _NO_CHANGE;
if (SP->refrbrk && (SP->cbreak || SP->raw_inp))
{
rc = PDC_breakout();
if (rc)
return(TRUE);
}
return(FALSE);
if (SP->refrbrk && (SP->cbreak || SP->raw_inp)
&& PDC_breakout())
return(TRUE);
return FALSE;
}
/*man-start*********************************************************************
@@ -465,18 +468,18 @@ bool PDC_transform_line(register int lineno)
PDC_doupdate() - display updated data in one call (Win32 only)
PDCurses Description:
This is a private PDCurses function.
This is a private PDCurses function.
Updates the given physical screen to look like _curscr.
Updates the given physical screen to look like _curscr.
PDCurses Return Value:
This routine returns nothing.
This routine returns nothing.
PDCurses Errors:
No errors are defined for this routine.
No errors are defined for this routine.
Portability:
PDCurses void PDC_doupdate( void );
PDCurses void PDC_doupdate(void);
**man-end**********************************************************************/
@@ -484,74 +487,79 @@ bool PDC_transform_line(register int lineno)
void PDC_doupdate(void)
/***********************************************************************/
{
extern unsigned char atrtab[MAX_ATRTAB];
extern unsigned char atrtab[MAX_ATRTAB];
register int i, j, k;
int starty = _NO_CHANGE, startx = _NO_CHANGE;
int size;
int endy = _NO_CHANGE, endx = _NO_CHANGE;
register chtype *srcp;
CHAR_INFO *ptr;
COORD bufSize, bufPos;
SMALL_RECT sr;
int i, j, k;
int starty = _NO_CHANGE, startx = _NO_CHANGE;
int size;
int endy = _NO_CHANGE, endx = _NO_CHANGE;
chtype *srcp;
PDC_LOG(("PDC_doupdate() - called:\n"));
CHAR_INFO *ptr;
COORD bufSize, bufPos;
SMALL_RECT sr;
if (curscr == (WINDOW *)NULL)
return;
PDC_LOG(("PDC_doupdate() - called:\n"));
for (i = 0; i < LINES; i++ )
{
if (curscr->_firstch[i] != _NO_CHANGE)
{
if (starty == _NO_CHANGE)
starty = i;
endy = i;
if (startx == _NO_CHANGE
&& curscr->_firstch[i] != _NO_CHANGE)
startx = curscr->_firstch[i];
if (curscr->_firstch[i] < startx)
startx = curscr->_firstch[i];
if (curscr->_lastch[i] > endx)
endx = curscr->_lastch[i];
}
}
if (starty == _NO_CHANGE) /* nothing to do... */
return;
if (curscr == (WINDOW *)NULL)
return;
size = ((endy - starty) + 1) * ((endx - startx) + 1);
ptr = (CHAR_INFO*)malloc(size*sizeof(CHAR_INFO));
if (ptr == NULL)
return;
for (i = 0; i < LINES; i++)
if (curscr->_firstch[i] != _NO_CHANGE)
{
if (starty == _NO_CHANGE)
starty = i;
bufPos.X = bufPos.Y = 0;
bufSize.X = endx - startx + 1;
bufSize.Y = endy - starty + 1;
endy = i;
sr.Top = starty;
sr.Bottom = endy;
sr.Left = startx;
sr.Right = endx;
if (startx == _NO_CHANGE
&& curscr->_firstch[i] != _NO_CHANGE)
startx = curscr->_firstch[i];
k = 0;
for (i = starty; i <= endy; i++ )
{
srcp = curscr->_y[i];
for (j = startx; j <= endx; j++)
{
ptr[k].Char.AsciiChar = *(srcp+j) & A_CHARTEXT;
ptr[k].Attributes = (chtype_attr(*(srcp+j)) & 0xFF00) >> 8 ;
if (curscr->_firstch[i] < startx)
startx = curscr->_firstch[i];
if (curscr->_lastch[i] > endx)
endx = curscr->_lastch[i];
}
if (starty == _NO_CHANGE) /* nothing to do... */
return;
size = ((endy - starty) + 1) * ((endx - startx) + 1);
ptr = (CHAR_INFO*)malloc(size * sizeof(CHAR_INFO));
if (ptr == NULL)
return;
bufPos.X = bufPos.Y = 0;
bufSize.X = endx - startx + 1;
bufSize.Y = endy - starty + 1;
sr.Top = starty;
sr.Bottom = endy;
sr.Left = startx;
sr.Right = endx;
k = 0;
for (i = starty; i <= endy; i++)
{
srcp = curscr->_y[i];
for (j = startx; j <= endx; j++)
{
ptr[k].Char.AsciiChar = srcp[j] & A_CHARTEXT;
ptr[k].Attributes =
(chtype_attr(srcp[j]) & 0xFF00) >> 8;
#ifdef HIDE_ATTR
ptr[k].Attributes = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
ptr[k].Attributes = COLOR_WHITE;
#endif
k++;
}
curscr->_firstch[i] = _NO_CHANGE;
curscr->_lastch[i] = _NO_CHANGE;
}
k++;
}
curscr->_firstch[i] = _NO_CHANGE;
curscr->_lastch[i] = _NO_CHANGE;
}
WriteConsoleOutput(hConOut, ptr, bufSize, bufPos, &sr);
free(ptr);
return;
WriteConsoleOutput(hConOut, ptr, bufSize, bufPos, &sr);
free(ptr);
}

View File

@@ -22,7 +22,7 @@
#include <curses.h>
#ifdef PDCDEBUG
char *rcsid_PDCgetsc = "$Id: pdcgetsc.c,v 1.4 2006/01/03 19:54:29 wmcbrine Exp $";
char *rcsid_PDCgetsc = "$Id: pdcgetsc.c,v 1.5 2006/01/08 11:53:43 wmcbrine Exp $";
#endif
extern HANDLE hConOut, hConIn;
@@ -33,32 +33,34 @@ extern CONSOLE_SCREEN_BUFFER_INFO scr;
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**********************************************************************/
int PDC_get_cursor_pos(int *row, int *col)
int PDC_get_cursor_pos(int *row, int *col)
{
PDC_LOG(("PDC_get_cursor_pos() - called\n"));
PDC_LOG(("PDC_get_cursor_pos() - called\n"));
GetConsoleScreenBufferInfo(hConOut, &scr);
*col = scr.dwCursorPosition.X;
*row = scr.dwCursorPosition.Y;
return(OK);
GetConsoleScreenBufferInfo(hConOut, &scr);
*col = scr.dwCursorPosition.X;
*row = scr.dwCursorPosition.Y;
return OK;
}
/*man-start*********************************************************************
@@ -66,29 +68,30 @@ int PDC_get_cursor_pos(int *row, int *col)
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**********************************************************************/
int PDC_get_cur_col(void)
int PDC_get_cur_col(void)
{
PDC_LOG(("PDC_get_cur_col() - called\n"));
PDC_LOG(("PDC_get_cur_col() - called\n"));
GetConsoleScreenBufferInfo(hConOut, &scr);
return (scr.dwCursorPosition.X);
GetConsoleScreenBufferInfo(hConOut, &scr);
return scr.dwCursorPosition.X;
}
/*man-start*********************************************************************
@@ -96,60 +99,57 @@ int PDC_get_cur_col(void)
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**********************************************************************/
int PDC_get_cur_row(void)
int PDC_get_cur_row(void)
{
PDC_LOG(("PDC_get_cur_row() - called\n"));
PDC_LOG(("PDC_get_cur_row() - called\n"));
GetConsoleScreenBufferInfo(hConOut, &scr);
return (scr.dwCursorPosition.Y);
GetConsoleScreenBufferInfo(hConOut, &scr);
return scr.dwCursorPosition.Y;
}
// Stopped Here...
/*man-start*********************************************************************
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**********************************************************************/
int PDC_get_attribute(void)
int PDC_get_attribute(void)
{
PDC_LOG(("PDC_get_attribute() - called\n"));
/* doesnt do anything !! */
return(0);
return 0;
}
/*man-start*********************************************************************
@@ -157,29 +157,32 @@ int PDC_get_attribute(void)
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 in the range 0 through
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**********************************************************************/
int PDC_get_cursor_mode(void)
int PDC_get_cursor_mode(void)
{
CONSOLE_CURSOR_INFO ci;
CONSOLE_CURSOR_INFO ci;
PDC_LOG(("PDC_get_cursor_mode() - called\n"));
PDC_LOG(("PDC_get_cursor_mode() - called\n"));
GetConsoleCursorInfo(hConOut, &ci);
/* size is between 1 and 100, so convert it */
return ((ci.dwSize * 32 / 100) - 1);
GetConsoleCursorInfo(hConOut, &ci);
/* size is between 1 and 100, so convert it */
return ci.dwSize * 32 / 100 - 1;
}
/*man-start*********************************************************************
@@ -187,27 +190,27 @@ int PDC_get_cursor_mode(void)
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**********************************************************************/
int PDC_get_font(void)
int PDC_get_font(void)
{
PDC_LOG(("PDC_get_font() - called\n"));
return(0); /* this is N/A */
return 0;
}
/*man-start*********************************************************************
@@ -215,31 +218,31 @@ int PDC_get_font(void)
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**********************************************************************/
int PDC_get_rows(void)
int PDC_get_rows(void)
{
PDC_LOG(("PDC_get_rows() - called\n"));
PDC_LOG(("PDC_get_rows() - called\n"));
GetConsoleScreenBufferInfo(hConOut, &scr);
GetConsoleScreenBufferInfo(hConOut, &scr);
#if FGC0
return ( scr.dwSize.Y ); /* Allow the whole screen to be accessed */
return scr.dwSize.Y; /* Allow the whole screen to be accessed */
#else
return (scr.srWindow.Bottom - scr.srWindow.Top + 1);
return scr.srWindow.Bottom - scr.srWindow.Top + 1;
#endif
}
@@ -248,25 +251,26 @@ int PDC_get_rows(void)
PDC_get_buffer_rows() - Return number of screen buffer rows.
PDCurses Description:
This is a private PDCurses routine.
This is a private PDCurses routine.
PDCurses Return Value:
Returns the maximum number of rows in the screen buffer.
Returns the maximum number of rows in the screen buffer.
PDCurses Errors:
No errors are defined for this function.
No errors are defined for this function.
Portability:
PDCurses int PDC_get_buffer_rows( void );
PDCurses int PDC_get_buffer_rows(void);
**man-end**********************************************************************/
int PDC_get_buffer_rows(void)
int PDC_get_buffer_rows(void)
{
PDC_LOG(("PDC_get_buffer_rows() - called\n"));
PDC_LOG(("PDC_get_buffer_rows() - called\n"));
GetConsoleScreenBufferInfo( hConOut, &scr );
return ( scr.dwSize.Y );
GetConsoleScreenBufferInfo(hConOut, &scr);
return scr.dwSize.Y;
}
/*man-start*********************************************************************
@@ -274,31 +278,31 @@ int PDC_get_buffer_rows(void)
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**********************************************************************/
int PDC_get_columns(void)
int PDC_get_columns(void)
{
PDC_LOG(("PDC_get_columns() - called\n"));
PDC_LOG(("PDC_get_columns() - called\n"));
GetConsoleScreenBufferInfo(hConOut, &scr);
GetConsoleScreenBufferInfo(hConOut, &scr);
#if FGC0
return ( scr.dwSize.X ); /* Allow the whole screen to be accessed */
return scr.dwSize.X; /* Allow the whole screen to be accessed */
#else
return (scr.srWindow.Right - scr.srWindow.Left + 1);
return scr.srWindow.Right - scr.srWindow.Left + 1;
#endif
}
@@ -307,22 +311,22 @@ int PDC_get_columns(void)
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.
Portability:
PDCurses int PDC_get_scrn_mode( void );
PDCurses int PDC_get_scrn_mode(void);
**man-end**********************************************************************/
int PDC_get_scrn_mode(void)
int PDC_get_scrn_mode(void)
{
PDC_LOG(("PDC_get_scrn_mode() - called\n"));
return(OK);
return OK;
}
/*man-start*********************************************************************
@@ -330,35 +334,31 @@ int PDC_get_scrn_mode(void)
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**********************************************************************/
int PDC_query_adapter_type(void)
int PDC_query_adapter_type(void)
{
int retval;
PDC_LOG(("PDC_query_adapter_type() - called\n"));
SP->mono = FALSE;
retval = _VGACOLOR;
return (retval);
return _VGACOLOR;
}
/*man-start*********************************************************************
@@ -366,24 +366,24 @@ int PDC_query_adapter_type(void)
PDC_sanity_check() - A video adapter identification sanity check
PDCurses Description:
This is a private PDCurses routine.
This is a private PDCurses routine.
This routine will force sane values for various control flags.
This routine will force sane values for various control flags.
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_sanity_check( int adapter );
PDCurses int PDC_sanity_check(int adapter);
**man-end**********************************************************************/
int PDC_sanity_check(int adapter)
int PDC_sanity_check(int adapter)
{
PDC_LOG(("PDC_sanity_check() - called: Adapter %d\n",adapter));
PDC_LOG(("PDC_sanity_check() - called: Adapter %d\n", adapter));
return (adapter);
return adapter;
}

File diff suppressed because it is too large Load Diff

View File

@@ -21,37 +21,36 @@
#include <curses.h>
#ifdef PDCDEBUG
char *rcsid_PDCprint = "$Id: pdcprint.c,v 1.2 2006/01/03 07:34:43 wmcbrine Exp $";
char *rcsid_PDCprint = "$Id: pdcprint.c,v 1.3 2006/01/08 11:53:43 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
PDC_print() - Provides primitive access to the BIOS printer functions
PDCurses Description:
This is a private PDCurses routine.
This is a private PDCurses routine.
Implements write/init/read printer services at the BIOS level.
Implements write/init/read printer services at the BIOS level.
This provides the basic support that PDCurses needs to dump the
contents of windows or pads to the printer attached to the BIOS
printer port.
This provides the basic support that PDCurses needs to dump the
contents of windows or pads to the printer attached to the BIOS
printer port.
PDCurses Return Value:
See the BIOS INT 0x17 specifications.
See the BIOS INT 0x17 specifications.
PDCurses Errors:
See the BIOS INT 0x17 specifications.
See the BIOS INT 0x17 specifications.
Portability:
PDCurses int PDC_print( int cmd, int byte, int port );
PDCurses int PDC_print(int cmd, int byte, int port);
**man-end**********************************************************************/
int PDC_print(int cmd, int byte, int port)
int PDC_print(int cmd, int byte, int port)
{
PDC_LOG(("PDC_print() - called\n"));
return( OK );
return OK;
}

File diff suppressed because it is too large Load Diff

View File

@@ -22,7 +22,7 @@
#include <curses.h>
#ifdef PDCDEBUG
char *rcsid_PDCsetsc = "$Id: pdcsetsc.c,v 1.5 2006/01/03 19:54:29 wmcbrine Exp $";
char *rcsid_PDCsetsc = "$Id: pdcsetsc.c,v 1.6 2006/01/08 11:53:43 wmcbrine Exp $";
#endif
extern HANDLE hConOut;
@@ -32,26 +32,26 @@ extern HANDLE hConOut;
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.
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**********************************************************************/
int PDC_set_80x25(void)
int PDC_set_80x25(void)
{
PDC_LOG(("PDC_set_80x25() - called\n"));
return(OK);
return OK;
}
/*man-start*********************************************************************
@@ -59,25 +59,26 @@ int PDC_set_80x25(void)
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**********************************************************************/
int PDC_set_cursor_mode( int startrow, int endrow )
int PDC_set_cursor_mode(int startrow, int endrow)
{
PDC_LOG(("PDC_set_cursor_mode() - called: startrow %d endrow %d\n",startrow,endrow));
PDC_LOG(("PDC_set_cursor_mode() - called: startrow %d endrow %d\n",
startrow, endrow));
return(OK);
return OK;
}
/*man-start*********************************************************************
@@ -85,30 +86,30 @@ int PDC_set_cursor_mode( int startrow, int endrow )
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.
Portability:
PDCurses int PDC_set_font( int size );
PDCurses int PDC_set_font(int size);
**man-end**********************************************************************/
int PDC_set_font(int size)
int PDC_set_font(int size)
{
PDC_LOG(("PDC_set_font() - called\n"));
return(OK);
return OK;
}
/*man-start*********************************************************************
@@ -116,30 +117,30 @@ int PDC_set_font(int size)
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.
Portability:
PDCurses int PDC_set_rows( int rows );
PDCurses int PDC_set_rows(int rows);
**man-end**********************************************************************/
int PDC_set_rows(int rows)
int PDC_set_rows(int rows)
{
PDC_LOG(("PDC_set_rows() - called\n"));
return(0);
return OK;
}
/*man-start*********************************************************************
@@ -161,17 +162,18 @@ int PDC_set_rows(int rows)
**man-end**********************************************************************/
int PDC_set_scrn_mode(int new_mode)
int PDC_set_scrn_mode(int new_mode)
{
PDC_LOG(("PDC_set_scrn_mode() - called\n"));
return(OK); /* this is N/A */
return OK;
}
/***********************************************************************/
#ifdef HAVE_PROTO
int PDC_curs_set(int visibility)
int PDC_curs_set(int visibility)
#else
int PDC_curs_set(visibility)
int PDC_curs_set(visibility)
int visibility;
#endif
/***********************************************************************/
@@ -179,7 +181,7 @@ int visibility;
CONSOLE_CURSOR_INFO cci;
int ret_vis;
PDC_LOG(("PDC_curs_set() - called: visibility=%d\n",visibility));
PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
ret_vis = SP->visibility;
@@ -188,17 +190,17 @@ int visibility;
switch(visibility)
{
case 0: /* invisible */
cci.bVisible = FALSE;
break;
case 2: /* highly visible */
cci.bVisible = TRUE;
cci.dwSize = 95;
break;
default: /* normal visibility */
cci.bVisible = TRUE;
cci.dwSize = 25;
break;
case 0: /* invisible */
cci.bVisible = FALSE;
break;
case 2: /* highly visible */
cci.bVisible = TRUE;
cci.dwSize = 95;
break;
default: /* normal visibility */
cci.bVisible = TRUE;
cci.dwSize = 25;
break;
}
if (SetConsoleCursorInfo(hConOut,&cci) == FALSE)
@@ -213,29 +215,24 @@ int visibility;
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.
PDCurses Return Value:
N/A
PDCurses Errors:
No errors are defined for this function.
Sets the title of the window in which the curses program is
running. This function may not do anything on some platforms.
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)
void PDC_set_title(char *title)
#else
void PDC_set_title(title)
void PDC_set_title(title)
char *title;
#endif
/***********************************************************************/
{
PDC_LOG(("PDC_set_title() - called:<%s>\n",title));
PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
SetConsoleTitle(title);
return;