summaryrefslogtreecommitdiffstats
path: root/enter.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>2000-05-17 09:06:38 +0000
committerThomas Roessler <roessler@does-not-exist.org>2000-05-17 09:06:38 +0000
commit8e118e11134c1af2141df87862eedd9a05d220c5 (patch)
tree47576341aa1f715a49898776040c1c7cf4df071e /enter.c
parenta8b89f675fa7087e010281940cd6e5c49833ec52 (diff)
Add forward-word and backward-word functions to the editor.
Diffstat (limited to 'enter.c')
-rw-r--r--enter.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/enter.c b/enter.c
index 63bb1b60..a9307223 100644
--- a/enter.c
+++ b/enter.c
@@ -277,6 +277,60 @@ int _mutt_enter_string (unsigned char *buf, size_t buflen, int y, int x,
}
}
break;
+ case OP_EDITOR_BACKWARD_WORD:
+ if (curpos == 0)
+ {
+ BEEP ();
+ }
+ else
+ {
+ if (curpos > 0 && !ISSPACE (buf[curpos]) && ISSPACE (buf[curpos - 1]))
+ curpos--;
+ while (curpos > 0 && ISSPACE (buf[curpos]))
+ curpos--;
+ while (curpos > 0 && !ISSPACE (buf[curpos]))
+ curpos--;
+ if (ISSPACE (buf[curpos]) && !ISSPACE (buf[curpos + 1]))
+ curpos++;
+
+ if (!pass)
+ {
+ if (curpos < begin)
+ {
+ begin = curpos - width/2;
+ redraw = M_REDRAW_LINE;
+ }
+ else
+ move (y, x + curpos - begin);
+ }
+ }
+ break;
+
+ case OP_EDITOR_FORWARD_WORD:
+ if (curpos == lastchar)
+ {
+ BEEP ();
+ }
+ else
+ {
+ while (curpos < lastchar && ISSPACE (buf[curpos]))
+ curpos++;
+ while (curpos < lastchar && !ISSPACE (buf[curpos]))
+ curpos++;
+
+ if (!pass)
+ {
+ if (curpos >= begin + width)
+ {
+ begin = curpos - width / 2;
+ redraw = M_REDRAW_LINE;
+ }
+ else
+ move (y, x + curpos - begin);
+ }
+ }
+ break;
+
case OP_EDITOR_DELETE_CHAR:
if (curpos != lastchar)
{