diff options
| author | svn2git <svn2git@FreeBSD.org> | 1993-11-01 08:00:00 +0000 |
|---|---|---|
| committer | svn2git <svn2git@FreeBSD.org> | 1993-11-01 08:00:00 +0000 |
| commit | 8503f4f13f77abf7adc8f7e329c6f9c1d52b6a20 (patch) | |
| tree | c5b2ce776438e0a52b492a2ab6ab41360b8ba1f6 /lib/libcurses | |
Release FreeBSD 1.0upstream/1.0.0_cvsrelease/1.0.0_cvs
This commit was manufactured to restore the state of the 1.0-RELEASE image.
Releases prior to 5.3-RELEASE are omitting the secure/ and crypto/ subdirs.
Diffstat (limited to 'lib/libcurses')
45 files changed, 4462 insertions, 0 deletions
diff --git a/lib/libcurses/Makefile b/lib/libcurses/Makefile new file mode 100644 index 000000000000..1a1538da63e0 --- /dev/null +++ b/lib/libcurses/Makefile @@ -0,0 +1,17 @@ +# @(#)Makefile 5.10 (Berkeley) 6/24/90 + +LIB= curses +SRCS= addbytes.c addch.c addstr.c box.c clear.c clrtobot.c clrtoeol.c \ + cr_put.c cr_tty.c curses.c delch.c deleteln.c delwin.c endwin.c \ + erase.c fullname.c getch.c getstr.c idlok.c id_subwins.c initscr.c \ + insch.c insertln.c longname.c move.c mvprintw.c mvscanw.c mvwin.c \ + newwin.c overlay.c overwrite.c printw.c putchar.c refresh.c scanw.c \ + scroll.c toucholap.c standout.c touchwin.c tstp.c unctrl.c +MAN3= curses.3 + +beforeinstall: + -cd ${.CURDIR}; cmp -s curses.h ${DESTDIR}/usr/include/curses.h || \ + install -c -o ${BINOWN} -g ${BINGRP} -m 444 curses.h \ + ${DESTDIR}/usr/include + +.include <bsd.lib.mk> diff --git a/lib/libcurses/addbytes.c b/lib/libcurses/addbytes.c new file mode 100644 index 000000000000..3d47b326acf4 --- /dev/null +++ b/lib/libcurses/addbytes.c @@ -0,0 +1,148 @@ +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)addbytes.c 5.4 (Berkeley) 6/1/90"; +#endif /* not lint */ + +# include "curses.ext" + +waddbytes(win, bytes, count) +reg WINDOW *win; +reg char *bytes; +int count; +{ + chtype c; + reg int i; + + for (i = 0; i < count; i++) { + c = (unsigned char) *bytes++; + if (_waddbytes(win, &c, 1) == ERR) + return ERR; + } + return OK; +} + +/* + * This routine adds the character to the current position + * + */ +_waddbytes(win, bytes, count) +reg WINDOW *win; +reg chtype *bytes; +reg int count; +{ +#define SYNCH_OUT() {win->_cury = y; win->_curx = x;} +#define SYNCH_IN() {y = win->_cury; x = win->_curx;} + reg int x, y; + reg int newx; + + SYNCH_IN(); + while (count--) { + register chtype c; + static chtype blanks[] = {' ',' ',' ',' ',' ',' ',' ',' '}; + + c = *bytes++; + switch (c) { + case '\t': + SYNCH_OUT(); + if (_waddbytes(win, blanks, 8-(x%8)) == ERR) { + return ERR; + } + SYNCH_IN(); + break; + + default: +# ifdef FULLDEBUG + fprintf(outf, "ADDBYTES: 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; + { +# ifdef FULLDEBUG + fprintf(outf, "ADDBYTES(%0.2o, %d, %d)\n", win, y, x); +# endif + if (win->_y[y][x] != c) { + newx = x + win->_ch_off; + if (win->_firstch[y] == _NOCHANGE) { + win->_firstch[y] = + win->_lastch[y] = newx; + } else if (newx < win->_firstch[y]) + win->_firstch[y] = newx; + else if (newx > win->_lastch[y]) + win->_lastch[y] = newx; +# ifdef FULLDEBUG + fprintf(outf, "ADDBYTES: 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 + } + } + win->_y[y][x++] = c; + if (x >= win->_maxx) { + x = 0; + newline: + if (++y >= win->_maxy) + if (win->_scroll) { + --y; + SYNCH_OUT(); + scroll(win); + SYNCH_IN(); + } + else + return ERR; + } +# ifdef FULLDEBUG + fprintf(outf, "ADDBYTES: 2: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]); +# endif + break; + case '\n': + SYNCH_OUT(); + wclrtoeol(win); + SYNCH_IN(); + if (!NONL) + x = 0; + goto newline; + case '\r': + x = 0; + break; + case '\b': + if (--x < 0) + x = 0; + break; + } + } + SYNCH_OUT(); + return OK; +} diff --git a/lib/libcurses/addch.c b/lib/libcurses/addch.c new file mode 100644 index 000000000000..027c4bf94476 --- /dev/null +++ b/lib/libcurses/addch.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)addch.c 5.5 (Berkeley) 6/1/90"; +#endif /* not lint */ + +# include "curses.ext" + +/* + * This routine adds the character to the current position + * + */ +waddch(win, c) +WINDOW *win; +char c; +{ + chtype ch = (unsigned char) c; + return _waddbytes(win, &ch, 1); +} diff --git a/lib/libcurses/addstr.c b/lib/libcurses/addstr.c new file mode 100644 index 000000000000..025fd43d4a08 --- /dev/null +++ b/lib/libcurses/addstr.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)addstr.c 5.5 (Berkeley) 6/1/90"; +#endif /* not lint */ + +# include "curses.ext" + +/* + * This routine adds a string starting at (_cury,_curx) + * + */ +waddstr(win,str) +reg WINDOW *win; +char *str; +{ + chtype c; + reg char *s; +# ifdef DEBUG + fprintf(outf, "WADDSTR(\"%s\")\n", str); +# endif + for (s = str; *s;) { + c = (unsigned char) *s++; + if (_waddbytes(win, &c, 1) == ERR) + return ERR; + } + return OK; +} diff --git a/lib/libcurses/box.c b/lib/libcurses/box.c new file mode 100644 index 000000000000..983ed66621ca --- /dev/null +++ b/lib/libcurses/box.c @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)box.c 5.4 (Berkeley) 6/1/90"; +#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 chtype *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] = (unsigned char) hor; + endx--; + for (i = 0; i <= endy; i++) + win->_y[i][0] = (win->_y[i][endx] = (unsigned char) vert); + if (!win->_scroll && (win->_flags&_SCROLLWIN)) + fp[0] = fp[endx] = lp[0] = lp[endx] = ' '; + touchwin(win); +} diff --git a/lib/libcurses/clear.c b/lib/libcurses/clear.c new file mode 100644 index 000000000000..a5884cbc4b11 --- /dev/null +++ b/lib/libcurses/clear.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)clear.c 5.4 (Berkeley) 6/1/90"; +#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/lib/libcurses/clrtobot.c b/lib/libcurses/clrtobot.c new file mode 100644 index 000000000000..86324389956f --- /dev/null +++ b/lib/libcurses/clrtobot.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)clrtobot.c 5.5 (Berkeley) 6/1/90"; +#endif /* not lint */ + +# include "curses.ext" + +/* + * This routine erases everything on the window. + * + */ +wclrtobot(win) +reg WINDOW *win; { + + reg int y; + reg chtype *sp, *end, *maxx; + reg int startx, minx; + + startx = win->_curx; + for (y = win->_cury; y < win->_maxy; y++) { + minx = _NOCHANGE; + end = &win->_y[y][win->_maxx]; + for (sp = &win->_y[y][startx]; sp < end; sp++) + if (*sp != ' ') { + maxx = sp; + if (minx == _NOCHANGE) + minx = sp - win->_y[y]; + *sp = ' '; + } + if (minx != _NOCHANGE) + touchline(win, y, minx, maxx - &win->_y[y][0]); + startx = 0; + } +} diff --git a/lib/libcurses/clrtoeol.c b/lib/libcurses/clrtoeol.c new file mode 100644 index 000000000000..6af2bfcededf --- /dev/null +++ b/lib/libcurses/clrtoeol.c @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)clrtoeol.c 5.4 (Berkeley) 6/1/90"; +#endif /* not lint */ + +# include "curses.ext" + +/* + * This routine clears up to the end of line + * + */ +wclrtoeol(win) +reg WINDOW *win; { + + reg chtype *sp, *end; + reg int y, x; + reg chtype *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/lib/libcurses/cr_put.c b/lib/libcurses/cr_put.c new file mode 100644 index 000000000000..c9d0e79134f1 --- /dev/null +++ b/lib/libcurses/cr_put.c @@ -0,0 +1,418 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)cr_put.c 5.5 (Berkeley) 6/1/90"; +#endif /* not lint */ + +# include "curses.ext" + +# define HARDTABS 8 + +extern char *tgoto(); +int plodput(); + +/* + * Terminal driving and line formatting routines. + * Basic motion optimizations are done here as well + * as formatting of lines (printing of control characters, + * line numbering and the like). + */ + +/* + * Sync the position of the output cursor. + * Most work here is rounding for terminal boundaries getting the + * column position implied by wraparound or the lack thereof and + * rolling up the screen to get destline on the screen. + */ + +static int outcol, outline, destcol, destline; + +WINDOW *_win; + +mvcur(ly, lx, y, x) +int ly, lx, y, x; { + +#ifdef DEBUG + fprintf(outf, "MVCUR: moving cursor from (%d,%d) to (%d,%d)\n", ly, lx, y, x); +#endif + destcol = x; + destline = y; + outcol = lx; + outline = ly; + fgoto(); +} + +fgoto() +{ + reg char *cgp; + reg int l, c; + + if (destcol >= COLS) { + destline += destcol / COLS; + destcol %= COLS; + } + if (outcol >= COLS) { + l = (outcol + 1) / COLS; + outline += l; + outcol %= COLS; + if (AM == 0) { + while (l > 0) { + if (_pfast) + if (CR) + _puts(CR); + else + _putchar('\r'); + if (NL) + _puts(NL); + else + _putchar('\n'); + l--; + } + outcol = 0; + } + if (outline > LINES - 1) { + destline -= outline - (LINES - 1); + outline = LINES - 1; + } + } + if (destline >= LINES) { + l = destline; + destline = LINES - 1; + if (outline < LINES - 1) { + c = destcol; + if (_pfast == 0 && !CA) + destcol = 0; + fgoto(); + destcol = c; + } + while (l >= LINES) { + /* + * The following linefeed (or simulation thereof) + * is supposed to scroll up the screen, since we + * are on the bottom line. We make the assumption + * that linefeed will scroll. If ns is in the + * capability list this won't work. We should + * probably have an sc capability but sf will + * generally take the place if it works. + * + * Superbee glitch: in the middle of the screen we + * have to use esc B (down) because linefeed screws up + * in "Efficient Paging" (what a joke) mode (which is + * essential in some SB's because CRLF mode puts garbage + * in at end of memory), but you must use linefeed to + * scroll since down arrow won't go past memory end. + * I turned this off after recieving Paul Eggert's + * Superbee description which wins better. + */ + if (NL /* && !XB */ && _pfast) + _puts(NL); + else + _putchar('\n'); + l--; + if (_pfast == 0) + outcol = 0; + } + } + if (destline < outline && !(CA || UP)) + destline = outline; + if (CA) { + cgp = tgoto(CM, destcol, destline); + if (plod(strlen(cgp)) > 0) + plod(0); + else + tputs(cgp, 0, _putchar); + } + else + plod(0); + outline = destline; + outcol = destcol; +} + +/* + * Move (slowly) to destination. + * Hard thing here is using home cursor on really deficient terminals. + * Otherwise just use cursor motions, hacking use of tabs and overtabbing + * and backspace. + */ + +static int plodcnt, plodflg; + +plodput(c) +{ + if (plodflg) + plodcnt--; + else + _putchar(c); +} + +plod(cnt) +{ + register int i, j, k; + register int soutcol, soutline; + chtype ch; + + plodcnt = plodflg = cnt; + soutcol = outcol; + soutline = outline; + /* + * Consider homing and moving down/right from there, vs moving + * directly with local motions to the right spot. + */ + if (HO) { + /* + * i is the cost to home and tab/space to the right to + * get to the proper column. This assumes ND space costs + * 1 char. So i+destcol is cost of motion with home. + */ + if (GT) + i = (destcol / HARDTABS) + (destcol % HARDTABS); + else + i = destcol; + /* + * j is cost to move locally without homing + */ + if (destcol >= outcol) { /* if motion is to the right */ + j = destcol / HARDTABS - outcol / HARDTABS; + if (GT && j) + j += destcol % HARDTABS; + else + j = destcol - outcol; + } + else + /* leftward motion only works if we can backspace. */ + if (outcol - destcol <= i && (BS || BC)) + i = j = outcol - destcol; /* cheaper to backspace */ + else + j = i + 1; /* impossibly expensive */ + + /* k is the absolute value of vertical distance */ + k = outline - destline; + if (k < 0) + k = -k; + j += k; + + /* + * Decision. We may not have a choice if no UP. + */ + if (i + destline < j || (!UP && destline < outline)) { + /* + * Cheaper to home. Do it now and pretend it's a + * regular local motion. + */ + tputs(HO, 0, plodput); + outcol = outline = 0; + } + else if (LL) { + /* + * Quickly consider homing down and moving from there. + * Assume cost of LL is 2. + */ + k = (LINES - 1) - destline; + if (i + k + 2 < j && (k<=0 || UP)) { + tputs(LL, 0, plodput); + outcol = 0; + outline = LINES - 1; + } + } + } + else + /* + * No home and no up means it's impossible. + */ + if (!UP && destline < outline) + return -1; + if (GT) + i = destcol % HARDTABS + destcol / HARDTABS; + else + i = destcol; +/* + if (BT && outcol > destcol && (j = (((outcol+7) & ~7) - destcol - 1) >> 3)) { + j *= (k = strlen(BT)); + if ((k += (destcol&7)) > 4) + j += 8 - (destcol&7); + else + j += k; + } + else +*/ + j = outcol - destcol; + /* + * If we will later need a \n which will turn into a \r\n by + * the system or the terminal, then don't bother to try to \r. + */ + if ((NONL || !_pfast) && outline < destline) + goto dontcr; + /* + * If the terminal will do a \r\n and there isn't room for it, + * then we can't afford a \r. + */ + if (NC && outline >= destline) + goto dontcr; + /* + * If it will be cheaper, or if we can't back up, then send + * a return preliminarily. + */ + if (j > i + 1 || outcol > destcol && !BS && !BC) { + /* + * BUG: this doesn't take the (possibly long) length + * of CR into account. + */ + if (CR) + tputs(CR, 0, plodput); + else + plodput('\r'); + if (NC) { + if (NL) + tputs(NL, 0, plodput); + else + plodput('\n'); + outline++; + } + outcol = 0; + } +dontcr: + while (outline < destline) { + outline++; + if (NL) + tputs(NL, 0, plodput); + else + plodput('\n'); + if (plodcnt < 0) + goto out; + if (NONL || _pfast == 0) + outcol = 0; + } + if (BT) + k = strlen(BT); + while (outcol > destcol) { + if (plodcnt < 0) + goto out; +/* + if (BT && outcol - destcol > k + 4) { + tputs(BT, 0, plodput); + outcol--; + outcol &= ~7; + continue; + } +*/ + outcol--; + if (BC) + tputs(BC, 0, plodput); + else + plodput('\b'); + } + while (outline > destline) { + outline--; + tputs(UP, 0, plodput); + if (plodcnt < 0) + goto out; + } + if (GT && destcol - outcol > 1) { + for (;;) { + i = tabcol(outcol, HARDTABS); + if (i > destcol) + break; + if (TA) + tputs(TA, 0, plodput); + else + plodput('\t'); + outcol = i; + } + if (destcol - outcol > 4 && i < COLS && (BC || BS)) { + if (TA) + tputs(TA, 0, plodput); + else + plodput('\t'); + outcol = i; + while (outcol > destcol) { + outcol--; + if (BC) + tputs(BC, 0, plodput); + else + plodput('\b'); + } + } + } + while (outcol < destcol) { + /* + * move one char to the right. We don't use ND space + * because it's better to just print the char we are + * moving over. + */ + if (_win != NULL) + if (plodflg) /* avoid a complex calculation */ + plodcnt--; + else { + ch = curscr->_y[outline][outcol]; + if ((ch&_STANDOUT) == (curscr->_flags&_STANDOUT)) + _putchar(ch); + else + goto nondes; + } + else +nondes: + if (ND) + tputs(ND, 0, plodput); + else + plodput(' '); + outcol++; + if (plodcnt < 0) + goto out; + } +out: + if (plodflg) { + outcol = soutcol; + outline = soutline; + } + return(plodcnt); +} + +/* + * Return the column number that results from being in column col and + * hitting a tab, where tabs are set every ts columns. Work right for + * the case where col > COLS, even if ts does not divide COLS. + */ +tabcol(col, ts) +int col, ts; +{ + int offset, result; + + if (col >= COLS) { + offset = COLS * (col / COLS); + col -= offset; + } + else + offset = 0; + return col + ts - (col % ts) + offset; +} diff --git a/lib/libcurses/cr_tty.c b/lib/libcurses/cr_tty.c new file mode 100644 index 000000000000..c67b0765ce2b --- /dev/null +++ b/lib/libcurses/cr_tty.c @@ -0,0 +1,239 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)cr_tty.c 5.8 (Berkeley) 6/1/90"; +#endif /* not lint */ + +/* + * Terminal initialization routines. + * + */ + +# include "curses.ext" + +static bool *sflags[] = { + &AM, &BS, &DA, &DB, &EO, &HC, &HZ, &IN, &MI, + &MS, &NC, &NS, &OS, &UL, &XB, &XN, &XT, &XS, + &XX + }; + +static char *_PC, + **sstrs[] = { + &AL, &BC, &BT, &CD, &CE, &CL, &CM, &CR, &CS, + &DC, &DL, &DM, &DO, &ED, &EI, &K0, &K1, &K2, + &K3, &K4, &K5, &K6, &K7, &K8, &K9, &HO, &IC, + &IM, &IP, &KD, &KE, &KH, &KL, &KR, &KS, &KU, + &LL, &MA, &ND, &NL, &_PC, &RC, &SC, &SE, &SF, + &SO, &SR, &TA, &TE, &TI, &UC, &UE, &UP, &US, + &VB, &VS, &VE, &AL_PARM, &DL_PARM, &UP_PARM, + &DOWN_PARM, &LEFT_PARM, &RIGHT_PARM, + }; + +extern char *tgoto(); + +char _tspace[2048]; /* Space for capability strings */ + +static char *aoftspace; /* Address of _tspace for relocation */ + +static int destcol, destline; + +/* + * This routine does terminal type initialization routines, and + * calculation of flags at entry. It is almost entirely stolen from + * Bill Joy's ex version 2.6. + */ +short ospeed = -1; + +gettmode() { + + if (ioctl(_tty_ch, TIOCGETP, &_tty) < 0) + return; + savetty(); + if (ioctl(_tty_ch, TIOCSETP, &_tty) < 0) + _tty.sg_flags = _res_flg; + ospeed = _tty.sg_ospeed; + _res_flg = _tty.sg_flags; + UPPERCASE = (_tty.sg_flags & LCASE) != 0; + GT = ((_tty.sg_flags & XTABS) == 0); + NONL = ((_tty.sg_flags & CRMOD) == 0); + _tty.sg_flags &= ~XTABS; + ioctl(_tty_ch, TIOCSETP, &_tty); +# ifdef DEBUG + fprintf(outf, "GETTMODE: UPPERCASE = %s\n", UPPERCASE ? "TRUE":"FALSE"); + fprintf(outf, "GETTMODE: GT = %s\n", GT ? "TRUE" : "FALSE"); + fprintf(outf, "GETTMODE: NONL = %s\n", NONL ? "TRUE" : "FALSE"); + fprintf(outf, "GETTMODE: ospeed = %d\n", ospeed); +# endif +} + +setterm(type) +reg char *type; { + + reg int unknown; + static char genbuf[1024]; +# ifdef TIOCGWINSZ + struct winsize win; +# endif + +# ifdef DEBUG + fprintf(outf, "SETTERM(\"%s\")\n", type); + fprintf(outf, "SETTERM: LINES = %d, COLS = %d\n", LINES, COLS); +# endif + if (type[0] == '\0') + type = "xx"; + unknown = FALSE; + if (tgetent(genbuf, type) != 1) { + unknown++; + strcpy(genbuf, "xx|dumb:"); + } +# ifdef DEBUG + fprintf(outf, "SETTERM: tty = %s\n", type); +# endif +# ifdef TIOCGWINSZ + if (ioctl(_tty_ch, TIOCGWINSZ, &win) >= 0) { + if (LINES == 0) + LINES = win.ws_row; + if (COLS == 0) + COLS = win.ws_col; + } +# endif + + if (LINES == 0) + LINES = tgetnum("li"); + if (LINES <= 5) + LINES = 24; + + if (COLS == 0) + COLS = tgetnum("co"); + if (COLS <= 4) + COLS = 80; + +# ifdef DEBUG + fprintf(outf, "SETTERM: LINES = %d, COLS = %d\n", LINES, COLS); +# endif + aoftspace = _tspace; + zap(); /* get terminal description */ + + /* + * Handle funny termcap capabilities + */ + if (CS && SC && RC) AL=DL=""; + if (AL_PARM && AL==NULL) AL=""; + if (DL_PARM && DL==NULL) DL=""; + if (IC && IM==NULL) IM=""; + if (IC && EI==NULL) EI=""; + if (!GT) BT=NULL; /* If we can't tab, we can't backtab either */ + + if (tgoto(CM, destcol, destline)[0] == 'O') + CA = FALSE, CM = 0; + else + CA = TRUE; + + PC = _PC ? _PC[0] : FALSE; + aoftspace = _tspace; + { + /* xtype should be the same size as genbuf for longname(). */ + static char xtype[1024]; + + (void)strcpy(xtype,type); + strncpy(ttytype, longname(genbuf, xtype), sizeof(ttytype) - 1); + } + ttytype[sizeof(ttytype) - 1] = '\0'; + if (unknown) + return ERR; + return OK; +} + +/* + * This routine gets all the terminal flags from the termcap database + */ + +zap() +{ + register char *namp; + register bool **fp; + register char ***sp; +#ifdef DEBUG + register char *cp; +#endif + extern char *tgetstr(); + + namp = "ambsdadbeohchzinmimsncnsosulxbxnxtxsxx"; + fp = sflags; + do { + *(*fp++) = tgetflag(namp); +#ifdef DEBUG + fprintf(outf, "%2.2s = %s\n", namp, *fp[-1] ? "TRUE" : "FALSE"); +#endif + namp += 2; + } while (*namp); + namp = "albcbtcdceclcmcrcsdcdldmdoedeik0k1k2k3k4k5k6k7k8k9hoicimipkdkekhklkrkskullmandnlpcrcscsesfsosrtatetiucueupusvbvsveALDLUPDOLERI"; + sp = sstrs; + do { + *(*sp++) = tgetstr(namp, &aoftspace); +#ifdef DEBUG + fprintf(outf, "%2.2s = %s", namp, *sp[-1] == NULL ? "NULL\n" : "\""); + if (*sp[-1] != NULL) { + for (cp = *sp[-1]; *cp; cp++) + fprintf(outf, "%s", unctrl(*cp)); + fprintf(outf, "\"\n"); + } +#endif + namp += 2; + } while (*namp); + if (XS) + SO = SE = NULL; + else { + if (tgetnum("sg") > 0) + SO = NULL; + if (tgetnum("ug") > 0) + US = NULL; + if (!SO && US) { + SO = US; + SE = UE; + } + } +} + +/* + * return a capability from termcap + */ +char * +getcap(name) +char *name; +{ + char *tgetstr(); + + return tgetstr(name, &aoftspace); +} diff --git a/lib/libcurses/curses.3 b/lib/libcurses/curses.3 new file mode 100644 index 000000000000..37b79419f947 --- /dev/null +++ b/lib/libcurses/curses.3 @@ -0,0 +1,197 @@ +.\" Copyright (c) 1985, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)curses.3 6.6 (Berkeley) 4/19/91 +.\" +.Dd April 19, 1991 +.Dt CURSES 3 +.Os BSD 4 +.Sh NAME +.Nm curses +.Nd screen functions with ``optimal'' cursor motion +.Sh SYNOPSIS +.Nm cc +.Op Ar flags +.Ar files +.Fl lcurses ltermcap +.Op Ar libraries +.Sh DESCRIPTION +These routines give the user a method of updating screens with reasonable +optimization. They keep an image of the current screen, +and the user sets up an image of a new one. Then the +.Fn refresh +tells the routines to make the current screen look like the new one. +In order to initialize the routines, the routine +.Fn initscr +must be called before any of the other routines that deal with windows and +screens are used. The routine +.Fn endwin +should be called before exiting. +.Sh SEE ALSO +.Xr ioctl 2 , +.Xr getenv 3 , +.Xr tty 4 , +.Xr termcap 5 +.Rs +.%T Screen Updating and Cursor Movement Optimization: A Library Package +.%A Ken Arnold +.Re +.Sh AUTHOR +.An Ken Arnold +.Sh FUNCTIONS +.Bl -column "subwin(win,lines,cols,begin_y,begin_x) " +.It addch(ch) add a character to +.Em stdscr +.It addstr(str) add a string to +.Em stdscr +.It box(win,vert,hor) draw a box around a window +.It cbreak() set cbreak mode +.It clear() clear +.Em stdscr +.It clearok(scr,boolf) set clear flag for +.Em scr +.It clrtobot() clear to bottom on +.Em stdscr +.It clrtoeol() clear to end of line on +.Em stdscr +.It delch() delete a character +.It deleteln() delete a line +.It delwin(win) delete +.Em stdscr +.It echo() set echo mode +.It endwin() end window modes +.It erase() erase +.Em stdscr +.It flusok(win,boolf) set flush-on-refresh flag for +.Em win +.It getch() get a char through +.Em stdscr +.It getcap(name) get terminal capability +.Em name +.It getstr(str) get a string through +.Em stdscr +.It gettmode() get tty modes +.It getyx(win,y,x) get (y,x) co-ordinates +.It inch() get char at current (y,x) co-ordinates +.It initscr() initialize screens +.It insch(c) insert a char +.It insertln() insert a line +.It leaveok(win,boolf) set leave flag for +.Em stdscr +.It longname(termbuf,name) get long name from +.Em termbuf +.It move(y,x) move to (y,x) on +.Em stdscr +.It mvcur(lasty,lastx,newy,newx) actually move cursor +.It newwin(lines,cols,begin_y,begin_x)\ create a new window +.It nl() set newline mapping +.It nocbreak() unset cbreak mode +.It noecho() unset echo mode +.It nonl() unset newline mapping +.It noraw() unset raw mode +.It overlay(win1,win2) overlay win1 on win2 +.It overwrite(win1,win2) overwrite win1 on top of win2 +.It printw(fmt,arg1,arg2,...) printf on +.Em stdscr +.It raw() set raw mode +.It refresh() make current screen look like +.Em stdscr +.It resetty() reset tty flags to stored value +.It savetty() stored current tty flags +.It scanw(fmt,arg1,arg2,...) scanf through +.Em stdscr +.It scroll(win) scroll +.Em win +one line +.It scrollok(win,boolf) set scroll flag +.It setterm(name) set term variables for name +.It standend() end standout mode +.It standout() start standout mode +.It subwin(win,lines,cols,begin_y,begin_x)\ create a subwindow +.It touchline(win,y,sx,ex) mark line +.Em y +.Em sx +through +.Em sy +as changed +.It touchoverlap(win1,win2) mark overlap of +.Em win1 +on +.Em win2 +as changed +.It touchwin(win) \*(lqchange\*(rq all of +.Em win +.It unctrl(ch) printable version of +.Em ch +.It waddch(win,ch) add char to +.Em win +.It waddstr(win,str) add string to +.Em win +.It wclear(win) clear +.Em win +.It wclrtobot(win) clear to bottom of +.Em win +.It wclrtoeol(win) clear to end of line on +.Em win +.It wdelch(win,c) delete char from +.Em win +.It wdeleteln(win) delete line from +.Em win +.It werase(win) erase +.Em win +.It wgetch(win) get a char through +.Em win +.It wgetstr(win,str) get a string through +.Em win +.It winch(win) get char at current (y,x) in +.Em win +.It winsch(win,c) insert char into +.Em win +.It winsertln(win) insert line into +.Em win +.It wmove(win,y,x) set current (y,x) co-ordinates on +.Em win +.It wprintw(win,fmt,arg1,arg2,...)\ printf on +.Em win +.It wrefresh(win) make screen look like +.Em win +.It wscanw(win,fmt,arg1,arg2,...)\ scanf through +.Em win +.It wstandend(win) end standout mode on +.Em win +.It wstandout(win) start standout mode on +.Em win +.El +.Sh HISTORY +The +.Nm +package appeared in +.Bx 4.0 . diff --git a/lib/libcurses/curses.c b/lib/libcurses/curses.c new file mode 100644 index 000000000000..3943595ca561 --- /dev/null +++ b/lib/libcurses/curses.c @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)curses.c 5.7 (Berkeley) 6/1/90"; +#endif /* not lint */ + +/* + * Define global variables + * + */ +# include "curses.h" + +bool _echoit = TRUE, /* set if stty indicates ECHO */ + _rawmode = FALSE,/* set if stty indicates RAW mode */ + My_term = FALSE,/* set if user specifies terminal type */ + _endwin = FALSE;/* set if endwin has been called */ + +char ttytype[50], /* long name of tty */ + *Def_term = "unknown"; /* default terminal type */ + +int _tty_ch = 0, /* file channel which is a tty */ + LINES, /* number of lines allowed on screen */ + COLS, /* number of columns allowed on screen */ + _res_flg; /* sgtty flags for reseting later */ + +WINDOW *stdscr = NULL, + *curscr = NULL; + +# ifdef DEBUG +FILE *outf; /* debug output file */ +# endif + +SGTTY _tty; /* tty modes */ + +bool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL, XB, XN, + XT, XS, XX; +char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, *DM, + *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, *K7, *K8, + *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, *KR, *KS, *KU, + *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, *SO, *SR, *TA, *TE, + *TI, *UC, *UE, *UP, *US, *VB, *VS, *VE, *AL_PARM, *DL_PARM, + *UP_PARM, *DOWN_PARM, *LEFT_PARM, *RIGHT_PARM; +char PC; + +/* + * From the tty modes... + */ + +bool GT, NONL, UPPERCASE, normtty, _pfast; diff --git a/lib/libcurses/curses.ext b/lib/libcurses/curses.ext new file mode 100644 index 000000000000..ff362297661a --- /dev/null +++ b/lib/libcurses/curses.ext @@ -0,0 +1,58 @@ +/*- + * Copyright (c) 1981 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)curses.ext 5.6 (Berkeley) 4/19/91 + */ + +/* + * External variables for the curses library + */ + +/* LINTLIBRARY */ + +# include "curses.h" + +extern bool _echoit, _rawmode, My_term, _endwin; + +extern char ttytype[50], *_unctrl[]; + +extern int _tty_ch, LINES, COLS; + +extern SGTTY _tty; + +char _putchar(); + +#ifdef DEBUG +# define outf _outf + +FILE *outf; +#endif diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h new file mode 100644 index 000000000000..e845bb22878c --- /dev/null +++ b/lib/libcurses/curses.h @@ -0,0 +1,219 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)curses.h 5.9 (Berkeley) 7/1/90 + */ + +#ifndef WINDOW + +#include <stdio.h> + +#define USE_OLD_TTY +#include <sys/ioctl.h> +#undef USE_OLD_TTY + +#define bool char +#define reg register + +typedef unsigned short chtype; + +#define TRUE (1) +#define FALSE (0) +#define ERR (0) +#define OK (1) + +#define _ENDLINE 001 +#define _FULLWIN 002 +#define _SCROLLWIN 004 +#define _FLUSH 010 +#define _FULLLINE 020 +#define _IDLINE 040 +#define _STANDOUT 0400 +#define _NOCHANGE -1 + +#define _puts(s) tputs(s, 0, _putchar) + +typedef struct sgttyb SGTTY; + +/* + * Capabilities from termcap + */ + +extern bool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL, + XB, XN, XT, XS, XX; +extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, + *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, + *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, + *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, + *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, + *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, + *LEFT_PARM, *RIGHT_PARM; +extern char PC; + +/* + * From the tty modes... + */ + +extern bool GT, NONL, UPPERCASE, normtty, _pfast; + +struct _win_st { + short _cury, _curx; + short _maxy, _maxx; + short _begy, _begx; + short _flags; + short _ch_off; + bool _clear; + bool _leave; + bool _scroll; + chtype **_y; + short *_firstch; + short *_lastch; + struct _win_st *_nextp, *_orig; +}; + +#define WINDOW struct _win_st + +extern bool My_term, _echoit, _rawmode, _endwin; + +extern char *Def_term, ttytype[]; + +extern int LINES, COLS, _tty_ch, _res_flg; + +extern SGTTY _tty; + +extern WINDOW *stdscr, *curscr; + +/* + * Define VOID to stop lint from generating "null effect" + * comments. + */ +#ifdef lint +int __void__; +#define VOID(x) (__void__ = (int) (x)) +#else +#define VOID(x) (x) +#endif + +/* + * psuedo functions for standard screen + */ +#define addch(ch) VOID(waddch(stdscr, ch)) +#define getch() VOID(wgetch(stdscr)) +#define addbytes(da,co) VOID(waddbytes(stdscr, da,co)) +#define addstr(str) VOID(waddstr(stdscr, str)) +#define getstr(str) VOID(wgetstr(stdscr, str)) +#define move(y, x) VOID(wmove(stdscr, y, x)) +#define clear() VOID(wclear(stdscr)) +#define erase() VOID(werase(stdscr)) +#define clrtobot() VOID(wclrtobot(stdscr)) +#define clrtoeol() VOID(wclrtoeol(stdscr)) +#define insertln() VOID(winsertln(stdscr)) +#define deleteln() VOID(wdeleteln(stdscr)) +#define refresh() VOID(wrefresh(stdscr)) +#define inch() VOID(winch(stdscr)) +#define insch(c) VOID(winsch(stdscr,c)) +#define delch() VOID(wdelch(stdscr)) +#define standout() VOID(wstandout(stdscr)) +#define standend() VOID(wstandend(stdscr)) + +/* + * mv functions + */ +#define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch)) +#define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win)) +#define mvwaddbytes(win,y,x,da,co) \ + VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,da,co)) +#define mvwaddstr(win,y,x,str) \ + VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str)) +#define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str)) +#define mvwinch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : winch(win)) +#define mvwdelch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win)) +#define mvwinsch(win,y,x,c) VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c)) +#define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch) +#define mvgetch(y,x) mvwgetch(stdscr,y,x) +#define mvaddbytes(y,x,da,co) mvwaddbytes(stdscr,y,x,da,co) +#define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str) +#define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str) +#define mvinch(y,x) mvwinch(stdscr,y,x) +#define mvdelch(y,x) mvwdelch(stdscr,y,x) +#define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c) + +/* + * psuedo functions + */ + +#define clearok(win,bf) (win->_clear = bf) +#define leaveok(win,bf) (win->_leave = bf) +#define scrollok(win,bf) (win->_scroll = bf) +#define flushok(win,bf) (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH)) +#define getyx(win,y,x) y = win->_cury, x = win->_curx +#define winch(win) (win->_y[win->_cury][win->_curx] & 0xFF) + +#define raw() (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, \ + ioctl(_tty_ch, TIOCSETP, &_tty)) +#define noraw() (_tty.sg_flags&=~RAW,_rawmode=FALSE,\ + _pfast=!(_tty.sg_flags&CRMOD),ioctl(_tty_ch, TIOCSETP, &_tty)) +#define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, \ + ioctl(_tty_ch, TIOCSETP, &_tty)) +#define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE, \ + ioctl(_tty_ch, TIOCSETP, &_tty)) +#define crmode() cbreak() /* backwards compatability */ +#define nocrmode() nocbreak() /* backwards compatability */ +#define echo() (_tty.sg_flags |= ECHO, _echoit = TRUE, \ + ioctl(_tty_ch, TIOCSETP, &_tty)) +#define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, \ + ioctl(_tty_ch, TIOCSETP, &_tty)) +#define nl() (_tty.sg_flags |= CRMOD,_pfast = _rawmode, \ + ioctl(_tty_ch, TIOCSETP, &_tty)) +#define nonl() (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, \ + ioctl(_tty_ch, TIOCSETP, &_tty)) +#define savetty() ((void) ioctl(_tty_ch, TIOCGETP, &_tty), \ + _res_flg = _tty.sg_flags) +#define resetty() (_tty.sg_flags = _res_flg, \ + _echoit = ((_res_flg & ECHO) == ECHO), \ + _rawmode = ((_res_flg & (CBREAK|RAW)) != 0), \ + _pfast = ((_res_flg & CRMOD) ? _rawmode : TRUE), \ + (void) ioctl(_tty_ch, TIOCSETP, &_tty)) + +#define erasechar() (_tty.sg_erase) +#define killchar() (_tty.sg_kill) +#define baudrate() (_tty.sg_ospeed) + +WINDOW *initscr(), *newwin(), *subwin(); +char *longname(), *getcap(); + +/* + * Used to be in unctrl.h. + */ +#define unctrl(c) _unctrl[(c) & 0177] +extern char *_unctrl[]; +#endif diff --git a/lib/libcurses/delch.c b/lib/libcurses/delch.c new file mode 100644 index 000000000000..23499eb55490 --- /dev/null +++ b/lib/libcurses/delch.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)delch.c 5.4 (Berkeley) 6/1/90"; +#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 chtype *temp1, *temp2; + reg chtype *end; + + 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/lib/libcurses/deleteln.c b/lib/libcurses/deleteln.c new file mode 100644 index 000000000000..ba5d4819743e --- /dev/null +++ b/lib/libcurses/deleteln.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)deleteln.c 5.4 (Berkeley) 6/1/90"; +#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 chtype *temp; + reg int y; + reg chtype *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 * sizeof(chtype)); + 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); + return OK; +} diff --git a/lib/libcurses/delwin.c b/lib/libcurses/delwin.c new file mode 100644 index 000000000000..6935f87550f1 --- /dev/null +++ b/lib/libcurses/delwin.c @@ -0,0 +1,79 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)delwin.c 5.4 (Berkeley) 6/1/90"; +#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/lib/libcurses/endwin.c b/lib/libcurses/endwin.c new file mode 100644 index 000000000000..aa740e6135bf --- /dev/null +++ b/lib/libcurses/endwin.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)endwin.c 5.4 (Berkeley) 6/1/90"; +#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/lib/libcurses/erase.c b/lib/libcurses/erase.c new file mode 100644 index 000000000000..9cbd79e7fd46 --- /dev/null +++ b/lib/libcurses/erase.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)erase.c 5.4 (Berkeley) 6/1/90"; +#endif /* not lint */ + +# include "curses.ext" + +/* + * This routine erases everything on the window. + * + */ +werase(win) +reg WINDOW *win; { + + reg int y; + reg chtype *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/lib/libcurses/fullname.c b/lib/libcurses/fullname.c new file mode 100644 index 000000000000..11cf4cbe5408 --- /dev/null +++ b/lib/libcurses/fullname.c @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)fullname.c 5.4 (Berkeley) 6/1/90"; +#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/lib/libcurses/getch.c b/lib/libcurses/getch.c new file mode 100644 index 000000000000..d3e04d08f667 --- /dev/null +++ b/lib/libcurses/getch.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)getch.c 5.6 (Berkeley) 6/1/90"; +#endif /* not lint */ + +# include "curses.ext" + +/* + * This routine reads in a character from the window. + * + */ +wgetch(win) +reg WINDOW *win; { + + reg bool weset = FALSE; + reg int inp; + + if (!win->_scroll && (win->_flags&_FULLWIN) + && win->_curx == win->_maxx - 1 && win->_cury == win->_maxy - 1) + return ERR; +# ifdef DEBUG + fprintf(outf, "WGETCH: _echoit = %c, _rawmode = %c\n", _echoit ? 'T' : 'F', _rawmode ? 'T' : 'F'); +# endif + if (_echoit && !_rawmode) { + cbreak(); + weset++; + } + inp = getchar(); + if (inp != EOF) { +# ifdef DEBUG + fprintf(outf,"WGETCH got '%s'\n",unctrl(inp)); +# endif + if (_echoit) { + mvwaddch(curscr, win->_cury + win->_begy, + win->_curx + win->_begx, (unsigned char) inp); + waddch(win, (unsigned char) inp); + } + } + if (weset) + nocbreak(); + return inp; +} diff --git a/lib/libcurses/getstr.c b/lib/libcurses/getstr.c new file mode 100644 index 000000000000..ec3af26fe7ae --- /dev/null +++ b/lib/libcurses/getstr.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)getstr.c 5.4 (Berkeley) 6/1/90"; +#endif /* not lint */ + +# include "curses.ext" + +/* + * This routine gets a string starting at (_cury,_curx) + * + */ +wgetstr(win,str) +reg WINDOW *win; +reg char *str; { + int c; + + while ((c = wgetch(win)) != ERR && c != EOF && c != '\n') + *str++ = c; + *str = '\0'; + if (c == ERR) + return ERR; + return OK; +} diff --git a/lib/libcurses/id_subwins.c b/lib/libcurses/id_subwins.c new file mode 100644 index 000000000000..9bbc3bc16a85 --- /dev/null +++ b/lib/libcurses/id_subwins.c @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)id_subwins.c 5.4 (Berkeley) 6/1/90"; +#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/lib/libcurses/idlok.c b/lib/libcurses/idlok.c new file mode 100644 index 000000000000..92566b20b35c --- /dev/null +++ b/lib/libcurses/idlok.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)idlok.c 5.4 (Berkeley) 6/1/90"; +#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/lib/libcurses/initscr.c b/lib/libcurses/initscr.c new file mode 100644 index 000000000000..5dd97e8b2255 --- /dev/null +++ b/lib/libcurses/initscr.c @@ -0,0 +1,93 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)initscr.c 5.6 (Berkeley) 3/3/91"; +#endif /* not lint */ + +# include "curses.ext" +# include <signal.h> + +extern char *getenv(); + +/* + * This routine initializes the current and standard screen. + * + */ +WINDOW * +initscr() { + + reg char *sp; + void tstp(); + +# ifdef DEBUG + fprintf(outf, "INITSCR()\n"); +# endif + if (My_term) + setterm(Def_term); + else { + 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/lib/libcurses/insch.c b/lib/libcurses/insch.c new file mode 100644 index 000000000000..5ec1c9a7d861 --- /dev/null +++ b/lib/libcurses/insch.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)insch.c 5.4 (Berkeley) 6/1/90"; +#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 chtype *temp1, *temp2; + reg chtype *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 = (unsigned char) 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/lib/libcurses/insertln.c b/lib/libcurses/insertln.c new file mode 100644 index 000000000000..09b8b4353035 --- /dev/null +++ b/lib/libcurses/insertln.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)insertln.c 5.4 (Berkeley) 6/1/90"; +#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 chtype *temp; + reg int y; + reg chtype *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 * sizeof(chtype)); + 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/lib/libcurses/longname.c b/lib/libcurses/longname.c new file mode 100644 index 000000000000..94364b4a1be3 --- /dev/null +++ b/lib/libcurses/longname.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)longname.c 5.4 (Berkeley) 6/1/90"; +#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/lib/libcurses/move.c b/lib/libcurses/move.c new file mode 100644 index 000000000000..78c104b31bc9 --- /dev/null +++ b/lib/libcurses/move.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)move.c 5.5 (Berkeley) 6/1/90"; +#endif /* not lint */ + +# include "curses.ext" + +/* + * This routine moves the cursor to the given point + * + */ +wmove(win, y, x) +reg WINDOW *win; +reg int y, x; { + +# ifdef DEBUG + fprintf(outf, "MOVE to (%d, %d)\n", y, x); +# endif + if (x < 0 || y < 0) + return ERR; + if (x >= win->_maxx || y >= win->_maxy) + return ERR; + win->_curx = x; + win->_cury = y; + return OK; +} diff --git a/lib/libcurses/mvprintw.c b/lib/libcurses/mvprintw.c new file mode 100644 index 000000000000..63aa58fefd34 --- /dev/null +++ b/lib/libcurses/mvprintw.c @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)mvprintw.c 5.8 (Berkeley) 6/19/91"; +#endif /* not lint */ + +#if __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif +#include "curses.ext" + +/* + * implement the mvprintw commands. Due to the variable number of + * arguments, they cannot be macros. Sigh.... + */ + +#if __STDC__ +mvprintw(reg int y, reg int x, const char *fmt, ...) +#else +mvprintw(y, x, fmt, va_alist) + reg int y, x; + char *fmt; + va_dcl +#endif +{ + va_list ap; + int ret; + + if (move(y, x) != OK) + return ERR; +#if __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif + ret = _sprintw(stdscr, fmt, ap); + va_end(ap); + return ret; +} + +#if __STDC__ +mvwprintw(reg WINDOW *win, reg int y, reg int x, const char *fmt, ...) +#else +mvwprintw(win, y, x, fmt, va_alist) + reg WINDOW *win; + reg int y, x; + char *fmt; + va_dcl +#endif +{ + va_list ap; + int ret; + + if (wmove(win, y, x) != OK) + return ERR; +#if __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif + ret = _sprintw(win, fmt, ap); + va_end(ap); + return ret; +} diff --git a/lib/libcurses/mvscanw.c b/lib/libcurses/mvscanw.c new file mode 100644 index 000000000000..544cbaa32d11 --- /dev/null +++ b/lib/libcurses/mvscanw.c @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)mvscanw.c 5.5 (Berkeley) 4/15/91"; +#endif /* not lint */ + +#if __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif +#include "curses.ext" + +/* + * implement the mvscanw commands. Due to the variable number of + * arguments, they cannot be macros. Another sigh.... + */ + +#if __STDC__ +mvscanw(reg int y, reg int x, const char *fmt, ...) +#else +mvscanw(y, x, fmt, va_alist) + reg int y, x; + char *fmt; + va_dcl +#endif +{ + va_list ap; + int ret; + + if (move(y, x) != OK) + return ERR; +#if __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif + ret = _sscans(stdscr, fmt, ap); + va_end(ap); + return ret; +} + +#if __STDC__ +mvwscanw(reg WINDOW *win, reg int y, reg int x, const char *fmt, ...) +#else +mvwscanw(win, y, x, fmt, va_alist) + reg WINDOW *win; + reg int y, x; + char *fmt; + va_dcl +#endif +{ + va_list ap; + int ret; + + if (move(y, x) != OK) + return ERR; +#if __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif + ret = _sscans(win, fmt, ap); + va_end(ap); + return ret; +} diff --git a/lib/libcurses/mvwin.c b/lib/libcurses/mvwin.c new file mode 100644 index 000000000000..69af8a9c4976 --- /dev/null +++ b/lib/libcurses/mvwin.c @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)mvwin.c 5.4 (Berkeley) 6/1/90"; +#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/lib/libcurses/newwin.c b/lib/libcurses/newwin.c new file mode 100644 index 000000000000..dfa7e75e63bf --- /dev/null +++ b/lib/libcurses/newwin.c @@ -0,0 +1,235 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)newwin.c 5.4 (Berkeley) 6/1/90"; +#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 chtype *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] = (chtype *) malloc(nc * sizeof(chtype))) == 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 = (chtype **) malloc(nl * sizeof(chtype *))) == 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/lib/libcurses/overlay.c b/lib/libcurses/overlay.c new file mode 100644 index 000000000000..d272c7ba6daf --- /dev/null +++ b/lib/libcurses/overlay.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)overlay.c 5.6 (Berkeley) 6/1/90"; +#endif /* not lint */ + +# include "curses.ext" + +# define min(a,b) (a < b ? a : b) +# define max(a,b) (a > b ? a : b) + +/* + * This routine writes win1 on win2 non-destructively. + * + */ +overlay(win1, win2) +reg WINDOW *win1, *win2; { + + reg chtype *sp, *end; + reg int x, y, endy, endx, starty, startx; + reg int y1,y2; + +# ifdef DEBUG + fprintf(outf, "OVERLAY(%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, "OVERLAY:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); +# endif + if (starty >= endy || startx >= endx) + return; + y1 = starty - win1->_begy; + y2 = starty - win2->_begy; + for (y = starty; y < endy; y++, y1++, y2++) { + end = &win1->_y[y1][endx - win1->_begx]; + x = startx - win2->_begx; + for (sp = &win1->_y[y1][startx - win1->_begx]; sp < end; sp++) { + if (*sp != ' ') + mvwaddch(win2, y2, x, *sp); + x++; + } + } +} diff --git a/lib/libcurses/overwrite.c b/lib/libcurses/overwrite.c new file mode 100644 index 000000000000..655f923ab26a --- /dev/null +++ b/lib/libcurses/overwrite.c @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)overwrite.c 5.4 (Berkeley) 6/1/90"; +#endif /* not lint */ + +# include "curses.ext" +# include <ctype.h> + +# 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 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 * sizeof(chtype)); + touchline(win2, y, startx - win2->_begx, endx - win2->_begx); + } +} diff --git a/lib/libcurses/printw.c b/lib/libcurses/printw.c new file mode 100644 index 000000000000..4568c5f4b875 --- /dev/null +++ b/lib/libcurses/printw.c @@ -0,0 +1,140 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)printw.c 5.8 (Berkeley) 4/15/91"; +#endif /* not lint */ + +/* + * printw and friends. + * + * These routines make nonportable assumptions about varargs if __STDC__ + * is not in effect. + */ + +#if __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif +#include "curses.ext" + +/* + * This routine implements a printf on the standard screen. + */ +#if __STDC__ +printw(const char *fmt, ...) +#else +printw(fmt, va_alist) + char *fmt; + va_dcl +#endif +{ + va_list ap; + int ret; + +#if __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif + ret = _sprintw(stdscr, fmt, ap); + va_end(ap); + return (ret); +} + +/* + * This routine implements a printf on the given window. + */ +#if __STDC__ +wprintw(WINDOW *win, const char *fmt, ...) +#else +wprintw(win, fmt, va_alist) + WINDOW *win; + char *fmt; + va_dcl +#endif +{ + va_list ap; + int ret; + +#ifdef __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif + ret = _sprintw(win, fmt, ap); + va_end(ap); + return (ret); +} + +/* + * Internal write-buffer-to-window function. + */ +static int +_winwrite(cookie, buf, n) + void *cookie; + register char *buf; + int n; +{ + register WINDOW *win = (WINDOW *)cookie; + register int c = n; + + while (--c >= 0) { + if (waddch(win, (unsigned char) *buf++) == ERR) + return (-1); + } + return n; +} + +/* + * This routine actually executes the printf and adds it to the window. + * It must not be declared static as it is used in mvprintw.c. + * THIS SHOULD BE RENAMED vwprintw AND EXPORTED + */ +_sprintw(win, fmt, ap) + WINDOW *win; +#if __STDC__ + const char *fmt; +#else + char *fmt; +#endif + va_list ap; +{ + FILE *f; + + if ((f = fwopen((void *)win, _winwrite)) == NULL) + return ERR; + (void) vfprintf(f, fmt, ap); + return fclose(f) ? ERR : OK; +} diff --git a/lib/libcurses/putchar.c b/lib/libcurses/putchar.c new file mode 100644 index 000000000000..886d1a94a399 --- /dev/null +++ b/lib/libcurses/putchar.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)putchar.c 5.4 (Berkeley) 6/1/90"; +#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/lib/libcurses/refresh.c b/lib/libcurses/refresh.c new file mode 100644 index 000000000000..62673d2f8797 --- /dev/null +++ b/lib/libcurses/refresh.c @@ -0,0 +1,339 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)refresh.c 5.5 (Berkeley) 3/3/91"; +#endif /* not lint */ + +/* + * make the current screen look like "win" over the area coverd by + * win. + */ + +# include "curses.ext" + +# ifdef DEBUG +# define STATIC +# else +# define STATIC static +# endif + +STATIC short ly, lx; + +STATIC bool curwin; + +WINDOW *_win = NULL; + +STATIC int domvcur(), makech(); + +wrefresh(win) +reg WINDOW *win; +{ + reg short wy; + reg int retval; + reg WINDOW *orig; + + /* + * make sure were in visual state + */ + if (_endwin) { + _puts(VS); + _puts(TI); + _endwin = FALSE; + } + + /* + * initialize loop parameters + */ + + ly = curscr->_cury; + lx = curscr->_curx; + wy = 0; + _win = win; + curwin = (win == curscr); + + if (win->_clear || curscr->_clear || curwin) { + if ((win->_flags & _FULLWIN) || curscr->_clear) { + _puts(CL); + ly = 0; + lx = 0; + if (!curwin) { + curscr->_clear = FALSE; + curscr->_cury = 0; + curscr->_curx = 0; + werase(curscr); + } + touchwin(win); + } + win->_clear = FALSE; + } + if (!CA) { + if (win->_curx != 0) + _putchar('\n'); + if (!curwin) + werase(curscr); + } +# ifdef DEBUG + fprintf(outf, "REFRESH(%0.2o): curwin = %d\n", win, curwin); + fprintf(outf, "REFRESH:\n\tfirstch\tlastch\n"); +# endif + for (wy = 0; wy < win->_maxy; wy++) { +# ifdef DEBUG + fprintf(outf, "%d\t%d\t%d\n", wy, win->_firstch[wy], + win->_lastch[wy]); +# endif + if (win->_firstch[wy] != _NOCHANGE) + if (makech(win, wy) == ERR) + return ERR; + else { + if (win->_firstch[wy] >= win->_ch_off) + win->_firstch[wy] = win->_maxx + + win->_ch_off; + if (win->_lastch[wy] < win->_maxx + + win->_ch_off) + win->_lastch[wy] = win->_ch_off; + if (win->_lastch[wy] < win->_firstch[wy]) + win->_firstch[wy] = _NOCHANGE; + } +# ifdef DEBUG + fprintf(outf, "\t%d\t%d\n", win->_firstch[wy], + win->_lastch[wy]); +# endif + } + + if (win == curscr) + domvcur(ly, lx, win->_cury, win->_curx); + else { + if (win->_leave) { + curscr->_cury = ly; + curscr->_curx = lx; + ly -= win->_begy; + lx -= win->_begx; + if (ly >= 0 && ly < win->_maxy && lx >= 0 && + lx < win->_maxx) { + win->_cury = ly; + win->_curx = lx; + } + else + win->_cury = win->_curx = 0; + } + else { + domvcur(ly, lx, win->_cury + win->_begy, + win->_curx + win->_begx); + curscr->_cury = win->_cury + win->_begy; + curscr->_curx = win->_curx + win->_begx; + } + } + retval = OK; +ret: + _win = NULL; + fflush(stdout); + return retval; +} + +/* + * make a change on the screen + */ +STATIC +makech(win, wy) +reg WINDOW *win; +short wy; +{ + reg chtype *nsp, *csp, *ce; + reg short wx, lch, y; + reg int nlsp, clsp; /* last space in lines */ + char *ce_tcap; + static chtype blank[] = {' ','\0'}; + + wx = win->_firstch[wy] - win->_ch_off; + if (wx >= win->_maxx) + return OK; + else if (wx < 0) + wx = 0; + lch = win->_lastch[wy] - win->_ch_off; + if (lch < 0) + return OK; + else if (lch >= win->_maxx) + lch = win->_maxx - 1;; + y = wy + win->_begy; + + if (curwin) + csp = blank; + else + csp = &curscr->_y[wy + win->_begy][wx + win->_begx]; + + nsp = &win->_y[wy][wx]; + if (CE && !curwin) { + for (ce = &win->_y[wy][win->_maxx - 1]; *ce == ' '; ce--) + if (ce <= win->_y[wy]) + break; + nlsp = ce - win->_y[wy]; + } + + if (!curwin) + ce_tcap = CE; + else + ce_tcap = NULL; + + while (wx <= lch) { + if (*nsp != *csp) { + domvcur(ly, lx, y, wx + win->_begx); +# ifdef DEBUG + fprintf(outf, "MAKECH: 1: wx = %d, lx = %d\n", wx, lx); +# endif + ly = y; + lx = wx + win->_begx; + while (*nsp != *csp && wx <= lch) { + if (ce_tcap != NULL && wx >= nlsp && *nsp == ' ') { + /* + * check for clear to end-of-line + */ + ce = &curscr->_y[ly][COLS - 1]; + while (*ce == ' ') + if (ce-- <= csp) + break; + clsp = ce - curscr->_y[ly] - win->_begx; +# ifdef DEBUG + fprintf(outf, "MAKECH: clsp = %d, nlsp = %d\n", clsp, nlsp); +# endif + if (clsp - nlsp >= strlen(CE) + && clsp < win->_maxx) { +# ifdef DEBUG + fprintf(outf, "MAKECH: using CE\n"); +# endif + _puts(CE); + lx = wx + win->_begx; + while (wx++ <= clsp) + *csp++ = ' '; + return OK; + } + ce_tcap = NULL; + } + /* + * enter/exit standout mode as appropriate + */ + if (SO && (*nsp&_STANDOUT) != (curscr->_flags&_STANDOUT)) { + if (*nsp & _STANDOUT) { + _puts(SO); + curscr->_flags |= _STANDOUT; + } + else { + _puts(SE); + curscr->_flags &= ~_STANDOUT; + } + } + wx++; + if (wx >= win->_maxx && wy == win->_maxy - 1) + if (win->_scroll) { + if ((curscr->_flags&_STANDOUT) && + (win->_flags & _ENDLINE)) + if (!MS) { + _puts(SE); + curscr->_flags &= ~_STANDOUT; + } + if (!curwin) + _putchar((*csp = *nsp)); + else + _putchar(*nsp); + if (win->_flags&_FULLWIN && !curwin) + scroll(curscr); + ly = win->_begy+win->_cury; + lx = win->_begx+win->_curx; + return OK; + } + else if (win->_flags&_SCROLLWIN) { + lx = --wx; + return ERR; + } + if (!curwin) + _putchar((*csp++ = *nsp)); + else + _putchar(*nsp); +# ifdef FULLDEBUG + fprintf(outf, + "MAKECH:putchar(%c)\n", *nsp); +# endif + if (UC && (*nsp & _STANDOUT)) { + _putchar('\b'); + _puts(UC); + } + nsp++; + } +# ifdef DEBUG + fprintf(outf, "MAKECH: 2: wx = %d, lx = %d\n", wx, lx); +# endif + if (lx == wx + win->_begx) /* if no change */ + break; + lx = wx + win->_begx; + if (lx >= COLS && AM) { + lx = 0; + ly++; + /* + * xn glitch: chomps a newline after auto-wrap. + * we just feed it now and forget about it. + */ + if (XN) { + _putchar('\n'); + _putchar('\r'); + } + } + } + else if (wx <= lch) + while (*nsp == *csp && wx <= lch) { + nsp++; + if (!curwin) + csp++; + ++wx; + } + else + break; +# ifdef DEBUG + fprintf(outf, "MAKECH: 3: wx = %d, lx = %d\n", wx, lx); +# endif + } + return OK; +} + +/* + * perform a mvcur, leaving standout mode if necessary + */ +STATIC +domvcur(oy, ox, ny, nx) +int oy, ox, ny, nx; { + + if (curscr->_flags & _STANDOUT && !MS) { + _puts(SE); + curscr->_flags &= ~_STANDOUT; + } + mvcur(oy, ox, ny, nx); +} diff --git a/lib/libcurses/scanw.c b/lib/libcurses/scanw.c new file mode 100644 index 000000000000..470b9bd47371 --- /dev/null +++ b/lib/libcurses/scanw.c @@ -0,0 +1,115 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)scanw.c 5.7 (Berkeley) 4/15/91"; +#endif /* not lint */ + +/* + * scanw and friends + * + */ + +#if __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif +#include "curses.ext" + +/* + * This routine implements a scanf on the standard screen. + */ +#if __STDC__ +scanw(const char *fmt, ...) +#else +scanw(fmt, va_alist) + char *fmt; + va_dcl +#endif +{ + va_list ap; + int ret; + +#if __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif + ret = _sscans(stdscr, fmt, ap); + va_end(ap); + return ret; +} + +/* + * This routine implements a scanf on the given window. + */ +#if __STDC__ +wscanw(WINDOW *win, const char *fmt, ...) +#else +wscanw(win, fmt, va_alist) + WINDOW *win; + char *fmt; + va_dcl +#endif +{ + va_list ap; + int ret; + +#if __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif + ret = _sscans(win, fmt, ap); + va_end(ap); + return ret; +} + +/* + * This routine actually executes the scanf from the window. + * THIS SHOULD BE RENAMED vwscanw AND EXPORTED + */ +_sscans(win, fmt, ap) + WINDOW *win; +#if __STDC__ + const char *fmt; +#else + char *fmt; +#endif + va_list ap; +{ + char buf[100]; + + return wgetstr(win, buf) == OK ? vsscanf(buf, fmt, ap) : ERR; +} diff --git a/lib/libcurses/scroll.c b/lib/libcurses/scroll.c new file mode 100644 index 000000000000..25cf822cba84 --- /dev/null +++ b/lib/libcurses/scroll.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)scroll.c 5.4 (Berkeley) 6/1/90"; +#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/lib/libcurses/standout.c b/lib/libcurses/standout.c new file mode 100644 index 000000000000..9cdaee6b1074 --- /dev/null +++ b/lib/libcurses/standout.c @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)standout.c 5.4 (Berkeley) 6/1/90"; +#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/lib/libcurses/toucholap.c b/lib/libcurses/toucholap.c new file mode 100644 index 000000000000..4404755a731c --- /dev/null +++ b/lib/libcurses/toucholap.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)toucholap.c 5.4 (Berkeley) 6/1/90"; +#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/lib/libcurses/touchwin.c b/lib/libcurses/touchwin.c new file mode 100644 index 000000000000..13d433138956 --- /dev/null +++ b/lib/libcurses/touchwin.c @@ -0,0 +1,83 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)touchwin.c 5.4 (Berkeley) 6/1/90"; +#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 +} diff --git a/lib/libcurses/tstp.c b/lib/libcurses/tstp.c new file mode 100644 index 000000000000..4c5f1a6ebbd6 --- /dev/null +++ b/lib/libcurses/tstp.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)tstp.c 5.6 (Berkeley) 3/3/91"; +#endif /* not lint */ + +# include <signal.h> + +# include "curses.ext" + +/* + * handle stop and start signals + * + * @(#)tstp.c 5.6 (Berkeley) 3/3/91 + */ +void +tstp() { + +# ifdef SIGTSTP + + SGTTY tty; + int omask; +# ifdef DEBUG + if (outf) + fflush(outf); +# endif + tty = _tty; + mvcur(0, COLS - 1, LINES - 1, 0); + endwin(); + fflush(stdout); + /* reset signal handler so kill below stops us */ + signal(SIGTSTP, SIG_DFL); +#define mask(s) (1 << ((s)-1)) + omask = sigsetmask(sigblock(0) &~ mask(SIGTSTP)); + kill(0, SIGTSTP); + sigblock(mask(SIGTSTP)); + signal(SIGTSTP, tstp); + _tty = tty; + ioctl(_tty_ch, TIOCSETP, &_tty); + wrefresh(curscr); +# endif SIGTSTP +} diff --git a/lib/libcurses/unctrl.c b/lib/libcurses/unctrl.c new file mode 100644 index 000000000000..fcd7a2f9a827 --- /dev/null +++ b/lib/libcurses/unctrl.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 1981 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)unctrl.c 5.4 (Berkeley) 6/1/90"; +#endif /* not lint */ + +/* + * define unctrl codes for each character + * + */ + +/* LINTLIBRARY */ +char *_unctrl[] = { /* unctrl codes for ttys */ + "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", "^H", "^I", "^J", "^K", + "^L", "^M", "^N", "^O", "^P", "^Q", "^R", "^S", "^T", "^U", "^V", "^W", + "^X", "^Y", "^Z", "^[", "^\\", "^]", "^~", "^_", + " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", + ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", + "<", "=", ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", + "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", + "X", "Y", "Z", "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", + "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", + "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "^?" +}; |
