Source-Changes-HG archive

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

[src/trunk]: src Add the POSIX filter() function to libcurses.



details:   https://anonhg.NetBSD.org/src/rev/d234a6497da1
branches:  trunk
changeset: 820130:d234a6497da1
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Dec 30 22:38:38 2016 +0000

description:
Add the POSIX filter() function to libcurses.

diffstat:

 distrib/sets/lists/comp/mi     |   5 ++++-
 lib/libcurses/Makefile         |   4 ++--
 lib/libcurses/curses.h         |   3 ++-
 lib/libcurses/curses_private.h |   3 ++-
 lib/libcurses/curses_screen.3  |  24 ++++++++++++++++++++++--
 lib/libcurses/screen.c         |  18 ++++++++++++++++--
 lib/libcurses/setterm.c        |  25 ++++++++++++++++++++++---
 7 files changed, 70 insertions(+), 12 deletions(-)

diffs (233 lines):

diff -r d7b946c3f33d -r d234a6497da1 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Fri Dec 30 21:08:23 2016 +0000
+++ b/distrib/sets/lists/comp/mi        Fri Dec 30 22:38:38 2016 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.2083 2016/12/22 16:32:31 maya Exp $
+#      $NetBSD: mi,v 1.2084 2016/12/30 22:38:38 roy Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.comp                           comp-sys-root
@@ -6380,6 +6380,7 @@
 ./usr/share/man/cat3/field_type.0              comp-c-catman           .cat
 ./usr/share/man/cat3/field_userptr.0           comp-c-catman           .cat
 ./usr/share/man/cat3/fileno.0                  comp-c-catman           .cat
+./usr/share/man/cat3/filter.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/finite.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/finitef.0                 comp-c-catman           .cat
 ./usr/share/man/cat3/flags_to_string.0         comp-c-catman           .cat
@@ -13720,6 +13721,7 @@
 ./usr/share/man/html3/field_type.html          comp-c-htmlman          html
 ./usr/share/man/html3/field_userptr.html       comp-c-htmlman          html
 ./usr/share/man/html3/fileno.html              comp-c-htmlman          html
+./usr/share/man/html3/filter.html              comp-c-htmlman          html
 ./usr/share/man/html3/finite.html              comp-c-htmlman          html
 ./usr/share/man/html3/finitef.html             comp-c-htmlman          html
 ./usr/share/man/html3/flags_to_string.html     comp-c-htmlman          html
@@ -20973,6 +20975,7 @@
 ./usr/share/man/man3/field_type.3              comp-c-man              .man
 ./usr/share/man/man3/field_userptr.3           comp-c-man              .man
 ./usr/share/man/man3/fileno.3                  comp-c-man              .man
+./usr/share/man/man3/filter.3                  comp-c-man              .man
 ./usr/share/man/man3/finite.3                  comp-c-man              .man
 ./usr/share/man/man3/finitef.3                 comp-c-man              .man
 ./usr/share/man/man3/flags_to_string.3         comp-c-man              .man
diff -r d7b946c3f33d -r d234a6497da1 lib/libcurses/Makefile
--- a/lib/libcurses/Makefile    Fri Dec 30 21:08:23 2016 +0000
+++ b/lib/libcurses/Makefile    Fri Dec 30 22:38:38 2016 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.71 2014/07/05 22:31:32 dholland Exp $
+#      $NetBSD: Makefile,v 1.72 2016/12/30 22:38:38 roy Exp $
 #      @(#)Makefile    8.2 (Berkeley) 1/2/94
 
 .include <bsd.own.mk>
@@ -75,7 +75,7 @@
         curses_refresh.3 doupdate.3 curses_window.3 dupwin.3 \
         curses_tty.3 echo.3 curses_echochar.3 echochar.3 \
         curses_screen.3 endwin.3 curses_clear.3 erase.3 \
-        curses_tty.3 erasechar.3 \
+        curses_tty.3 erasechar.3 curses_screen.3 filter.3 \
         curses_tty.3 flash.3 curses_tty.3 flushinp.3 \
         curses_refresh.3 flushok.3 \
         curses_termcap.3 fullname.3 curses_attributes.3 getattrs.3  \
diff -r d7b946c3f33d -r d234a6497da1 lib/libcurses/curses.h
--- a/lib/libcurses/curses.h    Fri Dec 30 21:08:23 2016 +0000
+++ b/lib/libcurses/curses.h    Fri Dec 30 22:38:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: curses.h,v 1.107 2015/06/08 12:38:57 joerg Exp $       */
+/*     $NetBSD: curses.h,v 1.108 2016/12/30 22:38:38 roy Exp $ */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -638,6 +638,7 @@
 int     echo(void);
 int     endwin(void);
 char     erasechar(void);
+void    filter(void);
 int     flash(void);
 int     flushinp(void);
 int     flushok(WINDOW *, bool);
