v05i025: PCcurses version 1.3, part 3/5
Steve Creps
creps at silver.bacs.indiana.edu
Mon Oct 31 12:53:08 AEST 1988
Posting-number: Volume 5, Issue 25
Submitted-by: "Steve Creps" <creps at silver.bacs.indiana.edu>
Archive-name: pc-curses-1.3/Part3
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 3 (of 5)."
# Contents: charadd.c cursesio.asm cursesio.c newwin.c prntscan.c
# strget.c update.c
# Wrapped by creps at silver on Fri Oct 28 17:43:08 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'charadd.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'charadd.c'\"
else
echo shar: Extracting \"'charadd.c'\" \(7172 characters\)
sed "s/^X//" >'charadd.c' <<'END_OF_FILE'
X/****************************************************************/
X/* Addch() routines of the PCcurses package */
X/* */
X/****************************************************************/
X/* This version of curses is based on ncurses, a curses version */
X/* originally written by Pavel Curtis at Cornell University. */
X/* I have made substantial changes to make it run on IBM PC's, */
X/* and therefore consider myself free to make it public domain. */
X/* Bjorn Larsson (...mcvax!enea!infovax!bl) */
X/****************************************************************/
X/* 1.0: Release: 870515 */
X/* 1.1: Added 'raw' output routines (allows PC charac- */
X/* ters < 0x20 to be displayed: 880306 */
X/* 1.2: Max limits off by 1. Fixed thanks to S. Creps: 881002 */
X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
X/****************************************************************/
X
X#include <curses.h>
X#include <curspriv.h>
X
Xchar _curses_charadd_rcsid[] = "@(#)charadd.c v1.3 - 881005";
X
X/****************************************************************/
X/* Newline() does line advance and returns the new cursor line. */
X/* If error, return -1. */
X/****************************************************************/
X
Xstatic short newline(win, lin)
X WINDOW *win;
X short lin;
X {
X if (++lin > win->_regbottom)
X {
X lin--;
X if (win->_scroll)
X scroll(win);
X else
X return(-1);
X } /* if */
X return(lin);
X } /* newline */
X
X/****************************************************************/
X/* _Chadd() inserts character 'c' at the current cursor posi- */
X/* tion in window 'win'. If xlat is TRUE, _chadd() will handle */
X/* things like tab, newline, cr etc.; otherwise the character */
X/* is simply output. */
X/****************************************************************/
X
Xint _chadd(win, c, xlat)
X register WINDOW *win;
X char c;
X bool xlat;
X {
X short x = win->_curx;
X short y = win->_cury;
X short newx;
X int ch = c;
X int ts = win->_tabsize;
X
X ch &= 0xff; /* kill any sing-extend */
X if (y >= win->_maxy || x >= win->_maxx || y < 0 || x < 0)
X return(ERR);
X
X if (xlat)
X {
X switch (ch)
X {
X case '\t': for (newx = ((x/ts) + 1) * ts; x < newx; x++)
X {
X if (waddch(win, ' ') == ERR)
X return(ERR);
X if (win->_curx == 0) /* if tab to next line */
X return(OK); /* exit the loop */
X } /* for */
X return(OK);
X case '\n': if (_cursvar.autocr && !(_cursvar.raw)) /* if lf -> crlf */
X x = 0;
X if ((y = newline(win, y)) < 0)
X return(ERR);
X win->_cury = y;
X win->_curx = x;
X return(OK);
X case '\r': x = 0;
X win->_curx = x;
X return(OK);
X case '\b': if (--x < 0) /* no back over left margin */
X x = 0;
X win->_curx = x;
X return(OK);
X case 0x7f: if (waddch(win,'^') == ERR)
X return(ERR);
X return(waddch(win,'?'));
X default: break;
X } /* switch */
X if (ch < ' ') /* handle control chars */
X {
X if (waddch(win,'^') == ERR)
X return(ERR);
X return(waddch(win,c + '@'));
X } /* if */
X } /* if xlat*/
X
X ch |= (win->_attrs & ATR_MSK);
X if (win->_line[y][x] != ch) /* only if data change */
X {
X if (win->_minchng[y] == _NO_CHANGE)
X win->_minchng[y] = win->_maxchng[y] = x;
X else
X {
X if (x < win->_minchng[y])
X win->_minchng[y] = x;
X else
X {
X if (x > win->_maxchng[y])
X win->_maxchng[y] = x;
X } /* else */
X } /* else */
X } /* if */
X win->_line[y][x++] = ch;
X if (x >= win->_maxx) /* wrap around test */
X {
X x = 0;
X if ((y = newline(win, y)) < 0)
X return(ERR);
X } /* if */
X win->_curx = x;
X win->_cury = y;
X return(OK);
X } /* _chadd */
X
X/****************************************************************/
X/* Addch() inserts character 'c' at the current cursor posi- */
X/* tion in stdscr, and takes any actions as dictated by the */
X/* character. */
X/****************************************************************/
X
Xint addch(c)
X char c;
X {
X return (_chadd(stdscr,c,TRUE));
X } /* addch */
X
X/****************************************************************/
X/* Waddch() inserts character 'c' at the current cursor posi- */
X/* tion in window 'win', and takes any actions as dictated by */
X/* the character. */
X/****************************************************************/
X
Xint waddch(win,c)
X WINDOW *win;
X char c;
X {
X return (_chadd(win,c,TRUE));
X } /* waddch */
X
X/****************************************************************/
X/* Mvaddch() moves to position in stdscr, then inserts charac- */
X/* ter 'c' at that point, and takes any actions as dictated by */
X/* the character. */
X/****************************************************************/
X
Xint mvaddch(y,x,c)
X int x;
X int y;
X char c;
X {
X if (wmove(stdscr,y,x) == ERR)
X return(ERR);
X return (_chadd(stdscr,c,TRUE));
X } /* mvaddch */
X
X/****************************************************************/
X/* Mvwaddch() moves to position in window 'win', then inserts */
X/* character 'c' at that point in the window, and takes any */
X/* actions as dictated by the character. */
X/****************************************************************/
X
Xint mvwaddch(win,y,x,c)
X WINDOW *win;
X int x;
X int y;
X char c;
X {
X if (wmove(win,y,x) == ERR)
X return(ERR);
X return (_chadd(win,c,TRUE));
X } /* mvwaddch */
X
X/****************************************************************/
X/* Addrawch() inserts character 'c' at the current cursor */
X/* position in stdscr, disregarding any traditional interpre- */
X/* tation of the character. */
X/****************************************************************/
X
Xint addrawch(c)
X char c;
X {
X return (_chadd(stdscr,c,FALSE));
X } /* addrawch */
X
X/****************************************************************/
X/* Waddrawch() inserts character 'c' at the current cursor */
X/* position in window 'win', disregarding any traditional in- */
X/* terpretation of the character. */
X/****************************************************************/
X
Xint waddrawch(win,c)
X WINDOW *win;
X char c;
X {
X return (_chadd(win,c,FALSE));
X } /* waddrawch */
X
X/****************************************************************/
X/* Mvaddrawch() moves to position in stdscr, then inserts cha- */
X/* racter 'c' at that point, disregarding any traditional in- */
X/* terpretation of the character. */
X/****************************************************************/
X
Xint mvaddrawch(y,x,c)
X int x;
X int y;
X char c;
X {
X if (wmove(stdscr,y,x) == ERR)
X return(ERR);
X return (_chadd(stdscr,c,FALSE));
X } /* mvaddrawch */
X
X/****************************************************************/
X/* Mvwaddrawch() moves to position in window 'win', then in- */
X/* serts character 'c' at that point in the window, disregar- */
X/* ding any traditional interpretation of the character. */
X/****************************************************************/
X
Xint mvwaddrawch(win,y,x,c)
X WINDOW *win;
X int x;
X int y;
X char c;
X {
X if (wmove(win,y,x) == ERR)
X return(ERR);
X return (_chadd(win,c,FALSE));
X } /* mvwaddrawch */
END_OF_FILE
if test 7172 -ne `wc -c <'charadd.c'`; then
echo shar: \"'charadd.c'\" unpacked with wrong size!
fi
# end of 'charadd.c'
fi
if test -f 'cursesio.asm' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'cursesio.asm'\"
else
echo shar: Extracting \"'cursesio.asm'\" \(8375 characters\)
sed "s/^X//" >'cursesio.asm' <<'END_OF_FILE'
X TITLE PCcurses BIOS Control Functions for MicroSoft Assembler
X NAME CURSESIO
X PAGE 46,132
X ;****************************************************************
X ;* CURSESIO.ASM *
X ;* *
X ;* This file contains 'C' functions for the MicroSoft 'C' com- *
X ;* piler v.4.0, and for Borland Turbo 'C'. It exercises a num- *
X ;* ber of BIOS video calls, and is intended for inclusion in *
X ;* a curses library package. *
X ;* *
X ;* The two files FARNEAR.INC and SMALHUGE.INC each contain one *
X ;* EQUate. These define the module's memory model. *
X ;* *
X ;****************************************************************
X ;* This version of curses is based on ncurses, a curses version *
X ;* originally written by Pavel Curtis at Cornell University. *
X ;* I have made substantial changes to make it run on IBM PC's, *
X ;* and therefore consider myself free to make it public domain. *
X ;* Bjorn Larsson (...mcvax!enea!infovax!bl) *
X ;****************************************************************
X ;* Author: Bjorn Larsson *
X ;* Revised: *
X ;* 1.0: Release: 870515 *
X ;* 1.1: Bad error in curseskeytst(): JZ -> JNZ! 870911 *
X ;* 1.2: Changed call sequence to some routines, thanks *
X ;* to S. Creps. Changed segment name in far code *
X ;* mode, thanks to N.D. Pentcheff: 881002 *
X ;* 1.3: Changes in 'C' modules for checking with *
X ;* MSC -W3, Turbo'C' -w -w-pro checkes: 881005 *
X ;****************************************************************
X ;
X INCLUDE FARNEAR.INC ;DEFINE FAR OR NEAR CALL SEQUENCE
X INCLUDE SMALHUGE.INC ;DEFINE FAR OR NEAR DATA ACCESS
X ;
XSYSTEM EQU 21H ;SYSTEM CALL
XBRKCHK EQU 33H ;BREAK SET/CHECK FUNCTION CODE
X ;
X if far_call ;OTHER TEXT NAME IF FAR CALLS
XCURSESIO_TEXT SEGMENT BYTE PUBLIC 'CODE'
X ASSUME CS: CURSESIO_TEXT
X else
X_TEXT SEGMENT BYTE PUBLIC 'CODE'
X ASSUME CS: _TEXT
X endif
X ;
X ;****************************************************************
X ;* Function entry and exit macros, and parameter fetch macro. *
X ;* Used by all functions. *
X ;****************************************************************
X ;
Xc_entry MACRO f_name
X ;
X if far_call
X&f_name proc far
X else
X&f_name proc near
X endif
X push bp
X mov bp,sp
X push di
X push si
X ;
X ENDM
X ;
Xc_exit MACRO f_name
X ;
X pop si
X pop di
X pop bp
X ret
X&f_name endp
X ;
X ENDM
X ;
Xg_parm MACRO reg,p_num
X if far_call
X mov ®,[bp+&p_num*2+4]
X else
X mov ®,[bp+&p_num*2+2]
X endif
X ;
X ENDM
X ;
X DB '@(#)cursesio.asm v1.3 - 881005', 0
X ;
X PAGE
X ;****************************************************************
X ;* _cursescattr *
X ;* *
X ;* void _cursescattr(chr,attr) *
X ;* *
X ;* Writes char 'chr' with attributes 'attr' to the current cur- *
X ;* sor location. *
X ;****************************************************************
X PUBLIC __cursescattr
X ;
X c_entry __cursescattr
X MOV AH,9
X MOV BH,0 ;USE PAGE 0
X g_parm AL,1 ;GET CHR PARAMETER
X g_parm BL,2 ;GET ATTR PARAMETER
X MOV CX,1 ;PUT 1 CHARACTER
X INT 10H
X c_exit __cursescattr
X ;
X ;****************************************************************
X ;* _cursescursor *
X ;* *
X ;* void _cursescursor(row,column) *
X ;* *
X ;* Sets the cursor position in video page 0. 'row' and 'column' *
X ;* are the cursor address. If 'row' is set to 25, no cursor at *
X ;* all is displayed. *
X ;****************************************************************
X PUBLIC __cursescursor
X ;
X c_entry __cursescursor
X MOV AH,2
X MOV BH,0 ;USE PAGE 0
X g_parm DH,1 ;GET ROW PARAMETER
X g_parm DL,2 ;GET COLUMN PARAMETER
X INT 10H
X c_exit __cursescursor
X ;
X ;****************************************************************
X ;* _cursesgcols *
X ;* *
X ;* int _cursesgcols() *
X ;* *
X ;* Return the current number of columns on the screen. *
X ;****************************************************************
X PUBLIC __cursesgcols
X ;
X c_entry __cursesgcols
X MOV AH,15
X INT 10H
X MOV AL,AH
X XOR AH,AH
X c_exit __cursesgcols
X ;
X ;****************************************************************
X ;* _cursesputc *
X ;* *
X ;* void _cursesputc(chr,colour) *
X ;* *
X ;* Output character 'chr' to screen in tty fashion. If a colour *
X ;* mode is active, the character is written with colour *
X ;* 'colour'. *
X ;****************************************************************
X PUBLIC __cursesputc
X ;
X c_entry __cursesputc
X MOV AH,14
X g_parm AL,1 ;GET CHR PARAMETER
X g_parm BL,2 ;GET COLOUR PARAMETER
X INT 10H
X c_exit __cursesputc
X ;
X ;****************************************************************
X ;* _cursesscroll *
X ;* *
X ;* void _cursesscroll(urow,lcol,lrow,rcol,lines,attr) *
X ;* *
X ;* Scroll a window in the current page up or down. Urow, lcol, *
X ;* lrow,rcol are the window coordinats. lines is the number of *
X ;* lines to scroll. If 0, clears the window, if < 0 scrolls *
X ;* down, > 0 scrolls up. Blanks areas that are left, and sets *
X ;* character attributes to attr. If in a colour graphics mode, *
X ;* fills them with the colour 'attr' instead. *
X ;****************************************************************
X PUBLIC __cursesscroll
X ;
X c_entry __cursesscroll
X g_parm AL,5 ;GET LINES PARAMETER
X MOV AH,6
X TEST AL,80H
X JZ SHORT CS_1
X ;
X MOV AH,7
X NEG AL
X ;
XCS_1: g_parm CH,1 ;GET UROW PARAMETER
X g_parm CL,2 ;GET LCOL PARAMETER
X g_parm DH,3 ;GET LROW PARAMETER
X g_parm DL,4 ;GET RCOL PARAMETER
X g_parm BH,6 ;GET ATTR PARAMETER
X INT 10H
X c_exit __cursesscroll
X ;
X ;****************************************************************
X ;* _cursesgcmode *
X ;* *
X ;* int _cursesgcmode() *
X ;* *
X ;* Return the current cursor type. Bits 8-15 of the return *
X ;* value is the start scan row, and bits 0-7 is the end scan *
X ;* row. *
X ;****************************************************************
X PUBLIC __cursesgcmode
X ;
X c_entry __cursesgcmode
X MOV AH,3
X INT 10H
X MOV AX,CX
X c_exit __cursesgcmode
X ;
X ;****************************************************************
X ;* _cursescmode *
X ;* *
X ;* void _cursescmode(startrow,endrow) *
X ;* *
X ;* Sets the cursor type to begin in scan line startrow and end *
X ;* in scan line endrow. Both values should be 0-31. *
X ;****************************************************************
X PUBLIC __cursescmode
X ;
X c_entry __cursescmode
X MOV AH,1
X g_parm CH,1 ;GET STARTROW PARAMETER
X g_parm CL,2 ;GET ENDROW PARAMETER
X INT 10H
X c_exit __cursescmode
X ;
X ;****************************************************************
X ;* _curseskey *
X ;* *
X ;* int _curseskey() *
X ;* *
X ;* Returns the next key code struck at the keyboard. If the low *
X ;* 8 bits are 0, the upper bits contain the extended character *
X ;* code. If bit 0-7 are non-zero, the upper bits = 0. *
X ;****************************************************************
X PUBLIC __curseskey
X ;
X c_entry __curseskey
X MOV AH,0
X INT 16H
X CMP AL,0
X JZ SHORT EXTKEY
X AND AX,0FFH
XEXTKEY:
X c_exit __curseskey
X ;
X ;****************************************************************
X ;* _curseskeytst *
X ;* *
X ;* int _curseskeytst() *
X ;* *
X ;* Returns 1 if a character is available, 0 otherwise. *
X ;****************************************************************
X PUBLIC __curseskeytst
X ;
X c_entry __curseskeytst
X MOV AH,1
X INT 16H
X JNZ SHORT TST1
X MOV AX,0
X JMP SHORT EXTTST
XTST1: MOV AX,1
XEXTTST:
X c_exit __curseskeytst
X ;
X ;****************************************************************
X ;* _cursesgcb *
X ;* *
X ;* int _cursesgcb() *
X ;* *
X ;* Returns 1 if MSDOS BREAK CHECK is on, otherwise 0. *
X ;****************************************************************
X PUBLIC __cursesgcb
X ;
X c_entry __cursesgcb
X MOV AX,BRKCHK*256+0
X INT SYSTEM
X XOR AH,AH
X MOV AL,DL
X c_exit __cursesgcb
X ;
X ;****************************************************************
X ;* _cursesscb *
X ;* *
X ;* void _cursesscb(setting) *
X ;* *
X ;* Sets MSDOS BREAK CHECK according to 'setting'. *
X ;****************************************************************
X PUBLIC __cursesscb
X ;
X c_entry __cursesscb
X MOV AX,BRKCHK*256+1
X g_parm DL,1
X AND DL,DL
X JZ SHORT SCB1
X MOV DL,1
XSCB1: INT SYSTEM
X c_exit __cursesscb
X ;
X if far_call
XCURSESIO_TEXT ENDS
X else
X_TEXT ENDS
X endif
X if1
X %OUT Pass 1 Completed
X else
X %OUT Assembly Completed
X endif
X END
END_OF_FILE
if test 8375 -ne `wc -c <'cursesio.asm'`; then
echo shar: \"'cursesio.asm'\" unpacked with wrong size!
fi
# end of 'cursesio.asm'
fi
if test -f 'cursesio.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'cursesio.c'\"
else
echo shar: Extracting \"'cursesio.c'\" \(6917 characters\)
sed "s/^X//" >'cursesio.c' <<'END_OF_FILE'
X/****************************************************************/
X/* Low-level I/O functions of the PCcurses package, 'C' version */
X/* */
X/****************************************************************/
X/* This version of curses is based on ncurses, a curses version */
X/* originally written by Pavel Curtis at Cornell University. */
X/* I have made substantial changes to make it run on IBM PC's, */
X/* and therefore consider myself free make it public domain. */
X/* Bjorn Larsson (...mcvax!enea!infovax!bl) */
X/****************************************************************/
X/* BUT: this particular module was written by */
X/* Steve Creps (creps at silver.bacs.indiana.edu) */
X/* It provides 'C' versions of the low-level I/O functions */
X/* that are also available in assembler in cursesio.asm. */
X/* B. Larsson took the liberty of modifying its style slightly */
X/* when incorporating it into PCcurses v.1.2. */
X/****************************************************************/
X/* 1.0: Original, S. Creps: 880827 */
X/* 1.2: Style clean-up, rcsid[] string for maintenance: 881002 */
X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
X/****************************************************************/
X
X#include <curses.h>
X#include <curspriv.h>
X#include <dos.h>
X
Xchar _curses_curseio_rcsid[] = "@(#)cursesio.c v1.3 - 881005";
X
Xstatic union REGS regs;
X
X/****************************************************************/
X/* _Cursescattr() writes char 'chr' with attributes 'attr' to */
X/* the current cursor location. */
X/****************************************************************/
X
Xvoid _cursescattr(chr, attr)
X char chr;
X char attr;
X {
X regs.h.ah = 0x09;
X regs.h.al = (unsigned char)chr;
X regs.h.bh = 0x00;
X regs.h.bl = (unsigned char)attr;
X regs.x.cx = 0x01;
X int86(0x10, ®s, ®s);
X } /* _cursescattr */
X
X/****************************************************************/
X/* _Cursescursor() sets the cursor position in video page 0. */
X/* 'row' and 'column' are the cursor address. If 'row' is set */
X/* to 25, no cursor at all is displayed. */
X/****************************************************************/
X
Xvoid _cursescursor(row, column)
X int row;
X int column;
X {
X regs.h.ah = 0x02;
X regs.h.bh = 0x00;
X regs.h.dh = (unsigned char)row;
X regs.h.dl = (unsigned char)column;
X int86(0x10, ®s, ®s);
X }/* _cursescursor */
X
X/****************************************************************/
X/* _Cursesgcols() returns the current number of columns on the */
X/* screen. */
X/****************************************************************/
X
Xint _cursesgcols()
X {
X regs.h.ah = 0x0f;
X int86(0x10, ®s, ®s);
X return (int)regs.h.ah;
X } /* _cursesgcols */
X
X/****************************************************************/
X/* _Cursesputc() outputs character 'chr' to screen in tty */
X/* fashion. If a colour mode is active, the character is writ- */
X/* ten with colour 'colour'. */
X/****************************************************************/
X
Xvoid _cursesputc(chr, color)
X char chr;
X char color;
X {
X regs.h.ah = 0x0e;
X regs.h.al = (unsigned char)chr;
X regs.h.bh = 0x00;
X regs.h.bl = (unsigned char)color;
X int86(0x10, ®s, ®s);
X } /* _cursesputc */
X
X/****************************************************************/
X/* _Cursesscroll() scrolls a window in the current page up or */
X/* down. Urow, lcol, lrow,rcol are the window coordinates. */
X/* Lines is the number of lines to scroll. If 0, clears the */
X/* window, if < 0 scrolls down, > 0 scrolls up. Blanks areas */
X/* that are left, and sets character attributes to attr. If in */
X/* a colour graphics mode, fills them with the colour 'attr' */
X/* instead. */
X/****************************************************************/
X
Xvoid _cursesscroll(urow, lcol, lrow, rcol, lines, attr)
X int urow;
X int lcol;
X int lrow;
X int rcol;
X int lines;
X char attr;
X {
X if (lines >= 0)
X {
X regs.h.ah = 0x06;
X regs.h.al = (unsigned char)lines;
X } /* if */
X else
X {
X regs.h.ah = 0x07;
X regs.h.al = (unsigned char)(-lines);
X } /* else */
X regs.h.bh = (unsigned char)attr;
X regs.h.ch = (unsigned char)urow;
X regs.h.cl = (unsigned char)lcol;
X regs.h.dh = (unsigned char)lrow;
X regs.h.dl = (unsigned char)rcol;
X int86(0x10, ®s, ®s);
X } /* _cursesscroll */
X
X/****************************************************************/
X/* _Cursesgcmode() returns the current cursor type. Bits 8-15 */
X/* of the return value is the start scan row, and bits 0-7 is */
X/* the end scan row. */
X/****************************************************************/
X
Xint _cursesgcmode()
X {
X regs.h.ah = 0x03;
X regs.h.bh = 0x00;
X int86(0x10, ®s, ®s);
X return (int)regs.x.cx;
X } /* _cursesgcmode */
X
X/****************************************************************/
X/* _Cursescmode() sets the cursor type to begin in scan line */
X/* startrow and end in scan line endrow. Both values should be */
X/* 0-31. */
X/****************************************************************/
X
Xvoid _cursescmode(startrow, endrow)
X int startrow;
X int endrow;
X {
X regs.h.ah = 0x01;
X regs.h.ch = (unsigned char)startrow;
X regs.h.cl = (unsigned char)endrow;
X int86(0x10, ®s, ®s);
X } /* _cursescmode */
X
X/****************************************************************/
X/* _Curseskey() returns the next key code struck at the key- */
X/* board. If the low 8 bits are 0, the upper bits contain the */
X/* extended character code. If bit 0-7 are non-zero, the upper */
X/* bits = 0. */
X/****************************************************************/
X
Xint _curseskey()
X {
X regs.h.ah = 0x00;
X int86(0x16, ®s, ®s);
X if (regs.h.al != 0)
X return (int)(regs.x.ax & 0x00ff);
X return (int)regs.x.ax;
X } /* _curseskey */
X
X/****************************************************************/
X/* _Curseskeytst() returns 1 if a keyboard character is avail- */
X/* able, 0 otherwise. */
X/****************************************************************/
X
Xbool _curseskeytst()
X {
X regs.h.ah = 0x01;
X int86(0x16, ®s, ®s);
X return ((bool)((regs.x.cflag & 0x40) ? 1 : 0));
X } /*_curseskeytst */
X
X/****************************************************************/
X/* _Cursesgcb() returns 1 if MSDOS BREAK CHECK is on, else 0. */
X/****************************************************************/
X
Xint _cursesgcb()
X {
X regs.h.ah = 0x33;
X regs.h.al = 0x00;
X int86(0x21, ®s, ®s);
X return (int)regs.h.dl;
X } /* _cursesgcb */
X
X/****************************************************************/
X/* _Cursesscb() sets MSDOS BREAK CHECK according to 'setting'. */
X/****************************************************************/
X
Xvoid _cursesscb(setting)
X int setting;
X {
X regs.h.ah = 0x33;
X regs.h.al = 0x00;
X regs.h.dl = (unsigned char)(setting ? 1 : 0);
X int86(0x21, ®s, ®s);
X } /* _cursesscb */
END_OF_FILE
if test 6917 -ne `wc -c <'cursesio.c'`; then
echo shar: \"'cursesio.c'\" unpacked with wrong size!
fi
# end of 'cursesio.c'
fi
if test -f 'newwin.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'newwin.c'\"
else
echo shar: Extracting \"'newwin.c'\" \(5921 characters\)
sed "s/^X//" >'newwin.c' <<'END_OF_FILE'
X/****************************************************************/
X/* Newwin(), subwin() routines of the PCcurses package */
X/* */
X/****************************************************************/
X/* This version of curses is based on ncurses, a curses version */
X/* originally written by Pavel Curtis at Cornell University. */
X/* I have made substantial changes to make it run on IBM PC's, */
X/* and therefore consider myself free to make it public domain. */
X/* Bjorn Larsson (...mcvax!enea!infovax!bl) */
X/****************************************************************/
X/* 1.0: Release: 870515 */
X/* 1.1: Fix in subwin: '+/-1' error when checking that */
X/* subwindow fits in parent window: 880305 */
X/* 1.2: Other max limits off by 1. Fixed thanks to */
X/* S. Creps: 881002 */
X/* 1.3: MSC '-W3', Turbo'C' '-w -w-pro' checks. Support */
X/* for border(), wborder() functions: 881005 */
X/****************************************************************/
X
X#include <stdio.h>
X#include <curses.h>
X#include <curspriv.h>
X
Xchar _curses_newwin_rcsid[] = "@(#)newwin.c v1.3 - 881005";
X
X/****************************************************************/
X/* Makenew() allocates all data for a new window except the */
X/* actual lines themselves. */
X/****************************************************************/
X
Xstatic WINDOW *makenew(num_lines, num_columns, begy, begx)
X int num_lines, num_columns, begy, begx;
X {
X int i;
X WINDOW *win;
X
X /* allocate the window structure itself */
X
X if ((win = (WINDOW *) malloc(sizeof(WINDOW))) == NULL)
X return ((WINDOW *) ERR);
X
X /* allocate the line pointer array */
X
X if ((win->_line = (int **) calloc(num_lines, sizeof (int *))) == NULL)
X {
X free(win);
X return((WINDOW *) ERR);
X }
X
X /* allocate the minchng and maxchng arrays */
X
X if ((win->_minchng = (int *) calloc(num_lines, sizeof(int))) == NULL)
X {
X free(win);
X free(win->_line);
X return((WINDOW *) ERR);
X }
X if ((win->_maxchng = (int *) calloc(num_lines, sizeof(int))) == NULL)
X {
X free(win);
X free(win->_line);
X free(win->_minchng);
X return((WINDOW *) ERR);
X }
X
X /* initialize window variables */
X
X win->_curx = 0;
X win->_cury = 0;
X win->_maxy = num_lines;
X win->_maxx = num_columns;
X win->_begy = begy;
X win->_begx = begx;
X win->_flags = 0;
X win->_attrs = ATR_NRM;
X win->_tabsize = 8;
X win->_clear = (bool) ((num_lines == LINES) && (num_columns == COLS));
X win->_leave = FALSE;
X win->_scroll = FALSE;
X win->_nodelay = FALSE;
X win->_keypad = FALSE;
X win->_regtop = 0;
X win->_regbottom = num_lines - 1;
X
X for (i = 0; i < 8; i++)
X win->_borderchars[i] = '\0';
X
X /* init to say window unchanged */
X
X for (i = 0; i < num_lines; i++)
X {
X win->_minchng[i] = 0;
X win->_maxchng[i] = num_columns-1;
X }
X
X /* set flags for window properties */
X
X if ((begy + num_lines) == LINES)
X {
X win->_flags |= _ENDLINE;
X if ((begx == 0) && (num_columns == COLS) && (begy == 0))
X win->_flags |= _FULLWIN;
X } /* if */
X
X if (((begy + num_lines) == LINES)
X &&
X ((begx + num_columns) == COLS))
X win->_flags |= _SCROLLWIN;
X return(win);
X } /* makenew */
X
X/****************************************************************/
X/* Newwin() creates a new window with size num_lines * num_co- */
X/* lumns, and origin begx,begy relative to the SCREEN. Special */
X/* case: if num_lines and/or num_columns is 0, the remainder of */
X/* the screen is used. */
X/****************************************************************/
X
XWINDOW *newwin(num_lines, num_columns, begy, begx)
X int num_lines, num_columns, begy, begx;
X {
X WINDOW *win;
X int *ptr;
X int i, j;
X
X if (num_lines == 0)
X num_lines = LINES - begy;
X if (num_columns == 0)
X num_columns = COLS - begx;
X if ((win = makenew(num_lines, num_columns, begy, begx)) == (WINDOW *) ERR)
X return((WINDOW *) ERR);
X for (i = 0; i < num_lines; i++) /* make and clear the lines */
X {
X if((win->_line[i] = (int *) calloc(num_columns,sizeof(int))) == NULL)
X {
X for (j = 0; j < i; j++) /* if error, free all the data */
X free(win->_line[j]);
X free(win->_minchng);
X free(win->_maxchng);
X free(win->_line);
X free(win);
X return((WINDOW *) ERR);
X } /* if */
X else
X for (ptr = win->_line[i]; ptr < win->_line[i] + num_columns;)
X *ptr++ = ' ' | ATR_NRM;
X } /* for */
X return(win);
X } /* newwin */
X
X/****************************************************************/
X/* Subwin() creates a sub-window in the 'orig' window, with */
X/* size num_lines * num_columns, and with origin begx, begy */
X/* relative to the SCREEN. Special case: if num_lines and/or */
X/* num_columns is 0, the remainder of the original window is */
X/* used. The subwindow uses the original window's line buffers */
X/* to store its own lines. */
X/****************************************************************/
X
XWINDOW *subwin(orig, num_lines, num_columns, begy, begx)
X WINDOW *orig;
X int num_lines, num_columns, begy, begx;
X {
X WINDOW *win;
X int i, j, k;
X
X /* make sure window fits inside the original one */
X
X if (
X begy < orig->_begy ||
X begx < orig->_begx ||
X (begy + num_lines) >= (orig->_begy + orig->_maxy) ||
X (begx + num_columns) >= (orig->_begx + orig->_maxx)
X )
X return((WINDOW *) ERR);
X
X if (num_lines == 0)
X num_lines = orig->_maxy - 1 - (begy - orig->_begy);
X if (num_columns == 0)
X num_columns = orig->_maxx - 1 - (begx - orig->_begx);
X if ((win = makenew(num_lines, num_columns, begy, begx)) == (WINDOW *) ERR)
X return((WINDOW *) ERR);
X
X /* set line pointers the same as in the original window */
X
X j = begy - orig->_begy;
X k = begx - orig->_begx;
X for (i = 0; i < num_lines; i++)
X win->_line[i] = (orig->_line[j++]) + k;
X win->_flags |= _SUBWIN;
X return(win);
X } /* subwin */
END_OF_FILE
if test 5921 -ne `wc -c <'newwin.c'`; then
echo shar: \"'newwin.c'\" unpacked with wrong size!
fi
# end of 'newwin.c'
fi
if test -f 'prntscan.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'prntscan.c'\"
else
echo shar: Extracting \"'prntscan.c'\" \(6592 characters\)
sed "s/^X//" >'prntscan.c' <<'END_OF_FILE'
X/****************************************************************/
X/* Printw() and scanw() routines of the PCcurses package */
X/* */
X/****************************************************************/
X/* This version of curses is based on ncurses, a curses version */
X/* originally written by Pavel Curtis at Cornell University. */
X/* I have made substantial changes to make it run on IBM PC's, */
X/* and therefore consider myself free to make it public domain. */
X/* Bjorn Larsson (...mcvax!enea!infovax!bl) */
X/****************************************************************/
X/* IMPLEMENTATION NOTE */
X/* These routines make a local copy of their parameter stack, */
X/* assuming at most 5 'double' arguments were passed (== 40 */
X/* bytes == 20 int's == 10 long's == 10-20 pointers {depending */
X/* on memory model}, etc). This means the invocation of the */
X/* routines themselves requires at least 80 bytes of stack just */
X/* for the parameters, and the sprintf() and sscanf() functions */
X/* will require more. Therefore, this module should be compiled */
X/* with stack checking on to avoid stack overflow errors. */
X/****************************************************************/
X/* 1.0: Release: 870515 */
X/* 1.2: Rcsid[] string for maintenance: 881002 */
X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
X/****************************************************************/
X
X#include <curses.h>
X#include <curspriv.h>
X
Xchar _curses_prntscan_rcsid[] = "@(#)prntscan.c v1.3 - 881005";
X
Xstatic int pblen(); /* gets length of buffer */
Xstatic char printscanbuf[513]; /* buffer used during I/O */
X
X/****************************************************************/
X/* Wprintw(win,fmt,args) does a printf() in window 'win'. */
X/****************************************************************/
X
Xint wprintw(win,fmt,A1,A2,A3,A4,A5)
X WINDOW *win;
X char *fmt;
X double A1,A2,A3,A4,A5;
X {
X sprintf(printscanbuf,fmt,A1,A2,A3,A4,A5);
X if (waddstr(win,printscanbuf) == ERR)
X return(ERR);
X return(pblen());
X } /* wprintw */
X
X/****************************************************************/
X/* Printw(fmt,args) does a printf() in stdscr. */
X/****************************************************************/
X
Xint printw(fmt,A1,A2,A3,A4,A5)
X char *fmt;
X double A1,A2,A3,A4,A5;
X {
X sprintf(printscanbuf,fmt,A1,A2,A3,A4,A5);
X if(waddstr(stdscr,printscanbuf) == ERR)
X return(ERR);
X return(pblen());
X } /* printw */
X
X/****************************************************************/
X/* Mvprintw(fmt,args) moves the stdscr cursor to a new posi- */
X/* tion, then does a printf() in stdscr. */
X/****************************************************************/
X
Xint mvprintw(y,x,fmt,A1,A2,A3,A4,A5)
X int y;
X int x;
X char *fmt;
X double A1,A2,A3,A4,A5;
X {
X if (wmove(stdscr,y,x) == ERR)
X return(ERR);
X sprintf(printscanbuf,fmt,A1,A2,A3,A4,A5);
X if(waddstr(stdscr,printscanbuf) == ERR)
X return(ERR);
X return(pblen());
X } /* mvprintw */
X
X/****************************************************************/
X/* Mvwprintw(win,fmt,args) moves the window 'win's cursor to */
X/* a new position, then does a printf() in window 'win'. */
X/****************************************************************/
X
Xint mvwprintw(win,y,x,fmt,A1,A2,A3,A4,A5)
X WINDOW *win;
X int y;
X int x;
X char *fmt;
X double A1,A2,A3,A4,A5;
X {
X if (wmove(win,y,x) == ERR)
X return(ERR);
X sprintf(printscanbuf,fmt,A1,A2,A3,A4,A5);
X if(waddstr(win,printscanbuf) == ERR)
X return(ERR);
X return(pblen());
X } /* mvwprintw */
X
X/****************************************************************/
X/* Wscanw(win,fmt,args) gets a string via window 'win', then */
X/* scans the string using format 'fmt' to extract the values */
X/* and put them in the variables pointed to the arguments. */
X/****************************************************************/
X
Xint wscanw(win,fmt,A1,A2,A3,A4,A5)
X WINDOW *win;
X char *fmt;
X double A1,A2,A3,A4,A5; /* really pointers */
X {
X wrefresh(win); /* set cursor */
X if (wgetstr(win,printscanbuf) == ERR) /* get string */
X return(ERR);
X return(sscanf(printscanbuf,fmt,A1,A2,A3,A4,A5));
X } /* wscanw */
X
X/****************************************************************/
X/* Scanw(fmt,args) gets a string via stdscr, then scans the */
X/* string using format 'fmt' to extract the values and put them */
X/* in the variables pointed to the arguments. */
X/****************************************************************/
X
Xint scanw(fmt,A1,A2,A3,A4,A5)
X char *fmt;
X double A1,A2,A3,A4,A5; /* really pointers */
X {
X wrefresh(stdscr); /* set cursor */
X if (wgetstr(stdscr,printscanbuf) == ERR) /* get string */
X return(ERR);
X return(sscanf(printscanbuf,fmt,A1,A2,A3,A4,A5));
X } /* scanw */
X
X/****************************************************************/
X/* Mvscanw(y,x,fmt,args) moves stdscr's cursor to a new posi- */
X/* tion, then gets a string via stdscr and scans the string */
X/* using format 'fmt' to extract the values and put them in the */
X/* variables pointed to the arguments. */
X/****************************************************************/
X
Xint mvscanw(y,x,fmt,A1,A2,A3,A4,A5)
X int y;
X int x;
X char *fmt;
X double A1,A2,A3,A4,A5; /* really pointers */
X {
X if (wmove(stdscr,y,x) == ERR)
X return(ERR);
X wrefresh(stdscr); /* set cursor */
X if (wgetstr(stdscr,printscanbuf) == ERR) /* get string */
X return(ERR);
X return(sscanf(printscanbuf,fmt,A1,A2,A3,A4,A5));
X } /* mvscanw */
X
X/****************************************************************/
X/* Mvwscanw(win,y,x,fmt,args) moves window 'win's cursor to a */
X/* new position, then gets a string via 'win' and scans the */
X/* string using format 'fmt' to extract the values and put them */
X/* in the variables pointed to the arguments. */
X/****************************************************************/
X
Xint mvwscanw(win,y,x,fmt,A1,A2,A3,A4,A5)
X WINDOW *win;
X int y;
X int x;
X char *fmt;
X double A1,A2,A3,A4,A5; /* really pointers */
X {
X if (wmove(win,y,x) == ERR)
X return(ERR);
X wrefresh(win); /* set cursor */
X if (wgetstr(win,printscanbuf) == ERR) /* get string */
X return(ERR);
X return(sscanf(printscanbuf,fmt,A1,A2,A3,A4,A5));
X } /* mvwscanw */
X
X/****************************************************************/
X/* Pblen() returns the length of the string in printscanbuf. */
X/****************************************************************/
X
Xstatic int pblen()
X {
X char *p = printscanbuf;
X
X while(*p++);
X return(p-printscanbuf-1);
X } /* plben */
END_OF_FILE
if test 6592 -ne `wc -c <'prntscan.c'`; then
echo shar: \"'prntscan.c'\" unpacked with wrong size!
fi
# end of 'prntscan.c'
fi
if test -f 'strget.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'strget.c'\"
else
echo shar: Extracting \"'strget.c'\" \(5704 characters\)
sed "s/^X//" >'strget.c' <<'END_OF_FILE'
X/****************************************************************/
X/* Getstr() routines of the PCcurses package */
X/* */
X/****************************************************************/
X/* This version of curses is based on ncurses, a curses version */
X/* originally written by Pavel Curtis at Cornell University. */
X/* I have made substantial changes to make it run on IBM PC's, */
X/* and therefore consider myself free to make it public domain. */
X/* Bjorn Larsson (...mcvax!enea!infovax!bl) */
X/****************************************************************/
X/* 1.0: Release: 870515 */
X/* 1.2: Max limits of by 1. Block nest error in function */
X/* backchar(). Fixed thanks to S. Creps: 881002 */
X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
X/****************************************************************/
X
X#include <curses.h>
X#include <curspriv.h>
X
Xstatic char *backchar();
X
Xchar _curses_strget_rcsid[] = "@(#)strget.c v1.3 - 881005";
X
Xstatic bool oldecho;
Xstatic bool oldcbreak;
Xstatic bool oldnodelay;
Xstatic char *strbeg;
Xstatic WINDOW *w;
Xstatic int xbeg;
X
X/****************************************************************/
X/* Wgetstr(win,str) reads in a string (terminated by \n or \r) */
X/* to the buffer pointed to by 'str', and displays the input */
X/* in window 'win'. The user's erase and kill characters are */
X/* active. */
X/****************************************************************/
X
Xint wgetstr(win,str)
X WINDOW *win;
X char *str;
X {
X w = win;
X strbeg = str; /* keep start for backspacing */
X oldcbreak = _cursvar.cbreak; /* remember states */
X oldecho = _cursvar.echo;
X oldnodelay = w->_nodelay;
X _cursvar.echo = FALSE; /* we do echo ourselves */
X _cursvar.cbreak = TRUE; /* no wait for chars */
X w->_nodelay = FALSE; /* don't return 'NOCHARS' */
X xbeg = w->_curx; /* remember screen start x-position */
X
X wrefresh(w); /* sets cursor at right place */
X while ((*str = (char) getch()) != '\n')
X {
X if (*str == '\r')
X break;
X if (*str == _DCCHAR)
X {
X if (str > strbeg)
X str = backchar(str);
X } /* if */
X else
X if (*str == _DLCHAR)
X while (str > strbeg)
X str = backchar(str);
X else
X {
X waddch(w,*str++);
X wrefresh(w);
X } /* else */
X } /* while */
X
X *str = '\0';
X _cursvar.echo = oldecho;
X _cursvar.cbreak = oldcbreak;
X win->_nodelay = oldnodelay;
X return(OK);
X } /* wgetstr */
X
X/****************************************************************/
X/* Getstr(str) reads in a string (terminated by \n or \r) to */
X/* the buffer pointed to by 'str', and displays the input in */
X/* stdscr. The user's erase and kill characters are active. */
X/****************************************************************/
X
Xint getstr(str)
X char *str;
X {
X return(wgetstr(stdscr,str));
X } /* getstr */
X
X/****************************************************************/
X/* Mvgetstr(y,x,str) moves the stdscr cursor to a new position, */
X/* then reads in a string (terminated by \n or \r) to the buf- */
X/* fer pointed to by 'str', and displays the input in stdscr. */
X/* The user's erase and kill characters are active. */
X/****************************************************************/
X
Xint mvgetstr(y,x,str)
X int y;
X int x;
X char *str;
X {
X if (wmove(stdscr,y,x) == ERR)
X return(ERR);
X return(wgetstr(stdscr,str));
X } /* mvgetstr */
X
X/****************************************************************/
X/* Mvwgetstr(win,y,x,str) moves the 'win' cursor to a new */
X/* position, then reads in a string (terminated by \n or \r) */
X/* to the buffer pointed to by 'str', and displays the input in */
X/* stdscr. The user's erase and kill characters are active. */
X/****************************************************************/
X
Xint mvwgetstr(win,y,x,str)
X WINDOW *win;
X int y;
X int x;
X char *str;
X {
X if (wmove(win,y,x) == ERR)
X return(ERR);
X return(wgetstr(win,str));
X } /* mvwgetstr */
X
X/****************************************************************/
X/* Backchar() does a character delete with screen erase, even */
X/* up to previous lines. It will not back-scroll if the begi- */
X/* ning of the string has scrolled off the window. Steps back */
X/* pointer 's', and returns the new value. */
X/****************************************************************/
X
Xstatic char *backchar(s)
X char *s;
X {
X static int nbs;
X static int x;
X static char *p;
X static int ts;
X
X x = xbeg;
X ts = w->_tabsize;
X
X s--; /* step back string */
X nbs = 1; /* step at least one pos */
X if ((*s < ' ') || (*s == 0x7f)) /* ctrl-char has size 2 */
X nbs++;
X if (*s == '\t') /* tabs are very special */
X {
X for (p = strbeg; p < s ;p++) /* find x-pos of last char */
X {
X if (*p == '\t') /* go to next tab */
X x = ((x/ts)+1) * ts;
X else
X {
X if ((*p < ' ') || (*p == 0x7f)) /* control character */
X x += 2;
X else /* normal char */
X x++;
X } /* else */
X if (x >= w->_maxx) /* go to next line? */
X x = 0;
X } /* for */
X if (!(w->_curx)) /* if step-over newline */
X nbs = w->_maxx - x;
X else /* in-line tab */
X nbs = w->_curx - x; /* positions to erase */
X } /* if */
X
X while(nbs--) /* do so many */
X {
X if (w->_curx > 0) /* if not at line beginning */
X waddstr(w,"\b \b");
X else
X if (w->_cury) /* if not on top line */
X {
X mvwaddch(w,w->_cury-1,w->_maxx -1,' '); /* put space at line end */
X wmove(w,w->_cury-1,w->_maxx - 1); /* and go there again */
X } /* else */
X } /* while */
X
X wrefresh(w); /* redraw screen */
X *(s+1) = '\0'; /* make string terminated */
X return(s);
X } /* backchar */
END_OF_FILE
if test 5704 -ne `wc -c <'strget.c'`; then
echo shar: \"'strget.c'\" unpacked with wrong size!
fi
# end of 'strget.c'
fi
if test -f 'update.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'update.c'\"
else
echo shar: Extracting \"'update.c'\" \(8444 characters\)
sed "s/^X//" >'update.c' <<'END_OF_FILE'
X/****************************************************************/
X/* Doupdate() routine of the PCcurses package */
X/* */
X/****************************************************************/
X/* This version of curses is based on ncurses, a curses version */
X/* originally written by Pavel Curtis at Cornell University. */
X/* I have made substantial changes to make it run on IBM PC's, */
X/* and therefore consider myself free to make it public domain. */
X/* Bjorn Larsson (...mcvax!enea!infovax!bl) */
X/****************************************************************/
X/* 1.0: Release: 870515 */
X/* 1.2: Changed call sequence to cursesio.[c,asm], Thanks */
X/* to S. Creps. Rcsid[] string for maintenance: 881002 */
X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
X/****************************************************************/
X
X#include <curses.h>
X#include <curspriv.h>
X
Xstatic void clrupdate(); /* fwd declaration */
Xstatic bool transformline();
Xstatic void clearscreen();
Xstatic void gotoxy();
Xstatic void Putchar();
X
Xchar _curses_update_rcsid[] = "@(#)update.c v1.3 - 881005";
X
Xstatic WINDOW *twin; /* used by many routines */
X
Xstatic char atrtab[64] = /* attribute encoding table. */
X { /* feel free to edit if your */
X (char)7, /* NORMAL (0) */ /* display board supports all */
X (char)0x87, /* BLINK */ /* possible combinations */
X (char)0, /* BLANK */
X (char)0, /* BLINK & BLANK */
X (char)0xf, /* BOLD */
X (char)0x8f, /* BOLD & BLINK */
X (char)0, /* BOLD & BLANK */
X (char)0, /* BOLD & BLINK & BLANK */
X (char)0x70, /* REVERSE (8) */
X (char)0xf0, /* REVERSE & BLINK */
X (char)0, /* REVERSE & BLANK */
X (char)0, /* REVERSE & BLINK & BLANK */
X (char)0x78, /* REVERSE & BOLD */
X (char)0xf8, /* REVERSE & BOLD & BLINK */
X (char)0, /* REVERSE & BOLD & BLANK */
X (char)0, /* REVERSE & BOLD & BLINK & BLANK */
X (char)0xf, /* STANDOUT (10) */
X (char)0x8f, /* STANDOUT & BLINK */
X (char)0, /* STANDOUT & BLANK */
X (char)0, /* STANDOUT & BLINK & BLANK */
X (char)0xf, /* STANDOUT & BOLD */
X (char)0x8f, /* STANDOUT & BOLD & BLINK */
X (char)0, /* STANDOUT & BOLD & BLANK */
X (char)0, /* STANDOUT & BOLD & BLINK & BLANK */
X (char)0x70, /* STANDOUT & REVERSE (18) */
X (char)0xf0, /* STANDOUT & REVERSE & BLINK */
X (char)0, /* STANDOUT & REVERSE & BLANK */
X (char)0, /* STANDOUT & REVERSE & BLINK & BLANK */
X (char)0x70, /* STANDOUT & REVERSE & BOLD */
X (char)0xf0, /* STANDOUT & REVERSE & BOLD & BLINK */
X (char)0, /* STANDOUT & REVERSE & BOLD & BLANK */
X (char)0, /* STANDOUT & REVERSE & BOLD & BLINK & BLANK */
X (char)1, /* UNDERLINE (20) */
X (char)0x81, /* UNDERLINE & BLINK */
X (char)0, /* UNDERLINE & BLANK */
X (char)0, /* UNDERLINE & BLINK & BLANK */
X (char)9, /* UNDERLINE & BOLD */
X (char)0x89, /* UNDERLINE & BOLD & BLINK */
X (char)0, /* UNDERLINE & BOLD & BLANK */
X (char)0, /* UNDERLINE & BOLD & BLINK & BLANK */
X (char)0x70, /* UNDERLINE & REVERSE (28) */
X (char)0xf0, /* UNDERLINE & REVERSE & BLINK */
X (char)0, /* UNDERLINE & REVERSE & BLANK */
X (char)0, /* UNDERLINE & REVERSE & BLINK & BLANK */
X (char)0x79, /* UNDERLINE & REVERSE & BOLD */
X (char)0xf9, /* UNDERLINE & REVERSE & BOLD & BLINK */
X (char)0, /* UNDERLINE & REVERSE & BOLD & BLANK */
X (char)0, /* UNDERLINE & REVERSE & BOLD & BLINK & BLANK */
X (char)9, /* UNDERLINE & STANDOUT (30) */
X (char)0x89, /* UNDERLINE & STANDOUT & BLINK */
X (char)0, /* UNDERLINE & STANDOUT & BLANK */
X (char)0, /* UNDERLINE & STANDOUT & BLINK & BLANK */
X (char)9, /* UNDERLINE & STANDOUT & BOLD */
X (char)0x89, /* UNDERLINE & STANDOUT & BOLD & BLINK */
X (char)0, /* UNDERLINE & STANDOUT & BOLD & BLANK */
X (char)0, /* UNDERLINE & STANDOUT & BOLD & BLINK & BLANK */
X (char)0x70, /* UNDERLINE & STANDOUT & REVERSE (38) */
X (char)0xf0, /* UNDERLINE & STANDOUT & REVERSE & BLINK */
X (char)0, /* UNDERLINE & STANDOUT & REVERSE & BLANK */
X (char)0, /* UNDERLINE & STANDOUT & REVERSE & BLINK & BLANK */
X (char)0x70, /* UNDERLINE & STANDOUT & REVERSE & BOLD */
X (char)0xf0, /* UNDERLINE & STANDOUT & REVERSE & BOLD & BLINK */
X (char)0, /* UNDERLINE & STANDOUT & REVERSE & BOLD & BLANK */
X (char)0, /* UNDERLINE & STANDOUT & REVERSE & BOLD & BLINK & BLANK */
X };
X
X/****************************************************************/
X/* Doupdate() updates the physical screen to look like _curs- */
X/* var.tmpwin if curscr is not 'Clear-marked'. Otherwise it */
X/* updates the screen to look like curscr. */
X/****************************************************************/
X
Xvoid doupdate()
X {
X register int i;
X
X twin = _cursvar.tmpwin;
X if (curscr->_clear)
X clrupdate(curscr);
X else
X {
X if (twin->_clear)
X clrupdate(twin);
X else
X {
X for (i=0; i < LINES; i++)
X if (twin->_minchng[i] != _NO_CHANGE)
X if (transformline(i))
X break;
X } /* else */
X } /* else */
X curscr->_curx = twin->_curx;
X curscr->_cury = twin->_cury;
X gotoxy(curscr->_cury, curscr->_curx);
X } /* doupdate */
X
X/****************************************************************/
X/* Clrupdate(scr) updates the screen by clearing it and then */
X/* redraw it in its entirety. If _cursvar.refrbrk is TRUE, and */
X/* there is pending input characters, the update will be pre- */
X/* maturely terminated. */
X/****************************************************************/
X
Xstatic void clrupdate(scr)
X WINDOW *scr;
X {
X register int *src;
X register int *dst;
X register int i;
X register int j;
X static WINDOW *w;
X
X w = curscr;
X
X if (scr != w) /* copy scr to curscr */
X {
X for (i=0; i < LINES; i++)
X {
X src = scr->_line[i];
X dst = w->_line[i];
X for (j=0; j < COLS; j++)
X *dst++ = *src++;
X } /* for */
X } /* if */
X clearscreen(); /* clear physical screen */
X scr->_clear = FALSE;
X for (i=0; i < LINES; i++) /* update physical screen */
X {
X src = w->_line[i];
X for(j=0; j < COLS; j++)
X {
X if (*src != (' ' | ATR_NRM))
X {
X gotoxy(i,j);
X Putchar(*src);
X } /* if */
X src++;
X } /* for */
X if(_cursvar.refrbrk && _cursespendch())
X return;
X } /* for */
X } /* clrupdate */
X
X/****************************************************************/
X/* Transformline() updates the given physical line to look */
X/* like the corresponding line in _cursvar.tmpwin. Transform- */
X/* returns 1 if premature refresh end is allowed, and there is */
X/* an input character pending. */
X/****************************************************************/
X
Xstatic bool transformline(lineno)
X register int lineno;
X {
X register int *dstp;
X register int *srcp;
X static int x;
X static int endx;
X
X x = twin->_minchng[lineno];
X endx = twin->_maxchng[lineno];
X dstp = curscr->_line[lineno] + x;
X srcp = twin->_line[lineno] + x;
X
X for( ; x <= endx; x++)
X {
X if(*dstp != *srcp)
X {
X gotoxy(lineno,x);
X Putchar(*srcp);
X } /* if */
X *dstp++ = *srcp++;
X } /* for */
X twin->_minchng[lineno] = _NO_CHANGE;
X twin->_maxchng[lineno] = _NO_CHANGE;
X return ((bool)(_cursvar.refrbrk && _cursespendch()));
X } /* transformline */
X
X/****************************************************************/
X/* Clearscreen() clears the physical screen and puts the cursor */
X/* in the home position. */
X/****************************************************************/
X
Xstatic void clearscreen()
X {
X _cursesscroll(0,0,LINES-1,COLS-1,0,atrtab[0]);
X gotoxy(0,0);
X } /* clearscreen */
X
X/****************************************************************/
X/* Gotoxy() moves the physical cursor to the desired address on */
X/* the screen. We don't optimize here - on a PC, it takes more */
X/* time to optimize than to do things directly. */
X/****************************************************************/
X
Xstatic void gotoxy(row,col)
X int row, col;
X {
X if((_cursvar.cursrow == row) && (_cursvar.curscol == col))
X return;
X _cursescursor(row,col);
X _cursvar.cursrow = row;
X _cursvar.curscol = col;
X } /* gotoxy */
X
X/****************************************************************/
X/* Putchar() writes a character, with attributes, to the physi- */
X/* cal screen, but avoids writing to the lower right screen */
X/* position. */
X/****************************************************************/
X
Xstatic void Putchar(ch)
X int ch;
X {
X if ((_cursvar.cursrow < LINES) || (_cursvar.curscol < COLS))
X _cursescattr(ch,atrtab[(ch >> 8) & 0x3f],1);
X } /* Putchar */
END_OF_FILE
if test 8444 -ne `wc -c <'update.c'`; then
echo shar: \"'update.c'\" unpacked with wrong size!
fi
# end of 'update.c'
fi
echo shar: End of archive 3 \(of 5\).
cp /dev/null ark3isdone
MISSING=""
for I in 1 2 3 4 5 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 5 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
More information about the Comp.sources.misc
mailing list