bammi@dsrgsun.ces.cwru.edu (Jwahar R. Bammi) (11/28/88)
#!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # delch.c # deleteln.c # delwin.c # endwin.c # erase.c # fullname.c # getch.c # getstr.c # id_subwins.c # idlok.c # initscr.c # insch.c # insertln.c # This archive created: Thu Oct 27 22:02:35 1988 # By: Jwahar R. Bammi(Case Western Reserve University) # Uucp: {decvax,sun,att}!cwjcc!dsrgsun!bammi # Csnet: bammi@dsrgsun.ces.CWRU.edu # Arpa: bammi@dsrgsun.ces.CWRU.edu # export PATH; PATH=/bin:$PATH echo shar: extracting "'delch.c'" '(764 characters)' if test -f 'delch.c' then echo shar: over-writing existing file "'delch.c'" fi sed 's/^X//' << \SHAR_EOF > 'delch.c' X/* X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the X * University of California. Permission is granted to freely X * distribute curses and its documentation provided that this X * notice is left intact. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)delch.c 5.1 (Berkeley) 6/7/85"; X#endif not lint X X# include "curses.ext" X X/* X * This routine performs an insert-char on the line, leaving X * (_cury,_curx) unchanged. X * X */ Xwdelch(win) Xreg WINDOW *win; { X X reg char *temp1, *temp2; X reg char *end; X reg int lch; X X end = &win->_y[win->_cury][win->_maxx - 1]; X temp1 = &win->_y[win->_cury][win->_curx]; X temp2 = temp1 + 1; X while (temp1 < end) X *temp1++ = *temp2++; X *temp1 = ' '; X touchline(win, win->_cury, win->_curx, win->_maxx - 1); X return OK; X} SHAR_EOF if test 764 -ne "`wc -c 'delch.c'`" then echo shar: error transmitting "'delch.c'" '(should have been 764 characters)' fi echo shar: extracting "'deleteln.c'" '(1073 characters)' if test -f 'deleteln.c' then echo shar: over-writing existing file "'deleteln.c'" fi sed 's/^X//' << \SHAR_EOF > 'deleteln.c' X/* X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the X * University of California. Permission is granted to freely X * distribute curses and its documentation provided that this X * notice is left intact. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)deleteln.c 5.1 (Berkeley) 6/7/85"; X#endif not lint X X# include "curses.ext" X X/* X * This routine deletes a line from the screen. It leaves X * (_cury,_curx) unchanged. X * X */ Xwdeleteln(win) Xreg WINDOW *win; X{ X reg char *temp; X reg int y; X reg char *end; X reg int x; X X# ifdef DEBUG X fprintf(outf, "DELETELN(%0.2o)\n", win); X# endif X temp = win->_y[win->_cury]; X for (y = win->_cury; y < win->_maxy - 1; y++) { X if (win->_orig == NULL) X win->_y[y] = win->_y[y + 1]; X else X bcopy(win->_y[y + 1], win->_y[y], win->_maxx); X touchline(win, y, 0, win->_maxx - 1); X } X if (win->_orig == NULL) X win->_y[y] = temp; X else X temp = win->_y[y]; X for (end = &temp[win->_maxx]; temp < end; ) X *temp++ = ' '; X touchline(win, win->_cury, 0, win->_maxx - 1); X if (win->_orig == NULL) X _id_subwins(win); X return OK; X} SHAR_EOF if test 1073 -ne "`wc -c 'deleteln.c'`" then echo shar: error transmitting "'deleteln.c'" '(should have been 1073 characters)' fi echo shar: extracting "'delwin.c'" '(1214 characters)' if test -f 'delwin.c' then echo shar: over-writing existing file "'delwin.c'" fi sed 's/^X//' << \SHAR_EOF > 'delwin.c' X/* X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the X * University of California. Permission is granted to freely X * distribute curses and its documentation provided that this X * notice is left intact. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)delwin.c 5.1 (Berkeley) 6/7/85"; X#endif not lint X X# include "curses.ext" X X/* X * This routine deletes a window and releases it back to the system. X * X */ Xdelwin(win) Xreg WINDOW *win; { X X reg int i; X reg WINDOW *wp, *np; X X if (win->_orig == NULL) { X /* X * If we are the original window, delete the space for X * all the subwindows, and the array of space as well. X */ X for (i = 0; i < win->_maxy && win->_y[i]; i++) X free(win->_y[i]); X free(win->_firstch); X free(win->_lastch); X wp = win->_nextp; X while (wp != win) { X np = wp->_nextp; X delwin(wp); X wp = np; X } X } X else { X /* X * If we are a subwindow, take ourselves out of the X * list. NOTE: if we are a subwindow, the minimum list X * is orig followed by this subwindow, so there are X * always at least two windows in the list. X */ X for (wp = win->_nextp; wp->_nextp != win; wp = wp->_nextp) X continue; X wp->_nextp = win->_nextp; X } X free(win->_y); X free(win); X} SHAR_EOF if test 1214 -ne "`wc -c 'delwin.c'`" then echo shar: error transmitting "'delwin.c'" '(should have been 1214 characters)' fi echo shar: extracting "'endwin.c'" '(555 characters)' if test -f 'endwin.c' then echo shar: over-writing existing file "'endwin.c'" fi sed 's/^X//' << \SHAR_EOF > 'endwin.c' X/* X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the X * University of California. Permission is granted to freely X * distribute curses and its documentation provided that this X * notice is left intact. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)endwin.c 5.1 (Berkeley) 6/7/85"; X#endif not lint X X/* X * Clean things up before exiting X * X */ X X# include "curses.ext" X Xendwin() X{ X resetty(); X _puts(VE); X _puts(TE); X if (curscr) { X if (curscr->_flags & _STANDOUT) { X _puts(SE); X curscr->_flags &= ~_STANDOUT; X } X _endwin = TRUE; X } X} SHAR_EOF if test 555 -ne "`wc -c 'endwin.c'`" then echo shar: error transmitting "'endwin.c'" '(should have been 555 characters)' fi echo shar: extracting "'erase.c'" '(911 characters)' if test -f 'erase.c' then echo shar: over-writing existing file "'erase.c'" fi sed 's/^X//' << \SHAR_EOF > 'erase.c' X/* X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the X * University of California. Permission is granted to freely X * distribute curses and its documentation provided that this X * notice is left intact. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)erase.c 5.1 (Berkeley) 6/7/85"; X#endif not lint X X# include "curses.ext" X X/* X * This routine erases everything on the window. X * X */ Xwerase(win) Xreg WINDOW *win; { X X reg int y; X reg char *sp, *end, *start, *maxx; X reg int minx; X X# ifdef DEBUG X fprintf(outf, "WERASE(%0.2o)\n", win); X# endif X for (y = 0; y < win->_maxy; y++) { X minx = _NOCHANGE; X start = win->_y[y]; X end = &start[win->_maxx]; X for (sp = start; sp < end; sp++) X if (*sp != ' ') { X maxx = sp; X if (minx == _NOCHANGE) X minx = sp - start; X *sp = ' '; X } X if (minx != _NOCHANGE) X touchline(win, y, minx, maxx - win->_y[y]); X } X win->_curx = win->_cury = 0; X} SHAR_EOF if test 911 -ne "`wc -c 'erase.c'`" then echo shar: error transmitting "'erase.c'" '(should have been 911 characters)' fi echo shar: extracting "'fullname.c'" '(854 characters)' if test -f 'fullname.c' then echo shar: over-writing existing file "'fullname.c'" fi sed 's/^X//' << \SHAR_EOF > 'fullname.c' X/* X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the X * University of California. Permission is granted to freely X * distribute curses and its documentation provided that this X * notice is left intact. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)fullname.c 5.1 (Berkeley) 6/7/85"; X#endif not lint X X# define reg register X X/* X * This routine fills in "def" with the full name of the terminal. X * This is assumed to be the last name in the list of aliases. X * X */ Xchar * Xfullname(bp, def) Xreg char *bp, *def; X{ X X reg char *cp; X X *def = 0; /* in case no name */ X X while (*bp && *bp != ':') { X cp = def; /* start of answer */ X while (*bp && *bp != ':' && *bp != '|') { X *cp++ = *bp++; /* copy name over */ X } X *cp = 0; /* zero end of name */ X if (*bp == '|') { X bp++; /* skip over '|' if that is case */ X } X } X return(def); X} SHAR_EOF if test 854 -ne "`wc -c 'fullname.c'`" then echo shar: error transmitting "'fullname.c'" '(should have been 854 characters)' fi echo shar: extracting "'getch.c'" '(1027 characters)' if test -f 'getch.c' then echo shar: over-writing existing file "'getch.c'" fi sed 's/^X//' << \SHAR_EOF > 'getch.c' X/* X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the X * University of California. Permission is granted to freely X * distribute curses and its documentation provided that this X * notice is left intact. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)getch.c 5.3 (Berkeley) 4/16/86"; X#endif not lint X X# include "curses.ext" X X/* X * This routine reads in a character from the window. X * X */ Xwgetch(win) Xreg WINDOW *win; { X X reg bool weset = FALSE; X reg char inp; X X if (!win->_scroll && (win->_flags&_FULLWIN) X && win->_curx == win->_maxx - 1 && win->_cury == win->_maxy - 1) X return ERR; X# ifdef DEBUG X fprintf(outf, "WGETCH: _echoit = %c, _rawmode = %c\n", _echoit ? 'T' : 'F', _rawmode ? 'T' : 'F'); X# endif X if (_echoit && !_rawmode) { X cbreak(); X weset++; X } X inp = getchar(); X# ifdef DEBUG X fprintf(outf,"WGETCH got '%s'\n",unctrl(inp)); X# endif X if (_echoit) { X mvwaddch(curscr, win->_cury + win->_begy, X win->_curx + win->_begx, inp); X waddch(win, inp); X } X if (weset) X nocbreak(); X return inp; X} SHAR_EOF if test 1027 -ne "`wc -c 'getch.c'`" then echo shar: error transmitting "'getch.c'" '(should have been 1027 characters)' fi echo shar: extracting "'getstr.c'" '(599 characters)' if test -f 'getstr.c' then echo shar: over-writing existing file "'getstr.c'" fi sed 's/^X//' << \SHAR_EOF > 'getstr.c' X/* X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the X * University of California. Permission is granted to freely X * distribute curses and its documentation provided that this X * notice is left intact. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)getstr.c 5.1 (Berkeley) 6/7/85"; X#endif not lint X X# include "curses.ext" X X/* X * This routine gets a string starting at (_cury,_curx) X * X */ Xwgetstr(win,str) Xreg WINDOW *win; Xreg char *str; { X X while ((*str = wgetch(win)) != ERR && *str != '\n') X str++; X if (*str == ERR) { X *str = '\0'; X return ERR; X } X *str = '\0'; X return OK; X} SHAR_EOF if test 599 -ne "`wc -c 'getstr.c'`" then echo shar: error transmitting "'getstr.c'" '(should have been 599 characters)' fi echo shar: extracting "'id_subwins.c'" '(908 characters)' if test -f 'id_subwins.c' then echo shar: over-writing existing file "'id_subwins.c'" fi sed 's/^X//' << \SHAR_EOF > 'id_subwins.c' X/* X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the X * University of California. Permission is granted to freely X * distribute curses and its documentation provided that this X * notice is left intact. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)id_subwins.c 5.1 (Berkeley) 6/7/85"; X#endif not lint X X# include "curses.ext" X X/* X * _id_subwins: X * Re-sync the pointers to _y for all the subwindows. X * X */ X_id_subwins(orig) Xregister WINDOW *orig; X{ X register WINDOW *win; X register int realy; X register int y, oy, x; X X realy = orig->_begy + orig->_cury; X for (win = orig->_nextp; win != orig; win = win->_nextp) { X /* X * If the window ends before our current position, X * don't need to do anything. X */ X if (win->_begy + win->_maxy <= realy) X continue; X X oy = orig->_cury; X for (y = realy - win->_begy; y < win->_maxy; y++, oy++) X win->_y[y] = &orig->_y[oy][win->_ch_off]; X } X} SHAR_EOF if test 908 -ne "`wc -c 'id_subwins.c'`" then echo shar: error transmitting "'id_subwins.c'" '(should have been 908 characters)' fi echo shar: extracting "'idlok.c'" '(552 characters)' if test -f 'idlok.c' then echo shar: over-writing existing file "'idlok.c'" fi sed 's/^X//' << \SHAR_EOF > 'idlok.c' X/* X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the X * University of California. Permission is granted to freely X * distribute curses and its documentation provided that this X * notice is left intact. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)idlok.c 5.1 (Berkeley) 6/7/85"; X#endif not lint X X# include "curses.ext" X X/* X * idlok: X * Turn on and off using insert/deleteln sequences for the given X * window. X * X */ Xidlok(win, bf) Xregister WINDOW *win; Xbool bf; X{ X if (bf) X win->_flags |= _IDLINE; X else X win->_flags &= ~_IDLINE; X} SHAR_EOF if test 552 -ne "`wc -c 'idlok.c'`" then echo shar: error transmitting "'idlok.c'" '(should have been 552 characters)' fi echo shar: extracting "'initscr.c'" '(1410 characters)' if test -f 'initscr.c' then echo shar: over-writing existing file "'initscr.c'" fi sed 's/^X//' << \SHAR_EOF > 'initscr.c' X/* X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the X * University of California. Permission is granted to freely X * distribute curses and its documentation provided that this X * notice is left intact. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)initscr.c 5.1 (Berkeley) 6/7/85"; X#endif not lint X X# include "curses.ext" X# include <signal.h> X Xextern char *getenv(); X X/* X * This routine initializes the current and standard screen. X * X */ XWINDOW * Xinitscr() { X X reg char *sp; X int tstp(); X int nfd; X X# ifdef DEBUG X fprintf(outf, "INITSCR()\n"); X# endif X if (My_term) X setterm(Def_term); X else { X for (_tty_ch = 0; _tty_ch < nfd; _tty_ch++) X if (isatty(_tty_ch)) X break; X gettmode(); X if ((sp = getenv("TERM")) == NULL) X sp = Def_term; X setterm(sp); X# ifdef DEBUG X fprintf(outf, "INITSCR: term = %s\n", sp); X# endif X } X _puts(TI); X _puts(VS); X# ifdef SIGTSTP X signal(SIGTSTP, tstp); X# endif X if (curscr != NULL) { X# ifdef DEBUG X fprintf(outf, "INITSCR: curscr = 0%o\n", curscr); X# endif X delwin(curscr); X } X# ifdef DEBUG X fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS); X# endif X if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR) X return ERR; X clearok(curscr, TRUE); X curscr->_flags &= ~_FULLLINE; X if (stdscr != NULL) { X# ifdef DEBUG X fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr); X# endif X delwin(stdscr); X } X stdscr = newwin(LINES, COLS, 0, 0); X return stdscr; X} SHAR_EOF if test 1410 -ne "`wc -c 'initscr.c'`" then echo shar: error transmitting "'initscr.c'" '(should have been 1410 characters)' fi echo shar: extracting "'insch.c'" '(923 characters)' if test -f 'insch.c' then echo shar: over-writing existing file "'insch.c'" fi sed 's/^X//' << \SHAR_EOF > 'insch.c' X/* X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the X * University of California. Permission is granted to freely X * distribute curses and its documentation provided that this X * notice is left intact. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)insch.c 5.1 (Berkeley) 6/7/85"; X#endif not lint X X# include "curses.ext" X X/* X * This routine performs an insert-char on the line, leaving X * (_cury,_curx) unchanged. X * X */ Xwinsch(win, c) Xreg WINDOW *win; Xchar c; { X X reg char *temp1, *temp2; X reg char *end; X X end = &win->_y[win->_cury][win->_curx]; X temp1 = &win->_y[win->_cury][win->_maxx - 1]; X temp2 = temp1 - 1; X while (temp1 > end) X *temp1-- = *temp2--; X *temp1 = c; X touchline(win, win->_cury, win->_curx, win->_maxx - 1); X if (win->_cury == LINES - 1 && win->_y[LINES-1][COLS-1] != ' ') X if (win->_scroll) { X wrefresh(win); X scroll(win); X win->_cury--; X } X else X return ERR; X return OK; X} SHAR_EOF if test 923 -ne "`wc -c 'insch.c'`" then echo shar: error transmitting "'insch.c'" '(should have been 923 characters)' fi echo shar: extracting "'insertln.c'" '(1085 characters)' if test -f 'insertln.c' then echo shar: over-writing existing file "'insertln.c'" fi sed 's/^X//' << \SHAR_EOF > 'insertln.c' X/* X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the X * University of California. Permission is granted to freely X * distribute curses and its documentation provided that this X * notice is left intact. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)insertln.c 5.1 (Berkeley) 6/7/85"; X#endif not lint X X# include "curses.ext" X X/* X * This routine performs an insert-line on the window, leaving X * (_cury,_curx) unchanged. X * X */ Xwinsertln(win) Xreg WINDOW *win; { X X reg char *temp; X reg int y; X reg char *end; X reg int x; X X#ifdef DEBUG X fprintf(outf, "INSERTLN(%0.2o)\n", win); X#endif X if (win->_orig == NULL) X temp = win->_y[win->_maxy - 1]; X for (y = win->_maxy - 1; y > win->_cury; --y) { X if (win->_orig == NULL) X win->_y[y] = win->_y[y - 1]; X else X bcopy(win->_y[y - 1], win->_y[y], win->_maxx); X touchline(win, y, 0, win->_maxx - 1); X } X if (win->_orig == NULL) X win->_y[y] = temp; X else X temp = win->_y[y]; X for (end = &temp[win->_maxx]; temp < end; ) X *temp++ = ' '; X touchline(win, y, 0, win->_maxx - 1); X if (win->_orig == NULL) X _id_subwins(win); X} SHAR_EOF if test 1085 -ne "`wc -c 'insertln.c'`" then echo shar: error transmitting "'insertln.c'" '(should have been 1085 characters)' fi # End of shell archive exit 0 usenet: {decvax,sun}!cwjcc!dsrgsun!bammi jwahar r. bammi csnet: bammi@dsrgsun.ces.CWRU.edu arpa: bammi@dsrgsun.ces.CWRU.edu compuServe: 71515,155