Source-Changes-HG archive

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

[src/trunk]: src Implement POSIX curses function ripoffline(3).



details:   https://anonhg.NetBSD.org/src/rev/22ef7c2e3772
branches:  trunk
changeset: 820465:22ef7c2e3772
user:      roy <roy%NetBSD.org@localhost>
date:      Tue Jan 10 10:13:24 2017 +0000

description:
Implement POSIX curses function ripoffline(3).

diffstat:

 distrib/sets/lists/comp/mi     |   5 ++-
 lib/libcurses/Makefile         |   3 +-
 lib/libcurses/curses.h         |   3 +-
 lib/libcurses/curses_private.h |   4 +-
 lib/libcurses/curses_screen.3  |  37 +++++++++++++++++-
 lib/libcurses/initscr.c        |   7 ++-
 lib/libcurses/resize.c         |  10 +++-
 lib/libcurses/screen.c         |  84 +++++++++++++++++++++++++++++++++++-------
 lib/libcurses/setterm.c        |   8 ++--
 9 files changed, 131 insertions(+), 30 deletions(-)

diffs (truncated from 410 to 300 lines):

diff -r d6393c1002fd -r 22ef7c2e3772 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Tue Jan 10 09:48:22 2017 +0000
+++ b/distrib/sets/lists/comp/mi        Tue Jan 10 10:13:24 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.2100 2017/01/07 04:44:12 ozaki-r Exp $
+#      $NetBSD: mi,v 1.2101 2017/01/10 10:13:24 roy Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.comp                           comp-sys-root
@@ -8689,6 +8689,7 @@
 ./usr/share/man/cat3/rintf.0                   comp-c-catman           .cat
 ./usr/share/man/cat3/rintl.0                   comp-c-catman           .cat
 ./usr/share/man/cat3/ripemd.0                  comp-obsolete           obsolete
+./usr/share/man/cat3/ripoffline.0              comp-c-catman           .cat
 ./usr/share/man/cat3/rmd160.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/rmtops.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/round.0                   comp-c-catman           .cat
@@ -16037,6 +16038,7 @@
 ./usr/share/man/html3/rint.html                        comp-c-htmlman          html
 ./usr/share/man/html3/rintf.html               comp-c-htmlman          html
 ./usr/share/man/html3/rintl.html               comp-c-htmlman          html
+./usr/share/man/html3/ripoffline.html          comp-c-htmlman          html
 ./usr/share/man/html3/rmd160.html              comp-c-htmlman          html
 ./usr/share/man/html3/rmtops.html              comp-c-htmlman          html
 ./usr/share/man/html3/round.html               comp-c-htmlman          html
@@ -23384,6 +23386,7 @@
 ./usr/share/man/man3/rintf.3                   comp-c-man              .man
 ./usr/share/man/man3/rintl.3                   comp-c-man              .man
 ./usr/share/man/man3/ripemd.3                  comp-obsolete           obsolete
+./usr/share/man/man3/ripoffline.3              comp-c-man              .man
 ./usr/share/man/man3/rmd160.3                  comp-c-man              .man
 ./usr/share/man/man3/rmtops.3                  comp-c-man              .man
 ./usr/share/man/man3/round.3                   comp-c-man              .man
diff -r d6393c1002fd -r 22ef7c2e3772 lib/libcurses/Makefile
--- a/lib/libcurses/Makefile    Tue Jan 10 09:48:22 2017 +0000
+++ b/lib/libcurses/Makefile    Tue Jan 10 10:13:24 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.81 2017/01/05 23:15:43 roy Exp $
+#      $NetBSD: Makefile,v 1.82 2017/01/10 10:13:24 roy Exp $
 #      @(#)Makefile    8.2 (Berkeley) 1/2/94
 
 .include <bsd.own.mk>
@@ -143,6 +143,7 @@
         curses_tty.3 reset_prog_mode.3 curses_tty.3 reset_shell_mode.3 \
         curses_tty.3 resetty.3 \
         curses_screen.3 resizeterm.3 curses_screen.3 resize_term.3 \
+        curses_screen.3 ripoffline.3 \
         curses_tty.3 savetty.3 curses_scanw.3 scanw.3 \
         curses_scroll.3 scrl.3 curses_scroll.3 scroll.3 \
         curses_scroll.3 scrollok.3 curses_scroll.3 setscrreg.3 \
