summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorart <art@openbsd.org>2001-05-03 20:43:12 +0000
committerart <art@openbsd.org>2001-05-03 20:43:12 +0000
commit8cd8f944d71ef3c6a03c0e3df53b88df61a4ddcc (patch)
tree8c01eed449e65a54b31028d4ef1d0efbc17e617f
parentAdd a delay (in miliseconds) argument to ttwait. (diff)
downloadwireguard-openbsd-8cd8f944d71ef3c6a03c0e3df53b88df61a4ddcc.tar.xz
wireguard-openbsd-8cd8f944d71ef3c6a03c0e3df53b88df61a4ddcc.zip
Fix another annoying feature in mg. When I try to use the keypad to
escape from I-search (I don't know if it's legal, but it works in emacs) the initial ESC in the sequence is caugth by I-search (which exits), but not the rest of it which ends up written into the buffer. This is extra annoying when we don't have undo. Note that this is better than emacs because the ESC is removed if nothing indicating a multi-char sequence comes within 300 miliseconds. (Try to ESC from I-search in emacs and then press 'x').
-rw-r--r--usr.bin/mg/search.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/mg/search.c b/usr.bin/mg/search.c
index b4b67e2c69d..1d8d22ab233 100644
--- a/usr.bin/mg/search.c
+++ b/usr.bin/mg/search.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: search.c,v 1.4 2001/01/29 01:58:09 niklas Exp $ */
+/* $OpenBSD: search.c,v 1.5 2001/05/03 20:43:12 art Exp $ */
/*
* Search commands.
@@ -190,6 +190,14 @@ isearch(dir)
switch (c = getkey(FALSE)) {
case CCHR('['):
+ /*
+ * If new characters come in the next 300 msec,
+ * we can assume that they belong to a longer
+ * escaped sequence so we should ungetkey the
+ * ESC to avoid writing out garbage.
+ */
+ if (ttwait(300) == FALSE)
+ ungetkey(c);
srch_lastdir = dir;
curwp->w_markp = clp;
curwp->w_marko = cbo;