summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-05-03 20:43:13 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-05-03 20:43:13 +0000
commit3f101cbfb74adfdb46934aea06cc4c3885f25f0f (patch)
tree2d9f5da69008a49ed309c4e798f600328119252f
parentee4fabc5c39065b30e24a2d63196cb833b73278c (diff)
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;