Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses * Major change to add support for the newterm/...



details:   https://anonhg.NetBSD.org/src/rev/9bb83343e82b
branches:  trunk
changeset: 518587:9bb83343e82b
user:      blymn <blymn%NetBSD.org@localhost>
date:      Sun Dec 02 09:14:20 2001 +0000

description:
* Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)

diffstat:

 lib/libcurses/Makefile         |    6 +-
 lib/libcurses/PSD.doc/fns.doc  |   35 +++-
 lib/libcurses/acs.c            |   18 +-
 lib/libcurses/clear.c          |    6 +-
 lib/libcurses/color.c          |  139 ++++++-------
 lib/libcurses/curs_set.c       |   16 +-
 lib/libcurses/curses.3         |   10 +-
 lib/libcurses/curses.c         |   15 +-
 lib/libcurses/curses.h         |    8 +-
 lib/libcurses/curses_private.h |  129 ++++++++++++-
 lib/libcurses/getch.c          |   77 ++++--
 lib/libcurses/getstr.c         |   10 +-
 lib/libcurses/initscr.c        |   70 ++----
 lib/libcurses/longname.c       |    6 +-
 lib/libcurses/meta.c           |   12 +-
 lib/libcurses/newwin.c         |   26 +-
 lib/libcurses/pause.c          |    6 +-
 lib/libcurses/putchar.c        |    6 +-
 lib/libcurses/refresh.c        |  126 ++++++------
 lib/libcurses/screen.c         |  243 ++++++++++++++++++++++++
 lib/libcurses/setterm.c        |  406 +++++++++++++++++++++++-----------------
 lib/libcurses/shlib_version    |    4 +-
 lib/libcurses/tstp.c           |   37 ++-
 lib/libcurses/tty.c            |  317 +++++++++++++++++--------------
 24 files changed, 1119 insertions(+), 609 deletions(-)

diffs (truncated from 3196 to 300 lines):

diff -r 885f806d2782 -r 9bb83343e82b lib/libcurses/Makefile
--- a/lib/libcurses/Makefile    Sun Dec 02 09:05:53 2001 +0000
+++ b/lib/libcurses/Makefile    Sun Dec 02 09:14:20 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.33 2001/09/20 11:11:54 blymn Exp $
+#      $NetBSD: Makefile,v 1.34 2001/12/02 09:14:20 blymn Exp $
 #      @(#)Makefile    8.2 (Berkeley) 1/2/94
 
 CPPFLAGS+=#-DTFILE=\"/dev/ttyp0\"
@@ -18,8 +18,8 @@
        insdelln.c insertln.c instr.c keypad.c leaveok.c line.c longname.c \
        meta.c move.c mvwin.c newwin.c nodelay.c notimeout.c overlay.c \
        overwrite.c pause.c printw.c putchar.c refresh.c resize.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
+       screen.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
diff -r 885f806d2782 -r 9bb83343e82b lib/libcurses/PSD.doc/fns.doc
--- a/lib/libcurses/PSD.doc/fns.doc     Sun Dec 02 09:05:53 2001 +0000
+++ b/lib/libcurses/PSD.doc/fns.doc     Sun Dec 02 09:14:20 2001 +0000
@@ -318,6 +318,10 @@
 and the bottom line will become blank.
 The current \*y will remain unchanged.
 .Ds
+.Fn delscreen "SCREEN *screen"
+.De
+Delete the screen and frees all associated resources.
+.Ds
 .Fn delwin "WINDOW *win"
 .De
 Deletes the window from existence.
@@ -914,6 +918,24 @@
 .Vn ms
 milliseconds.
 .Ds
+.Ft "SCREEN *"
+.Fn newterm "char *type" "FILE *outfd" "FILE *infd"
+.De
+Iinitialise the curses subsystem to use the terminal of type
+.Vn type
+connected via the input and output streams
+.Vn infd,outfd. 
+The 
+.Fn newterm
+is used in multi-terminal applications and returns a pointer to a
+.Ft "SCREEN"
+structure that holds the state for that particular terminal.  The
+application may swap between the terminals by calling the
+.Fn set_term
+function.  If the 
+.Vn type
+parameter is NULL then the $TERM variable is used as the terminal type.
+.Ds
 .Ft "WINDOW *"
 .Fn newwin "int lines" "int cols" "int begin_y" "int begin_x"
 .De
@@ -1174,6 +1196,17 @@
 is 0, scrolling is not allowed.
 This is its default setting.
 .Ds
