Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses * Fixed need for duplicate namp string in sett...



details:   https://anonhg.NetBSD.org/src/rev/693135fb73fc
branches:  trunk
changeset: 485213:693135fb73fc
user:      blymn <blymn%NetBSD.org@localhost>
date:      Sat Apr 22 13:29:01 2000 +0000

description:
* Fixed need for duplicate namp string in setterm.c
* Added meta function (turns meta bit on and off on terminal if supported)
* Added curs_set to control cursor visibility if supported.

diffstat:

 lib/libcurses/Makefile   |  17 ++++----
 lib/libcurses/curs_set.c |  91 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/libcurses/curses.3   |   7 +++-
 lib/libcurses/curses.c   |  14 +++---
 lib/libcurses/curses.h   |  16 ++++---
 lib/libcurses/meta.c     |  61 ++++++++++++++++++++++++++++++++
 lib/libcurses/setterm.c  |  35 +++++++++--------
 7 files changed, 201 insertions(+), 40 deletions(-)

diffs (truncated from 381 to 300 lines):

diff -r f6ae83a45c9a -r 693135fb73fc lib/libcurses/Makefile
--- a/lib/libcurses/Makefile    Sat Apr 22 13:13:21 2000 +0000
+++ b/lib/libcurses/Makefile    Sat Apr 22 13:29:01 2000 +0000
@@ -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 @@
 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 -r f6ae83a45c9a -r 693135fb73fc lib/libcurses/curs_set.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libcurses/curs_set.c  Sat Apr 22 13:29:01 2000 +0000
@@ -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@localhost, brett_lymn%yahoo.com.au@localhost)
+ * 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 -r f6ae83a45c9a -r 693135fb73fc lib/libcurses/curses.3
--- a/lib/libcurses/curses.3    Sat Apr 22 13:13:21 2000 +0000
+++ b/lib/libcurses/curses.3    Sat Apr 22 13:29:01 2000 +0000
@@ -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 @@
 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 @@
 .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 -r f6ae83a45c9a -r 693135fb73fc lib/libcurses/curses.c
--- a/lib/libcurses/curses.c    Sat Apr 22 13:13:21 2000 +0000
+++ b/lib/libcurses/curses.c    Sat Apr 22 13:29:01 2000 +0000
@@ -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 @@
 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 -r f6ae83a45c9a -r 693135fb73fc lib/libcurses/curses.h
--- a/lib/libcurses/curses.h    Sat Apr 22 13:13:21 2000 +0000
+++ b/lib/libcurses/curses.h    Sat Apr 22 13:29:01 2000 +0000
@@ -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 @@
                *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 @@
 __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 @@
 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 -r f6ae83a45c9a -r 693135fb73fc lib/libcurses/meta.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libcurses/meta.c      Sat Apr 22 13:29:01 2000 +0000
@@ -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@localhost, brett_lymn%yahoo.com.au@localhost)
+ * 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);
+               }
+       }
+



Home | Main Index | Thread Index | Old Index