Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!agate!violet.berkeley.edu!dean From: dean@violet.berkeley.edu (Dean Pentcheff) Newsgroups: comp.sources.bugs Subject: Re: PC Curses bug (and fixes) Message-ID: <7026@agate.BERKELEY.EDU> Date: 18 Feb 88 06:06:08 GMT References: <924@silver.bacs.indiana.edu> Sender: usenet@agate.BERKELEY.EDU Reply-To: dean@violet.berkeley.edu.UUCP (Dean Pentcheff) Followup-To: comp.sources.bugs Organization: University of California, Berkeley Department of Zoology Lines: 1583 Keywords: clrbot clrtobot cursesio raw Summary: Attached is a highly unofficial set of fixes for PC Curses bugs. In article <924@silver.bacs.indiana.edu> creps@silver.UUCP (Steve Creps) writes: > In the file clrtobot.c in the PC Curses package, there is a routine >named clrbot(). I'm pretty sure this should actually be named clrtobot(). Yes: looking at the documentation and the code, it should be. > While I'm at it, another problem I haven't had time to check into is >a possible bug in cursesio.asm. I've had my machine lock up before... Yes: I found problems in the Turbo C version (which I suspect was essentially unchanged from any other PC version). Attached below is a shar file which contains replacement and additional files for PC Curses, based on the Turbo C version posted by Michael Ewan. These are in no way to be considered "official" fixes - they are just fixes that I've tried that seem to work (on a No-Name 286 clone [Phoenix bios] and a Zenith Z-151). My modification notes are appended to Michael Ewan's in the file "readme.too". In general, I suspect that most of these modifications are _not_ peculiar to the Turbo C version. The only ones that probably are use Turbo C's special bios call routines. Good luck. If anyone finds problems herein, I'd appreciate knowing about it. -Dean ----------------- Dean Pentcheff (dean@violet.berkeley.edu) ----------------- "A university is a place where people pay high prices for goods which they then proceed to leave on the counter when they go out of the store." Loren Eiseley ---CutCutCutCutCutCutCutCutCutCutCutCutCutCutCutCutCutCutCutCutCutCutCutCut--- : : Shell Archive. Created Wed Feb 17 21:51:12 PST 1988 : Run under /bin/sh to create: : readme.too : makefile : cursesio.asm : charget.c : clrtobot.c : curses.cmd : curses.lst : curspriv.h : getch.c : setmode.c : xlist echo readme.too '(2143 characters)' if test -f readme.too then echo readme.too already exists - will not overwrite else sed 's/^X//' << 'SHARMARKER' > readme.too X X X The makefile and 'c' sources in this archive have been ported for X Borland TurboC. The libraries have been compiled using TurboC. X X Be sure to use the supplied make.exe if you re-compile the sources. X I tried the 'make' supplied with TurboC and found this one much X better. Also the makefile is specific to this 'make'. X X X Michael Ewan X Tektronix Inc. X PO Box 500 X Beaverton OR 97077 X X 503-627-6468 X X sytek@tekgen.TEK.COM X ...!tektronix!tekgen!owl!mike X--------------- XModifications by Dean Pentcheff (dean@violet.berkeley.edu) X X12/87 Changed the makefile a little. Switched to the Turbo librarian X tlib (added tlib-compatible response file curses.lst). X12/87 Added the setmode.c module, which adds the terminfo-compatible X routines: reset_prog_mode(), reset_shell_mode(), set_prog_mode(), X and set_shell_mode(); X1/88 Modified a few lines in cursesio.asm (search on NDP to find them). X Some to fit Turbo object module conventions, one fix to allow the X assembly language keypress checker to work (fixes raw() mode). X1/88 Moved an #undef line in charget to fix another problem with raw(). X1/88 Added the option of #defining UCMASM if you are working with an X assembler as old as mine that refuses to output lowercase symbols. X If UCMASM is defined before #including , then the X names of the asm routines in the C code will be uppercased. X1/88 Moved the "#undef getch" to the top of charget.c, so it covers the X flushinp() routine as well. X1/88 Added the getch.c module, which is a new version of getch(). Turbo's X getch() calls a DOS function which ignores ^C/^Break, which caused X cbreak() mode (when nodelay() is _not_ invoked) to improperly ignore X those ^C/^Break too. The substituted getch() fixes that, at the cost X of a linker warning message, since getch() is duplicated in the X Turbo library. X1/88 Made the file "xlist" as a Turbo librarian response file to extract X modules from the pcurses.lib modules. This can be useful if you want X to extract all the modules from the library prior to recompiling one X of them, to avoid having to recompile everything. X2/88 Fixed clrbot() to make it clrtobot() in clrtobot.c SHARMARKER len=`wc -c readme.too | sed "s/^ *\([0-9][0-9]*\) .*/\1/"` if test 2143 -ne $len then echo readme.too should be 2143, but is $len characters long fi fi echo makefile '(10209 characters)' if test -f makefile then echo makefile already exists - will not overwrite else sed 's/^X//' << 'SHARMARKER' > makefile X################################################################# X# PCCURSES # X# Makefile to generate scurses.lib, ccurses.lib, mcurses.lib, # X# lcurses.lib for turbo c. # X# # X# This makefile will generate subdirectories and call itself # X# recursively... # X# # X# Use the enclosed make rather than turboc make or MSC make # X################################################################# X# 1.0: Release: 870515 # X################################################################# X X# The following are the directories where your lib and include files X# will be installed X XLIBDIR= \usr\tc\lib XINCDIR= \usr\tc\include XCC = tcc X# suppress the Parameter "XXXXXX" is never used warning, X# include defines to fix up for braindamaged uppercase only MASM XCFLAGS = -w-par -DUCMASM X X# General definitions: X XCOBJS= attrib.obj beep.obj boxes.obj charadd.obj \ X chardel.obj charget.obj charins.obj charpick.obj \ X clrtobot.obj clrtoeol.obj endwin.obj initscr.obj \ X linedel.obj lineins.obj longname.obj move.obj \ X mvcursor.obj newwin.obj options.obj overlay.obj \ X prntscan.obj refresh.obj scrreg.obj setterm.obj \ X stradd.obj strget.obj termmisc.obj tabsize.obj \ X unctrl.obj update.obj winclear.obj windel.obj \ X winerase.obj winmove.obj winscrol.obj wintouch.obj \ X setmode.obj getch.obj X XASMOBJS= cursesio.obj X XOBJS= $(COBJS) $(ASMOBJS) X X################################################################# X# 'all' is all that can (and usually is) done # X################################################################# X Xall: small compact medium large X X################################################################# X# The following copies the header files to their proper place # X################################################################# X Xheaders: $(INCDIR)\curses.h $(INCDIR)\curspriv.h X X$(INCDIR)\curses.h: curses.h X copy curses.h $(INCDIR)\curses.h X X$(INCDIR)\curspriv.h: curspriv.h X copy curspriv.h $(INCDIR)\curspriv.h X X################################################################# X# The following will create a subdirectory for each memory # X# model, and initiate the make:ing in each one. # X################################################################# X X################################################################# X# create work directory if non-existent, go to it, and # X# perform the job - small model # X################################################################# X Xsmall: headers \ X smodel \ X smodel\farnear.inc \ X smodel\smalhuge.inc X cd smodel X make -f ..\makefile $(MAKEFLAGS) "MODEL=s" $(LIBDIR)\scurses.lib X cd .. X Xsmodel: X mkdir smodel X Xsmodel\farnear.inc: nearcall.inc X copy nearcall.inc smodel\farnear.inc X Xsmodel\smalhuge.inc: smaldata.inc X copy smaldata.inc smodel\smalhuge.inc X X################################################################# X# create work directory if non-existent, go to it, and # X# perform the job - compact model # X################################################################# X Xcompact: headers \ X cmodel \ X cmodel\farnear.inc \ X cmodel\smalhuge.inc X cd cmodel X -make -f ..\makefile $(MAKEFLAGS) "MODEL=c" $(LIBDIR)\ccurses.lib X cd .. X Xcmodel: X mkdir cmodel X Xcmodel\farnear.inc: nearcall.inc X copy nearcall.inc cmodel\farnear.inc X Xcmodel\smalhuge.inc: hugedata.inc X copy hugedata.inc cmodel\smalhuge.inc X X################################################################# X# create work directory if non-existent, go to it, and # X# perform the job - medium model # X################################################################# X Xmedium: headers \ X mmodel \ X mmodel\farnear.inc \ X mmodel\smalhuge.inc X cd mmodel X -make -f ..\makefile $(MAKEFLAGS) "MODEL=m" $(LIBDIR)\mcurses.lib X cd .. X Xmmodel: X mkdir mmodel X Xmmodel\farnear.inc: farcall.inc X copy farcall.inc mmodel\farnear.inc X Xmmodel\smalhuge.inc: smaldata.inc X copy smaldata.inc mmodel\smalhuge.inc X X################################################################# X# create work directory if non-existent, go to it, and # X# perform the job - large model # X################################################################# X Xlarge: headers \ X lmodel \ X lmodel\farnear.inc \ X lmodel\smalhuge.inc X cd lmodel X -make -f ..\makefile $(MAKEFLAGS) "MODEL=l" $(LIBDIR)\lcurses.lib X cd .. X Xlmodel: X mkdir lmodel X Xlmodel\farnear.inc: farcall.inc X copy farcall.inc lmodel\farnear.inc X Xlmodel\smalhuge.inc: hugedata.inc X copy hugedata.inc lmodel\smalhuge.inc X X################################################################# X# Put together the library in file tmp.lib, then copy it to # X# the appropriate name for the memory model in question, and # X# delete the temporary file # X################################################################# X X$(LIBDIR)\$(MODEL)curses.lib: $(OBJS) X del tmp.lib X# lib @..\curses.cmd X tlib @..\curses.lst X copy tmp.lib $(LIBDIR)\$(MODEL)curses.lib X del tmp.lib X X################################################################# X# commands and dependencies for individual modules # X################################################################# X Xattrib.obj: ..\attrib.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -oattrib ..\attrib.c X Xbeep.obj: ..\beep.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -obeep ..\beep.c X Xboxes.obj: ..\boxes.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -oboxes ..\boxes.c X Xcharadd.obj: ..\charadd.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -ocharadd ..\charadd.c X Xchardel.obj: ..\chardel.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -ochardel ..\chardel.c X Xcharget.obj: ..\charget.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -ocharget ..\charget.c X Xcharins.obj: ..\charins.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -ocharins ..\charins.c X Xcharpick.obj: ..\charpick.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -ocharpick ..\charpick.c X Xclrtobot.obj: ..\clrtobot.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -oclrtobot ..\clrtobot.c X Xclrtoeol.obj: ..\clrtoeol.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -oclrtoeol ..\clrtoeol.c X Xendwin.obj: ..\endwin.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -oendwin ..\endwin.c X Xinitscr.obj: ..\initscr.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -oinitscr ..\initscr.c X Xlinedel.obj: ..\linedel.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -olinedel ..\linedel.c X Xlineins.obj: ..\lineins.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -olineins ..\lineins.c X Xlongname.obj: ..\longname.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -olongname ..\longname.c X Xmove.obj: ..\move.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -omove ..\move.c X Xmvcursor.obj: ..\mvcursor.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -omvcursor ..\mvcursor.c X Xnewwin.obj: ..\newwin.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -onewwin ..\newwin.c X Xoptions.obj: ..\options.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -ooptions ..\options.c X Xoverlay.obj: ..\overlay.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -ooverlay ..\overlay.c X Xprntscan.obj: ..\prntscan.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -oprntscan ..\prntscan.c X Xrefresh.obj: ..\refresh.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -orefresh ..\refresh.c X Xscrreg.obj: ..\scrreg.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -oscrreg ..\scrreg.c X Xsetterm.obj: ..\setterm.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -osetterm ..\setterm.c X Xstradd.obj: ..\stradd.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -ostradd ..\stradd.c X Xstrget.obj: ..\strget.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -ostrget ..\strget.c X Xtabsize.obj: ..\tabsize.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -otabsize ..\tabsize.c X Xtermmisc.obj: ..\termmisc.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -otermmisc ..\termmisc.c X Xunctrl.obj: ..\unctrl.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -ounctrl ..\unctrl.c X Xupdate.obj: ..\update.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -oupdate ..\update.c X Xwinclear.obj: ..\winclear.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -owinclear ..\winclear.c X Xwindel.obj: ..\windel.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -owindel ..\windel.c X Xwinerase.obj: ..\winerase.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -owinerase ..\winerase.c X Xwinmove.obj: ..\winmove.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -owinmove ..\winmove.c X Xwinscrol.obj: ..\winscrol.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -owinscrol ..\winscrol.c X Xwintouch.obj: ..\wintouch.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -owintouch ..\wintouch.c X Xcursesio.obj: ..\cursesio.asm X# masm ..\cursesio.asm/mx,cursesio.obj,nul,nul; X masm ..\cursesio.asm/x,cursesio.obj,nul,nul; X Xsetmode.obj: ..\setmode.c ..\curses.h ..\curspriv.h X $(CC) $(CFLAGS) -m$(MODEL) -c -O -osetmode ..\setmode.c X Xgetch.obj: ..\getch.c X $(CC) $(CFLAGS) -A- -m$(MODEL) -c -O -ogetch ..\getch.c X X################################################################# X# Perform a backup of the files in the directory where the # X# 'make backup' command was issued - copies all files to the # X# directory \pcurses on the A: floppy # X################################################################# X Xbackup: X @echo ***** backup of curses ***** X @echo Insert backup diskette in drive A: and hit any key! X @pause X mkdir a:\pcurses X del a:\pcurses\*.* X copy *.* a:\pcurses X X################################################################# X# Remove all temporary files and work directories that were # X# created # X################################################################# X Xclean: X del smodel\*.* X del cmodel\*.* X del mmodel\*.* X del lmodel\*.* X rmdir smodel X rmdir cmodel X rmdir mmodel X rmdir lmodel SHARMARKER len=`wc -c makefile | sed "s/^ *\([0-9][0-9]*\) .*/\1/"` if test 10209 -ne $len then echo makefile should be 10209, but is $len characters long fi fi echo cursesio.asm '(8978 characters)' if test -f cursesio.asm then echo cursesio.asm already exists - will not overwrite else sed 's/^X//' << 'SHARMARKER' > cursesio.asm X ;TITLE PCcurses BIOS Control Functions for MicroSoft 'C' v.4.0 X TITLE PCcurses BIOS Control Functions for Turbo C 1.5 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. It exercises a number of BIOS video calls, and * X ;* is intended for inclusion in 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 ;**************************************************************** X ;* Modified by N. Dean Pentcheff (dean@violet.berkeley.edu) for * X ;* Turbo C 1.5. Search for "NDP" to see changes. * X ;* 1/88 * 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 ; NDP 1/88 Turbo C 1.5 XCURSESIO_TEXT SEGMENT BYTE PUBLIC 'CODE' ; NDP 1/88 X ASSUME CS: CURSESIO_TEXT ; NDP 1/88 X else ; NDP 1/88 X_TEXT SEGMENT BYTE PUBLIC 'CODE' X ASSUME CS: _TEXT Xendif ; NDP 1/88 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 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,2 ;GET CHR PARAMETER X g_parm BL,3 ;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,2 ;GET ROW PARAMETER X g_parm DL,3 ;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 non-0, the uper bits contain the extended cha- * X ;* racter 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 ;* NDP 1/88 * X ;* The change below bothers me. The original should be correct * X ;* according to the documentation in Peter Norton's Programmer's* X ;* Guide to the IBM PC. The modification agrees with Norton's * X ;* example (which contradicts his description), and seems to * X ;* work here. This has been tested on a Phoenix-BIOS AT clone * X ;* and a Zenith Z-151 PC clone (Zenith BIOS). * X ;**************************************************************** X PUBLIC __curseskeytst X ; X c_entry __curseskeytst X MOV AH,1 X INT 16H X JNZ SHORT TST1 ; NDP 1/88 Changed from JZ to JNZ 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 ; NDP 1/88 Turbo C 1.5 XCURSESIO_TEXT ENDS ; NDP 1/88 X else ; NDP 1/88 X_TEXT ENDS X endif ; NDP 1/88 X if1 X %OUT Pass 1 Completed X else X %OUT Assembly Completed X endif X END SHARMARKER len=`wc -c cursesio.asm | sed "s/^ *\([0-9][0-9]*\) .*/\1/"` if test 8978 -ne $len then echo cursesio.asm should be 8978, but is $len characters long fi fi echo charget.c '(8573 characters)' if test -f charget.c then echo charget.c already exists - will not overwrite else sed 's/^X//' << 'SHARMARKER' > charget.c X/****************************************************************/ X/* Getch() 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/****************************************************************/ X X#include X#include X X/* NDP 1/88 Moved undef from just sysgetch() to here so it covers X flushinp(). This caused raw() call to crash */ X#undef getch /* we use MSC getch() below */ X Xstatic int rawgetch(); /* get raw char via BIOS */ Xstatic int sysgetch(); /* get char via system */ Xstatic int validchar(); /* keypad xlate and char check */ X Xstatic int buffer[_INBUFSIZ]; /* character buffer */ Xstatic int pindex = 0; /* putter index */ Xstatic int gindex = 1; /* getter index */ Xstatic WINDOW *w; /* to reduce stack usage */ Xstatic int ungind = 0; /* wungetch() push index */ Xstatic int ungch[NUNGETCH]; /* array of ungotten chars */ X X/* table for key code translation of function keys in keypad mode */ X/* These values are for strict IBM keyboard compatibles only */ X Xstatic int kptab[] = X { X 0x3b,KEY_F(1), 0x3c,KEY_F(2), 0x3d,KEY_F(3), 0x3e,KEY_F(4), X 0x3f,KEY_F(5), 0x40,KEY_F(6), 0x41,KEY_F(7), 0x42,KEY_F(8), X 0x43,KEY_F(9), 0x44,KEY_F(10), 0x47,KEY_HOME, 0x48,KEY_UP, X 0x49,KEY_PPAGE, 0x4b,KEY_LEFT, 0x4d,KEY_RIGHT, 0x4f,KEY_LL, X 0x50,KEY_DOWN, 0x51,KEY_NPAGE, 0x52,KEY_IC, 0x53,KEY_DC, X 0x54,KEY_F(11), 0x55,KEY_F(12), 0x56,KEY_F(13), 0x57,KEY_F(14), X 0x58,KEY_F(15), 0x59,KEY_F(16), 0x5a,KEY_F(17), 0x5b,KEY_F(18), X 0x5c,KEY_F(19), 0x5d,KEY_F(20), 0x5e,KEY_F(21), 0x5f,KEY_F(22), X 0x60,KEY_F(23), 0x61,KEY_F(24), 0x62,KEY_F(25), 0x63,KEY_F(26), X 0x64,KEY_F(27), 0x65,KEY_F(28), 0x66,KEY_F(29), 0x67,KEY_F(30), X 0x73,KEY_LEFT, 0x74,KEY_RIGHT, 0x75,KEY_LL, 0x76,KEY_NPAGE, X 0x77,KEY_HOME, 0x84,KEY_PPAGE, 0x100, -1 X }; X X X/****************************************************************/ X/* Wgetch(win) gets a character from the terminal, in normal, */ X/* cbreak or raw mode, optionally echoing to window 'win'. */ X/****************************************************************/ X Xint wgetch(win) X WINDOW *win; X { X int key; X int cbr; X X if (ungind) /* if ungotten char exists */ X return(ungch[--ungind]); /* remove and return it */ X X if ((!_cursvar.raw) && (!_cursvar.cbreak)) /* if normal */ X if (gindex < pindex) /* and data in buffer */ X return(buffer[gindex++]); X X w = win; /* static for speed & stack */ X pindex = 0; /* prepare to buffer data */ X gindex = 0; X while(1) /* loop for any buffering */ X { X if (_cursvar.raw) /* get a raw character */ X key = rawgetch(); X else /* get a system character */ X { X cbr = _cursesgcb(); /* get ^BREAK status */ X _cursesscb(_cursvar.orgcbr); /* if break return proper */ X key = sysgetch(); X _cursesscb(cbr); /* restore as it was */ X } X if (w->_nodelay && (key == -1)) /* if nodelay and no char */ X return(-1); X if ((key == '\r') && _cursvar.autocr && !_cursvar.raw) /* translate cr */ X key = '\n'; X if (_cursvar.echo && (key < 0x100)) /* check if echo */ X { X waddch(w,key); X wrefresh(w); X } X if (_cursvar.raw || _cursvar.cbreak) /* if no buffering */ X return(key); X if (pindex < _INBUFSIZ-2) /* if no overflow, */ X buffer[pindex++] = key; /* put data in buffer */ X if ((key == '\n') || (key == '\r')) /* if we got a line */ X return(buffer[gindex++]); X } /* while */ X } /* wgetch */ X X/****************************************************************/ X/* Flushinp() kills any pending input characters. */ X/****************************************************************/ X Xvoid flushinp() X { X while(_curseskeytst()) /* empty keyboard buffer */ X _curseskey(); X while(kbhit()) /* empty system's buffers */ X getch(); X gindex = 1; /* set indices to kill buffer */ X pindex = 0; X ungind = 0; /* clear ungch array */ X } /* flushinp */ X X/****************************************************************/ X/* Wungetch() pushes back it's argument on the input stream. If */ X/* OK, returns 1, otherwise returns 0. */ X/****************************************************************/ X Xint wungetch(ch) X int ch; X { X if (ungind >= NUNGETCH) /* pushback stack full */ X return(0); X ungch[ungind++] = ch; X return(1); X } /* wungetch() */ X X/****************************************************************/ X/* Mvgetch() first moves the stdscr cursor to a new location, */ X/* then does a wgetch() on stdscr. */ X/****************************************************************/ X Xint mvgetch(y,x) X int y; X int x; X { X wmove(stdscr,y,x); X wgetch(stdscr); X } /* mvgetch */ X X/****************************************************************/ X/* Mvwgetch() first moves the cursor of window 'win' to a new */ X/* location, then does a wgetch() in 'win'. */ X/****************************************************************/ X Xint mvwgetch(win,y,x) X WINDOW *win; X int y; X int x; X { X wmove(win,y,x); X wgetch(win); X } /* mvwgetch */ X X/****************************************************************/ X/* rawgetch() gets a character without any interpretation at */ X/* all and returns it. If keypad mode is active for the desig- */ X/* nated window, function key translation will be performed. */ X/* Otherwise, function keys are ignored.If nodelay mode is */ X/* active in the window, then rawgetch() returns -1 if no cha- */ X/* racter is available. */ X/****************************************************************/ X Xstatic int rawgetch() X { X int c; X X if (w->_nodelay && !_curseskeytst()) X return(-1); X while(1) /* loop to get valid char */ X { X if ((c = validchar(_curseskey())) >= 0) X return(c); X } /* while */ X } /* rawgetch */ X X/****************************************************************/ X/* Sysgetch() gets a character with normal ^S, ^Q, ^P and ^C */ X/* interpretation and returns it. If keypad mode is active for */ X/* the designated window, function key translation will be per- */ X/* formed. Otherwise, function keys are ignored. If nodelay */ X/* mode is active in the window, then sysgetch() returns -1 if */ X/* no character is available. */ X/****************************************************************/ X Xstatic int sysgetch() X { X int c; X X if (w->_nodelay && !kbhit()) X return(-1); X while(1) X { X c = getch(); X if (c) /* if not a function key */ X return(c & 0xff); /* avoids sign-extending */ X c = getch(); X if ((c = validchar(c << 8)) >= 0) /* get & check next char */ X return(c); X } /* while */ X } /* sysgetch */ X X/****************************************************************/ X/* Validchar(c) chacks that 'c' is a valid character, and */ X/* if so returns it, with function key translation applied if */ X/* 'w' has keypad mode set. If char is invalid, returns -1. */ X/****************************************************************/ X Xstatic int validchar(c) X int c; X { X int *scanp; X X if (c == 0x0300) /* special case, ^@ = NULL */ X return(0); X if (!(c & 0xff00)) /* normal character */ X return(c); X if (!(w->_keypad)) /* skip f keys if not keypad mode */ X return(-1); X c = (c >> 8) & 0xff; X scanp = kptab; X while(*scanp <= c) /* search for value */ X { /* (stops on table entry 0x100) */ X if (*scanp++ == c) X return(*scanp); /* found, return it */ X scanp++; X } X return(-1); /* not found, invalid */ X } /* validchar */ X X/****************************************************************/ X/* _cursespendch() returns 1 if there is any character avai- */ X/* lable, and 0 if there is none. this is not for programmer */ X/* usage, but for the updatew routines. */ X/****************************************************************/ X Xbool _cursespendch() X { X if (ungind) /* ungotten char */ X return(TRUE); X if (pindex > gindex) /* buffered char */ X return(TRUE); X if (_cursvar.raw) /* raw mode test */ X return(_curseskeytst()); X return(kbhit()); /* normal mode test */ X } /* _cursespendch */ SHARMARKER len=`wc -c charget.c | sed "s/^ *\([0-9][0-9]*\) .*/\1/"` if test 8573 -ne $len then echo charget.c should be 8573, but is $len characters long fi fi echo clrtobot.c '(3150 characters)' if test -f clrtobot.c then echo clrtobot.c already exists - will not overwrite else sed 's/^X//' << 'SHARMARKER' > clrtobot.c X/****************************************************************/ X/* Wclrtobot() 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/* NDP 2/88 Fixed "clrbot()" to be "clrtobot()" */ X/****************************************************************/ X X#include X#include X X/****************************************************************/ X/* Wclrtobot() fills the right half of the cursor line of */ X/* window 'win', and all lines below it with blanks. */ X/****************************************************************/ X Xint wclrtobot(win) X WINDOW *win; X { X int y; X int minx; X static int startx; X static int *ptr; X static int *end; X static int *maxx; X static int blank; X X blank = ' ' | (win->_attrs & ATR_MSK); X startx = win->_curx; X for (y = win->_cury; y <= win->_regbottom; y++) X { X minx = _NO_CHANGE; X end = &win->_line[y][win->_maxx]; X for (ptr = &win->_line[y][startx]; ptr <= end; ptr++) X { X if (*ptr != blank) X { X maxx = ptr; X if (minx == _NO_CHANGE) X minx = ptr - win->_line[y]; X *ptr = blank; X } /* if */ X } /* for */ X if (minx != _NO_CHANGE) X { X if ((win->_minchng[y] > minx) || (win->_minchng[y] == _NO_CHANGE)) X win->_minchng[y] = minx; X if (win->_maxchng[y] < maxx - win->_line[y]) X win->_maxchng[y] = maxx - win->_line[y]; X } /* if */ X startx = 0; X } /* for */ X return(OK); X } /* wclrtobot */ X X/****************************************************************/ X/* Clrtobot() fills the right half of the cursor line of */ X/* stdscr, and all lines below it with blanks. */ X/****************************************************************/ X Xint clrtobot() /* NDP 2/88 Used to be clrbot() */ X { X return(wclrtobot(stdscr)); X } /* clrtobot */ X X/****************************************************************/ X/* Mvclrtobot() moves the cursor to a new position in stdscr */ X/* and fills the right half of the cursor line, and all lines */ X/* below it with blanks. */ X/****************************************************************/ X Xint mvclrtobot(y,x) X int y; X int x; X { X if (wmove(stdscr,y,x) == ERR) X return(ERR); X return(wclrtobot(stdscr)); X } /* mvclrtobot */ X X/****************************************************************/ X/* Mvwclrtobot() moves the cursor to a new position in window */ X/* 'win', and fills the right half of the cursor line, and all */ X/* lines below it with blanks. */ X/****************************************************************/ X Xint mvwclrtobot(win,y,x) X WINDOW *win; X int y; X int x; X { X if (wmove(win,y,x) == ERR) X return(ERR); X return(wclrtobot(win)); X } /* mvwclrtobot */ SHARMARKER len=`wc -c clrtobot.c | sed "s/^ *\([0-9][0-9]*\) .*/\1/"` if test 3150 -ne $len then echo clrtobot.c should be 3150, but is $len characters long fi fi echo curses.cmd '(615 characters)' if test -f curses.cmd then echo curses.cmd already exists - will not overwrite else sed 's/^X//' << 'SHARMARKER' > curses.cmd Xtmp Xy Xattrib.obj & X+beep.obj & X+boxes.obj & X+charadd.obj & X+chardel.obj & X+charget.obj & X+charins.obj & X+charpick.obj & X+clrtobot.obj & X+clrtoeol.obj & X+cursesio.obj & X+endwin.obj & X+initscr.obj & X+linedel.obj & X+lineins.obj & X+longname.obj & X+move.obj & X+mvcursor & X+newwin.obj & X+options.obj & X+overlay.obj & X+prntscan.obj & X+refresh.obj & X+scrreg.obj & X+setterm.obj & X+stradd.obj & X+strget.obj & X+tabsize.obj & X+termmisc.obj & X+unctrl.obj & X+update.obj & X+winclear.obj & X+windel.obj & X+winerase.obj & X+winmove.obj & X+winscrol.obj & X+wintouch.obj & X+setmode.obj Xnul SHARMARKER len=`wc -c curses.cmd | sed "s/^ *\([0-9][0-9]*\) .*/\1/"` if test 615 -ne $len then echo curses.cmd should be 615, but is $len characters long fi fi echo curses.lst '(636 characters)' if test -f curses.lst then echo curses.lst already exists - will not overwrite else sed 's/^X//' << 'SHARMARKER' > curses.lst Xtmp & X+attrib.obj & X+beep.obj & X+boxes.obj & X+charadd.obj & X+chardel.obj & X+charget.obj & X+charins.obj & X+charpick.obj & X+clrtobot.obj & X+clrtoeol.obj & X+cursesio.obj & X+endwin.obj & X+initscr.obj & X+linedel.obj & X+lineins.obj & X+longname.obj & X+move.obj & X+mvcursor & X+newwin.obj & X+options.obj & X+overlay.obj & X+prntscan.obj & X+refresh.obj & X+scrreg.obj & X+setterm.obj & X+stradd.obj & X+strget.obj & X+tabsize.obj & X+termmisc.obj & X+unctrl.obj & X+update.obj & X+winclear.obj & X+windel.obj & X+winerase.obj & X+winmove.obj & X+winscrol.obj & X+wintouch.obj & X+setmode & X+getch, Xnul SHARMARKER len=`wc -c curses.lst | sed "s/^ *\([0-9][0-9]*\) .*/\1/"` if test 636 -ne $len then echo curses.lst should be 636, but is $len characters long fi fi echo curspriv.h '(3386 characters)' if test -f curspriv.h then echo curspriv.h already exists - will not overwrite else sed 's/^X//' << 'SHARMARKER' > curspriv.h X/****************************************************************/ X/* CURSPRIV.H */ X/* Header file for definitions and declarations for the */ X/* PCcurses package. These definitions should not be gene- */ X/* rally accessible to programmers. */ 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/****************************************************************/ X X/* window properties */ X X#define _SUBWIN 1 /* window is a subwindow */ X#define _ENDLINE 2 /* last winline is last screen line */ X#define _FULLWIN 4 /* window fills screen */ X#define _SCROLLWIN 8 /* window lwr rgt is screen lwr rgt */ X X/* Miscellaneous */ X X#define _INBUFSIZ 200 /* size of terminal input buffer */ X#define _NO_CHANGE -1 /* flags line edge unchanged */ X X#define _BREAKCHAR 0x03 /* ^C character */ X#define _DCCHAR 0x08 /* Delete Char char (BS) */ X#define _DLCHAR 0x1b /* Delete Line char (ESC) */ X#define _GOCHAR 0x11 /* ^Q character */ X#define _PRINTCHAR 0x10 /* ^P character */ X#define _STOPCHAR 0x13 /* ^S character */ X#define NUNGETCH 10 /* max # chars to ungetch() */ X X/* character mask definitions */ X X#define CHR_MSK ((int) 0x00ff) /* ASCIIZ character mask */ X#define ATR_MSK ((int) 0xff00) /* attribute mask */ X#define ATR_NRM ((int) 0x0000) /* no special attributes */ X X/* type declarations */ X Xtypedef struct X { X WINDOW *tmpwin; /* window used for updates */ X int cursrow; /* position of physical cursor */ X int curscol; X bool autocr; /* if lf -> crlf */ X bool cbreak; /* if terminal unbuffered */ X bool echo; /* if terminal echo */ X bool raw; /* if terminal raw mode */ X bool refrbrk; /* if premature refresh brk allowed */ X bool orgcbr; /* original MSDOS ^-BREAK setting */ X } cursv; X X/* External variables */ X Xextern cursv _cursvar; /* curses variables */ X X/* 'C' standard library function declarations */ X Xextern char *calloc(); Xextern char *malloc(); Xextern void free(); Xextern int sprintf(); Xextern int sscanf(); X X/* curses internal functions, not to be used by programmers */ X X/* For those of us with braindamaged assemblers that only X * produce upper case public identifiers... X */ X#ifdef UCMASM X#define _cursescattr _CURSESCATTR X#define _cursescmode _CURSESCMODE X#define _cursescursor _CURSESCURSOR X#define _cursesgcb _CURSESGCB X#define _cursesgcmode _CURSESGCMODE X#define _cursesgcols _CURSESGCOLS X#define _curseskey _CURSESKEY X#define _cursesscroll _CURSESSCROLL X#define _curseskeytst _CURSESKEYTST X#define _cursesputc _CURSESPUTC X#define _cursesscb _CURSESSCB X#endif X Xextern void _cursescattr(); Xextern void _cursescmode(); Xextern void _cursescursor(); Xextern int _cursesgcb(); Xextern int _cursesgcmode(); Xextern int _cursesgcols(); Xextern int _curseskey(); Xextern int _curseskeytst(); Xextern void _cursesscroll(); /* NDP 1/88 Was missing. */ Xextern bool _cursespendch(); /* NDP Note: not asm, in charget() */ Xextern void _cursesputc(); Xextern void _cursesscb(); SHARMARKER len=`wc -c curspriv.h | sed "s/^ *\([0-9][0-9]*\) .*/\1/"` if test 3386 -ne $len then echo curspriv.h should be 3386, but is $len characters long fi fi echo getch.c '(2088 characters)' if test -f getch.c then echo getch.c already exists - will not overwrite else sed 's/^X//' << 'SHARMARKER' > getch.c X/* X * Replacement for Turbo C getch(). X * Turbo C getch() uses BDOS function 7, which doesn't respond to X * ^C or ^Break, whereas we would like it to do so. X * This uses BDOS function 7, which does not respond to ^C/^Break, but X * simulates BDOS function 8, which _does_ respond to ^C/^Break. The X * simulation is done to avoid echoing the annoying '^C' to the screen. X * Must be compiled with tc Option/Compiler/Source/Ansionly OFF, to allow X * Turbo's PC-specific stuff (with tcc, compile with flag: '-A-'). X * Compile with TESTPROG #defined to see a demo. X * When linked, the linker may warn you that symbol _getch is duplicated. X * As long as this module is linked in before the libraries are searched, X * this version of getch() will override the library version. X * N. Dean Pentcheff 1/88 dean@violet.berkeley.edu X * Arguments: none X * Returns: (int) The code corresponding to the keypress, or '0' to indicate X * that a special key was pressed (another getch() call will return X * the special code for that special key). Note that the top byte X * is always cleared to 0. X */ X X#include X#define KEYIN_NOECHO 7 /* DOS function: noecho input, ignore ^C */ X#define BRKINT 35 /* BIOS interrupt for ^C/^Break action */ X#define BREAK 3 /* ASCII ^C and ^Break */ X Xint Xgetch(void) X{ X register int ch; X union REGS regs; X X do { X ch = 0xff & bdos(KEYIN_NOECHO, 0, 0); /* mask high byte */ X if (ch == BREAK) /* if ^C or ^Break */ X int86(BRKINT, ®s, ®s); /* simulate ^Break */ X } while (ch == BREAK); /* until not ^Break */ X return(ch); X} X X X#ifdef TESTPROG X#include Xvoid Xmain(void) X{ X register int ch; X register int count; X int handler(void); /* ^Break handler */ X X printf("Press keys or Break characters. Type 'x' to quit\n"); X ctrlbrk(handler); X count = 0; X while ((ch = getch()) != 'x') { X printf("%c(%03d) ", ch, ch); X if (++count % 10 == 0) X putchar('\n'); X } X} X Xint Xhandler(void) X{ X putchar(7); X printf("\nInterrupt: \'x\' to quit\n"); X return(1); X} X#endif TESTPROG SHARMARKER len=`wc -c getch.c | sed "s/^ *\([0-9][0-9]*\) .*/\1/"` if test 2088 -ne $len then echo getch.c should be 2088, but is $len characters long fi fi echo setmode.c '(2111 characters)' if test -f setmode.c then echo setmode.c already exists - will not overwrite else sed 's/^X//' << 'SHARMARKER' > setmode.c X/* X * setmode.c X * PC Curses versions of: X * reset_prog_mode(); X * reset_shell_mode(); X * set_prog_mode(); X * set_shell_mode(); X * N. Dean Pentcheff (dean@violet.berkeley.edu) X * 1/88 X */ X X#include X#include X Xstruct cttyset { X bool been_set; X bool oautocr; X bool ocbreak; X bool oecho; X bool oraw; X}; X Xstatic struct cttyset sh_tty = {FALSE}; /* tty modes for shell_mode */ Xstatic struct cttyset pr_tty = {FALSE}; /* tty modes for prog_mode */ X X/****************************************************************/ X/* Def_prog_mode saves the current tty status, to be recalled */ X/* later by reset_prog_mode */ X/****************************************************************/ X Xvoid def_prog_mode() X{ X pr_tty.been_set = TRUE; X pr_tty.oautocr = _cursvar.autocr; X pr_tty.ocbreak = _cursvar.cbreak; X pr_tty.oecho = _cursvar.echo; X pr_tty.oraw = _cursvar.raw; X} /* def_prog_mode */ X X X/****************************************************************/ X/* Reset_prog_mode resets tty modes to the values saved in a */ X/* call to def_prog_mode. */ X/****************************************************************/ Xvoid reset_prog_mode() X{ X if (pr_tty.been_set == TRUE) { X _cursvar.autocr = pr_tty.oautocr; X _cursvar.cbreak = pr_tty.ocbreak; X _cursvar.echo = pr_tty.oecho; X _cursvar.raw = pr_tty.oraw; X } X} X X/****************************************************************/ X/* Def_shell_mode saves the tty status, to be recalled by */ X/* reset_shell_mode. A noop in PC Curses */ X/****************************************************************/ Xvoid def_shell_mode() X{ X return; X} X X/****************************************************************/ X/* Reset_shell_mode resets the tty status to the status it had */ X/* before curses began. */ X/****************************************************************/ Xvoid reset_shell_mode() X{ X _cursvar.autocr = TRUE; X _cursvar.cbreak = FALSE; X _cursvar.echo = TRUE; X _cursvar.raw = FALSE; X} SHARMARKER len=`wc -c setmode.c | sed "s/^ *\([0-9][0-9]*\) .*/\1/"` if test 2111 -ne $len then echo setmode.c should be 2111, but is $len characters long fi fi echo xlist '(455 characters)' if test -f xlist then echo xlist already exists - will not overwrite else sed 's/^X//' << 'SHARMARKER' > xlist X*ATTRIB & X*BEEP & X*BOXES & X*CHARADD & X*CHARDEL & X*CHARGET & X*CHARINS & X*CHARPICK & X*CLRTOBOT & X*CLRTOEOL & X*CURSESIO & X*ENDWIN & X*INITSCR & X*LINEDEL & X*LINEINS & X*LONGNAME & X*MOVE & X*MVCURSOR & X*NEWWIN & X*OPTIONS & X*OVERLAY & X*PRNTSCAN & X*REFRESH & X*SCRREG & X*SETMODE & X*SETTERM & X*STRADD & X*STRGET & X*TABSIZE & X*TERMMISC & X*UNCTRL & X*UPDATE & X*WINCLEAR & X*WINDEL & X*WINERASE & X*WINMOVE & X*WINSCROL & X*WINTOUCH SHARMARKER len=`wc -c xlist | sed "s/^ *\([0-9][0-9]*\) .*/\1/"` if test 455 -ne $len then echo xlist should be 455, but is $len characters long fi fi echo shar: done : End of Shell Archive. Created Wed Feb 17 21:51:25 PST 1988 ----------------- Dean Pentcheff (dean@violet.berkeley.edu) ----------------- "A university is a place where people pay high prices for goods which they then proceed to leave on the counter when they go out of the store." Loren Eiseley