Module Name: src
Committed By: roy
Date: Thu Jan 5 20:31:37 UTC 2017
Modified Files:
src/distrib/sets/lists/comp: mi
src/lib/libcurses: Makefile curses.3 curses.h curses_input.3
curses_private.h curses_screen.3 get_wch.c getch.c setterm.c
Log Message:
Add the set_escdelay(3) and set_tabsize(3) ncurses extensions.
To generate a diff of this commit:
cvs rdiff -u -r1.2095 -r1.2096 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.78 -r1.79 src/lib/libcurses/Makefile
cvs rdiff -u -r1.63 -r1.64 src/lib/libcurses/curses.3
cvs rdiff -u -r1.115 -r1.116 src/lib/libcurses/curses.h
cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/curses_input.3
cvs rdiff -u -r1.55 -r1.56 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.19 -r1.20 src/lib/libcurses/curses_screen.3
cvs rdiff -u -r1.10 -r1.11 src/lib/libcurses/get_wch.c
cvs rdiff -u -r1.60 -r1.61 src/lib/libcurses/getch.c
cvs rdiff -u -r1.56 -r1.57 src/lib/libcurses/setterm.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.2095 src/distrib/sets/lists/comp/mi:1.2096
--- src/distrib/sets/lists/comp/mi:1.2095 Thu Jan 5 13:45:51 2017
+++ src/distrib/sets/lists/comp/mi Thu Jan 5 20:31:37 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.2095 2017/01/05 13:45:51 wiz Exp $
+# $NetBSD: mi,v 1.2096 2017/01/05 20:31:37 roy Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
./etc/mtree/set.comp comp-sys-root
@@ -8841,6 +8841,7 @@
./usr/share/man/cat3/set_current_field.0 comp-c-catman .cat
./usr/share/man/cat3/set_current_item.0 comp-c-catman .cat
./usr/share/man/cat3/set_curterm.0 comp-c-catman .cat
+./usr/share/man/cat3/set_escdelay.0 comp-c-catman .cat
./usr/share/man/cat3/set_field_back.0 comp-c-catman .cat
./usr/share/man/cat3/set_field_buffer.0 comp-c-catman .cat
./usr/share/man/cat3/set_field_fore.0 comp-c-catman .cat
@@ -8884,6 +8885,7 @@
./usr/share/man/cat3/set_menu_win.0 comp-c-catman .cat
./usr/share/man/cat3/set_new_page.0 comp-c-catman .cat
./usr/share/man/cat3/set_panel_userptr.0 comp-c-catman .cat
+./usr/share/man/cat3/set_tabsize.0 comp-c-catman .cat
./usr/share/man/cat3/set_term.0 comp-c-catman .cat
./usr/share/man/cat3/set_top_row.0 comp-c-catman .cat
./usr/share/man/cat3/setbuf.0 comp-c-catman .cat
@@ -16148,6 +16150,7 @@
./usr/share/man/html3/set_current_field.html comp-c-htmlman html
./usr/share/man/html3/set_current_item.html comp-c-htmlman html
./usr/share/man/html3/set_curterm.html comp-c-htmlman html
+./usr/share/man/html3/set_escdelay.html comp-c-htmlman html
./usr/share/man/html3/set_field_back.html comp-c-htmlman html
./usr/share/man/html3/set_field_buffer.html comp-c-htmlman html
./usr/share/man/html3/set_field_fore.html comp-c-htmlman html
@@ -16191,6 +16194,7 @@
./usr/share/man/html3/set_menu_win.html comp-c-htmlman html
./usr/share/man/html3/set_new_page.html comp-c-htmlman html
./usr/share/man/html3/set_panel_userptr.html comp-c-htmlman html
+./usr/share/man/html3/set_tabsize.html comp-c-htmlman html
./usr/share/man/html3/set_term.html comp-c-htmlman html
./usr/share/man/html3/set_top_row.html comp-c-htmlman html
./usr/share/man/html3/setbuf.html comp-c-htmlman html
@@ -23458,6 +23462,7 @@
./usr/share/man/man3/set_current_field.3 comp-c-man .man
./usr/share/man/man3/set_current_item.3 comp-c-man .man
./usr/share/man/man3/set_curterm.3 comp-c-man .man
+./usr/share/man/man3/set_escdelay.3 comp-c-man .man
./usr/share/man/man3/set_field_back.3 comp-c-man .man
./usr/share/man/man3/set_field_buffer.3 comp-c-man .man
./usr/share/man/man3/set_field_fore.3 comp-c-man .man
@@ -23501,6 +23506,7 @@
./usr/share/man/man3/set_menu_win.3 comp-c-man .man
./usr/share/man/man3/set_new_page.3 comp-c-man .man
./usr/share/man/man3/set_panel_userptr.3 comp-c-man .man
+./usr/share/man/man3/set_tabsize.3 comp-c-man .man
./usr/share/man/man3/set_term.3 comp-c-man .man
./usr/share/man/man3/set_top_row.3 comp-c-man .man
./usr/share/man/man3/setbuf.3 comp-c-man .man
Index: src/lib/libcurses/Makefile
diff -u src/lib/libcurses/Makefile:1.78 src/lib/libcurses/Makefile:1.79
--- src/lib/libcurses/Makefile:1.78 Tue Jan 3 13:21:40 2017
+++ src/lib/libcurses/Makefile Thu Jan 5 20:31:37 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.78 2017/01/03 13:21:40 roy Exp $
+# $NetBSD: Makefile,v 1.79 2017/01/05 20:31:37 roy Exp $
# @(#)Makefile 8.2 (Berkeley) 1/2/94
.include <bsd.own.mk>
@@ -145,6 +145,7 @@ MLINKS+= curses_addch.3 addch.3 curses_a
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_input.3 set_escdelay.3 curses_screen.3 set_tabsize.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.3
diff -u src/lib/libcurses/curses.3:1.63 src/lib/libcurses/curses.3:1.64
--- src/lib/libcurses/curses.3:1.63 Sat Apr 21 12:27:27 2012
+++ src/lib/libcurses/curses.3 Thu Jan 5 20:31:37 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: curses.3,v 1.63 2012/04/21 12:27:27 roy Exp $
+.\" $NetBSD: curses.3,v 1.64 2017/01/05 20:31:37 roy Exp $
.\"
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)curses.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd April 5, 2012
+.Dd January 5, 2017
.Dt CURSES 3
.Os
.Sh NAME
@@ -221,6 +221,8 @@ must be called before any of the other r
.It scrl Ta Xr curses_scroll 3
.It scroll Ta Xr curses_scroll 3
.It scrollok Ta Xr curses_scroll 3
+.It set_escdelay Ta Xr curses_input 3
+.It set_tabsize Ta Xr curses_screen 3
.It set_term Ta Xr curses_screen 3
.It setscrreg Ta Xr curses_scroll 3
.It setterm Ta Xr curses_screen 3
@@ -309,6 +311,9 @@ The maximum delay in milliseconds betwee
keystrokes (such are arrow keys) where the adjacent characters are considered
part of the same multi-character sequence.
The default is 300 milliseconds.
+.It TABSIZE
+The number of spaces making up a tab.
+The default is 8 if not specified by the terminal description.
.It LINES
The number of lines in the terminal if set.
is usually automatically configured by querying the kernel.
Index: src/lib/libcurses/curses.h
diff -u src/lib/libcurses/curses.h:1.115 src/lib/libcurses/curses.h:1.116
--- src/lib/libcurses/curses.h:1.115 Wed Jan 4 03:51:29 2017
+++ src/lib/libcurses/curses.h Thu Jan 5 20:31:37 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: curses.h,v 1.115 2017/01/04 03:51:29 roy Exp $ */
+/* $NetBSD: curses.h,v 1.116 2017/01/05 20:31:37 roy Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -749,6 +749,8 @@ int scanw(const char *, ...) __scanflik
int scroll(WINDOW *);
int scrollok(WINDOW *, bool);
int setterm(char *);
+int set_escdelay(int);
+int set_tabsize(int);
SCREEN *set_term(SCREEN *);
int start_color(void);
WINDOW *subpad(WINDOW *, int, int, int, int);
Index: src/lib/libcurses/curses_input.3
diff -u src/lib/libcurses/curses_input.3:1.23 src/lib/libcurses/curses_input.3:1.24
--- src/lib/libcurses/curses_input.3:1.23 Sun Jan 1 03:06:06 2017
+++ src/lib/libcurses/curses_input.3 Thu Jan 5 20:31:37 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: curses_input.3,v 1.23 2017/01/01 03:06:06 roy Exp $
+.\" $NetBSD: curses_input.3,v 1.24 2017/01/05 20:31:37 roy Exp $
.\"
.\" Copyright (c) 2002
.\" Brett Lymn ([email protected], [email protected])
@@ -55,7 +55,8 @@
.Nm timeout ,
.Nm wtimeout ,
.Nm nodelay ,
-.Nm ungetch
+.Nm ungetch ,
+.Nm set_escdelay
.Nd curses input stream routines
.Sh LIBRARY
.Lb libcurses
@@ -103,6 +104,8 @@
.Fn nodelay "WINDOW *win" "boolf flag"
.Ft int
.Fn ungetch "int c"
+.Ft int
+.Fn set_escdelay "int escdelay"
.Pp
.Va extern int ESCDELAY ;
.Sh DESCRIPTION
@@ -385,6 +388,13 @@ will convert
into an unsigned char and push that character back onto the input stream.
Only one character of push-back is guaranteed to work, more may be possible
depending on system resources.
+.Pp
+The
+.Fn set_escdelay
+function sets the
+.Va ESCDELAY
+value of the current screen to
+.Fa escdelay.
.Sh RETURN VALUES
The functions
.Fn getch ,
@@ -592,3 +602,10 @@ Portable implementations should avoid th
.Sh HISTORY
The Curses package appeared in
.Bx 4.0 .
+The
+.Fn set_tabsize
+function is a
+.Em ncurses
+extension to the Curses library and was added in
+.Nx 8.0 .
+
Index: src/lib/libcurses/curses_private.h
diff -u src/lib/libcurses/curses_private.h:1.55 src/lib/libcurses/curses_private.h:1.56
--- src/lib/libcurses/curses_private.h:1.55 Tue Jan 3 12:42:06 2017
+++ src/lib/libcurses/curses_private.h Thu Jan 5 20:31:37 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: curses_private.h,v 1.55 2017/01/03 12:42:06 roy Exp $ */
+/* $NetBSD: curses_private.h,v 1.56 2017/01/05 20:31:37 roy Exp $ */
/*-
* Copyright (c) 1998-2000 Brett Lymn
@@ -201,7 +201,10 @@ struct __screen {
int lx, ly; /* loop parameters for refresh */
int COLS; /* Columns on the screen. */
int LINES; /* Lines on the screen. */
+ int ESCDELAY; /* Delay between keys in esc seq's. */
+#define ESCDELAY_DEFAULT 300 /* milliseconds. */
int TABSIZE; /* Size of a tab. */
+#define TABSIZE_DEFAULT 8 /* spaces. */
int COLORS; /* Maximum colors on the screen */
int COLOR_PAIRS; /* Maximum color pairs on the screen */
int My_term; /* Use Def_term regardless. */
Index: src/lib/libcurses/curses_screen.3
diff -u src/lib/libcurses/curses_screen.3:1.19 src/lib/libcurses/curses_screen.3:1.20
--- src/lib/libcurses/curses_screen.3:1.19 Thu Jan 5 12:35:41 2017
+++ src/lib/libcurses/curses_screen.3 Thu Jan 5 20:31:37 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: curses_screen.3,v 1.19 2017/01/05 12:35:41 wiz Exp $
+.\" $NetBSD: curses_screen.3,v 1.20 2017/01/05 20:31:37 roy Exp $
.\"
.\" Copyright (c) 2002
.\" Brett Lymn ([email protected], [email protected])
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\"
-.Dd December 30, 2016
+.Dd January 5, 2017
.Dt CURSES_SCREEN 3
.Os
.Sh NAME
@@ -44,7 +44,8 @@
.Nm initscr ,
.Nm isendwin ,
.Nm resizeterm ,
-.Nm setterm
+.Nm setterm ,
+.Nm set_tabsize
.Nd curses terminal and screen routines
.Sh LIBRARY
.Lb libcurses
@@ -70,6 +71,8 @@
.Fn resizeterm "int lines" "int cols"
.Ft int
.Fn setterm "char *name"
+.Ft int
+.Fn set_tabsize "int value"
.Pp
.Va extern int LINES ;
.Pp
@@ -209,6 +212,13 @@ must precede calls to
.Fn newterm ,
or
.Fn setupterm .
+.Pp
+The
+.Fn set_tabsize
+function will set
+.Va TABSIZE
+of the current screen to
+.Va tabsize .
.Sh RETURN VALUES
Functions returning pointers will return
.Dv NULL
@@ -241,3 +251,9 @@ function is a
.Em ncurses
extension to the Curses library and was added in
.Nx 1.6 .
+The
+.Fn set_tabsize
+function is a
+.Em ncurses
+extension to the Curses library and was added in
+.Nx 8.0 .
Index: src/lib/libcurses/get_wch.c
diff -u src/lib/libcurses/get_wch.c:1.10 src/lib/libcurses/get_wch.c:1.11
--- src/lib/libcurses/get_wch.c:1.10 Fri Jun 29 10:40:29 2012
+++ src/lib/libcurses/get_wch.c Thu Jan 5 20:31:37 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: get_wch.c,v 1.10 2012/06/29 10:40:29 blymn Exp $ */
+/* $NetBSD: get_wch.c,v 1.11 2017/01/05 20:31:37 roy Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: get_wch.c,v 1.10 2012/06/29 10:40:29 blymn Exp $");
+__RCSID("$NetBSD: get_wch.c,v 1.11 2017/01/05 20:31:37 roy Exp $");
#endif /* not lint */
#include <string.h>
@@ -91,6 +91,7 @@ inkey(wchar_t *wc, int to, int delay)
*working = &_cursesi_screen->cbuf_cur,
*end = &_cursesi_screen->cbuf_tail;
char *inbuf = &_cursesi_screen->cbuf[ 0 ];
+ int escdelay = _cursesi_screen->ESCDELAY;
#ifdef DEBUG
__CTRACE(__CTRACE_INPUT, "inkey (%p, %d, %d)\n", wc, to, delay);
@@ -139,11 +140,11 @@ inkey(wchar_t *wc, int to, int delay)
} else if (wstate == INKEY_ASSEMBLING) {
/* assembling a key sequence */
if (delay) {
- if (__timeout(to ? (ESCDELAY / 100) : delay)
+ if (__timeout(to ? (escdelay / 100) : delay)
== ERR)
return ERR;
} else {
- if (to && (__timeout(ESCDELAY / 100) == ERR))
+ if (to && (__timeout(escdelay / 100) == ERR))
return ERR;
}
@@ -189,11 +190,11 @@ inkey(wchar_t *wc, int to, int delay)
} else if (wstate == INKEY_WCASSEMBLING) {
/* assembling a wide-char sequence */
if (delay) {
- if (__timeout(to ? (ESCDELAY / 100) : delay)
+ if (__timeout(to ? (escdelay / 100) : delay)
== ERR)
return ERR;
} else {
- if (to && (__timeout(ESCDELAY / 100) == ERR))
+ if (to && (__timeout(escdelay / 100) == ERR))
return ERR;
}
Index: src/lib/libcurses/getch.c
diff -u src/lib/libcurses/getch.c:1.60 src/lib/libcurses/getch.c:1.61
--- src/lib/libcurses/getch.c:1.60 Sun Jan 1 03:06:06 2017
+++ src/lib/libcurses/getch.c Thu Jan 5 20:31:37 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: getch.c,v 1.60 2017/01/01 03:06:06 roy Exp $ */
+/* $NetBSD: getch.c,v 1.61 2017/01/05 20:31:37 roy Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)getch.c 8.2 (Berkeley) 5/4/94";
#else
-__RCSID("$NetBSD: getch.c,v 1.60 2017/01/01 03:06:06 roy Exp $");
+__RCSID("$NetBSD: getch.c,v 1.61 2017/01/05 20:31:37 roy Exp $");
#endif
#endif /* not lint */
@@ -203,7 +203,7 @@ static const struct tcdata tc[] = {
/* Number of TC entries .... */
static const int num_tcs = (sizeof(tc) / sizeof(struct tcdata));
-int ESCDELAY = 300; /* Delay in ms between keys for esc seq's */
+int ESCDELAY; /* Delay in ms between keys for esc seq's */
/* Key buffer */
#define INBUF_SZ 16 /* size of key buffer - must be larger than
@@ -550,6 +550,7 @@ inkey(int to, int delay)
int c, mapping;
keymap_t *current = _cursesi_screen->base_keymap;
FILE *infd = _cursesi_screen->infd;
+ int escdelay = _cursesi_screen->ESCDELAY;
k = 0; /* XXX gcc -Wuninitialized */
@@ -595,11 +596,11 @@ reread:
} else if (state == INKEY_ASSEMBLING) {
/* assembling a key sequence */
if (delay) {
- if (__timeout(to ? (ESCDELAY / 100) : delay)
+ if (__timeout(to ? (escdelay / 100) : delay)
== ERR)
return ERR;
} else {
- if (to && (__timeout(ESCDELAY / 100) == ERR))
+ if (to && (__timeout(escdelay / 100) == ERR))
return ERR;
}
@@ -977,3 +978,16 @@ has_key(int key_type)
do_keyok(_cursesi_screen->base_keymap, key_type, false, false, &result);
return result;
}
+
+/*
+ * set_escdelay --
+ * Sets the escape delay for the current screen.
+ */
+int
+set_escdelay(int escdelay)
+{
+
+ _cursesi_screen->ESCDELAY = escdelay;
+ ESCDELAY = escdelay;
+ return OK;
+}
Index: src/lib/libcurses/setterm.c
diff -u src/lib/libcurses/setterm.c:1.56 src/lib/libcurses/setterm.c:1.57
--- src/lib/libcurses/setterm.c:1.56 Sat Dec 31 17:46:35 2016
+++ src/lib/libcurses/setterm.c Thu Jan 5 20:31:37 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: setterm.c,v 1.56 2016/12/31 17:46:35 roy Exp $ */
+/* $NetBSD: setterm.c,v 1.57 2017/01/05 20:31:37 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.56 2016/12/31 17:46:35 roy Exp $");
+__RCSID("$NetBSD: setterm.c,v 1.57 2017/01/05 20:31:37 roy Exp $");
#endif
#endif /* not lint */
@@ -134,13 +134,15 @@ _cursesi_setterm(char *type, SCREEN *scr
screen->COLS = (int) strtol(p, NULL, 0);
}
if ((p = getenv("ESCDELAY")) != NULL)
- ESCDELAY = (int) strtol(p, NULL, 0);
+ screen->ESCDELAY = (int) strtol(p, NULL, 0);
+ else
+ screen->ESCDELAY = ESCDELAY_DEFAULT;
if ((p = getenv("TABSIZE")) != NULL)
screen->TABSIZE = (int) strtol(p, NULL, 0);
else if (t_init_tabs(screen->term) >= 0)
screen->TABSIZE = (int) t_init_tabs(screen->term);
else
- screen->TABSIZE = 8;
+ screen->TABSIZE = TABSIZE_DEFAULT;
/*
* Want cols > 4, otherwise things will fail.
*/
@@ -149,6 +151,7 @@ _cursesi_setterm(char *type, SCREEN *scr
LINES = screen->LINES;
COLS = screen->COLS;
+ ESCDELAY = screen->ESCDELAY;
TABSIZE = screen->TABSIZE;
#ifdef DEBUG
@@ -280,6 +283,7 @@ _cursesi_resetterm(SCREEN *screen)
LINES = screen->LINES;
COLS = screen->COLS;
+ ESCDELAY = screen->ESCDELAY;
TABSIZE = screen->TABSIZE;
__GT = screen->GT;
@@ -389,3 +393,16 @@ does_ctrl_o(const char *exit_cap, const
}
return 0;
}
+
+/*
+ * set_tabsize --
+ * Sets the tabsize for the current screen.
+ */
+int
+set_tabsize(int tabsize)
+{
+
+ _cursesi_screen->TABSIZE = tabsize;
+ TABSIZE = tabsize;
+ return OK;
+}