Module Name: src
Committed By: roy
Date: Sat Dec 31 13:50:16 UTC 2016
Modified Files:
src/distrib/sets/lists/comp: mi
src/lib/libcurses: Makefile curses.h curses_cursor.3 curses_pad.3
curses_refresh.3 keypad.c leaveok.c
Log Message:
Implement ncurses extensions is_leaveok and is_keypad.
The former allows the ncurses (and pdcurses) macros getsyx and setsyx
to be implemented, which is needed by a surprising number of applications.
The latter is needed for Python curses support so it doesn't have to dive
into ncurses window structure.
To generate a diff of this commit:
cvs rdiff -u -r1.2084 -r1.2085 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.72 -r1.73 src/lib/libcurses/Makefile
cvs rdiff -u -r1.108 -r1.109 src/lib/libcurses/curses.h
cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/curses_cursor.3
cvs rdiff -u -r1.4 -r1.5 src/lib/libcurses/curses_pad.3
cvs rdiff -u -r1.10 -r1.11 src/lib/libcurses/curses_refresh.3
cvs rdiff -u -r1.12 -r1.13 src/lib/libcurses/keypad.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libcurses/leaveok.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2084 src/distrib/sets/lists/comp/mi:1.2085
--- src/distrib/sets/lists/comp/mi:1.2084 Fri Dec 30 22:38:38 2016
+++ src/distrib/sets/lists/comp/mi Sat Dec 31 13:50:16 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.2084 2016/12/30 22:38:38 roy Exp $
+# $NetBSD: mi,v 1.2085 2016/12/31 13:50:16 roy Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
./etc/mtree/set.comp comp-sys-root
@@ -6663,6 +6663,7 @@
./usr/share/man/cat3/getskeyprompt.0 comp-c-catman skey,.cat
./usr/share/man/cat3/getstr.0 comp-c-catman .cat
./usr/share/man/cat3/getsubopt.0 comp-c-catman .cat
+./usr/share/man/cat3/getsyx.0 comp-c-catman .cat
./usr/share/man/cat3/gettext.0 comp-c-catman .cat
./usr/share/man/cat3/gettmode.0 comp-c-catman .cat
./usr/share/man/cat3/getttyent.0 comp-c-catman .cat
@@ -6873,6 +6874,8 @@
./usr/share/man/cat3/ipsec_strerror.0 comp-c-catman .cat
./usr/share/man/cat3/iruserok.0 comp-c-catman .cat
./usr/share/man/cat3/iruserok_sa.0 comp-c-catman .cat
+./usr/share/man/cat3/is_keypad.0 comp-c-catman .cat
+./usr/share/man/cat3/is_leaveok.0 comp-c-catman .cat
./usr/share/man/cat3/is_linetouched.0 comp-c-catman .cat
./usr/share/man/cat3/is_wintouched.0 comp-c-catman .cat
./usr/share/man/cat3/isalnum.0 comp-c-catman .cat
@@ -8920,6 +8923,7 @@
./usr/share/man/cat3/setscrreg.0 comp-c-catman .cat
./usr/share/man/cat3/setservent.0 comp-c-catman .cat
./usr/share/man/cat3/setstate.0 comp-c-catman .cat
+./usr/share/man/cat3/setsyx.0 comp-c-catman .cat
./usr/share/man/cat3/setterm.0 comp-c-catman .cat
./usr/share/man/cat3/setttyent.0 comp-c-catman .cat
./usr/share/man/cat3/setttyentpath.0 comp-c-catman .cat
@@ -14011,6 +14015,7 @@
./usr/share/man/html3/getutmpx.html comp-c-htmlman html
./usr/share/man/html3/getutxent.html comp-c-htmlman html
./usr/share/man/html3/getutxid.html comp-c-htmlman html
+./usr/share/man/html3/getsyx.html comp-c-htmlman html
./usr/share/man/html3/getutxline.html comp-c-htmlman html
./usr/share/man/html3/getw.html comp-c-htmlman html
./usr/share/man/html3/getwc.html comp-c-htmlman html
@@ -14212,6 +14217,8 @@
./usr/share/man/html3/ipsec_strerror.html comp-c-htmlman html
./usr/share/man/html3/iruserok.html comp-c-htmlman html
./usr/share/man/html3/iruserok_sa.html comp-c-htmlman html
+./usr/share/man/html3/is_keypad.html comp-c-htmlman html
+./usr/share/man/html3/is_leaveok.html comp-c-htmlman html
./usr/share/man/html3/is_linetouched.html comp-c-htmlman html
./usr/share/man/html3/is_wintouched.html comp-c-htmlman html
./usr/share/man/html3/isalnum.html comp-c-htmlman html
@@ -16212,6 +16219,7 @@
./usr/share/man/html3/setscrreg.html comp-c-htmlman html
./usr/share/man/html3/setservent.html comp-c-htmlman html
./usr/share/man/html3/setstate.html comp-c-htmlman html
+./usr/share/man/html3/setsyx.html comp-c-htmlman html
./usr/share/man/html3/setterm.html comp-c-htmlman html
./usr/share/man/html3/setttyent.html comp-c-htmlman html
./usr/share/man/html3/setttyentpath.html comp-c-htmlman html
@@ -21258,6 +21266,7 @@
./usr/share/man/man3/getskeyprompt.3 comp-c-man skey,.man
./usr/share/man/man3/getstr.3 comp-c-man .man
./usr/share/man/man3/getsubopt.3 comp-c-man .man
+./usr/share/man/man3/getsyx.3 comp-c-man .man
./usr/share/man/man3/gettext.3 comp-c-man .man
./usr/share/man/man3/gettmode.3 comp-c-man .man
./usr/share/man/man3/getttyent.3 comp-c-man .man
@@ -21468,6 +21477,8 @@
./usr/share/man/man3/ipsec_strerror.3 comp-c-man .man
./usr/share/man/man3/iruserok.3 comp-c-man .man
./usr/share/man/man3/iruserok_sa.3 comp-c-man .man
+./usr/share/man/man3/is_keypad.3 comp-c-man .man
+./usr/share/man/man3/is_leaveok.3 comp-c-man .man
./usr/share/man/man3/is_linetouched.3 comp-c-man .man
./usr/share/man/man3/is_wintouched.3 comp-c-man .man
./usr/share/man/man3/isalnum.3 comp-c-man .man
@@ -23511,6 +23522,7 @@
./usr/share/man/man3/setscrreg.3 comp-c-man .man
./usr/share/man/man3/setservent.3 comp-c-man .man
./usr/share/man/man3/setstate.3 comp-c-man .man
+./usr/share/man/man3/setsyx.3 comp-c-man .man
./usr/share/man/man3/setterm.3 comp-c-man .man
./usr/share/man/man3/setttyent.3 comp-c-man .man
./usr/share/man/man3/setttyentpath.3 comp-c-man .man
Index: src/lib/libcurses/Makefile
diff -u src/lib/libcurses/Makefile:1.72 src/lib/libcurses/Makefile:1.73
--- src/lib/libcurses/Makefile:1.72 Fri Dec 30 22:38:38 2016
+++ src/lib/libcurses/Makefile Sat Dec 31 13:50:16 2016
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.72 2016/12/30 22:38:38 roy Exp $
+# $NetBSD: Makefile,v 1.73 2016/12/31 13:50:16 roy Exp $
# @(#)Makefile 8.2 (Berkeley) 1/2/94
.include <bsd.own.mk>
@@ -88,7 +88,8 @@ MLINKS+= curses_addch.3 addch.3 curses_a
curses_cursor.3 getpary.3 curses_cursor.3 getparx.3 \
curses_cursor.3 getparyx.3 curses_fileio.3 getwin.3 \
curses_input.3 getstr.3 \
- curses_tty.3 gettmode.3 curses_cursor.3 getyx.3 \
+ curses_tty.3 gettmode.3 \
+ curses_cursor.3 getyx.3 curses_cursor.3 getsyx.3 \
curses_color.3 has_colors.3 curses_tty.3 has_ic.3 \
curses_tty.3 halfdelay.3 curses_tty.3 has_il.3 \
curses_line.3 hline.3 curses_tty.3 idcok.3 \
@@ -98,7 +99,9 @@ MLINKS+= curses_addch.3 addch.3 curses_a
curses_color.3 init_pair.3 curses_screen.3 initscr.3 \
curses_insertch.3 insch.3 curses_insdelln.3 insdelln.3 \
curses_insertln.3 insertln.3 curses_inch.3 instr.3 \
- curses_tty.3 intrflush.3 curses_touch.3 is_linetouched.3 \
+ curses_tty.3 intrflush.3 \
+ curses_pad.3 is_keypad.3 \
+ curses_refresh.3 is_leaveok.3 curses_touch.3 is_linetouched.3 \
curses_touch.3 is_wintouched.3 curses_screen.3 isendwin.3 \
curses_keyname.3 keyname.3 \
curses_input.3 keypad.3 curses_tty.3 killchar.3 \
@@ -140,6 +143,7 @@ MLINKS+= curses_addch.3 addch.3 curses_a
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 \
+ curses_cursor.3 setsyx.3 \
curses_screen.3 set_term.3 curses_screen.3 setterm.3 \
curses_standout.3 standend.3 curses_standout.3 standout.3 \
curses_color.3 start_color.3 curses_pad.3 subpad.3 \
Index: src/lib/libcurses/curses.h
diff -u src/lib/libcurses/curses.h:1.108 src/lib/libcurses/curses.h:1.109
--- src/lib/libcurses/curses.h:1.108 Fri Dec 30 22:38:38 2016
+++ src/lib/libcurses/curses.h Sat Dec 31 13:50:16 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: curses.h,v 1.108 2016/12/30 22:38:38 roy Exp $ */
+/* $NetBSD: curses.h,v 1.109 2016/12/31 13:50:16 roy Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -614,6 +614,24 @@ __END_DECLS
#define getmaxyx(w, y, x) (y) = getmaxy(w), (x) = getmaxx(w)
#define getparyx(w, y, x) (y) = getpary(w), (x) = getparx(w)
+#define getsyx(y, x) \
+ do { \
+ if (is_leaveok(curscr)) \
+ (y) = (x) = -1; \
+ else \
+ getyx(curscr,(y), (x)); \
+ } while(0 /* CONSTCOND */)
+#define setsyx(y, x) \
+ do { \
+ if ((y) == -1 && (x) == -1) \
+ leaveok(curscr, TRUE); \
+ else { \
+ leaveok(curscr, FALSE); \
+ wmove(curscr, (y), (x)); \
+ } \
+ } while(0 /* CONSTCOND */)
+
+
/* Public function prototypes. */
__BEGIN_DECLS
int assume_default_colors(short, short);
@@ -923,6 +941,10 @@ int wbkgrnd(WINDOW *, const cchar_t *);
void wbkgrndset(WINDOW *, const cchar_t *);
int wgetbkgrnd(WINDOW *, cchar_t *);
+/* ncurses window tests */
+bool is_keypad(const WINDOW *);
+bool is_leaveok(const WINDOW *);
+
/* Private functions that are needed for user programs prototypes. */
int __cputchar(int);
int __waddbytes(WINDOW *, const char *, int, attr_t);
Index: src/lib/libcurses/curses_cursor.3
diff -u src/lib/libcurses/curses_cursor.3:1.7 src/lib/libcurses/curses_cursor.3:1.8
--- src/lib/libcurses/curses_cursor.3:1.7 Wed Feb 24 13:02:13 2010
+++ src/lib/libcurses/curses_cursor.3 Sat Dec 31 13:50:16 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: curses_cursor.3,v 1.7 2010/02/24 13:02:13 drochner Exp $
+.\" $NetBSD: curses_cursor.3,v 1.8 2016/12/31 13:50:16 roy Exp $
.\"
.\" Copyright (c) 2002
.\" Brett Lymn ([email protected], [email protected])
@@ -30,13 +30,14 @@
.\" SUCH DAMAGE.
.\"
.\"
-.Dd February 23, 2010
+.Dd December 31, 2016
.Dt CURSES 3
.Os
.Sh NAME
.Nm curses_cursor ,
.Nm getcury ,
.Nm getcurx ,
+.Nm getsyx ,
.Nm getyx ,
.Nm getbegy ,
.Nm getbegx ,
@@ -48,6 +49,7 @@
.Nm getparx ,
.Nm getparyx ,
.Nm move ,
+.Nm setsyx ,
.Nm wmove ,
.Nm mvcur ,
.Nm wcursyncup
@@ -60,6 +62,8 @@
.Fn getcury "WINDOW *win"
.Ft int
.Fn getcurx "WINDOW *win"
+.Ft int
+.Fn getsyx "int y" "int x"
.Ft void
.Fn getyx "WINDOW *win" "int y" "int x"
.Ft int
@@ -83,6 +87,8 @@
.Ft int
.Fn move "int y" "int x"
.Ft int
+.Fn setsyx "int y" "int x"
+.Ft int
.Fn wmove "WINDOW *win" "int y" "int x"
.Ft int
.Fn mvcur "int oldy" "int oldx" "int y" "int x"
@@ -107,6 +113,30 @@ and
to the current row and column positions of the cursor in the window
.Fa win .
.Pp
+The
+.Fn getsyx
+macro sets the values of
+.Fa y
+and
+.Fa x
+of the current window if
+.Fn is_leaveok
+is false, otherwise \-1, \-1.
+The
+.Fn setsyx
+macro sets the row and column positions, respectively, of the cursor in the
+current window to the values of
+.Fa y
+and
+.Fa x.
+If both
+.Fa y
+and
+.Fa x
+are both \-1 then
+.Fn leaveok
+is set.
+.Pp
The origin row and columns of a window
.Fa win
can be
@@ -221,3 +251,11 @@ functions are extensions.
.Sh HISTORY
The Curses package appeared in
.Bx 4.0 .
+The
+.Fn getsyx
+and
+.Fn setsyx
+functions are
+.Em ncurses
+extensions to the Curses library and were added in
+.Nx 8.0 .
Index: src/lib/libcurses/curses_pad.3
diff -u src/lib/libcurses/curses_pad.3:1.4 src/lib/libcurses/curses_pad.3:1.5
--- src/lib/libcurses/curses_pad.3:1.4 Wed Apr 30 13:10:51 2008
+++ src/lib/libcurses/curses_pad.3 Sat Dec 31 13:50:16 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: curses_pad.3,v 1.4 2008/04/30 13:10:51 martin Exp $
+.\" $NetBSD: curses_pad.3,v 1.5 2016/12/31 13:50:16 roy Exp $
.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
@@ -25,7 +25,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd December 4, 2002
+.Dd December 31, 2016
.Dt CURSES_PAD 3
.Os
.Sh NAME
@@ -47,6 +47,8 @@
.Fn prefresh "WINDOW *pad" "int pbeg_y" "int pbeg_x" "int sbeg_y" "int sbeg_x" "int smax_y" "int smax_x"
.Ft int
.Fn pnoutrefresh "WINDOW *pad" "int pbeg_y" "int pbeg_x" "int sbeg_y" "int sbeg_x" "int smax_y" "int smax_x"
+.Ft bool
+.Fn is_keypad "const WINDOW *pad"
.Sh DESCRIPTION
These functions create and display pads on the current screen.
.Pp
@@ -108,6 +110,10 @@ and
functions can be used together to speed up terminal redraws by
deferring the actual terminal updates until after a batch of updates
to multiple pads has been done.
+.Pp
+The
+.Fn is_keypad
+function returns true if the given window is a pad, otherwise false.
.Sh RETURN VALUES
Functions returning pointers will return
.Dv NULL
@@ -140,3 +146,9 @@ Single Unix Specification.
.Sh HISTORY
The Curses package appeared in
.Bx 4.0 .
+The
+.Fn is_keypad
+function is a
+.Em ncurses
+extension to the Curses library and was added in
+.Nx 8.0 .
Index: src/lib/libcurses/curses_refresh.3
diff -u src/lib/libcurses/curses_refresh.3:1.10 src/lib/libcurses/curses_refresh.3:1.11
--- src/lib/libcurses/curses_refresh.3:1.10 Wed Apr 16 13:35:01 2003
+++ src/lib/libcurses/curses_refresh.3 Sat Dec 31 13:50:16 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: curses_refresh.3,v 1.10 2003/04/16 13:35:01 wiz Exp $
+.\" $NetBSD: curses_refresh.3,v 1.11 2016/12/31 13:50:16 roy Exp $
.\"
.\" Copyright (c) 2002
.\" Brett Lymn ([email protected], [email protected])
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\"
-.Dd March 26, 2003
+.Dd December 31, 2016
.Dt CURSES_REFRESH 3
.Os
.Sh NAME
@@ -40,6 +40,7 @@
.Nm wnoutrefresh ,
.Nm doupdate ,
.Nm leaveok ,
+.Nm is_leaveok ,
.Nm flushok
.Nd curses terminal update routines
.Sh LIBRARY
@@ -56,6 +57,8 @@
.Fn doupdate "void"
.Ft int
.Fn leaveok "WINDOW *win" "boolf flag"
+.Ft bool
+.Fn is_leaveok "const WINDOW *win"
.Ft int
.Fn flushok "WINDOW *win" "boolf flag"
.Sh DESCRIPTION
@@ -116,6 +119,9 @@ to
.Dv FALSE
ensures that the screen cursor is positioned at the current cursor
position after a refresh operation has taken place.
+The
+.Fn is_leaveok
+function returns the setting.
.Pp
The
.Fn flushok
@@ -155,3 +161,10 @@ Single Unix Specification.
.Sh HISTORY
The Curses package appeared in
.Bx 4.0 .
+The
+.Fn is_leaveok
+function is a
+.Em ncurses
+extension to the Curses library and was added in
+.Nx 8.0 .
+
Index: src/lib/libcurses/keypad.c
diff -u src/lib/libcurses/keypad.c:1.12 src/lib/libcurses/keypad.c:1.13
--- src/lib/libcurses/keypad.c:1.12 Wed Feb 3 15:34:40 2010
+++ src/lib/libcurses/keypad.c Sat Dec 31 13:50:16 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: keypad.c,v 1.12 2010/02/03 15:34:40 roy Exp $ */
+/* $NetBSD: keypad.c,v 1.13 2016/12/31 13:50:16 roy Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn ([email protected], [email protected])
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: keypad.c,v 1.12 2010/02/03 15:34:40 roy Exp $");
+__RCSID("$NetBSD: keypad.c,v 1.13 2016/12/31 13:50:16 roy Exp $");
#endif /* not lint */
#include "curses.h"
@@ -57,3 +57,14 @@ keypad(WINDOW *win, bool bf)
return OK;
}
+
+/*
+ * is_keypad --
+ * Return true if window is set for keypad.
+ */
+bool
+is_keypad(const WINDOW *win)
+{
+
+ return win->flags & __KEYPAD ? true : false;
+}
Index: src/lib/libcurses/leaveok.c
diff -u src/lib/libcurses/leaveok.c:1.5 src/lib/libcurses/leaveok.c:1.6
--- src/lib/libcurses/leaveok.c:1.5 Mon Apr 28 20:23:01 2008
+++ src/lib/libcurses/leaveok.c Sat Dec 31 13:50:16 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: leaveok.c,v 1.5 2008/04/28 20:23:01 martin Exp $ */
+/* $NetBSD: leaveok.c,v 1.6 2016/12/31 13:50:16 roy Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: leaveok.c,v 1.5 2008/04/28 20:23:01 martin Exp $");
+__RCSID("$NetBSD: leaveok.c,v 1.6 2016/12/31 13:50:16 roy Exp $");
#endif /* not lint */
#include "curses.h"
@@ -50,3 +50,14 @@ leaveok(WINDOW *win, bool bf)
win->flags &= ~__LEAVEOK;
return (OK);
}
+
+/*
+ * is_leaveok --
+ * Return true if window is set for leaveok.
+ */
+bool
+is_leaveok(const WINDOW *win)
+{
+
+ return win->flags & __LEAVEOK ? true : false;
+}