From 8e118e11134c1af2141df87862eedd9a05d220c5 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Wed, 17 May 2000 09:06:38 +0000 Subject: Add forward-word and backward-word functions to the editor. --- enter.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'enter.c') 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) { -- cgit v1.2.3