home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-08-28 | 52.2 KB | 1,588 lines |
- Article 185 of comp.sources.misc:
- Relay-Version: version B 2.10.3 alpha 5/22/85; site osu-eddie.UUCP
- Path: osu-eddie!cbosgd!ihnp4!ptsfa!ames!ll-xn!husc6!necntc!ncoast!allbery
- From: bl@infovax.UUCP (Bj|rn Larsson)
- Newsgroups: comp.sources.misc
- Subject: PCcurses shar 1
- Message-ID: <4269@ncoast.UUCP>
- Date: 26 Aug 87 22:51:34 GMT
- Date-Received: 27 Aug 87 12:23:09 GMT
- Sender: allbery@ncoast.UUCP
- Lines: 1571
- Approved: allbery@ncoast.UUCP
- X-Archive: comp.sources.misc/8708/pc-curses/1
-
- # This is a shar archive.
- # Remove everything above this line.
- # Run the file through sh, not csh.
- # (type `sh pccurses.sh.1')
- echo extracting - Makefile
- sed 's/^X//' > Makefile << 'FRIDAY_NIGHT'
- X#################################################################
- X# PCCURSES #
- X# Makefile to generate scurses.lib, ccurses.lib, mcurses.lib, #
- X# lcurses.lib for MicroSoft 'C'. Use MicroSoft 'C' v.4.0! #
- X# #
- X# This makefile will generate subdirectories and call itself #
- X# recursively... #
- 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= \msc\lib
- XINCDIR= \msc\inc
- 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
- 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 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 cl -M$(MODEL) -c -Ox -Foattrib ..\attrib.c
- X
- Xbeep.obj: ..\beep.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fobeep ..\beep.c
- X
- Xboxes.obj: ..\boxes.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Foboxes ..\boxes.c
- X
- Xcharadd.obj: ..\charadd.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Focharadd ..\charadd.c
- X
- Xchardel.obj: ..\chardel.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fochardel ..\chardel.c
- X
- Xcharget.obj: ..\charget.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Focharget ..\charget.c
- X
- Xcharins.obj: ..\charins.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Focharins ..\charins.c
- X
- Xcharpick.obj: ..\charpick.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Focharpick ..\charpick.c
- X
- Xclrtobot.obj: ..\clrtobot.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Foclrtobot ..\clrtobot.c
- X
- Xclrtoeol.obj: ..\clrtoeol.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Foclrtoeol ..\clrtoeol.c
- X
- Xendwin.obj: ..\endwin.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Foendwin ..\endwin.c
- X
- Xinitscr.obj: ..\initscr.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Foinitscr ..\initscr.c
- X
- Xlinedel.obj: ..\linedel.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Folinedel ..\linedel.c
- X
- Xlineins.obj: ..\lineins.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Folineins ..\lineins.c
- X
- Xlongname.obj: ..\longname.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Folongname ..\longname.c
- X
- Xmove.obj: ..\move.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fomove ..\move.c
- X
- Xmvcursor.obj: ..\mvcursor.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fomvcursor ..\mvcursor.c
- X
- Xnewwin.obj: ..\newwin.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fonewwin ..\newwin.c
- X
- Xoptions.obj: ..\options.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fooptions ..\options.c
- X
- Xoverlay.obj: ..\overlay.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fooverlay ..\overlay.c
- X
- Xprntscan.obj: ..\prntscan.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Oat -Foprntscan ..\prntscan.c
- X
- Xrefresh.obj: ..\refresh.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Forefresh ..\refresh.c
- X
- Xscrreg.obj: ..\scrreg.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Foscrreg ..\scrreg.c
- X
- Xsetterm.obj: ..\setterm.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fosetterm ..\setterm.c
- X
- Xstradd.obj: ..\stradd.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fostradd ..\stradd.c
- X
- Xstrget.obj: ..\strget.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fostrget ..\strget.c
- X
- Xtabsize.obj: ..\tabsize.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fotabsize ..\tabsize.c
- X
- Xtermmisc.obj: ..\termmisc.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fotermmisc ..\termmisc.c
- X
- Xunctrl.obj: ..\unctrl.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Founctrl ..\unctrl.c
- X
- Xupdate.obj: ..\update.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Foupdate ..\update.c
- X
- Xwinclear.obj: ..\winclear.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fowinclear ..\winclear.c
- X
- Xwindel.obj: ..\windel.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fowindel ..\windel.c
- X
- Xwinerase.obj: ..\winerase.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fowinerase ..\winerase.c
- X
- Xwinmove.obj: ..\winmove.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fowinmove ..\winmove.c
- X
- Xwinscrol.obj: ..\winscrol.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fowinscrol ..\winscrol.c
- X
- Xwintouch.obj: ..\wintouch.c ..\curses.h ..\curspriv.h
- X cl -M$(MODEL) -c -Ox -Fowintouch ..\wintouch.c
- X
- Xcursesio.obj: ..\cursesio.asm
- X masm ..\cursesio.asm/mx,cursesio.obj,nul,nul;
- 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 \pccurses 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:\pccurses
- X del a:\pccurses\*.*
- X copy *.* a:\pccurses
- 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
- FRIDAY_NIGHT
- echo extracting - README.NOW
- sed 's/^X//' > README.NOW << 'FRIDAY_NIGHT'
- X PCCURSES v.1.0 Release Notes - 870824
- X ===================================================
- X
- X
- X
- X This is the release notes for the PCcurses v.1.0 cursor/window control
- Xpackage. PCcurses offers the functionality of UNIX curses, plus some
- Xextras. Normally it should be possible to port curses-based programs from
- XUNIX curses to PCcurses on the IBM PC without changes. PCcurses is a port/
- Xrewrite of Pavel Curtis' public domain 'ncurses' package. All the code has
- Xbeen re-written - it is not just an edit of ncurses (or UNIX curses). I
- Xmention this to clarify any copyright violation claims. The data struc-
- Xtures and ideas are very similar to ncurses. As for UNIX curses, I have
- Xnot even seen any sources for it.
- X
- X For an introduction to the use of 'curses' and it's derivatives, you
- Xshould read 'Screen Updating and Cursor Movement Optimization: A Library
- XPackage' by Kenneth C. R. C. Arnold, which describes the original Berkely
- XUNIX version of curses. It is available as part of the UNIX manuals. The
- Xother source of information is 'The Ncurses Reference Manual' by Pavel
- XCurtis. The latter is part of Curtis' ncurses package.
- X
- X The only other documentation provided is a 'man' page which describes
- Xall the included functions in a very terse way. In the sources, each
- Xfunction is preceded by a rather thourough description of what the
- Xfunction does. I didn't have time to write a nice manual/tutorial - sorry.
- X
- X PCcurses is released as a number of source files, a man page, and a make
- Xfile. A uuencoded copy of a 'make' utility, and a manpage for the 'make' is
- Xalso provided to make it easier to put together PCcurses libraries. Even if
- Xyou are not interested in PCcurses, it may be worthwhile to grab the make.
- X
- X The makefile assumes the presence of the MicroSoft 'C' compiler (3.0 or
- X4.0), MicroSoft MASM and LIB, plus some MS-DOS utilities. The reason for
- Xsupplying MAKE.EXE is that the MicroSoft 'MAKE:s' are much inferior to a
- Xreal UNIX make. The supplied make is a port of a public domain make, pub-
- Xlished on UseNet. It is almost completely compatible with UNIX make. When
- Xgenerating the curses libraries, the makefile will direct make to do some
- Xdirectory creating and file copying, and then re-invoke itself with new
- Xtargets. The workings of the makefile are not absolutely crystal clear at
- Xfirst sight... just start it and see what it does.
- X
- X For portability, the curses libraries depend on one assembler file for
- Xaccess to the BIOS routines. There is no support for the EGA, but both
- XCGA, MGA, and the HGA can be used. The libraries are originally for Micro-
- XSoft 'C', but all C modules should be portable right away. In the assembler
- Xfile, segment names probably need to be changed, and possibly the parameter
- Xpassing scheme. I think Turbo C will work right away - as far as I under-
- Xstand, all it's conventions are compatible with MicroSoft C.
- X
- X There are some parts left out between ncurses and PCcurses. One is the
- Xsupport for multiple terminals - not very interesting on a PC anyway. Be-
- Xcause we KNOW what terminal we have, there is no need for a termcap or
- Xtermio library. PCcurses also has some things that neither curses nor
- Xncurses have. Compared to the original UNIX curses, PCcurses has lots
- Xof extras.
- X
- X The BIOS routines are used directly, which gives fast screen updates.
- XPCcurses does not do direct writes to screen RAM - in my opinion it is
- Xa bit ugly to rely that much on hardware compatibility. Anyone could fix
- Xthat, of course...
- X
- X One of the more serious problems with PCcurses is the way in which nor-
- Xmal, cbreak, and raw input modes are done. All those details are in the
- X'charget' module - I do raw I/O via the BIOS, and perform any buffering
- Xmyself. If an application program uses PCcurses, it should do ALL it's
- XI/O via PCcurses calls, otherwise the mix of normal and PCcurses I/O may
- Xmess up the display. I think my code is reasonable... comments are welcome,
- Xprovided you express them nicely...
- X
- X To install, copy all files to a work directory, edit 'makefile' to define
- Xthe standard include and library file directory names of your choice (these
- Xdirectories must exist already, and their path names must be relative to the
- Xroot directory, not to the current one). You must also run uudecode on
- Xmake.uu, to generate MAKE.EXE. You can do that on your PC, if you have
- Xuudecode there, otherwise you can do it under UNIX and do a binary transfer
- Xto the PC. When you have MAKE.EXE in your work directory (or in your /bin
- Xdirectory), type make.
- X
- X Make will now create 4 sub-directories (one for each memory model), copy
- Xsome assembler include files into them, copy two include files to your
- Xinclude directory, CHDIR to each sub-directory and re-invoke itself with
- Xother make targets to compile and assemble all the source files into the
- Xappropriate directories. Then the library manager is run to create the
- Xlibrary files in your desired library directory. Presto!
- X
- X If you only want to generate a library for one memory model, type 'make
- Xsmall', 'make large', etc. The name of the memory model must be in lower
- Xcase, like in the makefile.
- X
- X I think the package is fairly well debugged - but then again, that's
- Xwhat I always think. It was completed in May-87, and no problems found
- Xyet. Now it's your turn... Comments, suggestions and bug reports and
- Xfixes (no flames please) to
- X
- XBjorn Larsson
- XINFOVOX AB
- XBox 2503 (...seismo!mcvax!enea!infovax!bl)
- XS-171 02 Solna
- XSWEDEN
- FRIDAY_NIGHT
- echo extracting - attrib.c
- sed 's/^X//' > attrib.c << 'FRIDAY_NIGHT'
- X/****************************************************************/
- X/* Character attribute 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 make it public domain. */
- X/* Bjorn Larsson (...mcvax!enea!infovax!bl) */
- X/****************************************************************/
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- X/****************************************************************/
- X/* Wattrset() sets the attributes as specified in window 'win'. */
- X/****************************************************************/
- X
- Xvoid wattrset(win,attrs)
- X WINDOW *win;
- X int attrs;
- X {
- X win->_attrs = attrs & ATR_MSK;
- X } /* wattrset */
- X
- X/****************************************************************/
- X/* Wattron() sets the specified attribute(s) in window 'win'. */
- X/****************************************************************/
- X
- Xvoid wattron(win,attrs)
- X WINDOW *win;
- X int attrs;
- X {
- X win->_attrs |= (attrs & ATR_MSK);
- X } /* wattron */
- X
- X/****************************************************************/
- X/* Wattroff() clears the specified attribute(s) in window */
- X/* 'win'. */
- X/****************************************************************/
- X
- Xvoid wattroff(win,attrs)
- X WINDOW *win;
- X int attrs;
- X {
- X win->_attrs &= (~attrs & ATR_MSK);
- X } /* wattroff */
- X
- X/****************************************************************/
- X/* Wstandout() starts standout mode in window 'win'. */
- X/****************************************************************/
- X
- Xvoid wstandout(win)
- X WINDOW *win;
- X {
- X win->_attrs = A_STANDOUT;
- X } /* wstandout */
- X
- X/****************************************************************/
- X/* Wstandend() clears all special attributes in window 'win'. */
- X/****************************************************************/
- X
- Xvoid wstandend(win)
- X WINDOW *win;
- X {
- X win->_attrs = ATR_NRM;
- X } /* wstandend */
- X
- X/****************************************************************/
- X/* Attrset() sets the attributes as specified in stdscr. */
- X/****************************************************************/
- X
- Xvoid attrset(attrs)
- X int attrs;
- X {
- X stdscr->_attrs = attrs & ATR_MSK;
- X } /* attrset */
- X
- X/****************************************************************/
- X/* Attron() sets the specified attribute(s) in stdscr. */
- X/****************************************************************/
- X
- Xvoid attron(attrs)
- X int attrs;
- X {
- X stdscr->_attrs |= (attrs & ATR_MSK);
- X } /* attron */
- X
- X/****************************************************************/
- X/* Attroff() clears the specified attribute(s) in stdscr. */
- X/****************************************************************/
- X
- Xvoid attroff(attrs)
- X int attrs;
- X {
- X stdscr->_attrs &= (~attrs & ATR_MSK);
- X } /* attroff */
- X
- X/****************************************************************/
- X/* Standout() starts standout mode in stdscr. */
- X/****************************************************************/
- X
- Xvoid standout()
- X {
- X stdscr->_attrs = A_STANDOUT;
- X } /* standout */
- X
- X/****************************************************************/
- X/* Standend() clears all special attributes in stdscr. */
- X/****************************************************************/
- X
- Xvoid standend()
- X {
- X stdscr->_attrs = ATR_NRM;
- X } /* standend */
- FRIDAY_NIGHT
- echo extracting - beep.c
- sed 's/^X//' > beep.c << 'FRIDAY_NIGHT'
- X/****************************************************************/
- X/* */
- X/* Beep() and flash() 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 <curses.h>
- X#include <curspriv.h>
- X
- X/****************************************************************/
- X/* Beep() sounds the terminal bell. */
- X/****************************************************************/
- X
- Xvoid beep()
- X {
- X _cursesputc('\007',0);
- X } /* beep */
- X
- X/****************************************************************/
- X/* Flash() flashes the terminal screen. */
- X/****************************************************************/
- X
- Xvoid flash()
- X {
- X int i;
- X
- X _cursesscroll(0,0,LINES-1,COLS-1,0,0x70);
- X for (i=0;i<10000;)
- X i++;
- X _cursesscroll(0,0,LINES-1,COLS-1,0,0x0);
- X wrefresh(curscr);
- X } /* flash */
- FRIDAY_NIGHT
- echo extracting - boxes.c
- sed 's/^X//' > boxes.c << 'FRIDAY_NIGHT'
- X/****************************************************************/
- X/* Box() 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 <curses.h>
- X#include <curspriv.h>
- X
- X/****************************************************************/
- X/* wbox(win,ymin,xmin,ymax,xmax,v,h) draws a box in window */
- X/* 'win', enclosing the area xmin-xmax and ymin-xmax. If */
- X/* xmax and/or ymax is 0, the window max value is used. 'v' and */
- X/* 'h' are the vertical and horizontal characters to use. If */
- X/* 'v' and 'h' are PC grapics lines, wbox will make the corners */
- X/* in a pretty way. */
- X/****************************************************************/
- X
- Xint wbox(win,ymin,xmin,ymax,xmax,v,h)
- X WINDOW *win;
- X int ymin;
- X int xmin;
- X int ymax;
- X int xmax;
- X char v;
- X char h;
- X {
- X static int vc,hc,ulc,urc,llc,lrc; /* corner chars */
- X int i;
- X
- X if (ymax == 0)
- X ymax = win->_maxy;
- X if (xmax == 0)
- X xmax = win->_maxx;
- X
- X if (ymin >= win->_maxy || ymax > win->_maxy ||
- X xmin >= win->_maxx || xmax > win->_maxx ||
- X ymin >= ymax || xmin >= xmax
- X )
- X return(ERR);
- X
- X vc = v;
- X hc = h;
- X vc &= 0xff; /* get rid of sign-extended int */
- X hc &= 0xff;
- X ulc = urc = llc = lrc = vc; /* default same as vertical */
- X
- X if (vc == 0xba) /* vertical double bars */
- X {
- X if (hc == 0xcd) /* horizontal too? */
- X {
- X ulc = 0xc9; /* use double bar corners */
- X urc = 0xbb;
- X llc = 0xc8;
- X lrc = 0xbc;
- X } /* if */
- X else
- X {
- X ulc = 0xd6; /* use hor-s vert-d corners */
- X urc = 0xb7;
- X llc = 0xd3;
- X lrc = 0xbd;
- X } /* else */
- X } /* if */
- X
- X if (vc == 0xb3) /* vertical single bars */
- X {
- X if (hc == 0xcd) /* horizontal double bars */
- X {
- X ulc = 0xd5;
- X urc = 0xb8;
- X llc = 0xd4;
- X lrc = 0xbe;
- X } /* if */
- X else /* use hor-s vert-s bars */
- X {
- X ulc = 0xda;
- X urc = 0xbf;
- X llc = 0xc0;
- X lrc = 0xd9;
- X } /* else */
- X } /* if */
- X
- X for (i = xmin+1;i <= xmax-1;i++)
- X {
- X win->_line[ymin][i] = hc | win->_attrs;
- X win->_line[ymax][i] = hc | win->_attrs;
- X }
- X for (i = ymin+1;i <= ymax-1;i++)
- X {
- X win->_line[i][xmin] = vc | win->_attrs;
- X win->_line[i][xmax] = vc | win->_attrs;
- X }
- X win->_line[ymin][xmin] = ulc | win->_attrs;
- X win->_line[ymin][xmax] = urc | win->_attrs;
- X win->_line[ymax][xmin] = llc | win->_attrs;
- X win->_line[ymax][xmax] = lrc | win->_attrs;
- X
- X for (i=ymin; i <= ymax ; i++)
- X {
- X if (win->_minchng[i] == _NO_CHANGE)
- X {
- X win->_minchng[i] = xmin;
- X win->_maxchng[i] = xmax;
- X } /* if */
- X else
- X {
- X win->_minchng[i] = min(win->_minchng[i], xmin);
- X win->_maxchng[i] = max(win->_maxchng[i], xmax);
- X } /* else */
- X } /* for */
- X return(OK);
- X } /* box */
- X
- X/****************************************************************/
- X/* box(win,v,h) draws a box around window window 'win'. 'v' and */
- X/* 'h' are the vertical and horizontal characters to use. */
- X/****************************************************************/
- X
- Xvoid box(win,vc,hc)
- X WINDOW *win;
- X char vc;
- X char hc;
- X {
- X wbox(win,0,0,0,0,vc,hc);
- X } /* box */
- FRIDAY_NIGHT
- echo extracting - charadd.c
- sed 's/^X//' > charadd.c << 'FRIDAY_NIGHT'
- 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/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- 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/* 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 register WINDOW *win;
- X char c;
- 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 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 break;
- X case '\r': x = 0;
- X break;
- X case '\b': if (--x < 0) /* no back over left margin */
- X x = 0;
- X break;
- X case 0x7f: if (waddch(win,'^') == ERR)
- X return(ERR);
- X return(waddch(win,'?'));
- X default: if (ch < ' ') /* handle control chars */
- X {
- X if (waddch(win,'^') == ERR)
- X return(ERR);
- X return(waddch(win,c + '@'));
- X } /* if */
- 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 if (x < win->_minchng[y])
- X win->_minchng[y] = x;
- X else
- X if (x > win->_maxchng[y])
- X win->_maxchng[y] = x;
- 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 break;
- X } /* switch */
- X win->_curx = x;
- X win->_cury = y;
- X return(OK);
- X } /* waddch */
- 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 (waddch(stdscr,c));
- X } /* addch */
- 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 (waddch(stdscr,c));
- 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 (waddch(win,c));
- X } /* mvwaddch */
- FRIDAY_NIGHT
- echo extracting - chardel.c
- sed 's/^X//' > chardel.c << 'FRIDAY_NIGHT'
- X/****************************************************************/
- X/* Wdelch() 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/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- X/****************************************************************/
- X/* Wdelch() deletes the character at the window cursor, and the */
- X/* characters to the right of it are shifted left, inserting a */
- X/* space at the last position of the line. */
- X/****************************************************************/
- X
- Xint wdelch(win)
- X WINDOW *win;
- X {
- X int *temp1;
- X int *temp2;
- X int *end;
- X short y = win->_cury;
- X short x = win->_curx;
- X short maxx = win->_maxx;
- X
- X end = &win->_line[y][maxx];
- X temp1 = &win->_line[y][x];
- X temp2 = temp1 + 1;
- X while (temp1 < end)
- X *temp1++ = *temp2++;
- X *temp1 = ' ' | (win->_attrs & ATR_MSK);
- X win->_maxchng[y] = maxx;
- X if (win->_minchng[y] == _NO_CHANGE || win->_minchng[y] > x)
- X win->_minchng[y] = x;
- X return(OK);
- X } /* wdelch */
- X
- X/****************************************************************/
- X/* Delch() deletes the character at the stdscr cursor, and the */
- X/* characters to the right of it are shifted left, inserting a */
- X/* space at the last position of the line. */
- X/****************************************************************/
- X
- Xint delch()
- X {
- X return(wdelch(stdscr));
- X } /* delch */
- X
- X/****************************************************************/
- X/* Mvdelch() moves the stdscr cursor to a new position, then */
- X/* deletes the character at the stdscr cursor, and the charac- */
- X/* ters to the right of it are shifted left, inserting a space */
- X/* at the last position of the line. */
- X/****************************************************************/
- X
- Xint mvdelch(y,x)
- X int y;
- X int x;
- X {
- X if (wmove(stdscr,y,x) == ERR)
- X return(ERR);
- X return(wdelch(stdscr));
- X } /* mvdelch */
- X
- X/****************************************************************/
- X/* Mvwdelch() moves the cursor of window 'win' to a new posi- */
- X/* tion, then deletes the character at the stdscr cursor, and */
- X/* the characters to the right of it are shifted left, inser- */
- X/* ting a space at the last position of the line. */
- X/****************************************************************/
- X
- Xint mvwdelch(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(wdelch(win));
- X } /* mvwdelch */
- FRIDAY_NIGHT
- echo extracting - charget.c
- sed 's/^X//' > charget.c << 'FRIDAY_NIGHT'
- 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 <curses.h>
- X#include <curspriv.h>
- 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#undef getch /* we use MSC getch() below */
- 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(_curseskeytest());
- X return(kbhit()); /* normal mode test */
- X } /* _cursespendch */
- FRIDAY_NIGHT
- echo extracting - charins.c
- sed 's/^X//' > charins.c << 'FRIDAY_NIGHT'
- X/****************************************************************/
- X/* Winsch() 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/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- X/****************************************************************/
- X/* Winsch() inserts character 'c' at the cursor position in */
- X/* window 'win'. The cursor is advanced. */
- X/****************************************************************/
- X
- Xint winsch(win, c)
- X WINDOW *win;
- X char c;
- X {
- X int *temp1;
- X int *temp2;
- X int *end;
- X int x = win->_curx;
- X int y = win->_cury;
- X int maxx = win->_maxx;
- X
- X if((c < ' ') && (c == '\n' || c == '\r' || c == '\t' || c == '\b'))
- X return(waddch(win, c));
- X end = &win->_line[y][x];
- X temp1 = &win->_line[y][maxx];
- X temp2 = temp1 - 1;
- X if(c < ' ') /* if CTRL-char make space for 2 */
- X temp2--;
- X while (temp1 > end)
- X *temp1-- = *temp2--;
- X win->_maxchng[y] = maxx;
- X if ((win->_minchng[y] == _NO_CHANGE) || (win->_minchng[y] > x))
- X win->_minchng[y] = x;
- X return(waddch(win, c)); /* fixes CTRL-chars too */
- X } /* winsch */
- X
- X/****************************************************************/
- X/* Insch() inserts character 'c' at the cursor position in */
- X/* stdscr. The cursor is advanced. */
- X/****************************************************************/
- X
- Xint insch(c)
- X char c;
- X {
- X winsch(stdscr,c);
- X } /* insch */
- X
- X/****************************************************************/
- X/* Mvinsch() moves the stdscr cursor to a new position, then */
- X/* inserts character 'c' at the cursor position in stdscr. The */
- X/* cursor is advanced. */
- X/****************************************************************/
- X
- Xint mvinsch(y,x,c)
- X int y;
- X int x;
- X char c;
- X {
- X if (wmove(stdscr,y,x) == ERR)
- X return(ERR);
- X return(winsch(stdscr,c));
- X } /* mvinsch */
- X
- X/****************************************************************/
- X/* Mvwinsch() moves the cursor of window 'win' to a new posi- */
- X/* tion, then inserts character 'c' at the cursor position in */
- X/* window 'win'. The cursor is advanced. */
- X/****************************************************************/
- X
- Xint mvwinsch(win,y,x,c)
- X WINDOW *win;
- X int y;
- X int x;
- X char c;
- X {
- X if (wmove(win,y,x) == ERR)
- X return(ERR);
- X return(winsch(win,c));
- X } /* mvwinsch */
- FRIDAY_NIGHT
- echo extracting - charpick.c
- sed 's/^X//' > charpick.c << 'FRIDAY_NIGHT'
- X/****************************************************************/
- X/* Winch() 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/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- X/****************************************************************/
- X/* Winch(win) returns the character at the current position in */
- X/* window 'win'. */
- X/****************************************************************/
- X
- Xint winch(win)
- X WINDOW *win;
- X {
- X return((win->_line[win->_cury][win->_curx]) & 0xff);
- X } /* winch */
- X
- X/****************************************************************/
- X/* Inch() returns the character at the current cursor position */
- X/* in stdscr. */
- X/****************************************************************/
- X
- Xint inch()
- X {
- X return((stdscr->_line[stdscr->_cury][stdscr->_curx]) & 0xff);
- X } /* inch */
- X
- X/****************************************************************/
- X/* Mvinch() moves the stdscr cursor to a new position, then */
- X/* returns the character at that position. */
- X/****************************************************************/
- X
- Xint mvinch(y,x)
- X int y;
- X int x;
- X {
- X if (wmove(stdscr,y,x) == ERR)
- X return(ERR);
- X return((stdscr->_line[stdscr->_cury][stdscr->_curx]) & 0xff);
- X } /* mvinch */
- X
- X/****************************************************************/
- X/* Mvwinch() moves the cursor of window 'win' to a new posi- */
- X/* tion, then returns the character at that position. */
- X/****************************************************************/
- X
- Xint mvwinch(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((win->_line[win->_cury][win->_curx]) & 0xff);
- X } /* mvwinch */
- FRIDAY_NIGHT
- echo extracting - clrtobot.c
- sed 's/^X//' > clrtobot.c << 'FRIDAY_NIGHT'
- 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/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- 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/* Wclrtobot() fills the right half of the cursor line of */
- X/* stdscr, and all lines below it with blanks. */
- X/****************************************************************/
- X
- Xint clrbot()
- X {
- X return(wclrtobot(stdscr));
- X } /* clrbot */
- 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 */
- FRIDAY_NIGHT
- echo extracting - clrtoeol.c
- sed 's/^X//' > clrtoeol.c << 'FRIDAY_NIGHT'
- X/****************************************************************/
- X/* Wclrtoeol() 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/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- X/****************************************************************/
- X/* Wclrtoeol() fills the half of the cursor line to the right */
- X/* of the cursor in window 'win' with blanks. */
- X/****************************************************************/
- X
- Xint wclrtoeol(win)
- X WINDOW *win;
- X {
- X int *maxx;
- X int *ptr;
- X int *end;
- X static int y;
- X static int x;
- X static int minx;
- X static int blank;
- X
- X y = win->_cury;
- X x = win->_curx;
- X blank = ' ' | (win->_attrs & ATR_MSK);
- X
- X end = &win->_line[y][win->_maxx];
- X minx = _NO_CHANGE;
- X maxx = &win->_line[y][x];
- X for (ptr = maxx; 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
- 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 return(OK);
- X } /* wclrtoeol */
- X
- X/****************************************************************/
- X/* Clrtoeol() fills the half of the cursor line to the right */
- X/* of the cursor in stdscr with blanks. */
- X/****************************************************************/
- X
- Xint clrtoeol()
- X {
- X return(wclrtoeol(stdscr));
- X } /* clrtoeol */
- X
- X/****************************************************************/
- X/* Mvclrtoeol() moves the cursor to a new position in stdscr */
- X/* and fills the right half of the cursor line with blanks. */
- X/****************************************************************/
- X
- Xint mvcltoreol(y,x)
- X int y;
- X int x;
- X {
- X if (wmove(stdscr,y,x) == ERR)
- X return(ERR);
- X return(wclrtoeol(stdscr));
- X } /* mvclrtoeol */
- X
- X/****************************************************************/
- X/* Mvwclrtoeol() moves the cursor to a new position in window */
- X/* 'win', and fills the right half of the cursor line with */
- X/* blanks. */
- X/****************************************************************/
- X
- Xint mvwclrtoeol(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(wclrtoeol(win));
- X } /* mvwclrtoeol */
- FRIDAY_NIGHT
- echo pccurses.sh.1 completed!
-
-
-