Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libcurses Add ESCDELAY variable to control the inter-key...
details: https://anonhg.NetBSD.org/src/rev/7c966ca8628b
branches: trunk
changeset: 545425:7c966ca8628b
user: jdc <jdc%NetBSD.org@localhost>
date: Tue Apr 08 18:55:43 2003 +0000
description:
Add ESCDELAY variable to control the inter-key delay in escape sequences.
Fixes PR 20031 by Thomas Klausner.
diffstat:
lib/libcurses/curses.h | 4 +++-
lib/libcurses/curses_input.3 | 15 ++++++++++++---
lib/libcurses/getch.c | 16 ++++++++--------
3 files changed, 23 insertions(+), 12 deletions(-)
diffs (118 lines):
diff -r 5304d5ef48fc -r 7c966ca8628b lib/libcurses/curses.h
--- a/lib/libcurses/curses.h Tue Apr 08 18:16:01 2003 +0000
+++ b/lib/libcurses/curses.h Tue Apr 08 18:55:43 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: curses.h,v 1.73 2003/03/30 07:38:42 jdc Exp $ */
+/* $NetBSD: curses.h,v 1.74 2003/04/08 18:55:43 jdc Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -312,6 +312,8 @@
extern int COLORS; /* Max colours on the screen. */
extern int COLOR_PAIRS; /* Max colour pairs on the screen. */
+extern int ESCDELAY; /* Delay between keys in esc seq's. */
+
#define ERR (0) /* Error return. */
#define OK (1) /* Success return. */
diff -r 5304d5ef48fc -r 7c966ca8628b lib/libcurses/curses_input.3
--- a/lib/libcurses/curses_input.3 Tue Apr 08 18:16:01 2003 +0000
+++ b/lib/libcurses/curses_input.3 Tue Apr 08 18:55:43 2003 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: curses_input.3,v 1.7 2003/02/14 16:29:11 grant Exp $
+.\" $NetBSD: curses_input.3,v 1.8 2003/04/08 18:55:43 jdc Exp $
.\"
.\" Copyright (c) 2002
.\" Brett Lymn (blymn%NetBSD.org@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\"
-.Dd August 12, 2002
+.Dd April 8, 2003
.Dt CURSES_INPUT 3
.Os
.Sh NAME
@@ -94,6 +94,8 @@
.Fn nodelay "WINDOW *win" "boolf flag"
.Ft int
.Fn ungetch "int c"
+.Ft extern int
+.Dv ESCDELAY
.Sh DESCRIPTION
These functions read characters and strings from the window input file
descriptor.
@@ -275,7 +277,8 @@
is
.Dv FALSE ,
then the component characters of a multi-character sequence must not
-have an inter-character gap of more than 200ms.
+have an inter-character gap of more than
+.Dv ESCDELAY .
If this timing is exceeded, then the multi-character key assembly is
deemed to have failed and the characters read thus far are returned
one at a time when
@@ -283,6 +286,12 @@
is called.
The default setting for the flag is
.Dv FALSE .
+The default value of
+.Dv ESCDELAY
+is 300ms. If
+.Dv ESCDELAY
+is negative, no timeout applied between characters comprising a
+multi-character key sequence.
.Pp
The
.Fn timeout
diff -r 5304d5ef48fc -r 7c966ca8628b lib/libcurses/getch.c
--- a/lib/libcurses/getch.c Tue Apr 08 18:16:01 2003 +0000
+++ b/lib/libcurses/getch.c Tue Apr 08 18:55:43 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getch.c,v 1.40 2003/04/05 10:06:59 jdc Exp $ */
+/* $NetBSD: getch.c,v 1.41 2003/04/08 18:55:43 jdc Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getch.c 8.2 (Berkeley) 5/4/94";
#else
-__RCSID("$NetBSD: getch.c,v 1.40 2003/04/05 10:06:59 jdc Exp $");
+__RCSID("$NetBSD: getch.c,v 1.41 2003/04/08 18:55:43 jdc Exp $");
#endif
#endif /* not lint */
@@ -49,7 +49,7 @@
#include "curses.h"
#include "curses_private.h"
-#define DEFAULT_DELAY 3 /* default delay for timeout() */
+int ESCDELAY=300; /* Delay in ms between keys for esc seq's */
/*
* Keyboard input handler. Do this by snarfing
@@ -629,17 +629,17 @@
* out of keys in the
* backlog */
- /* if we have then switch to
- assembling */
+ /* if we have then switch to assembling */
state = INKEY_ASSEMBLING;
}
} else if (state == INKEY_ASSEMBLING) {
/* assembling a key sequence */
if (delay) {
- if (__timeout(to ? DEFAULT_DELAY : delay) == ERR)
- return ERR;
+ if (__timeout(to ? (ESCDELAY / 100) : delay)
+ == ERR)
+ return ERR;
} else {
- if (to && (__timeout(DEFAULT_DELAY) == ERR))
+ if (to && (__timeout(ESCDELAY / 100) == ERR))
return ERR;
}
Home |
Main Index |
Thread Index |
Old Index