Commit 8e118e11 authored by Thomas Roessler's avatar Thomas Roessler

Add forward-word and backward-word functions to the editor.

parent a8b89f67
......@@ -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"
......
......@@ -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)
{
......
......@@ -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 }
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment