diff --git a/lib/libcurses/Makefile b/lib/libcurses/Makefile index 6fcca87fd556..7c0631fac880 100644 --- a/lib/libcurses/Makefile +++ b/lib/libcurses/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.25 2000/04/20 09:56:38 kleink Exp $ +# $NetBSD: Makefile,v 1.26 2000/04/22 13:29:01 blymn Exp $ # @(#)Makefile 8.2 (Berkeley) 1/2/94 CPPFLAGS+=#-DTFILE=\"/dev/ttyp0\" @@ -6,13 +6,14 @@ CPPFLAGS+=-D_CURSES_PRIVATE -I${.CURDIR} LIB= curses SRCS= addbytes.c addch.c addnstr.c acs.c attributes.c background.c bell.c \ border.c box.c clear.c clearok.c clrtobot.c clrtoeol.c color.c \ - copywin.c cr_put.c ctrace.c cur_hash.c curses.c delch.c deleteln.c \ - delwin.c erase.c flushok.c fullname.c getch.c getstr.c getyx.c \ - id_subwins.c idlok.c inch.c initscr.c insch.c insdelln.c insertln.c \ - keypad.c leaveok.c longname.c move.c mvwin.c newwin.c nodelay.c \ - notimeout.c overlay.c overwrite.c printw.c putchar.c refresh.c \ - scanw.c scroll.c scrollok.c setterm.c standout.c timeout.c \ - toucholap.c touchwin.c tscroll.c tstp.c tty.c unctrl.c underscore.c + copywin.c cr_put.c ctrace.c cur_hash.c curses.c curs_set.c delch.c \ + deleteln.c delwin.c erase.c flushok.c fullname.c getch.c getstr.c \ + getyx.c id_subwins.c idlok.c inch.c initscr.c insch.c insdelln.c \ + insertln.c keypad.c leaveok.c longname.c meta.c move.c mvwin.c \ + newwin.c nodelay.c notimeout.c overlay.c overwrite.c printw.c \ + putchar.c refresh.c scanw.c scroll.c scrollok.c setterm.c standout.c \ + timeout.c toucholap.c touchwin.c tscroll.c tstp.c tty.c unctrl.c \ + underscore.c MAN= curses.3 INCS= curses.h unctrl.h INCSDIR=/usr/include diff --git a/lib/libcurses/curs_set.c b/lib/libcurses/curs_set.c new file mode 100644 index 000000000000..95131b998f83 --- /dev/null +++ b/lib/libcurses/curs_set.c @@ -0,0 +1,91 @@ +/* $NetBSD: curs_set.c,v 1.1 2000/04/22 13:29:01 blymn Exp $ */ + +/*- + * Copyright (c) 1998-2000 Brett Lymn + * (blymn@baea.com.au, brett_lymn@yahoo.com.au) + * All rights reserved. + * + * This code has been donated to The NetBSD Foundation by the Author. + * + * 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. The name of the author may not be used to endorse or promote products + * derived from this software withough specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + * + * + */ + +#include "curses.h" +#include "curses_private.h" + +static int old_mode = 1; /* assume cursor normal on start */ + +/* + * curs_set -- + * Set the visibility of the cursor, 0 means invisible, 1 means normal + * visibility and 2 means high visibility. Return the previous + * visibility iff the terminal supports the new visibility otherwise + * return ERR. + */ +int +curs_set(int visibility) +{ + int old_one; + + old_one = old_mode; + switch (visibility) { + case 0: /* invisible */ + if (VI != NULL) { +#ifdef DEBUG + __CTRACE("curs_set: invisible\n"); +#endif + old_mode = 0; + tputs(VI, 0, __cputchar); + return old_one; + } + break; + + case 1: /* normal */ + if (VE != NULL) { +#ifdef DEBUG + __CTRACE("curs_set: normal\n"); +#endif + old_mode = 1; + tputs(VE, 0, __cputchar); + return old_one; + } + break; + + case 2: /* high visibility */ + if (VS != NULL) { +#ifdef DEBUG + __CTRACE("curs_set: high vis\n"); +#endif + old_mode = 2; + tputs(VS, 0, __cputchar); + return old_one; + } + break; + + default: + break; + } + + return ERR; +} + + diff --git a/lib/libcurses/curses.3 b/lib/libcurses/curses.3 index a0eed5819003..d0f8821ce7eb 100644 --- a/lib/libcurses/curses.3 +++ b/lib/libcurses/curses.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses.3,v 1.19 2000/04/20 13:12:14 blymn Exp $ +.\" $NetBSD: curses.3,v 1.20 2000/04/22 13:29:01 blymn Exp $ .\" .\" Copyright (c) 1985, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -112,6 +112,8 @@ and applies this rendition to to .Em dstwin. If overlay is true then copy is nondestructive. +.It curs_set(vis) change cursor visibility, 0 is invisible, 1 is +normal, 2 is high visibility. Returns previous value on success. .It def_prog_mode() define program (in curses) terminal modes .It def_shell_mode() define shell (not in curses) terminal modes .It delch() delete a character @@ -162,6 +164,9 @@ relative to .Em win .It longname(termbuf,name) get long name from .Em termbuf +.It meta(win,boolf) turn terminal meta mode on and off. Note +.Em win +is always ignored. .It move(y,x) move to (y,x) on .Em stdscr .It mvcur(lasty,lastx,newy,newx) actually move cursor diff --git a/lib/libcurses/curses.c b/lib/libcurses/curses.c index 23b48d27ce0a..c4022e34867d 100644 --- a/lib/libcurses/curses.c +++ b/lib/libcurses/curses.c @@ -1,4 +1,4 @@ -/* $NetBSD: curses.c,v 1.14 2000/04/17 12:25:45 blymn Exp $ */ +/* $NetBSD: curses.c,v 1.15 2000/04/22 13:29:01 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)curses.c 8.3 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: curses.c,v 1.14 2000/04/17 12:25:45 blymn Exp $"); +__RCSID("$NetBSD: curses.c,v 1.15 2000/04/22 13:29:01 blymn Exp $"); #endif #endif /* not lint */ @@ -59,11 +59,11 @@ int PA, cO, nc; char *AC, *AE, *AL, *AS, *BC, *BL, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, *DM, *DO, *Ea, *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, *MB, *MD, *ME, *MH, *MK, *MP, *MR, *ND, *NL, - *OC, *OP, *RC, *SC, *SE, *SF, *SO, *SP, *SR, *TA, *TE, *TI, *UC, - *UE, *UP, *US, *VB, *VS, *VE, *ab, *af, *al, *dl, *iC, *iP, *sB, - *sF, *sf, *sr, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM, - *RIGHT_PARM; + *KS, *KU, *LL, *MA, *MB, *MD, *ME, *MH, *MK, *MM, *MO, *MP, *MR, + *ND, *NL, *OC, *OP, *RC, *SC, *SE, *SF, *SO, *SP, *SR, *TA, *TE, + *TI, *UC, *UE, *UP, *US, *VB, *VI, *VS, *VE, *ab, *af, *al, *dl, *iC, + *iP, *sB, *sF, *sf, *sr, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, + *LEFT_PARM, *RIGHT_PARM; /* * Public. * diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h index aa13eddbea9c..6315956a0132 100644 --- a/lib/libcurses/curses.h +++ b/lib/libcurses/curses.h @@ -1,4 +1,4 @@ -/* $NetBSD: curses.h,v 1.39 2000/04/20 13:12:14 blymn Exp $ */ +/* $NetBSD: curses.h,v 1.40 2000/04/22 13:29:01 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -95,11 +95,11 @@ extern char *AC, *AE, *AL, *AS, *BC, *BL, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, *DM, *DO, *Ea, *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, *MB, - *MD, *ME, *MH, *MK, *MP, *MR, *ND, *NL, *OC, *OP, *RC, - *SC, *SE, *SF, *SO, *SP, *SR, *TA, *TE, *TI, *UC, *UE, - *UP, *US, *VB, *VS, *VE, *ab, *af, *al, *dl, *iC, *iP, - *sB, *sF, *sf, *sr, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, - *LEFT_PARM, *RIGHT_PARM; + *MD, *ME, *MH, *MK, *MM, *MO, *MP, *MR, *ND, *NL, *OC, + *OP, *RC, *SC, *SE, *SF, *SO, *SP, *SR, *TA, *TE, *TI, + *UC, *UE, *UP, *US, *VB, *VI, *VS, *VE, *ab, *af, *al, *dl, + *iC, *iP, *sB, *sF, *sf, *sr, *AL_PARM, *DL_PARM, *UP_PARM, + *DOWN_PARM, *LEFT_PARM, *RIGHT_PARM; /* END BACKWARD COMPATIBILITY ONLY. */ @@ -485,13 +485,14 @@ int mvwinsch(WINDOW *win, int y, int x, chtype ch); __BEGIN_DECLS int beep(void); int box(WINDOW *win, chtype vert, chtype horiz); +bool can_change_colors(void); int cbreak(void); int clearok(WINDOW *win, bool flag); -bool can_change_colors(void); int color_content(short colour, short *redp, short *greenp, short *bluep); int copywin(const WINDOW *srcwin, WINDOW *dstwin, int sminrow, int smincol, int dminrow, int dmincol, int dmaxrow, int dmaxcol, int overlay); +int curs_set(int visibility); int def_prog_mode(void); int def_shell_mode(void); int delwin(WINDOW *win); @@ -522,6 +523,7 @@ bool isendwin(void); void keypad(WINDOW *win, bool bf); int leaveok(WINDOW *win, bool bf); char *longname(void); +int meta(WINDOW *win, bool bf); int mvcur(int ly, int lx, int y, int x); int mvprintw(int y, int x, const char *fmt, ...); int mvscanw(int y, int x, const char *fmt, ...); diff --git a/lib/libcurses/meta.c b/lib/libcurses/meta.c new file mode 100644 index 000000000000..32a96b4a0cd8 --- /dev/null +++ b/lib/libcurses/meta.c @@ -0,0 +1,61 @@ +/* $NetBSD: meta.c,v 1.1 2000/04/22 13:29:02 blymn Exp $ */ + +/*- + * Copyright (c) 1998-2000 Brett Lymn + * (blymn@baea.com.au, brett_lymn@yahoo.com.au) + * All rights reserved. + * + * This code has been donated to The NetBSD Foundation by the Author. + * + * 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. The name of the author may not be used to endorse or promote products + * derived from this software withough specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + * + * + */ + +#include "curses.h" +#include "curses_private.h" + +/* + * meta -- + * Turn on or off the terminal meta mode. + */ +int +meta(/*ARGSUSED*/ WINDOW *win, bool bf) +{ + if (bf == TRUE) { + if (MM != NULL) { +#ifdef DEBUG + __CTRACE("meta: TRUE\n"); +#endif + tputs(MM, 0, __cputchar); + } + } else { + if (MO != NULL) { +#ifdef DEBUG + __CTRACE("meta: FALSE\n"); +#endif + tputs(MO, 0, __cputchar); + } + } + + return OK; +} + + diff --git a/lib/libcurses/setterm.c b/lib/libcurses/setterm.c index b3ad08979bb2..9119486f5ccc 100644 --- a/lib/libcurses/setterm.c +++ b/lib/libcurses/setterm.c @@ -1,4 +1,4 @@ -/* $NetBSD: setterm.c,v 1.18 2000/04/19 13:52:39 blymn Exp $ */ +/* $NetBSD: setterm.c,v 1.19 2000/04/22 13:29:02 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)setterm.c 8.8 (Berkeley) 10/25/94"; #else -__RCSID("$NetBSD: setterm.c,v 1.18 2000/04/19 13:52:39 blymn Exp $"); +__RCSID("$NetBSD: setterm.c,v 1.19 2000/04/22 13:29:02 blymn Exp $"); #endif #endif /* not lint */ @@ -81,18 +81,18 @@ static char *_PC, &K7, &K8, &K9, &HO, &IC, &IM, &IP, &KD, &KE, /* kh kl kr ks ku ll ma mb md */ &KH, &KL, &KR, &KS, &KU, &LL, &MA, &MB, &MD, - /* me mh mk mp mr nd nl oc op */ - &ME, &MH, &MK, &MP, &MR, &ND, &NL, &OC, &OP, - /* pc rc sc se SF so sp SR ta */ - &_PC, &RC, &SC, &SE, &SF, &SO, &SP, &SR, &TA, - /* te ti uc ue up us vb vs ve */ - &TE, &TI, &UC, &UE, &UP, &US, &VB, &VS, &VE, - /* AB AF al dl Ic Ip Sb Sf sf */ - &ab, &af, &al, &dl, &iC, &iP, &sB, &sF, &sf, - /* sr AL DL UP DO */ - &sr, &AL_PARM, &DL_PARM, &UP_PARM, &DOWN_PARM, - /* LE RI */ - &LEFT_PARM, &RIGHT_PARM, + /* me mh mk mm mo mp mr nd nl */ + &ME, &MH, &MK, &MM, &MO, &MP, &MR, &ND, &NL, + /* oc op pc rc sc se SF so sp */ + &OC, &OP, &_PC, &RC, &SC, &SE, &SF, &SO, &SP, + /* SR ta te ti uc ue up us vb */ + &SR, &TA, &TE, &TI, &UC, &UE, &UP, &US, &VB, + /* vi vs ve AB AF al dl Ic Ip */ + &VI, &VS, &VE, &ab, &af, &al, &dl, &iC, &iP, + /* Sb Sf sf sr AL DL UP */ + &sB, &sF, &sf, &sr, &AL_PARM, &DL_PARM, &UP_PARM, + /* DO LE RI */ + &DOWN_PARM, &LEFT_PARM, &RIGHT_PARM, }; static char *aoftspace; /* Address of _tspace for relocation */ @@ -202,7 +202,7 @@ setterm(char *type) static int zap(struct tinfo *tinfo) { - const char *namp; + const char *nampstr, *namp; char ***sp; int **vp; char **fp; @@ -239,7 +239,8 @@ zap(struct tinfo *tinfo) } while (*namp); /* calculate the size of tspace.... */ - namp = "acaeALasbcblbtcdceclcmcrcsdcDLdmdoeAedeik0k1k2k3k4k5k6k7k8k9hoicimipkdkekhklkrkskullmambmdmemhmkmpmrndnlocoppcprscseSFsospSRtatetiucueupusvbvsveABAFaldlIcIpSbSfsfsrALDLUPDOLERI"; + nampstr = "acaeALasbcblbtcdceclcmcrcsdcDLdmdoeAedeik0k1k2k3k4k5k6k7k8k9hoicimipkdkekhklkrkskullmambmdmemhmkmmmompmrndnlocoppcprscseSFsospSRtatetiucueupusvbvivsveABAFaldlIcIpSbSfsfsrALDLUPDOLERI"; + namp = nampstr; tspace_size = 0; do { *tmp = *namp; @@ -257,7 +258,7 @@ zap(struct tinfo *tinfo) #endif aoftspace = tspace; - namp = "acaeALasbcblbtcdceclcmcrcsdcDLdmdoeAedeik0k1k2k3k4k5k6k7k8k9hoicimipkdkekhklkrkskullmambmdmemhmkmpmrndnlocoppcprscseSFsospSRtatetiucueupusvbvsveABAFaldlIcIpSbSfsfsrALDLUPDOLERI"; + namp = nampstr; sp = sstrs; do { *tmp = *namp;