+.Ft "SCREEN *"
+.Fn set_term "SCREEN *new"
+.De
+Sets the current screen for input and output to be the one given.  The 
+.Vn new
+structure must be one that has been previously created by the 
+.Fn newterm
+function.  The 
+.Fn set_term
+function returns the previous screen on successful completion.
+.Ds
 .Fn standend "" \(dg
 .De
 End standout mode initiated by
@@ -1196,7 +1229,7 @@
 .Ds
 .Fn start_color ""
 .De
-Initialize the cplor routines. 
+Initialize the color routines. 
 This must be called before any of the color routines are used.
 .Ds
 .Ft "WINDOW *"
diff -r 885f806d2782 -r 9bb83343e82b lib/libcurses/acs.c
--- a/lib/libcurses/acs.c       Sun Dec 02 09:05:53 2001 +0000
+++ b/lib/libcurses/acs.c       Sun Dec 02 09:14:20 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acs.c,v 1.8 2000/12/19 21:34:24 jdc Exp $      */
+/*     $NetBSD: acs.c,v 1.9 2001/12/02 09:14:20 blymn Exp $    */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: acs.c,v 1.8 2000/12/19 21:34:24 jdc Exp $");
+__RCSID("$NetBSD: acs.c,v 1.9 2001/12/02 09:14:20 blymn Exp $");
 #endif                         /* not lint */
 
 #include "curses.h"
@@ -52,7 +52,7 @@
  *     character pairs - ACS definition then terminal representation.
  */
 void
-__init_acs(void)
+__init_acs(SCREEN *screen)
 {
        int             count;
        char            *aofac; /* Address of 'ac' */
@@ -110,6 +110,18 @@
 #endif
        }
 
+       for (count=0; count < NUM_ACS; count++)
+               screen->acs_char[count]= _acs_char[count];
+
        if (__tc_eA != NULL)
                tputs(__tc_eA, 0, __cputchar);
 }
