diff --git a/WEGA/contrib/lcc/contrib/libcurses/addch.c b/WEGA/contrib/lcc/contrib/libcurses/addch.c new file mode 100644 index 0000000..9b772a8 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/addch.c @@ -0,0 +1,105 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)addch.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * This routine adds the character to the current position + * + */ +waddch(win, c) +reg WINDOW *win; +char c; +{ + reg int x, y; + reg WINDOW *wp; + reg int newx; + + x = win->_curx; + y = win->_cury; +# ifdef FULLDEBUG + fprintf(outf, "ADDCH('%c') at (%d, %d)\n", c, y, x); +# endif + switch (c) { + case '\t': + for (newx = x + (8 - (x & 07)); x < newx; x++) + if (waddch(win, ' ') == ERR) + return ERR; + return OK; + + default: +# ifdef FULLDEBUG + fprintf(outf, "ADDCH: 1: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]); +# endif + if (win->_flags & _STANDOUT) + c |= _STANDOUT; + set_ch(win, y, x, c); + win->_y[y][x++] = c; + if (x >= win->_maxx) { + x = 0; +newline: + if (++y >= win->_maxy) + if (win->_scroll) { + scroll(win); + --y; + } + else + return ERR; + } +# ifdef FULLDEBUG + fprintf(outf, "ADDCH: 2: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]); +# endif + break; + case '\n': + wclrtoeol(win); + if (!NONL) + x = 0; + goto newline; + case '\r': + x = 0; + break; + case '\b': + if (--x < 0) + x = 0; + break; + } + win->_curx = x; + win->_cury = y; + return OK; +} + +/* + * set_ch: + * Set the first and last change flags for this window. + */ +static +set_ch(win, y, x, ch) +reg WINDOW *win; +int y, x; +{ +# ifdef FULLDEBUG + fprintf(outf, "SET_CH(%0.2o, %d, %d)\n", win, y, x); +# endif + if (win->_y[y][x] != ch) { + x += win->_ch_off; + if (win->_firstch[y] == _NOCHANGE) + win->_firstch[y] = win->_lastch[y] = x; + else if (x < win->_firstch[y]) + win->_firstch[y] = x; + else if (x > win->_lastch[y]) + win->_lastch[y] = x; +# ifdef FULLDEBUG + fprintf(outf, "SET_CH: change gives f/l: %d/%d [%d/%d]\n", + win->_firstch[y], win->_lastch[y], + win->_firstch[y] - win->_ch_off, + win->_lastch[y] - win->_ch_off); +# endif + } +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/addstr.c b/WEGA/contrib/lcc/contrib/libcurses/addstr.c new file mode 100644 index 0000000..c22f8d6 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/addstr.c @@ -0,0 +1,28 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)addstr.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * This routine adds a string starting at (_cury,_curx) + * + */ +waddstr(win,str) +reg WINDOW *win; +reg char *str; +{ +# ifdef DEBUG + fprintf(outf, "WADDSTR(\"%s\")\n", str); +# endif + while (*str) + if (waddch(win, *str++) == ERR) + return ERR; + return OK; +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/box.c b/WEGA/contrib/lcc/contrib/libcurses/box.c new file mode 100644 index 0000000..ec6e6e2 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/box.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)box.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * This routine draws a box around the given window with "vert" + * as the vertical delimiting char, and "hor", as the horizontal one. + * + */ +box(win, vert, hor) +reg WINDOW *win; +char vert, hor; { + + reg int i; + reg int endy, endx; + reg char *fp, *lp; + + endx = win->_maxx; + endy = win->_maxy - 1; + fp = win->_y[0]; + lp = win->_y[endy]; + for (i = 0; i < endx; i++) + fp[i] = lp[i] = hor; + endx--; + for (i = 0; i <= endy; i++) + win->_y[i][0] = (win->_y[i][endx] = vert); + if (!win->_scroll && (win->_flags&_SCROLLWIN)) + fp[0] = fp[endx] = lp[0] = lp[endx] = ' '; + touchwin(win); +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/clear.c b/WEGA/contrib/lcc/contrib/libcurses/clear.c new file mode 100644 index 0000000..7042009 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/clear.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)clear.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * This routine clears the window. + * + */ +wclear(win) +reg WINDOW *win; { + + werase(win); + win->_clear = TRUE; + return OK; +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/clrtoeol.c b/WEGA/contrib/lcc/contrib/libcurses/clrtoeol.c new file mode 100644 index 0000000..b96c2ba --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/clrtoeol.c @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)clrtoeol.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * This routine clears up to the end of line + * + */ +wclrtoeol(win) +reg WINDOW *win; { + + reg char *sp, *end; + reg int y, x; + reg char *maxx; + reg int minx; + + y = win->_cury; + x = win->_curx; + end = &win->_y[y][win->_maxx]; + minx = _NOCHANGE; + maxx = &win->_y[y][x]; + for (sp = maxx; sp < end; sp++) + if (*sp != ' ') { + maxx = sp; + if (minx == _NOCHANGE) + minx = sp - win->_y[y]; + *sp = ' '; + } + /* + * update firstch and lastch for the line + */ + touchline(win, y, win->_curx, win->_maxx - 1); +# ifdef DEBUG + fprintf(outf, "CLRTOEOL: minx = %d, maxx = %d, firstch = %d, lastch = %d\n", minx, maxx - win->_y[y], win->_firstch[y], win->_lastch[y]); +# endif +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/delch.c b/WEGA/contrib/lcc/contrib/libcurses/delch.c new file mode 100644 index 0000000..ea77d6f --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/delch.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)delch.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * This routine performs an insert-char on the line, leaving + * (_cury,_curx) unchanged. + * + */ +wdelch(win) +reg WINDOW *win; { + + reg char *temp1, *temp2; + reg char *end; + reg int lch; + + end = &win->_y[win->_cury][win->_maxx - 1]; + temp1 = &win->_y[win->_cury][win->_curx]; + temp2 = temp1 + 1; + while (temp1 < end) + *temp1++ = *temp2++; + *temp1 = ' '; + touchline(win, win->_cury, win->_curx, win->_maxx - 1); + return OK; +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/deleteln.c b/WEGA/contrib/lcc/contrib/libcurses/deleteln.c new file mode 100644 index 0000000..9e870c9 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/deleteln.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)deleteln.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * This routine deletes a line from the screen. It leaves + * (_cury,_curx) unchanged. + * + */ +wdeleteln(win) +reg WINDOW *win; +{ + reg char *temp; + reg int y; + reg char *end; + reg int x; + +# ifdef DEBUG + fprintf(outf, "DELETELN(%0.2o)\n", win); +# endif + temp = win->_y[win->_cury]; + for (y = win->_cury; y < win->_maxy - 1; y++) { + if (win->_orig == NULL) + win->_y[y] = win->_y[y + 1]; + else + bcopy(win->_y[y + 1], win->_y[y], win->_maxx); + touchline(win, y, 0, win->_maxx - 1); + } + if (win->_orig == NULL) + win->_y[y] = temp; + else + temp = win->_y[y]; + for (end = &temp[win->_maxx]; temp < end; ) + *temp++ = ' '; + touchline(win, win->_cury, 0, win->_maxx - 1); + if (win->_orig == NULL) + _id_subwins(win); + return OK; +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/delwin.c b/WEGA/contrib/lcc/contrib/libcurses/delwin.c new file mode 100644 index 0000000..943e6c1 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/delwin.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)delwin.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * This routine deletes a window and releases it back to the system. + * + */ +delwin(win) +reg WINDOW *win; { + + reg int i; + reg WINDOW *wp, *np; + + if (win->_orig == NULL) { + /* + * If we are the original window, delete the space for + * all the subwindows, and the array of space as well. + */ + for (i = 0; i < win->_maxy && win->_y[i]; i++) + free(win->_y[i]); + free(win->_firstch); + free(win->_lastch); + wp = win->_nextp; + while (wp != win) { + np = wp->_nextp; + delwin(wp); + wp = np; + } + } + else { + /* + * If we are a subwindow, take ourselves out of the + * list. NOTE: if we are a subwindow, the minimum list + * is orig followed by this subwindow, so there are + * always at least two windows in the list. + */ + for (wp = win->_nextp; wp->_nextp != win; wp = wp->_nextp) + continue; + wp->_nextp = win->_nextp; + } + free(win->_y); + free(win); +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/endwin.c b/WEGA/contrib/lcc/contrib/libcurses/endwin.c new file mode 100644 index 0000000..4b14b33 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/endwin.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)endwin.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +/* + * Clean things up before exiting + * + */ + +# include "curses.ext" + +endwin() +{ + resetty(); + _puts(VE); + _puts(TE); + if (curscr) { + if (curscr->_flags & _STANDOUT) { + _puts(SE); + curscr->_flags &= ~_STANDOUT; + } + _endwin = TRUE; + } +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/erase.c b/WEGA/contrib/lcc/contrib/libcurses/erase.c new file mode 100644 index 0000000..e1c3d65 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/erase.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)erase.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * This routine erases everything on the window. + * + */ +werase(win) +reg WINDOW *win; { + + reg int y; + reg char *sp, *end, *start, *maxx; + reg int minx; + +# ifdef DEBUG + fprintf(outf, "WERASE(%0.2o)\n", win); +# endif + for (y = 0; y < win->_maxy; y++) { + minx = _NOCHANGE; + start = win->_y[y]; + end = &start[win->_maxx]; + for (sp = start; sp < end; sp++) + if (*sp != ' ') { + maxx = sp; + if (minx == _NOCHANGE) + minx = sp - start; + *sp = ' '; + } + if (minx != _NOCHANGE) + touchline(win, y, minx, maxx - win->_y[y]); + } + win->_curx = win->_cury = 0; +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/fullname.c b/WEGA/contrib/lcc/contrib/libcurses/fullname.c new file mode 100644 index 0000000..abd4cd2 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/fullname.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)fullname.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# define reg register + +/* + * This routine fills in "def" with the full name of the terminal. + * This is assumed to be the last name in the list of aliases. + * + */ +char * +fullname(bp, def) +reg char *bp, *def; +{ + + reg char *cp; + + *def = 0; /* in case no name */ + + while (*bp && *bp != ':') { + cp = def; /* start of answer */ + while (*bp && *bp != ':' && *bp != '|') { + *cp++ = *bp++; /* copy name over */ + } + *cp = 0; /* zero end of name */ + if (*bp == '|') { + bp++; /* skip over '|' if that is case */ + } + } + return(def); +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/getstr.c b/WEGA/contrib/lcc/contrib/libcurses/getstr.c new file mode 100644 index 0000000..7f3efa8 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/getstr.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)getstr.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * This routine gets a string starting at (_cury,_curx) + * + */ +wgetstr(win,str) +reg WINDOW *win; +reg char *str; { + + while ((*str = wgetch(win)) != ERR && *str != '\n') + str++; + if (*str == ERR) { + *str = '\0'; + return ERR; + } + *str = '\0'; + return OK; +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/id_subwins.c b/WEGA/contrib/lcc/contrib/libcurses/id_subwins.c new file mode 100644 index 0000000..41490f3 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/id_subwins.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)id_subwins.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * _id_subwins: + * Re-sync the pointers to _y for all the subwindows. + * + */ +_id_subwins(orig) +register WINDOW *orig; +{ + register WINDOW *win; + register int realy; + register int y, oy, x; + + realy = orig->_begy + orig->_cury; + for (win = orig->_nextp; win != orig; win = win->_nextp) { + /* + * If the window ends before our current position, + * don't need to do anything. + */ + if (win->_begy + win->_maxy <= realy) + continue; + + oy = orig->_cury; + for (y = realy - win->_begy; y < win->_maxy; y++, oy++) + win->_y[y] = &orig->_y[oy][win->_ch_off]; + } +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/idlok.c b/WEGA/contrib/lcc/contrib/libcurses/idlok.c new file mode 100644 index 0000000..f3cd2a9 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/idlok.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)idlok.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * idlok: + * Turn on and off using insert/deleteln sequences for the given + * window. + * + */ +idlok(win, bf) +register WINDOW *win; +bool bf; +{ + if (bf) + win->_flags |= _IDLINE; + else + win->_flags &= ~_IDLINE; +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/initscr.c b/WEGA/contrib/lcc/contrib/libcurses/initscr.c new file mode 100644 index 0000000..e7451d2 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/initscr.c @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)initscr.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" +# include + +extern char *getenv(); + +/* + * This routine initializes the current and standard screen. + * + */ +WINDOW * +initscr() { + + reg char *sp; + int tstp(); + int nfd; + +# ifdef DEBUG + fprintf(outf, "INITSCR()\n"); +# endif + if (My_term) + setterm(Def_term); + else { + for (_tty_ch = 0; _tty_ch < nfd; _tty_ch++) + if (isatty(_tty_ch)) + break; + gettmode(); + if ((sp = getenv("TERM")) == NULL) + sp = Def_term; + setterm(sp); +# ifdef DEBUG + fprintf(outf, "INITSCR: term = %s\n", sp); +# endif + } + _puts(TI); + _puts(VS); +# ifdef SIGTSTP + signal(SIGTSTP, tstp); +# endif + if (curscr != NULL) { +# ifdef DEBUG + fprintf(outf, "INITSCR: curscr = 0%o\n", curscr); +# endif + delwin(curscr); + } +# ifdef DEBUG + fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS); +# endif + if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR) + return ERR; + clearok(curscr, TRUE); + curscr->_flags &= ~_FULLLINE; + if (stdscr != NULL) { +# ifdef DEBUG + fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr); +# endif + delwin(stdscr); + } + stdscr = newwin(LINES, COLS, 0, 0); + return stdscr; +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/insch.c b/WEGA/contrib/lcc/contrib/libcurses/insch.c new file mode 100644 index 0000000..0cf8d59 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/insch.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)insch.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * This routine performs an insert-char on the line, leaving + * (_cury,_curx) unchanged. + * + */ +winsch(win, c) +reg WINDOW *win; +char c; { + + reg char *temp1, *temp2; + reg char *end; + + end = &win->_y[win->_cury][win->_curx]; + temp1 = &win->_y[win->_cury][win->_maxx - 1]; + temp2 = temp1 - 1; + while (temp1 > end) + *temp1-- = *temp2--; + *temp1 = c; + touchline(win, win->_cury, win->_curx, win->_maxx - 1); + if (win->_cury == LINES - 1 && win->_y[LINES-1][COLS-1] != ' ') + if (win->_scroll) { + wrefresh(win); + scroll(win); + win->_cury--; + } + else + return ERR; + return OK; +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/insertln.c b/WEGA/contrib/lcc/contrib/libcurses/insertln.c new file mode 100644 index 0000000..bae87cb --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/insertln.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)insertln.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * This routine performs an insert-line on the window, leaving + * (_cury,_curx) unchanged. + * + */ +winsertln(win) +reg WINDOW *win; { + + reg char *temp; + reg int y; + reg char *end; + reg int x; + +#ifdef DEBUG + fprintf(outf, "INSERTLN(%0.2o)\n", win); +#endif + if (win->_orig == NULL) + temp = win->_y[win->_maxy - 1]; + for (y = win->_maxy - 1; y > win->_cury; --y) { + if (win->_orig == NULL) + win->_y[y] = win->_y[y - 1]; + else + bcopy(win->_y[y - 1], win->_y[y], win->_maxx); + touchline(win, y, 0, win->_maxx - 1); + } + if (win->_orig == NULL) + win->_y[y] = temp; + else + temp = win->_y[y]; + for (end = &temp[win->_maxx]; temp < end; ) + *temp++ = ' '; + touchline(win, y, 0, win->_maxx - 1); + if (win->_orig == NULL) + _id_subwins(win); +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/longname.c b/WEGA/contrib/lcc/contrib/libcurses/longname.c new file mode 100644 index 0000000..22a453d --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/longname.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)longname.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# define reg register + +/* + * This routine fills in "def" with the long name of the terminal. + * + */ +char * +longname(bp, def) +reg char *bp, *def; { + + reg char *cp; + + while (*bp && *bp != ':' && *bp != '|') + bp++; + if (*bp == '|') { + bp++; + cp = def; + while (*bp && *bp != ':' && *bp != '|') + *cp++ = *bp++; + *cp = 0; + } + return def; +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/mvprintw.c b/WEGA/contrib/lcc/contrib/libcurses/mvprintw.c new file mode 100644 index 0000000..7b27fbb --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/mvprintw.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)mvprintw.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * implement the mvprintw commands. Due to the variable number of + * arguments, they cannot be macros. Sigh.... + * + */ + +mvprintw(y, x, fmt, args) +reg int y, x; +char *fmt; +int args; { + + return move(y, x) == OK ? _sprintw(stdscr, fmt, &args) : ERR; +} + +mvwprintw(win, y, x, fmt, args) +reg WINDOW *win; +reg int y, x; +char *fmt; +int args; { + + return wmove(win, y, x) == OK ? _sprintw(win, fmt, &args) : ERR; +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/mvscanw.c b/WEGA/contrib/lcc/contrib/libcurses/mvscanw.c new file mode 100644 index 0000000..203ab67 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/mvscanw.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)mvscanw.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * implement the mvscanw commands. Due to the variable number of + * arguments, they cannot be macros. Another sigh.... + * + */ + +mvscanw(y, x, fmt, args) +reg int y, x; +char *fmt; +int args; { + + return move(y, x) == OK ? _sscans(stdscr, fmt, &args) : ERR; +} + +mvwscanw(win, y, x, fmt, args) +reg WINDOW *win; +reg int y, x; +char *fmt; +int args; { + + return wmove(win, y, x) == OK ? _sscans(win, fmt, &args) : ERR; +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/mvwin.c b/WEGA/contrib/lcc/contrib/libcurses/mvwin.c new file mode 100644 index 0000000..e49f83b --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/mvwin.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)mvwin.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * relocate the starting position of a window + * + */ + +mvwin(win, by, bx) +reg WINDOW *win; +reg int by, bx; { + + register WINDOW *orig; + register int dy, dx; + + if (by + win->_maxy > LINES || bx + win->_maxx > COLS) + return ERR; + dy = by - win->_begy; + dx = bx - win->_begx; + orig = win->_orig; + if (orig == NULL) { + orig = win; + do { + win->_begy += dy; + win->_begx += dx; + _swflags_(win); + win = win->_nextp; + } while (win != orig); + } + else { + if (by < orig->_begy || win->_maxy + dy > orig->_maxy) + return ERR; + if (bx < orig->_begx || win->_maxx + dx > orig->_maxx) + return ERR; + win->_begy = by; + win->_begx = bx; + _swflags_(win); + _set_subwin_(orig, win); + } + touchwin(win); + return OK; +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/newwin.c b/WEGA/contrib/lcc/contrib/libcurses/newwin.c new file mode 100644 index 0000000..338bd35 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/newwin.c @@ -0,0 +1,208 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)newwin.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +/* + * allocate space for and set up defaults for a new window + * + */ + +# include "curses.ext" + +char *malloc(); + +# define SMALLOC (short *) malloc + +static WINDOW *makenew(); + +# undef nl /* don't need it here, and it interferes */ + +WINDOW * +newwin(num_lines, num_cols, begy, begx) +int num_lines, num_cols, begy, begx; +{ + reg WINDOW *win; + reg char *sp; + reg int i, by, bx, nl, nc; + reg int j; + + by = begy; + bx = begx; + nl = num_lines; + nc = num_cols; + + if (nl == 0) + nl = LINES - by; + if (nc == 0) + nc = COLS - bx; + if ((win = makenew(nl, nc, by, bx)) == NULL) + return ERR; + if ((win->_firstch = SMALLOC(nl * sizeof win->_firstch[0])) == NULL) { + free(win->_y); + free(win); + return NULL; + } + if ((win->_lastch = SMALLOC(nl * sizeof win->_lastch[0])) == NULL) { + free(win->_y); + free(win->_firstch); + free(win); + return NULL; + } + win->_nextp = win; + for (i = 0; i < nl; i++) { + win->_firstch[i] = _NOCHANGE; + win->_lastch[i] = _NOCHANGE; + } + for (i = 0; i < nl; i++) + if ((win->_y[i] = malloc(nc * sizeof win->_y[0])) == NULL) { + for (j = 0; j < i; j++) + free(win->_y[j]); + free(win->_firstch); + free(win->_lastch); + free(win->_y); + free(win); + return ERR; + } + else + for (sp = win->_y[i]; sp < win->_y[i] + nc; ) + *sp++ = ' '; + win->_ch_off = 0; +# ifdef DEBUG + fprintf(outf, "NEWWIN: win->_ch_off = %d\n", win->_ch_off); +# endif + return win; +} + +WINDOW * +subwin(orig, num_lines, num_cols, begy, begx) +reg WINDOW *orig; +int num_lines, num_cols, begy, begx; +{ + reg int i; + reg WINDOW *win; + reg int by, bx, nl, nc; + + by = begy; + bx = begx; + nl = num_lines; + nc = num_cols; + + /* + * make sure window fits inside the original one + */ +# ifdef DEBUG + fprintf(outf, "SUBWIN(%0.2o, %d, %d, %d, %d)\n", orig, nl, nc, by, bx); +# endif + if (by < orig->_begy || bx < orig->_begx + || by + nl > orig->_maxy + orig->_begy + || bx + nc > orig->_maxx + orig->_begx) + return ERR; + if (nl == 0) + nl = orig->_maxy + orig->_begy - by; + if (nc == 0) + nc = orig->_maxx + orig->_begx - bx; + if ((win = makenew(nl, nc, by, bx)) == NULL) + return ERR; + win->_nextp = orig->_nextp; + orig->_nextp = win; + win->_orig = orig; + _set_subwin_(orig, win); + return win; +} + +/* + * this code is shared with mvwin() + */ +_set_subwin_(orig, win) +register WINDOW *orig, *win; +{ + register int i, j, k; + + j = win->_begy - orig->_begy; + k = win->_begx - orig->_begx; + win->_ch_off = k; +# ifdef DEBUG + fprintf(outf, "_SET_SUBWIN_: win->_ch_off = %d\n", win->_ch_off); +# endif + win->_firstch = &orig->_firstch[j]; + win->_lastch = &orig->_lastch[j]; + for (i = 0; i < win->_maxy; i++, j++) + win->_y[i] = &orig->_y[j][k]; + +} + +/* + * This routine sets up a window buffer and returns a pointer to it. + */ +static WINDOW * +makenew(num_lines, num_cols, begy, begx) +int num_lines, num_cols, begy, begx; { + + reg int i; + reg WINDOW *win; + reg int by, bx, nl, nc; + + by = begy; + bx = begx; + nl = num_lines; + nc = num_cols; + +# ifdef DEBUG + fprintf(outf, "MAKENEW(%d, %d, %d, %d)\n", nl, nc, by, bx); +# endif + if ((win = (WINDOW *) malloc(sizeof *win)) == NULL) + return NULL; +# ifdef DEBUG + fprintf(outf, "MAKENEW: nl = %d\n", nl); +# endif + if ((win->_y = (char **) malloc(nl * sizeof win->_y[0])) == NULL) { + free(win); + return NULL; + } +# ifdef DEBUG + fprintf(outf, "MAKENEW: nc = %d\n", nc); +# endif + win->_cury = win->_curx = 0; + win->_clear = FALSE; + win->_maxy = nl; + win->_maxx = nc; + win->_begy = by; + win->_begx = bx; + win->_flags = 0; + win->_scroll = win->_leave = FALSE; + _swflags_(win); +# ifdef DEBUG + fprintf(outf, "MAKENEW: win->_clear = %d\n", win->_clear); + fprintf(outf, "MAKENEW: win->_leave = %d\n", win->_leave); + fprintf(outf, "MAKENEW: win->_scroll = %d\n", win->_scroll); + fprintf(outf, "MAKENEW: win->_flags = %0.2o\n", win->_flags); + fprintf(outf, "MAKENEW: win->_maxy = %d\n", win->_maxy); + fprintf(outf, "MAKENEW: win->_maxx = %d\n", win->_maxx); + fprintf(outf, "MAKENEW: win->_begy = %d\n", win->_begy); + fprintf(outf, "MAKENEW: win->_begx = %d\n", win->_begx); +# endif + return win; +} + +_swflags_(win) +register WINDOW *win; +{ + win->_flags &= ~(_ENDLINE|_FULLLINE|_FULLWIN|_SCROLLWIN); + if (win->_begx + win->_maxx == COLS) { + win->_flags |= _ENDLINE; + if (win->_begx == 0) { + if (AL && DL) + win->_flags |= _FULLLINE; + if (win->_maxy == LINES && win->_begy == 0) + win->_flags |= _FULLWIN; + } + if (win->_begy + win->_maxy == LINES) + win->_flags |= _SCROLLWIN; + } +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/overwrite.c b/WEGA/contrib/lcc/contrib/libcurses/overwrite.c new file mode 100644 index 0000000..c4c7760 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/overwrite.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)overwrite.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" +# include + +# define min(a,b) (a < b ? a : b) +# define max(a,b) (a > b ? a : b) + +/* + * This routine writes win1 on win2 destructively. + * + */ +overwrite(win1, win2) +reg WINDOW *win1, *win2; { + + reg char *sp, *end; + reg int x, y, endy, endx, starty, startx; + +# ifdef DEBUG + fprintf(outf, "OVERWRITE(%0.2o, %0.2o);\n", win1, win2); +# endif + starty = max(win1->_begy, win2->_begy); + startx = max(win1->_begx, win2->_begx); + endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); + endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); + if (starty >= endy || startx >= endx) + return; +# ifdef DEBUG + fprintf(outf, "OVERWRITE:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); +# endif + x = endx - startx; + for (y = starty; y < endy; y++) { + bcopy(&win1->_y[y - win1->_begy][startx - win1->_begx], + &win2->_y[y - win2->_begy][startx - win2->_begx], x); + touchline(win2, y, startx - win2->_begx, endx - win2->_begx); + } +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/putchar.c b/WEGA/contrib/lcc/contrib/libcurses/putchar.c new file mode 100644 index 0000000..1338169 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/putchar.c @@ -0,0 +1,21 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)putchar.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +char +_putchar(c) +reg char c; { + + putchar(c); +#ifdef DEBUG + fprintf(outf, "_PUTCHAR(%s)\n", unctrl(c)); +#endif +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/scroll.c b/WEGA/contrib/lcc/contrib/libcurses/scroll.c new file mode 100644 index 0000000..41eae9e --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/scroll.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)scroll.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * This routine scrolls the window up a line. + * + */ +scroll(win) +register WINDOW *win; +{ + register int oy, ox; + +# ifdef DEBUG + fprintf(outf, "SCROLL(%0.2o)\n", win); +# endif + + if (!win->_scroll) + return ERR; + + getyx(win, oy, ox); + wmove(win, 0, 0); + wdeleteln(win); + wmove(win, oy, ox); + + if (win == curscr) { + _putchar('\n'); + if (!NONL) + win->_curx = 0; +# ifdef DEBUG + fprintf(outf, "SCROLL: win == curscr\n"); +# endif + } +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/standout.c b/WEGA/contrib/lcc/contrib/libcurses/standout.c new file mode 100644 index 0000000..e4f6616 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/standout.c @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)standout.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +/* + * routines dealing with entering and exiting standout mode + * + */ + +# include "curses.ext" + +/* + * enter standout mode + */ +char * +wstandout(win) +reg WINDOW *win; +{ + if (!SO && !UC) + return FALSE; + + win->_flags |= _STANDOUT; + return (SO ? SO : UC); +} + +/* + * exit standout mode + */ +char * +wstandend(win) +reg WINDOW *win; +{ + if (!SO && !UC) + return FALSE; + + win->_flags &= ~_STANDOUT; + return (SE ? SE : UC); +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/toucholap.c b/WEGA/contrib/lcc/contrib/libcurses/toucholap.c new file mode 100644 index 0000000..68fe57c --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/toucholap.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)toucholap.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +# define min(a,b) (a < b ? a : b) +# define max(a,b) (a > b ? a : b) + +/* + * Touch, on win2, the part that overlaps with win1. + * + */ +touchoverlap(win1, win2) +reg WINDOW *win1, *win2; { + + reg int x, y, endy, endx, starty, startx; + +# ifdef DEBUG + fprintf(outf, "TOUCHOVERLAP(%0.2o, %0.2o);\n", win1, win2); +# endif + starty = max(win1->_begy, win2->_begy); + startx = max(win1->_begx, win2->_begx); + endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); + endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); +# ifdef DEBUG + fprintf(outf, "TOUCHOVERLAP:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); + fprintf(outf, "TOUCHOVERLAP:win1 (%d,%d) to (%d,%d)\n", win1->_begy, win1->_begx, win1->_begy + win1->_maxy, win1->_begx + win1->_maxx); + fprintf(outf, "TOUCHOVERLAP:win2 (%d,%d) to (%d,%d)\n", win2->_begy, win2->_begx, win2->_begy + win2->_maxy, win2->_begx + win2->_maxx); +# endif + if (starty >= endy || startx >= endx) + return; + starty -= win2->_begy; + startx -= win2->_begx; + endy -= win2->_begy; + endx -= win2->_begx; + endx--; + for (y = starty; y < endy; y++) + touchline(win2, y, startx, endx); +} diff --git a/WEGA/contrib/lcc/contrib/libcurses/touchwin.c b/WEGA/contrib/lcc/contrib/libcurses/touchwin.c new file mode 100644 index 0000000..b32f9c7 --- /dev/null +++ b/WEGA/contrib/lcc/contrib/libcurses/touchwin.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)touchwin.c 5.1 (Berkeley) 6/7/85"; +#endif not lint + +# include "curses.ext" + +/* + * make it look like the whole window has been changed. + * + */ +touchwin(win) +register WINDOW *win; +{ + register int y, maxy; + +# ifdef DEBUG + fprintf(outf, "TOUCHWIN(%0.2o)\n", win); +# endif + maxy = win->_maxy; + for (y = 0; y < maxy; y++) + touchline(win, y, 0, win->_maxx - 1); +} + +/* + * touch a given line + */ +touchline(win, y, sx, ex) +register WINDOW *win; +register int y, sx, ex; +{ +# ifdef DEBUG + fprintf(outf, "TOUCHLINE(%0.2o, %d, %d, %d)\n", win, y, sx, ex); + fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", win->_firstch[y], win->_lastch[y]); +# endif + sx += win->_ch_off; + ex += win->_ch_off; + if (win->_firstch[y] == _NOCHANGE) { + win->_firstch[y] = sx; + win->_lastch[y] = ex; + } + else { + if (win->_firstch[y] > sx) + win->_firstch[y] = sx; + if (win->_lastch[y] < ex) + win->_lastch[y] = ex; + } +# ifdef DEBUG + fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", win->_firstch[y], win->_lastch[y]); +# endif +}