diff -r d6393c1002fd -r 22ef7c2e3772 lib/libcurses/curses.h
--- a/lib/libcurses/curses.h    Tue Jan 10 09:48:22 2017 +0000
+++ b/lib/libcurses/curses.h    Tue Jan 10 10:13:24 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: curses.h,v 1.119 2017/01/06 09:14:07 roy Exp $ */
+/*     $NetBSD: curses.h,v 1.120 2017/01/10 10:13:24 roy Exp $ */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -746,6 +746,7 @@
 int     resetty(void);
 int      resizeterm(int, int);
 int     resize_term(int, int);
+int     ripoffline(int, int (*)(WINDOW *, int));
 int     savetty(void);
 int     scanw(const char *, ...) __scanflike(1, 2);
 int     scroll(WINDOW *);
diff -r d6393c1002fd -r 22ef7c2e3772 lib/libcurses/curses_private.h
--- a/lib/libcurses/curses_private.h    Tue Jan 10 09:48:22 2017 +0000
+++ b/lib/libcurses/curses_private.h    Tue Jan 10 10:13:24 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: curses_private.h,v 1.57 2017/01/06 09:14:07 roy Exp $  */
+/*     $NetBSD: curses_private.h,v 1.58 2017/01/10 10:13:24 roy Exp $  */
 
 /*-
  * Copyright (c) 1998-2000 Brett Lymn
@@ -201,6 +201,8 @@
        int      lx, ly;        /* loop parameters for refresh */
        int      COLS;          /* Columns on the screen. */
        int      LINES;         /* Lines on the screen. */
+       int      ripped_top;    /* Lines ripped from the top of the screen. */
+       int      ripped_bottom; /* Lines ripped from the bottom. */
        int      ESCDELAY;      /* Delay between keys in esc seq's. */
 #define        ESCDELAY_DEFAULT        300 /* milliseconds. */
        int      TABSIZE;       /* Size of a tab. */
diff -r d6393c1002fd -r 22ef7c2e3772 lib/libcurses/curses_screen.3
--- a/lib/libcurses/curses_screen.3     Tue Jan 10 09:48:22 2017 +0000
+++ b/lib/libcurses/curses_screen.3     Tue Jan 10 10:13:24 2017 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: curses_screen.3,v 1.21 2017/01/05 21:25:18 roy Exp $
+.\"    $NetBSD: curses_screen.3,v 1.22 2017/01/10 10:13:24 roy Exp $
 .\"
 .\" Copyright (c) 2002
 .\"    Brett Lymn (blymn%NetBSD.org@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -30,12 +30,13 @@
 .\" SUCH DAMAGE.
 .\"
 .\"
-.Dd January 5, 2017
+.Dd January 9, 2017
 .Dt CURSES_SCREEN 3
 .Os
 .Sh NAME
 .Nm curses_screen ,
 .Nm filter ,
+.Nm ripoffline ,
 .Nm use_env ,
 .Nm newterm ,
 .Nm set_term ,
@@ -55,6 +56,8 @@
 .In curses.h
 .Ft void
 .Fn filter "void"
+.Ft int
+.Fn ripoffline "int line" "int (*init)(WINDOW *win, int cols)"
 .Ft void
 .Fn use_env "bool value"
 .Ft SCREEN *
@@ -212,6 +215,36 @@
 .El
 .Pp
 The
+.Fn ripoffline
+funcion will rip a line from
+.Dv stdscr
+at the top if
+.Fa line
+is positive, or at the bottom if negative.
+When
+.Fn initscr
+or
+.Fn newterm
+is called, a window will be created for each line ripped and passed
+to the
+.Fa init
+function pointer alongwith the number of columns in the window.
+This init function cannot use the
+.Dv LINES
+or
+.Dv COLS
+variables and cannot call
+.Xr wrefresh 3
+or
+.Xr doupdate 3 ,
+but may call
+.Xr wnoutrefresh 3 .
+.Dv LINES
+will be reduced by the total number of lines ripped off.
+.Fn ripoffline
+can be called up to five times.
+.Pp
+The
 .Fn use_env
 function determines whether the environment variables
 .Ev LINES
diff -r d6393c1002fd -r 22ef7c2e3772 lib/libcurses/initscr.c
--- a/lib/libcurses/initscr.c   Tue Jan 10 09:48:22 2017 +0000
+++ b/lib/libcurses/initscr.c   Tue Jan 10 10:13:24 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: initscr.c,v 1.30 2017/01/06 13:53:18 roy Exp $ */
+/*     $NetBSD: initscr.c,v 1.31 2017/01/10 10:13:24 roy Exp $ */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)initscr.c  8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: initscr.c,v 1.30 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: initscr.c,v 1.31 2017/01/10 10:13:24 roy Exp $");
 #endif
 #endif /* not lint */
 