+
+void
+_cursesi_reset_acs(SCREEN *screen)
+{
+       int count;
+
+       for (count=0; count < NUM_ACS; count++)
+               _acs_char[count]= screen->acs_char[count];
+}
diff -r 885f806d2782 -r 9bb83343e82b lib/libcurses/clear.c
--- a/lib/libcurses/clear.c     Sun Dec 02 09:05:53 2001 +0000
+++ b/lib/libcurses/clear.c     Sun Dec 02 09:14:20 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clear.c,v 1.11 2000/04/15 13:17:03 blymn Exp $ */
+/*     $NetBSD: clear.c,v 1.12 2001/12/02 09:14:20 blymn Exp $ */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)clear.c    8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: clear.c,v 1.11 2000/04/15 13:17:03 blymn Exp $");
+__RCSID("$NetBSD: clear.c,v 1.12 2001/12/02 09:14:20 blymn Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -54,7 +54,7 @@
 int
 clear(void)
 {
-       return wclear(stdscr);
+       return wclear(_cursesi_screen->stdscr);
 }
 
 #endif
diff -r 885f806d2782 -r 9bb83343e82b lib/libcurses/color.c
--- a/lib/libcurses/color.c     Sun Dec 02 09:05:53 2001 +0000
+++ b/lib/libcurses/color.c     Sun Dec 02 09:14:20 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: color.c,v 1.14 2001/01/05 22:57:56 christos Exp $      */
+/*     $NetBSD: color.c,v 1.15 2001/12/02 09:14:20 blymn Exp $ */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -38,49 +38,35 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: color.c,v 1.14 2001/01/05 22:57:56 christos Exp $");
+__RCSID("$NetBSD: color.c,v 1.15 2001/12/02 09:14:20 blymn Exp $");
 #endif                         /* not lint */
 
 #include "curses.h"
 #include "curses_private.h"
 
-/* the following is defined and set up in setterm.c */
-extern struct tinfo *_cursesi_genbuf;
-
-/* Maximum colours */
-#define        MAX_COLORS      64
-/* Maximum colour pairs - determined by number of colour bits in attr_t */
-#define        MAX_PAIRS       64      /* PAIR_NUMBER(__COLOR) + 1 */
-
 /* Flags for colours and pairs */
 #define        __USED          0x01
 
 /* List of colours */
-struct color {
+/*struct color {
        short   num;
        short   red;
        short   green;
        short   blue;
        int     flags;
-} colors[MAX_COLORS];
+       } colors[MAX_COLORS];*/
 
 /* List of colour pairs */
-struct pair {
+/*struct pair {
        short   fore;
        short   back;
        int     flags;
-} pairs[MAX_PAIRS];
+       } pairs[MAX_PAIRS];*/
 
 /* Attributes that clash with colours */
 attr_t __nca;
 
-/* Style of colour manipulation */
-#define COLOR_NONE     0
-#define COLOR_ANSI     1       /* ANSI/DEC-style colour manipulation */
-#define COLOR_HP       2       /* HP-style colour manipulation */
-#define COLOR_TEK      3       /* Tektronix-style colour manipulation */
-#define COLOR_OTHER    4       /* None of the others but can set fore/back */
-int    __color_type = COLOR_NONE;
+/*int  __color_type = COLOR_NONE;*/
 
 static void
 __change_pair __P((short));
@@ -140,30 +126,33 @@
        if (!COLORS)
                return (ERR);
 
+       _cursesi_screen->COLORS = COLORS;
+       _cursesi_screen->COLOR_PAIRS = COLOR_PAIRS;
+       
        /* Reset terminal colour and colour pairs. */
        if (__tc_oc != NULL)
                tputs(__tc_oc, 0, __cputchar);
        if (__tc_op != NULL) {
                tputs(__tc_op, 0, __cputchar);
-               curscr->wattr &= __mask_op;
+               curscr->wattr &= _cursesi_screen->mask_op;
        }
 
        /* Type of colour manipulation - ANSI/TEK/HP/other */
        if (__tc_AF != NULL && __tc_AB != NULL)
-               __color_type = COLOR_ANSI;
+               _cursesi_screen->color_type = COLOR_ANSI;
        else if (__tc_Ip != NULL)
-               __color_type = COLOR_HP;
+               _cursesi_screen->color_type = COLOR_HP;
        else if (__tc_Ic != NULL)
-               __color_type = COLOR_TEK;
+               _cursesi_screen->color_type = COLOR_TEK;
        else if (__tc_Sb != NULL && __tc_Sf != NULL)
-               __color_type = COLOR_OTHER;
+               _cursesi_screen->color_type = COLOR_OTHER;
        else
                return(ERR);            /* Unsupported colour method */
 
 #ifdef DEBUG
        __CTRACE("start_color: COLORS = %d, COLOR_PAIRS = %d",
            COLORS, COLOR_PAIRS);
-       switch (__color_type) {
+       switch (_cursesi_screen->color_type) {
        case COLOR_ANSI:
                __CTRACE(" (ANSI style)\n");
                break;
@@ -183,30 +172,30 @@
         * Attributes that cannot be used with color.
         * Store these in an attr_t for wattrset()/wattron().
         */
-       __nca = __NORMAL;
+       _cursesi_screen->nca = __NORMAL;
        if (__tc_NC != -1) {
-               temp_nc = (attr_t) t_getnum(_cursesi_genbuf, "NC");
+               temp_nc = (attr_t) t_getnum(_cursesi_screen->cursesi_genbuf, "NC");
                if (temp_nc & 0x0001)
-                       __nca |= __STANDOUT;
+                       _cursesi_screen->nca |= __STANDOUT;
                if (temp_nc & 0x0002)
-                       __nca |= __UNDERSCORE;
+                       _cursesi_screen->nca |= __UNDERSCORE;
                if (temp_nc & 0x0004)
-                       __nca |= __REVERSE;
+                       _cursesi_screen->nca |= __REVERSE;
                if (temp_nc & 0x0008)
-                       __nca |= __BLINK;
+                       _cursesi_screen->nca |= __BLINK;
                if (temp_nc & 0x0010)
-                       __nca |= __DIM;
+                       _cursesi_screen->nca |= __DIM;
                if (temp_nc & 0x0020)
-                       __nca |= __BOLD;
+                       _cursesi_screen->nca |= __BOLD;
                if (temp_nc & 0x0040)
-                       __nca |= __BLANK;
+                       _cursesi_screen->nca |= __BLANK;
                if (temp_nc & 0x0080)
-                       __nca |= __PROTECT;
+                       _cursesi_screen->nca |= __PROTECT;
                if (temp_nc & 0x0100)
-                       __nca |= __ALTCHARSET;
+                       _cursesi_screen->nca |= __ALTCHARSET;



Home | Main Index | Thread Index | Old Index