]> granicus.if.org Git - neomutt/commitdiff
Add forward-word and backward-word functions to the editor.
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 17 May 2000 09:06:38 +0000 (09:06 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 17 May 2000 09:06:38 +0000 (09:06 +0000)
OPS
enter.c
functions.h

diff --git a/OPS b/OPS
index 91e0a783172d1eeec6ce39fd1ef0b6bce11e8bb1..76aabce035c9209354acc58f991e6946f6b6fa2f 100644 (file)
--- a/OPS
+++ b/OPS
@@ -57,6 +57,7 @@ OP_DISPLAY_MESSAGE "display a message"
 OP_EDIT_MESSAGE "edit the raw message"
 OP_EDITOR_BACKSPACE "delete the char in front of the cursor"
 OP_EDITOR_BACKWARD_CHAR "move the cursor one character to the left"
+OP_EDITOR_BACKWARD_WORD "move the cursor to the beginning of the word"
 OP_EDITOR_BOL "jump to the beginning of the line"
 OP_EDITOR_BUFFY_CYCLE "cycle among incoming mailboxes"
 OP_EDITOR_COMPLETE "complete filename or alias"
@@ -64,6 +65,7 @@ OP_EDITOR_COMPLETE_QUERY "complete address with query"
 OP_EDITOR_DELETE_CHAR "delete the char under the cursor"
 OP_EDITOR_EOL "jump to the end of the line"
 OP_EDITOR_FORWARD_CHAR "move the cursor one character to the right"
+OP_EDITOR_FORWARD_WORD "move the cursor to the end of the word"
 OP_EDITOR_HISTORY_DOWN "scroll up through the history list"
 OP_EDITOR_HISTORY_UP "scroll up through the history list"
 OP_EDITOR_KILL_EOL "delete chars from cursor to end of line"
diff --git a/enter.c b/enter.c
index 63bb1b6058e95c22dc6839f2eec5b04e9541d7ef..a9307223aaa88eb8286585ad29bed2fbf664b276 100644 (file)
--- 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)
          {
index 04849decf2adaa6ca69bc5264203e56f5bfdd57d..4b9e762e58f6a93a56b3edede667bb0d96c9f757 100644 (file)
@@ -352,22 +352,24 @@ struct binding_t OpQuery[] = {
 struct binding_t OpEditor[] = {
   { "bol",             OP_EDITOR_BOL,                  "\001" },
   { "backward-char",   OP_EDITOR_BACKWARD_CHAR,        "\002" },
+  { "backward-word",   OP_EDITOR_BACKWARD_WORD,        "\033b"},
   { "delete-char",     OP_EDITOR_DELETE_CHAR,          "\004" },
   { "eol",             OP_EDITOR_EOL,                  "\005" },
   { "forward-char",    OP_EDITOR_FORWARD_CHAR,         "\006" },
+  { "forward-word",    OP_EDITOR_FORWARD_WORD,         "\033f"},
   { "backspace",       OP_EDITOR_BACKSPACE,            "\010" },
   { "kill-eol",                OP_EDITOR_KILL_EOL,             "\013" },
-  { "kill-eow",                OP_EDITOR_KILL_EOW,             "\033d" },
+  { "kill-eow",                OP_EDITOR_KILL_EOW,             "\033d"},
   { "kill-line",       OP_EDITOR_KILL_LINE,            "\025" },
   { "quote-char",      OP_EDITOR_QUOTE_CHAR,           "\026" },
   { "kill-word",       OP_EDITOR_KILL_WORD,            "\027" },
-  { "complete",                OP_EDITOR_COMPLETE,             "\t" },
+  { "complete",                OP_EDITOR_COMPLETE,             "\t"   },
   { "complete-query",  OP_EDITOR_COMPLETE_QUERY,       "\024" },
-  { "buffy-cycle",     OP_EDITOR_BUFFY_CYCLE,          " " },
-  { "history-up",      OP_EDITOR_HISTORY_UP,           NULL },
-  { "history-down",    OP_EDITOR_HISTORY_DOWN,         NULL },
-  { "transpose-chars", OP_EDITOR_TRANSPOSE_CHARS,      NULL },
-  { NULL,              0,                              NULL }
+  { "buffy-cycle",     OP_EDITOR_BUFFY_CYCLE,          " "    },
+  { "history-up",      OP_EDITOR_HISTORY_UP,           NULL   },
+  { "history-down",    OP_EDITOR_HISTORY_DOWN,         NULL   },
+  { "transpose-chars", OP_EDITOR_TRANSPOSE_CHARS,      NULL   },
+  { NULL,              0,                              NULL   }
 };