summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-22 06:08:50 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-22 06:08:50 -0700
commit206f432b1b5811c99ecf5f14a914de8da37277c0 (patch)
treec14930e3690021bcf14474042b020e6b51c9067d
parentd0c25e3cb12f6905a68952b0eeb9c17f6edcee48 (diff)
downloadtxr-206f432b1b5811c99ecf5f14a914de8da37277c0.tar.gz
txr-206f432b1b5811c99ecf5f14a914de8da37277c0.tar.bz2
txr-206f432b1b5811c99ecf5f14a914de8da37277c0.zip
linenoise: forward paren jump too.
* linenoise/linenoise.c (paren_jump): Scan forward also, if reverse scan turns up nothing, thereby jumping to a closing parenthesis in the forward direction. * txr.1: Documentation updated.
-rw-r--r--linenoise/linenoise.c4
-rw-r--r--txr.112
2 files changed, 14 insertions, 2 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c
index 7dd29aa5..1a16ac7c 100644
--- a/linenoise/linenoise.c
+++ b/linenoise/linenoise.c
@@ -1118,6 +1118,9 @@ static void paren_jump(lino_t *l)
{
size_t pos = scan_rev(l->data, l->dpos - 1);
+ if (pos == -1)
+ pos = scan_fwd(l->data, l->dpos - 1);
+
if (pos != -1) {
size_t dp = l->dpos;
l->dpos = pos;
@@ -1840,6 +1843,7 @@ static int edit(lino_t *l, const char *prompt)
}
break;
case ')': case ']': case '}':
+ case '(': case '[': case '{':
if (edit_insert(l,c)) {
l->error = lino_ioerr;
goto out;
diff --git a/txr.1 b/txr.1
index 273dd533..18fd43d0 100644
--- a/txr.1
+++ b/txr.1
@@ -34126,12 +34126,20 @@ When any of the three closing characters
or
.code }
is inserted, the listener scans backward for the matching opening
-character. If the matching character is found, the cursor jumps to that
+character. Likewise, if any of the three opening characters
+.codn ( ,
+.codn [
+or
+.code {
+is inserted in the middle of text, the listener scans forward for the matching
+closing character.
+
+If the matching character is found, the cursor jumps to that
character and then returns to the original position a brief moment later. If a
new character is typed during the brief time delay, the delay is immediately
canceled, so as not to hinder rapid typing.
-Note that the backward matching is unsophisticated; it doesn't observe the
+Note that the matching is unsophisticated; it doesn't observe the
lexical conventions and syntax of the \*(TL programming language. For
instance, a closing parenthesis outside a string literal may match
match an opening one inside a string literal.