summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--linenoise/linenoise.c36
-rw-r--r--txr.14
2 files changed, 34 insertions, 6 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c
index 9319d52c..552b9183 100644
--- a/linenoise/linenoise.c
+++ b/linenoise/linenoise.c
@@ -1267,17 +1267,41 @@ static void edit_move_right(lino_t *l) {
/* Move cursor to the start of the line. */
static void edit_move_home(lino_t *l) {
- if (l->dpos != 0) {
- l->dpos = 0;
- l->need_refresh = 1;
+ if (!l->mlmode) {
+ if (l->dpos != 0) {
+ l->dpos = 0;
+ l->need_refresh = 1;
+ }
+ } else {
+ size_t dpos = l->dpos;
+
+ while (dpos > 0 && l->data[dpos-1] != '\r')
+ dpos--;
+
+ if (l->dpos != dpos) {
+ l->dpos = dpos;
+ l->need_refresh = 1;
+ }
}
}
/* Move cursor to the end of the line. */
static void edit_move_end(lino_t *l) {
- if (l->dpos != l->dlen) {
- l->dpos = l->dlen;
- l->need_refresh = 1;
+ if (!l->mlmode) {
+ if (l->dpos != l->dlen) {
+ l->dpos = l->dlen;
+ l->need_refresh = 1;
+ }
+ } else {
+ size_t dpos = l->dpos;
+
+ dpos += strspn(l->data + dpos, "\r");
+ dpos += strcspn(l->data + dpos, "\r");
+
+ if (l->dpos != dpos) {
+ l->dpos = dpos;
+ l->need_refresh = 1;
+ }
}
}
diff --git a/txr.1 b/txr.1
index 8ed59dbf..6eb155c4 100644
--- a/txr.1
+++ b/txr.1
@@ -33600,6 +33600,10 @@ such that the last character of the line is to the left of the cursor
position. On terminals which have the Home and End keys, these may also
be used instead of Ctrl-A and Ctrl-E.
+In multi-line mode, these commands jump to the beginning or end of the
+current physical line. In line mode, they move to the beginning or end of the
+edit buffer.
+
.NP* Jump to Matching Parenthesis
If the cursor is on an opening or closing parenthesis, brace or bracket,