bl@infovax.UUCP (Bj|rn Larsson) (08/27/87)
# This is a shar archive. # Remove everything above this line. # Run the file through sh, not csh. # (type `sh pccurses.sh.4') echo extracting - refresh.c sed 's/^X//' > refresh.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Wrefresh() and wnoutrefresh() routines of the PCcurses */ X/* 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/* Wrefresh() updates window win's area of the physical screen. */ X/****************************************************************/ X Xvoid wrefresh(win) X WINDOW *win; X { X if (win == curscr) X curscr->_clear = TRUE; X else X wnoutrefresh(win); X doupdate(); X } /* wrefresh */ X X/****************************************************************/ X/* Wnoutrefresh() updates the image of the desired screen, */ X/* without doing physical update (copies window win's image to */ X/* the _cursvar.tmpwin window, which is hidden from the user). */ X/****************************************************************/ X Xvoid wnoutrefresh(win) X register WINDOW *win; X { X register int *dst; /* start destination in temp window */ X register int *end; /* end destination in temp window */ X register int *src; /* source in user window */ X register int first; /* first changed char on line */ X register int last; /* last changed char on line */ X static WINDOW *nscr; X static int begy; /* window's place on screen */ X static int begx; X static int i; X static int j; X X nscr = _cursvar.tmpwin; X begy = win->_begy; X begx = win->_begx; X X for (i=0, j=begy; i <= win->_maxy; i++, j++) X { X if (win->_minchng[i] != _NO_CHANGE) X { X first = win->_minchng[i]; X last = win->_maxchng[i]; X dst = &(nscr->_line[j][begx + first]); X end = &(nscr->_line[j][begx + last]); X src = &(win->_line[i][first]); X X while (dst <= end) /* copy user line to temp window */ X *dst++ = *src++; X X first += begx; /* nscr's min/max change positions */ X last += begx; X X if ((nscr->_minchng[j] == _NO_CHANGE)||(nscr->_minchng[j] > first)) X nscr->_minchng[j] = first; X if (last > nscr->_maxchng[j]) X nscr->_maxchng[j] = last; X X win->_minchng[i] = _NO_CHANGE; /* updated now */ X } /* if */ X win->_maxchng[i] = _NO_CHANGE; /* updated now */ X } /* for */ X X if (win->_clear) X { X win->_clear = FALSE; X nscr->_clear = TRUE; X } /* if */ X X if (!win->_leave) X { X nscr->_cury = win->_cury + begy; X nscr->_curx = win->_curx + begx; X } /* if */ X } /* wnoutrefresh */ X X/****************************************************************/ X/* Refresh() updates stdscr's area of the physical screen. */ X/****************************************************************/ X Xvoid refresh() X { X wrefresh(stdscr); X } /* refresh */ FRIDAY_NIGHT echo extracting - scrreg.c sed 's/^X//' > scrreg.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Wsetscrreg() 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/* Wsetscrreg() set the scrolling region of window 'win' to in- */ X/* clude all lines between 'top' and 'bottom'. */ X/****************************************************************/ X Xint wsetscrreg(win, top, bottom) X WINDOW *win; X int top; X int bottom; X { X if ( (0 <= top) X && X (top <= win->_cury) X && X (win->_cury <= bottom) X && X (bottom <= win->_maxy) X ) X { X win->_regtop = top; X win->_regbottom = bottom; X return(OK); X } /* if */ X else X return(ERR); X } /* wsetscrreg */ X X/****************************************************************/ X/* Setscrreg() set the scrolling region of stdscr to include */ X/* all lines between 'top' and 'bottom'. */ X/****************************************************************/ X Xint setscrreg(top, bottom) X int top; X int bottom; X { X return(wsetscrreg(stdscr,top,bottom)); X } /* setscrreg */ FRIDAY_NIGHT echo extracting - setterm.c sed 's/^X//' > setterm.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Raw(), noraw(), echo(), noecho(), nl(), nonl(), cbreak(), */ X/* nocbreak(), crmode(), nocrmode() and refrbrk() routines of */ X/* 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/* Raw() and noraw() sets or clears raw mode. */ X/****************************************************************/ X Xvoid raw() X { X _cursvar.raw = TRUE; X _cursesscb(FALSE); /* disallow ^BREAK on disk I/O */ X flushinp(); X } /* raw */ X Xvoid noraw() X { X _cursvar.raw = FALSE; X _cursesscb(_cursvar.orgcbr); /* restore original ^BREAK status */ X } /* noraw */ X X/****************************************************************/ X/* Echo() and noecho() sets or clears echo mode. */ X/****************************************************************/ X Xvoid echo() X { X _cursvar.echo = TRUE; X } /* echo */ X Xvoid noecho() X { X _cursvar.echo = FALSE; X } /* noecho */ X X/****************************************************************/ X/* Nl() and nonl() sets or clears autocr mapping mode. */ X/****************************************************************/ X Xvoid nl() X { X _cursvar.autocr = TRUE; X } /* nl */ X Xvoid nonl() X { X _cursvar.autocr = FALSE; X } /* nonl */ X X/****************************************************************/ X/* Cbreak(), nocbreak(), crmode() amd nocrmode() sets or */ X/* clears cbreak mode. */ X/****************************************************************/ X Xvoid cbreak() X { X _cursvar.cbreak = TRUE; X } /* cbreak */ X Xvoid nocbreak() X { X _cursvar.cbreak = FALSE; X } /* nocbreak */ X Xvoid crmode() X { X _cursvar.cbreak = TRUE; X } /* crmode */ X Xvoid nocrmode() X { X _cursvar.cbreak = FALSE; X } /* nocrmode */ X X/****************************************************************/ X/* Refrbrk() sets or unsets the screen refresh break flag. If */ X/* this flag is set, and there is any input available, any */ X/* screen refresh will be prematurely terminated, anticipating */ X/* more screen updates. This flag is FALSE by default. */ X/****************************************************************/ X Xvoid refrbrk(bf) X bool bf; X { X _cursvar.refrbrk = bf; X } /* refrbrk */ FRIDAY_NIGHT echo extracting - smaldata.inc sed 's/^X//' > smaldata.inc << 'FRIDAY_NIGHT' X huge_data EQU 0 FRIDAY_NIGHT echo extracting - stradd.c sed 's/^X//' > stradd.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Addstr() 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/* Waddstr() inserts string 'str' at the current cursor posi- */ X/* tion in window 'win', and takes any actions as dictated by */ X/* the characters. */ X/****************************************************************/ X Xint waddstr(win, str) X WINDOW *win; X char *str; X { X while (*str) X { X if (waddch(win, *str++) == ERR) X return(ERR); X } X return(OK); X } /* waddstr */ X X/****************************************************************/ X/* Addstr() inserts string 'str' at the current cursor posi- */ X/* tion in stdscr, and takes any actions as dictated by the */ X/* characters. */ X/****************************************************************/ X Xint addstr(str) X char *str; X { X return (waddstr(stdscr,str)); X } /* addstr */ X X/****************************************************************/ X/* Mvaddstr() move to a new position in stdscr, then inserts */ X/* string 'str' at the new position, taking any actions as dic- */ X/* tated by the characters. */ X/****************************************************************/ X Xint mvaddstr(y,x,str) X int y; X int x; X char *str; X { X if (wmove(stdscr,y,x) == ERR) X return (ERR); X return (waddstr(stdscr,str)); X } /* mvaddstr */ X X/****************************************************************/ X/* Mvwaddstr() move to a new position in window 'win', then */ X/* inserts string 'str' at the new position, taking any actions */ X/* as dictated by the characters. */ X/****************************************************************/ X Xint mvwaddstr(win,y,x,str) X WINDOW *win; X int y; X int x; X char *str; X { X if (wmove(win,y,x) == ERR) X return (ERR); X return (waddstr(win,str)); X } /* mvwaddstr */ FRIDAY_NIGHT echo extracting - strget.c sed 's/^X//' > strget.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Getstr() routines of the PCcurses package */ X/* */ X/****************************************************************/ X/* This version of curses is based on ncurses, a curses version */ X/* originally written by Pavel Curtis at Cornell University. */ X/* I have made substantial changes to make it run on IBM PC's, */ X/* and therefore consider myself free to make it public domain. */ X/* Bjorn Larsson (...mcvax!enea!infovax!bl) */ X/****************************************************************/ X/* 1.0: Release: 870515 */ X/****************************************************************/ X X#include <curses.h> X#include <curspriv.h> X Xstatic char *backchar(); X Xstatic bool oldecho; Xstatic bool oldcbreak; Xstatic bool oldnodelay; Xstatic char *strbeg; Xstatic WINDOW *w; Xstatic int xbeg; X X/****************************************************************/ X/* Wgetstr(win,str) reads in a string (terminated by \n or \r) */ X/* to the buffer pointed to by 'str', and displays the input */ X/* in window 'win'. The user's erase and kill characters are */ X/* active. */ X/****************************************************************/ X Xint wgetstr(win,str) X WINDOW *win; X char *str; X { X w = win; X strbeg = str; /* keep start for backspacing */ X oldcbreak = _cursvar.cbreak; /* remember states */ X oldecho = _cursvar.echo; X oldnodelay = w->_nodelay; X _cursvar.echo = FALSE; /* we do echo ourselves */ X _cursvar.cbreak = TRUE; /* no wait for chars */ X w->_nodelay = FALSE; /* don't return 'NOCHARS' */ X xbeg = w->_curx; /* remember screen start x-position */ X X wrefresh(w); /* sets cursor at right place */ X while ((*str = getch()) != '\n') X { X if (*str == '\r') X break; X if (*str == _DCCHAR) X { X if (str > strbeg) X str = backchar(str); X } /* if */ X else X if (*str == _DLCHAR) X while (str > strbeg) X str = backchar(str); X else X { X waddch(w,*str++); X wrefresh(w); X } /* else */ X } /* while */ X X *str = '\0'; X _cursvar.echo = oldecho; X _cursvar.cbreak = oldcbreak; X win->_nodelay = oldnodelay; X return(OK); X } /* wgetstr */ X X/****************************************************************/ X/* Getstr(str) reads in a string (terminated by \n or \r) to */ X/* the buffer pointed to by 'str', and displays the input in */ X/* stdscr. The user's erase and kill characters are active. */ X/****************************************************************/ X Xint getstr(str) X char *str; X { X return(wgetstr(stdscr,str)); X } /* getstr */ X X/****************************************************************/ X/* Mvgetstr(y,x,str) moves the stdscr cursor to a new position, */ X/* then reads in a string (terminated by \n or \r) to the buf- */ X/* fer pointed to by 'str', and displays the input in stdscr. */ X/* The user's erase and kill characters are active. */ X/****************************************************************/ X Xint mvgetstr(y,x,str) X int y; X int x; X char *str; X { X if (wmove(stdscr,y,x) == ERR) X return(ERR); X return(wgetstr(stdscr,str)); X } /* mvgetstr */ X X/****************************************************************/ X/* Mvwgetstr(win,y,x,str) moves the 'win' cursor to a new */ X/* position, then reads in a string (terminated by \n or \r) */ X/* to the buffer pointed to by 'str', and displays the input in */ X/* stdscr. The user's erase and kill characters are active. */ X/****************************************************************/ X Xint mvwgetstr(win,y,x,str) X WINDOW *win; X int y; X int x; X char *str; X { X if (wmove(win,y,x) == ERR) X return(ERR); X return(wgetstr(win,str)); X } /* mvwgetstr */ X X/****************************************************************/ X/* Backchar() does a character delete with screen erase, even */ X/* up to previous lines. It will not back-scroll if the begi- */ X/* ning of the string has scrolled off the window. Steps back */ X/* pointer 's', and returns the new value. */ X/****************************************************************/ X Xstatic char *backchar(s) X char *s; X { X static int nbs; X static int x; X static char *p; X static int ts; X X x = xbeg; X ts = w->_tabsize; X X s--; /* step back string */ X nbs = 1; /* step at least one pos */ X if ((*s < ' ') || (*s == 0x7f)) /* ctrl-char has size 2 */ X nbs++; X if (*s == '\t') /* tabs are very special */ X { X for (p = strbeg; p < s ;p++) /* find x-pos of last char */ X { X if (*p == '\t') /* go to next tab */ X x = ((x/ts)+1) * ts; X else X if ((*p < ' ') || (*p == 0x7f)) /* control character */ X x += 2; X else /* normal char */ X x++; X if (x > w->_maxx) /* go to next line? */ X x = 0; X } /* while */ X if (!(w->_curx)) /* if step-over newline */ X nbs = w->_maxx+1 - x; X else /* in-line tab */ X nbs = w->_curx - x; /* positions to erase */ X } /* if */ X X while(nbs--) /* do so many */ X { X if (w->_curx > 0) /* if not at line begining */ X waddstr(w,"\b \b"); X else X if (w->_cury) /* if not on top line */ X { X mvwaddch(w,w->_cury-1,w->_maxx,' '); /* put space at line end */ X wmove(w,w->_cury-1,w->_maxx); /* and go there again */ X } /* else */ X } /* while */ X X wrefresh(w); /* redraw screen */ X *(s+1) = '\0'; /* make string terminated */ X return(s); X } /* backchar */ FRIDAY_NIGHT echo extracting - tabsize.c sed 's/^X//' > tabsize.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Tabsize() 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/* Wtabsize(win,ts) sets the tabsize of window 'win' to 'ts', */ X/* and returns the original value. */ X/****************************************************************/ X Xint wtabsize(win,ts) X WINDOW *win; X int ts; X { X int origval; X X origval = win->_tabsize; X win->_tabsize = ts; X return(origval); X } /* wtabsize*/ X X/****************************************************************/ X/* Tabsize(ts) sets the tabsize of stdscr to 'ts', and returns */ X/* the original value. */ X/****************************************************************/ X Xint tabsize(ts) X int ts; X { X int origval; X X origval = stdscr->_tabsize; X stdscr->_tabsize = ts; X return(origval); X } /* tabsize */ FRIDAY_NIGHT echo extracting - termmisc.c sed 's/^X//' > termmisc.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Miscellaneous Terminal 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/* static variables or saving terminal modes */ X Xstatic bool savedacr; Xstatic bool savedcbr; Xstatic bool savedecho; Xstatic bool savedraw; X X/****************************************************************/ X/* Fixterm(), resetterm(), saveoldterm, saveterm() gettmode(), */ X/* setterm() and baudrate() function dummies for compatibility. */ X/****************************************************************/ X Xint fixterm() X { X return(OK); X } /* fixterm */ X Xint resetterm() X { X return(OK); X } X Xint saveoldterm() X { X return(OK); X } /* saveoldterm */ X Xint saveterm() X { X return(OK); X } /* saveterm */ X Xint gettmode() X { X return(OK); X } /* gettmode */ X Xint setterm(type) X char *type; X { X return(OK); X } /* setterm */ X Xint baudrate() X { X return(19200); X } /* baudrate */ X X/****************************************************************/ X/* Erasechar(), killchar() returns std MSDOS erase chars. */ X/****************************************************************/ X Xint erasechar() X { X return(_DCCHAR); /* character delete char */ X } /* erasechar */ X Xint killchar() X { X return(_DLCHAR); /* line delete char */ X } /* killchar */ X X/****************************************************************/ X/* Savetty() and resetty() saves and restores the terminal I/O */ X/* settings. */ X/****************************************************************/ X Xint savetty() X { X savedacr = _cursvar.autocr; X savedcbr = _cursvar.cbreak; X savedecho = _cursvar.echo; X savedraw = _cursvar.raw; X return(OK); X } /* savetty */ X Xint resetty() X { X _cursvar.autocr = savedacr; X _cursvar.cbreak = savedcbr; X _cursvar.echo = savedecho; X _cursvar.raw = savedraw; X return(OK); X } /* resetty */ X X/****************************************************************/ X/* Setupterm() sets up the terminal. On a PC, it is always suc- */ X/* cessful, and returns 1. */ X/****************************************************************/ X Xint setupterm() X { X return(1); X } /* setupterm */ FRIDAY_NIGHT echo extracting - unctrl.c sed 's/^X//' > unctrl.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Unctrl() 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 char strbuf[3] = {0,0,0}; X X/****************************************************************/ X/* Unctrl() returns a char pointer to a string corresponding to */ X/* argument character 'c'. */ X/****************************************************************/ X Xchar *unctrl(c) X char c; X { X int ic = c; X ic &= 0xff; X X if ((ic >= ' ') && (ic != 0x7f)) /* normal characters */ X { X strbuf[0] = ic; X strbuf[1] = '\0'; X return(strbuf); X } /* if */ X strbuf[0] = '^'; /* '^' prefix */ X if (c == 0x7f) /* DEL */ X strbuf[1] = '?'; X else /* other control */ X strbuf[1] = ic + '@'; X return(strbuf); X } /* unctrl */ FRIDAY_NIGHT echo extracting - update.c sed 's/^X//' > update.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Doupdate() routine of the PCcurses package */ X/* */ X/****************************************************************/ X/* This version of curses is based on ncurses, a curses version */ X/* originally written by Pavel Curtis at Cornell University. */ X/* I have made substantial changes to make it run on IBM PC's, */ X/* and therefore consider myself free to make it public domain. */ X/* Bjorn Larsson (...mcvax!enea!infovax!bl) */ X/****************************************************************/ X/* 1.0: Release: 870515 */ X/****************************************************************/ X X#include <curses.h> X#include <curspriv.h> X Xstatic void clrupdate(); /* fwd declaration */ Xstatic bool transformline(); Xstatic void clearscreen(); Xstatic void gotoxy(); Xstatic void Putchar(); X Xstatic WINDOW *twin; /* used by many routines */ X Xstatic char atrtab[64] = /* attribute encoding table. */ X { /* feel free to edit if your */ X 7, /* NORMAL (0) */ /* display board supports all */ X 0x87, /* BLINK */ /* possible combinations */ X 0, /* BLANK */ X 0, /* BLINK & BLANK */ X 0xf, /* BOLD */ X 0x8f, /* BOLD & BLINK */ X 0, /* BOLD & BLANK */ X 0, /* BOLD & BLINK & BLANK */ X 0x70, /* REVERSE (8) */ X 0xf0, /* REVERSE & BLINK */ X 0, /* REVERSE & BLANK */ X 0, /* REVERSE & BLINK & BLANK */ X 0x78, /* REVERSE & BOLD */ X 0xf8, /* REVERSE & BOLD & BLINK */ X 0, /* REVERSE & BOLD & BLANK */ X 0, /* REVERSE & BOLD & BLINK & BLANK */ X 0xf, /* STANDOUT (10) */ X 0x8f, /* STANDOUT & BLINK */ X 0, /* STANDOUT & BLANK */ X 0, /* STANDOUT & BLINK & BLANK */ X 0xf, /* STANDOUT & BOLD */ X 0x8f, /* STANDOUT & BOLD & BLINK */ X 0, /* STANDOUT & BOLD & BLANK */ X 0, /* STANDOUT & BOLD & BLINK & BLANK */ X 0x70, /* STANDOUT & REVERSE (18) */ X 0xf0, /* STANDOUT & REVERSE & BLINK */ X 0, /* STANDOUT & REVERSE & BLANK */ X 0, /* STANDOUT & REVERSE & BLINK & BLANK */ X 0x70, /* STANDOUT & REVERSE & BOLD */ X 0xf0, /* STANDOUT & REVERSE & BOLD & BLINK */ X 0, /* STANDOUT & REVERSE & BOLD & BLANK */ X 0, /* STANDOUT & REVERSE & BOLD & BLINK & BLANK */ X 1, /* UNDERLINE (20) */ X 0x81, /* UNDERLINE & BLINK */ X 0, /* UNDERLINE & BLANK */ X 0, /* UNDERLINE & BLINK & BLANK */ X 9, /* UNDERLINE & BOLD */ X 0x89, /* UNDERLINE & BOLD & BLINK */ X 0, /* UNDERLINE & BOLD & BLANK */ X 0, /* UNDERLINE & BOLD & BLINK & BLANK */ X 0x70, /* UNDERLINE & REVERSE (28) */ X 0xf0, /* UNDERLINE & REVERSE & BLINK */ X 0, /* UNDERLINE & REVERSE & BLANK */ X 0, /* UNDERLINE & REVERSE & BLINK & BLANK */ X 0x79, /* UNDERLINE & REVERSE & BOLD */ X 0xf9, /* UNDERLINE & REVERSE & BOLD & BLINK */ X 0, /* UNDERLINE & REVERSE & BOLD & BLANK */ X 0, /* UNDERLINE & REVERSE & BOLD & BLINK & BLANK */ X 9, /* UNDERLINE & STANDOUT (30) */ X 0x89, /* UNDERLINE & STANDOUT & BLINK */ X 0, /* UNDERLINE & STANDOUT & BLANK */ X 0, /* UNDERLINE & STANDOUT & BLINK & BLANK */ X 9, /* UNDERLINE & STANDOUT & BOLD */ X 0x89, /* UNDERLINE & STANDOUT & BOLD & BLINK */ X 0, /* UNDERLINE & STANDOUT & BOLD & BLANK */ X 0, /* UNDERLINE & STANDOUT & BOLD & BLINK & BLANK */ X 0x70, /* UNDERLINE & STANDOUT & REVERSE (38) */ X 0xf0, /* UNDERLINE & STANDOUT & REVERSE & BLINK */ X 0, /* UNDERLINE & STANDOUT & REVERSE & BLANK */ X 0, /* UNDERLINE & STANDOUT & REVERSE & BLINK & BLANK */ X 0x70, /* UNDERLINE & STANDOUT & REVERSE & BOLD */ X 0xf0, /* UNDERLINE & STANDOUT & REVERSE & BOLD & BLINK */ X 0, /* UNDERLINE & STANDOUT & REVERSE & BOLD & BLANK */ X 0, /* UNDERLINE & STANDOUT & REVERSE & BOLD & BLINK & BLANK */ X }; X X/****************************************************************/ X/* Doupdate() updates the physical screen to look like _curs- */ X/* var.tmpwin if curscr is not 'Clear-marked'. Otherwise it */ X/* updates the screen to look like curscr. */ X/****************************************************************/ X Xvoid doupdate() X { X register int i; X X twin = _cursvar.tmpwin; X if (curscr->_clear) X clrupdate(curscr); X else X { X if (twin->_clear) X clrupdate(twin); X else X { X for (i=0; i < LINES; i++) X if (twin->_minchng[i] != _NO_CHANGE) X if (transformline(i)) X break; X } /* else */ X } /* else */ X curscr->_curx = twin->_curx; X curscr->_cury = twin->_cury; X gotoxy(curscr->_cury, curscr->_curx); X } /* doupdate */ X X/****************************************************************/ X/* Clrupdate(scr) updates the screen by clearing it and then */ X/* redraw it in it's entirety. If _cursvar.refrbrk is TRUE, and */ X/* there is pending input characters, the update will be pre- */ X/* maturely terminated. */ X/****************************************************************/ X Xstatic void clrupdate(scr) X WINDOW *scr; X { X register int *src; X register int *dst; X register int i; X register int j; X static WINDOW *w; X X w = curscr; X X if (scr != w) /* copy scr to curscr */ X { X for (i=0; i < LINES; i++) X { X src = scr->_line[i]; X dst = w->_line[i]; X for (j=0; j < COLS; j++) X *dst++ = *src++; X } /* for */ X } /* if */ X clearscreen(); /* clear physical screen */ X scr->_clear = FALSE; X for (i=0; i < LINES; i++) /* update physical screen */ X { X src = w->_line[i]; X for(j=0; j < COLS; j++) X { X if (*src != (' ' | ATR_NRM)) X { X gotoxy(i,j); X Putchar(*src); X } /* if */ X src++; X } /* for */ X if(_cursvar.refrbrk && _cursespendch()) X return; X } /* for */ X } /* clrupdate */ X X/****************************************************************/ X/* Transformline() updates the given physical line to look */ X/* like the corresponding line in _cursvar.tmpwin. Transform- */ X/* returns 1 if premature refresh end is allowed, and there is */ X/* an input character pending. */ X/****************************************************************/ X Xstatic bool transformline(lineno) X register int lineno; X { X register int *dstp; X register int *srcp; X static int x; X static int endx; X X x = twin->_minchng[lineno]; X endx = twin->_maxchng[lineno]; X dstp = curscr->_line[lineno] + x; X srcp = twin->_line[lineno] + x; X X for( ; x <= endx; x++) X { X if(*dstp != *srcp) X { X gotoxy(lineno,x); X Putchar(*srcp); X } /* if */ X *dstp++ = *srcp++; X } /* for */ X twin->_minchng[lineno] = _NO_CHANGE; X twin->_maxchng[lineno] = _NO_CHANGE; X return (_cursvar.refrbrk && _cursespendch()); X } /* transformline */ X X/****************************************************************/ X/* Clearscreen() clears the physical screen and puts the cursor */ X/* in the home position. */ X/****************************************************************/ X Xstatic void clearscreen() X { X _cursesscroll(0,0,LINES-1,COLS-1,0,atrtab[0]); X gotoxy(0,0); X } /* clearscreen */ X X/****************************************************************/ X/* Gotoxy() moves the physical cursor to the desired address on */ X/* the screen. We don't optimize here - on a PC, it takes more */ X/* time to optimize than to do things directly. */ X/****************************************************************/ X Xstatic void gotoxy(row,col) X int row, col; X { X if((_cursvar.cursrow == row) && (_cursvar.curscol == col)) X return; X _cursescursor(0,row,col); X _cursvar.cursrow = row; X _cursvar.curscol = col; X } /* gotoxy */ X X/****************************************************************/ X/* Putchar() writes a character, with attributes, to the physi- */ X/* cal screen, but avoids writing to the lower right screen */ X/* position. */ X/****************************************************************/ X Xstatic void Putchar(ch) X int ch; X { X if ((_cursvar.cursrow < LINES) || (_cursvar.curscol < COLS)) X _cursescattr(0,ch,atrtab[(ch >> 8) & 0x3f],1); X } /* Putchar */ FRIDAY_NIGHT echo extracting - winclear.c sed 's/^X//' > winclear.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Clear() 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/* Wclear() fills all lines of window 'win' with blanks, and */ X/* marks the window to be cleared at next refresh operation. */ X/****************************************************************/ X Xvoid wclear(win) X WINDOW *win; X { X werase(win); X win->_clear = TRUE; X } /* wclear */ X X/****************************************************************/ X/* Clear() fills all lines of stdscr with blanks, and marks */ X/* marks sdtscr to be cleared at next refresh operation. */ X/****************************************************************/ X Xvoid clear() X { X werase(stdscr); X stdscr->_clear = TRUE; X } /* clear */ FRIDAY_NIGHT echo extracting - windel.c sed 's/^X//' > windel.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Delwin() 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/* Delwin() deallocates all data allocated by 'win'. If 'win' */ X/* is a subwindow, it uses the original window's lines for sto- */ X/* rage, and thus the line arrays are not deallocated. */ X/****************************************************************/ X Xvoid delwin(win) X WINDOW *win; X { X int i; X X if (! (win->_flags & _SUBWIN)) /* subwindow uses 'parent's' lines */ X { X for (i = 0; i <= win->_maxy && win->_line[i]; i++) X free(win->_line[i]); X } X free(win->_minchng); X free(win->_maxchng); X free(win->_line); X free(win); X } /* delwin */ FRIDAY_NIGHT echo extracting - winerase.c sed 's/^X//' > winerase.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* */ X/* Erase() 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/* Werase() fills all lines of window 'win' with blanks and po- */ X/* sitions the cursor at home in the scroll region. */ X/****************************************************************/ X Xvoid werase(win) X WINDOW *win; X { X int *end; X int *start; X short y; X static int blank; X X blank = ' ' | (win->_attrs & ATR_MSK); X X for (y = win->_regtop; y <= win->_regbottom; y++) /* clear all lines */ X { X start = win->_line[y]; X end = &start[win->_maxx]; X while (start <= end) /* clear all line */ X *start++ = blank; X win->_minchng[y] = 0; X win->_maxchng[y] = win->_maxx; X } X win->_cury = win->_regtop; /* cursor home */ X win->_curx = 0; X } /* werase */ X X/****************************************************************/ X/* Erase() fills all lines of stdscr with blanks and positions */ X/* the cursor at home in the scroll region. */ X/****************************************************************/ X Xvoid erase() X { X werase(stdscr); X } /* erase */ FRIDAY_NIGHT echo extracting - winmove.c sed 's/^X//' > winmove.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Mvwin() 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/* Mvwin() moves window 'win' to position (begx, begy) on the */ X/* screen. */ X/****************************************************************/ X Xint mvwin(win, begy, begx) X WINDOW *win; X int begy, begx; X { X if ((begy + win->_maxy) > (LINES-1) || (begx + win->_maxx) > (COLS-1)) X return(ERR); X win->_begy = begy; X win->_begx = begx; X touchwin(win); X return(OK); X } /* mvwin */ FRIDAY_NIGHT echo extracting - winscrol.c sed 's/^X//' > winscrol.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Scroll() 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/* Scroll() scrolls the scrolling region of 'win', but only if */ X/* scrolling is allowed and if the cursor is inside the scrol- */ X/* ling region. */ X/****************************************************************/ X Xvoid scroll(win) X WINDOW *win; X { X int i; X int *ptr; X int *temp; X static int blank; X X blank = ' ' | (win->_attrs & ATR_MSK); X if ( (!win->_scroll) /* check if window scrolls */ X || (win->_cury < win->_regtop) /* and cursor in region */ X || (win->_cury > win->_regbottom) X ) X return; X X temp = win->_line[win->_regtop]; X for (i = win->_regtop; i < win->_regbottom; i++) X { X win->_line[i] = win->_line[i+1]; /* re-arrange line pointers */ X win->_minchng[i] = 0; X win->_maxchng[i] = win->_maxx; X } X for (ptr = temp; ptr - temp <= win->_maxx; ptr++) X *ptr = blank; /* make a blank line */ X win->_line[win->_regbottom] = temp; X if (win->_cury > win->_regtop) /* if not on top line */ X win->_cury--; /* cursor scrolls too */ X win->_minchng[win->_regbottom] = 0; X win->_maxchng[win->_regbottom] = win->_maxx; X } /* scroll */ FRIDAY_NIGHT echo extracting - wintouch.c sed 's/^X//' > wintouch.c << 'FRIDAY_NIGHT' X/****************************************************************/ X/* Touchwin() 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/* Touchwin() marks all lines of window 'win' as changed, from */ X/* the first to the last character on the line. */ X/****************************************************************/ X Xvoid touchwin(win) X WINDOW *win; X { X int y; X int maxy; X int maxx; X X maxy = win->_maxy; X maxx = win->_maxx; X X for (y = 0; y <= maxy; y++) X { X win->_minchng[y] = 0; X win->_maxchng[y] = maxx; X } /* for */ X } /* touchwin */ FRIDAY_NIGHT echo pccurses.sh.4 completed!