@@ -73,7 +73,8 @@
        __rawmode = _cursesi_screen->rawmode;
        __noqch = _cursesi_screen->noqch;
        COLS = _cursesi_screen->COLS;
-       LINES = _cursesi_screen->LINES;
+       LINES = _cursesi_screen->LINES
+           - _cursesi_screen->ripped_top - _cursesi_screen->ripped_bottom;
        COLORS = _cursesi_screen->COLORS;
        COLOR_PAIRS = _cursesi_screen->COLOR_PAIRS;
        __GT = _cursesi_screen->GT;
diff -r d6393c1002fd -r 22ef7c2e3772 lib/libcurses/resize.c
--- a/lib/libcurses/resize.c    Tue Jan 10 09:48:22 2017 +0000
+++ b/lib/libcurses/resize.c    Tue Jan 10 10:13:24 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: resize.c,v 1.22 2017/01/06 13:53:18 roy Exp $  */
+/*     $NetBSD: resize.c,v 1.23 2017/01/10 10:13:24 roy Exp $  */
 
 /*
  * Copyright (c) 2001
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)resize.c   blymn 2001/08/26";
 #else
-__RCSID("$NetBSD: resize.c,v 1.22 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: resize.c,v 1.23 2017/01/10 10:13:24 roy Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -144,7 +144,10 @@
 is_term_resized(int nlines, int ncols)
 {
 
-       return (nlines > 0 && ncols > 0 && (nlines != LINES || ncols != COLS));
+       return (nlines > 0 && ncols > 0 &&
+           (nlines != _cursesi_screen->LINES
+           + _cursesi_screen->ripped_top + _cursesi_screen->ripped_bottom ||
+           ncols != _cursesi_screen->COLS));
 }
 
 /*
@@ -190,6 +193,7 @@
                return ERR;
        if (__resizeterm(__virtscr, nlines, ncols) == ERR)
                return ERR;
+       nlines -= _cursesi_screen->ripped_top - _cursesi_screen->ripped_bottom;
        if (__resizeterm(stdscr, nlines, ncols) == ERR)
                return ERR;
 
diff -r d6393c1002fd -r 22ef7c2e3772 lib/libcurses/screen.c
--- a/lib/libcurses/screen.c    Tue Jan 10 09:48:22 2017 +0000
+++ b/lib/libcurses/screen.c    Tue Jan 10 10:13:24 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: screen.c,v 1.27 2017/01/06 13:53:18 roy Exp $  */
+/*     $NetBSD: screen.c,v 1.28 2017/01/10 10:13:24 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.27 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: screen.c,v 1.28 2017/01/10 10:13:24 roy Exp $");
 #endif
 #endif                                 /* not lint */
 
@@ -45,6 +45,14 @@
 
 static int filtered;
 
+/* List of ripoffline calls */
+#define        NRIPS   5
+static struct ripoff {
+       int     nlines;
+       int     (*init)(WINDOW *, int);
+} ripoffs[NRIPS];
+static int nrips;
+
 /*
  * filter has to be called before either initscr or newterm.
  */
@@ -56,6 +64,24 @@
 }
 
 /*
+ *ripoffline --
+ *     Ripoff a line from the top of bottom of stdscr.
+ *     Must be called before initscr or newterm.
+ */
+int
+ripoffline(int line, int (*init)(WINDOW *, int))
+{
+
+       if (nrips >= NRIPS || init == NULL)
+               return ERR; /* This makes sense, but not standards compliant. */
+       if (line == 0)
+               return OK;
+       ripoffs[nrips].nlines = line < 0 ? -1 : 1;
+       ripoffs[nrips++].init = init;
+       return OK;
+}
+
+/*
  * set_term --
  *      Change the term to the given screen.
  *
@@ -72,7 +98,8 @@
                old_screen->rawmode = __rawmode;
                old_screen->noqch = __noqch;
                old_screen->COLS = COLS;
-               old_screen->LINES = LINES;
+               old_screen->LINES = LINES
+                   + old_screen->ripped_top + old_screen->ripped_bottom;
                old_screen->COLORS = COLORS;
                old_screen->COLOR_PAIRS = COLOR_PAIRS;
                old_screen->GT = __GT;
@@ -87,7 +114,7 @@
        __rawmode = new->rawmode;
        __noqch = new->noqch;
        COLS = new->COLS;
-       LINES = new->LINES;
+       LINES = new->LINES - new->ripped_top - new->ripped_bottom;
        COLORS = new->COLORS;
        COLOR_PAIRS = new->COLOR_PAIRS;
        __GT = new->GT;
@@ -124,6 +151,7 @@
 {



Home | Main Index | Thread Index | Old Index