diff -r d7b946c3f33d -r d234a6497da1 lib/libcurses/curses_private.h
--- a/lib/libcurses/curses_private.h    Fri Dec 30 21:08:23 2016 +0000
+++ b/lib/libcurses/curses_private.h    Fri Dec 30 22:38:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: curses_private.h,v 1.51 2016/10/23 21:20:56 christos Exp $     */
+/*     $NetBSD: curses_private.h,v 1.52 2016/12/30 22:38:38 roy Exp $  */
 
 /*-
  * Copyright (c) 1998-2000 Brett Lymn
@@ -252,6 +252,7 @@
        int resized;
        wchar_t *unget_list;
        int unget_len, unget_pos;
+       int filtered;
 #ifdef HAVE_WCHAR
 #define MB_LEN_MAX 8
 #define MAX_CBUF_SIZE MB_LEN_MAX
diff -r d7b946c3f33d -r d234a6497da1 lib/libcurses/curses_screen.3
--- a/lib/libcurses/curses_screen.3     Fri Dec 30 21:08:23 2016 +0000
+++ b/lib/libcurses/curses_screen.3     Fri Dec 30 22:38:38 2016 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: curses_screen.3,v 1.15 2012/04/21 12:27:28 roy Exp $
+.\"    $NetBSD: curses_screen.3,v 1.16 2016/12/30 22:38:38 roy Exp $
 .\"
 .\" Copyright (c) 2002
 .\"    Brett Lymn (blymn%NetBSD.org@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -30,10 +30,11 @@
 .\" SUCH DAMAGE.
 .\"
 .\"
-.Dd April 5, 2012
+.Dd December 30, 2016
 .Dt CURSES_SCREEN 3
 .Os
 .Sh NAME
+.Nm filter ,
 .Nm curses_screen ,
 .Nm newterm ,
 .Nm set_term ,
@@ -48,6 +49,8 @@
 .Lb libcurses
 .Sh SYNOPSIS
 .In curses.h
+.Ft void
+.Fn filter "void"
 .Ft SCREEN *
 .Fn newterm "char *type" "FILE *outfd" "FILE *infd"
 .Ft SCREEN *
@@ -170,6 +173,23 @@
 argument must be a valid name or alias in the
 .Xr terminfo 5
 database for this function to succeed.
+.Pp
+The
+.Fn filter
+function changes the way the terminal is initialised.
+A subsequent call to
+.Fn initscr
+or
+.Fn newterm
+performs the following additonal actions:
+.Bl -bullet -compact
+.It
+Disable use of clear, cud, cud1, cup, cuu, cuu1 and vpa.
+.It
+Set the value of the home string to the value of the cr string.
+.It
+Set lines equal to 1.
+.El
 .Sh RETURN VALUES
 Functions returning pointers will return
 .Dv NULL
diff -r d7b946c3f33d -r d234a6497da1 lib/libcurses/screen.c
--- a/lib/libcurses/screen.c    Fri Dec 30 21:08:23 2016 +0000
+++ b/lib/libcurses/screen.c    Fri Dec 30 22:38:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: screen.c,v 1.24 2015/11/26 01:05:08 christos Exp $     */
+/*     $NetBSD: screen.c,v 1.25 2016/12/30 22:38:38 roy Exp $  */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)screen.c   8.2 (blymn) 11/27/2001";
 #else
-__RCSID("$NetBSD: screen.c,v 1.24 2015/11/26 01:05:08 christos Exp $");
+__RCSID("$NetBSD: screen.c,v 1.25 2016/12/30 22:38:38 roy Exp $");
 #endif
 #endif                                 /* not lint */
 
@@ -43,6 +43,18 @@
 #include "curses.h"
 #include "curses_private.h"
 
+static int filtered;
+
+/*
+ * filter has to be called before either initscr or newterm.
+ */
+void
+filter(void)
+{
+
+       filtered = TRUE;
+}
+
 /*
  * set_term --
  *      Change the term to the given screen.
@@ -128,6 +140,8 @@
        new_screen->outfd = outfd;
        new_screen->echoit = new_screen->nl = 1;
        new_screen->pfast = new_screen->rawmode = new_screen->noqch = 0;
+       new_screen->filtered = filtered;
+       filtered = FALSE; /* filter() must preceed each newterm() */
        new_screen->nca = A_NORMAL;
        new_screen->color_type = COLOR_NONE;
        new_screen->COLOR_PAIRS = 0;
diff -r d7b946c3f33d -r d234a6497da1 lib/libcurses/setterm.c
--- a/lib/libcurses/setterm.c   Fri Dec 30 21:08:23 2016 +0000
+++ b/lib/libcurses/setterm.c   Fri Dec 30 22:38:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: setterm.c,v 1.54 2016/01/09 19:05:13 jdc Exp $ */
+/*     $NetBSD: setterm.c,v 1.55 2016/12/30 22:38:38 roy Exp $ */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setterm.c  8.8 (Berkeley) 10/25/94";
 #else
-__RCSID("$NetBSD: setterm.c,v 1.54 2016/01/09 19:05:13 jdc Exp $");
+__RCSID("$NetBSD: setterm.c,v 1.55 2016/12/30 22:38:38 roy Exp $");
 #endif
 #endif /* not lint */
 
@@ -99,8 +99,27 @@
                }
        }
 
+       if (screen->filtered) {
+               /* Disable use of clear, cud, cud1, cup, cuu1 and vpa. */
+               screen->term->strs[TICODE_clear] = NULL;
+               screen->term->strs[TICODE_cud] = NULL;
+               screen->term->strs[TICODE_cud1] = NULL;
+               screen->term->strs[TICODE_cup] = NULL;
+               screen->term->strs[TICODE_cuu] = NULL;
+               screen->term->strs[TICODE_cuu1] = NULL;
+               screen->term->strs[TICODE_vpa] = NULL;
+               /* Set the value of the home string to the value of
+                * the cr string. */
+               screen->term->strs[TICODE_home] = screen->term->strs[TICODE_cr];
+               /* Set lines equal to 1. */
+               screen->LINES = 1;
+       }
+#ifdef DEBUG
+       __CTRACE(__CTRACE_INIT, "setterm: filtered %d", screen->filtered);
+#endif
+
        /* POSIX 1003.2 requires that the environment override. */
-       if ((p = getenv("LINES")) != NULL)
+       if (!screen->filtered && (p = getenv("LINES")) != NULL)
                screen->LINES = (int) strtol(p, NULL, 0);
        if ((p = getenv("COLUMNS")) != NULL)
                screen->COLS = (int) strtol(p, NULL, 0);



Home | Main Index | Thread Index | Old Index