aboutsummaryrefslogtreecommitdiff
path: root/config.def.h
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-10-26 14:34:48 +0100
committerMarc André Tanner <mat@brain-dump.org>2015-10-26 15:04:43 +0100
commit7bf93d00b0e40e0ba5b9c45e3be43985555c3f6c (patch)
tree3bab643693cd3006028a8df87f202ea762b98be9 /config.def.h
parente912a488cbb9065700316ff0f34cde183c90cbfc (diff)
downloadvis-7bf93d00b0e40e0ba5b9c45e3be43985555c3f6c.tar.gz
vis-7bf93d00b0e40e0ba5b9c45e3be43985555c3f6c.tar.xz
vis: move key handling functions to main.c
Diffstat (limited to 'config.def.h')
-rw-r--r--config.def.h1199
1 files changed, 5 insertions, 1194 deletions
diff --git a/config.def.h b/config.def.h
index 722dc07..f0c6508 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,963 +1,7 @@
-/** start by reading from the top of vis.c up until config.h is included */
-
-static Mode vis_modes[VIS_MODE_LAST];
-
-/* command recognized at the ':'-prompt. commands are found using a unique
- * prefix match. that is if a command should be available under an abbreviation
- * which is a prefix for another command it has to be added as an alias. the
- * long human readable name should always come first */
-static Command cmds[] = {
- /* command name / optional alias, function, options */
- { { "bdelete" }, cmd_bdelete, CMD_OPT_FORCE },
- { { "edit" }, cmd_edit, CMD_OPT_FORCE },
- { { "help" }, cmd_help, CMD_OPT_NONE },
- { { "new" }, cmd_new, CMD_OPT_NONE },
- { { "open" }, cmd_open, CMD_OPT_NONE },
- { { "qall" }, cmd_qall, CMD_OPT_FORCE },
- { { "quit", "q" }, cmd_quit, CMD_OPT_FORCE },
- { { "read", }, cmd_read, CMD_OPT_FORCE },
- { { "saveas" }, cmd_saveas, CMD_OPT_FORCE },
- { { "set", }, cmd_set, CMD_OPT_ARGS },
- { { "split" }, cmd_split, CMD_OPT_NONE },
- { { "substitute", "s" }, cmd_substitute, CMD_OPT_NONE },
- { { "vnew" }, cmd_vnew, CMD_OPT_NONE },
- { { "vsplit", }, cmd_vsplit, CMD_OPT_NONE },
- { { "wq", }, cmd_wq, CMD_OPT_FORCE },
- { { "write", "w" }, cmd_write, CMD_OPT_FORCE },
- { { "xit", }, cmd_xit, CMD_OPT_FORCE },
- { { "earlier" }, cmd_earlier_later, CMD_OPT_NONE },
- { { "later" }, cmd_earlier_later, CMD_OPT_NONE },
- { { "!", }, cmd_filter, CMD_OPT_NONE },
- { /* array terminator */ },
-};
-
+/** configure your desired default key bindings */
#define ALIAS(name) .alias = name,
#define ACTION(id) .action = &vis_action[VIS_ACTION_##id],
-enum {
- VIS_ACTION_EDITOR_SUSPEND,
- VIS_ACTION_CURSOR_CHAR_PREV,
- VIS_ACTION_CURSOR_CHAR_NEXT,
- VIS_ACTION_CURSOR_WORD_START_PREV,
- VIS_ACTION_CURSOR_WORD_START_NEXT,
- VIS_ACTION_CURSOR_WORD_END_PREV,
- VIS_ACTION_CURSOR_WORD_END_NEXT,
- VIS_ACTION_CURSOR_LONGWORD_START_PREV,
- VIS_ACTION_CURSOR_LONGWORD_START_NEXT,
- VIS_ACTION_CURSOR_LONGWORD_END_PREV,
- VIS_ACTION_CURSOR_LONGWORD_END_NEXT,
- VIS_ACTION_CURSOR_LINE_UP,
- VIS_ACTION_CURSOR_LINE_DOWN,
- VIS_ACTION_CURSOR_LINE_START,
- VIS_ACTION_CURSOR_LINE_FINISH,
- VIS_ACTION_CURSOR_LINE_BEGIN,
- VIS_ACTION_CURSOR_LINE_END,
- VIS_ACTION_CURSOR_SCREEN_LINE_UP,
- VIS_ACTION_CURSOR_SCREEN_LINE_DOWN,
- VIS_ACTION_CURSOR_SCREEN_LINE_BEGIN,
- VIS_ACTION_CURSOR_SCREEN_LINE_MIDDLE,
- VIS_ACTION_CURSOR_SCREEN_LINE_END,
- VIS_ACTION_CURSOR_BRACKET_MATCH,
- VIS_ACTION_CURSOR_PARAGRAPH_PREV,
- VIS_ACTION_CURSOR_PARAGRAPH_NEXT,
- VIS_ACTION_CURSOR_SENTENCE_PREV,
- VIS_ACTION_CURSOR_SENTENCE_NEXT,
- VIS_ACTION_CURSOR_FUNCTION_START_PREV,
- VIS_ACTION_CURSOR_FUNCTION_END_PREV,
- VIS_ACTION_CURSOR_FUNCTION_START_NEXT,
- VIS_ACTION_CURSOR_FUNCTION_END_NEXT,
- VIS_ACTION_CURSOR_COLUMN,
- VIS_ACTION_CURSOR_LINE_FIRST,
- VIS_ACTION_CURSOR_LINE_LAST,
- VIS_ACTION_CURSOR_WINDOW_LINE_TOP,
- VIS_ACTION_CURSOR_WINDOW_LINE_MIDDLE,
- VIS_ACTION_CURSOR_WINDOW_LINE_BOTTOM,
- VIS_ACTION_CURSOR_SEARCH_FORWARD,
- VIS_ACTION_CURSOR_SEARCH_BACKWARD,
- VIS_ACTION_CURSOR_SEARCH_WORD_FORWARD,
- VIS_ACTION_CURSOR_SEARCH_WORD_BACKWARD,
- VIS_ACTION_WINDOW_PAGE_UP,
- VIS_ACTION_WINDOW_PAGE_DOWN,
- VIS_ACTION_WINDOW_HALFPAGE_UP,
- VIS_ACTION_WINDOW_HALFPAGE_DOWN,
- VIS_ACTION_MODE_NORMAL,
- VIS_ACTION_MODE_VISUAL,
- VIS_ACTION_MODE_VISUAL_LINE,
- VIS_ACTION_MODE_INSERT,
- VIS_ACTION_MODE_REPLACE,
- VIS_ACTION_MODE_OPERATOR_PENDING,
- VIS_ACTION_DELETE_CHAR_PREV,
- VIS_ACTION_DELETE_CHAR_NEXT,
- VIS_ACTION_DELETE_LINE_BEGIN,
- VIS_ACTION_DELETE_WORD_PREV,
- VIS_ACTION_JUMPLIST_PREV,
- VIS_ACTION_JUMPLIST_NEXT,
- VIS_ACTION_CHANGELIST_PREV,
- VIS_ACTION_CHANGELIST_NEXT,
- VIS_ACTION_UNDO,
- VIS_ACTION_REDO,
- VIS_ACTION_EARLIER,
- VIS_ACTION_LATER,
- VIS_ACTION_MACRO_RECORD,
- VIS_ACTION_MACRO_REPLAY,
- VIS_ACTION_MARK_SET,
- VIS_ACTION_MARK_GOTO,
- VIS_ACTION_MARK_GOTO_LINE,
- VIS_ACTION_REDRAW,
- VIS_ACTION_REPLACE_CHAR,
- VIS_ACTION_TOTILL_REPEAT,
- VIS_ACTION_TOTILL_REVERSE,
- VIS_ACTION_SEARCH_FORWARD,
- VIS_ACTION_SEARCH_BACKWARD,
- VIS_ACTION_TILL_LEFT,
- VIS_ACTION_TILL_RIGHT,
- VIS_ACTION_TO_LEFT,
- VIS_ACTION_TO_RIGHT,
- VIS_ACTION_REGISTER,
- VIS_ACTION_OPERATOR_CHANGE,
- VIS_ACTION_OPERATOR_DELETE,
- VIS_ACTION_OPERATOR_YANK,
- VIS_ACTION_OPERATOR_SHIFT_LEFT,
- VIS_ACTION_OPERATOR_SHIFT_RIGHT,
- VIS_ACTION_OPERATOR_CASE_LOWER,
- VIS_ACTION_OPERATOR_CASE_UPPER,
- VIS_ACTION_OPERATOR_CASE_SWAP,
- VIS_ACTION_COUNT,
- VIS_ACTION_INSERT_NEWLINE,
- VIS_ACTION_INSERT_TAB,
- VIS_ACTION_INSERT_VERBATIM,
- VIS_ACTION_INSERT_REGISTER,
- VIS_ACTION_WINDOW_NEXT,
- VIS_ACTION_WINDOW_PREV,
- VIS_ACTION_OPEN_LINE_ABOVE,
- VIS_ACTION_OPEN_LINE_BELOW,
- VIS_ACTION_JOIN_LINE_BELOW,
- VIS_ACTION_JOIN_LINES,
- VIS_ACTION_PROMPT_SHOW,
- VIS_ACTION_PROMPT_BACKSPACE,
- VIS_ACTION_PROMPT_ENTER,
- VIS_ACTION_PROMPT_SHOW_VISUAL,
- VIS_ACTION_REPEAT,
- VIS_ACTION_SELECTION_FLIP,
- VIS_ACTION_SELECTION_RESTORE,
- VIS_ACTION_WINDOW_REDRAW_TOP,
- VIS_ACTION_WINDOW_REDRAW_CENTER,
- VIS_ACTION_WINDOW_REDRAW_BOTTOM,
- VIS_ACTION_WINDOW_SLIDE_UP,
- VIS_ACTION_WINDOW_SLIDE_DOWN,
- VIS_ACTION_PUT_AFTER,
- VIS_ACTION_PUT_BEFORE,
- VIS_ACTION_PUT_AFTER_END,
- VIS_ACTION_PUT_BEFORE_END,
- VIS_ACTION_CURSOR_SELECT_WORD,
- VIS_ACTION_CURSORS_NEW_LINE_ABOVE,
- VIS_ACTION_CURSORS_NEW_LINE_BELOW,
- VIS_ACTION_CURSORS_NEW_LINES_BEGIN,
- VIS_ACTION_CURSORS_NEW_LINES_END,
- VIS_ACTION_CURSORS_NEW_MATCH_NEXT,
- VIS_ACTION_CURSORS_NEW_MATCH_SKIP,
- VIS_ACTION_CURSORS_ALIGN,
- VIS_ACTION_CURSORS_REMOVE_ALL,
- VIS_ACTION_CURSORS_REMOVE_LAST,
- VIS_ACTION_TEXT_OBJECT_WORD_OUTER,
- VIS_ACTION_TEXT_OBJECT_WORD_INNER,
- VIS_ACTION_TEXT_OBJECT_LONGWORD_OUTER,
- VIS_ACTION_TEXT_OBJECT_LONGWORD_INNER,
- VIS_ACTION_TEXT_OBJECT_SENTENCE,
- VIS_ACTION_TEXT_OBJECT_PARAGRAPH,
- VIS_ACTION_TEXT_OBJECT_SQUARE_BRACKET_OUTER,
- VIS_ACTION_TEXT_OBJECT_SQUARE_BRACKET_INNER,
- VIS_ACTION_TEXT_OBJECT_PARANTHESE_OUTER,
- VIS_ACTION_TEXT_OBJECT_PARANTHESE_INNER,
- VIS_ACTION_TEXT_OBJECT_ANGLE_BRACKET_OUTER,
- VIS_ACTION_TEXT_OBJECT_ANGLE_BRACKET_INNER,
- VIS_ACTION_TEXT_OBJECT_CURLY_BRACKET_OUTER,
- VIS_ACTION_TEXT_OBJECT_CURLY_BRACKET_INNER,
- VIS_ACTION_TEXT_OBJECT_QUOTE_OUTER,
- VIS_ACTION_TEXT_OBJECT_QUOTE_INNER,
- VIS_ACTION_TEXT_OBJECT_SINGLE_QUOTE_OUTER,
- VIS_ACTION_TEXT_OBJECT_SINGLE_QUOTE_INNER,
- VIS_ACTION_TEXT_OBJECT_BACKTICK_OUTER,
- VIS_ACTION_TEXT_OBJECT_BACKTICK_INNER,
- VIS_ACTION_TEXT_OBJECT_ENTIRE_OUTER,
- VIS_ACTION_TEXT_OBJECT_ENTIRE_INNER,
- VIS_ACTION_TEXT_OBJECT_FUNCTION_OUTER,
- VIS_ACTION_TEXT_OBJECT_FUNCTION_INNER,
- VIS_ACTION_TEXT_OBJECT_LINE_OUTER,
- VIS_ACTION_TEXT_OBJECT_LINE_INNER,
- VIS_ACTION_MOTION_CHARWISE,
- VIS_ACTION_MOTION_LINEWISE,
- VIS_ACTION_NOP,
-};
-
-static KeyAction vis_action[] = {
- [VIS_ACTION_EDITOR_SUSPEND] = {
- "editor-suspend",
- "Suspend the editor",
- suspend,
- },
- [VIS_ACTION_CURSOR_CHAR_PREV] = {
- "cursor-char-prev",
- "Move cursor left, to the previous character",
- movement, { .i = MOVE_CHAR_PREV }
- },
- [VIS_ACTION_CURSOR_CHAR_NEXT] = {
- "cursor-char-next",
- "Move cursor right, to the next character",
- movement, { .i = MOVE_CHAR_NEXT }
- },
- [VIS_ACTION_CURSOR_WORD_START_PREV] = {
- "cursor-word-start-prev",
- "Move cursor words backwards",
- movement, { .i = MOVE_WORD_START_PREV }
- },
- [VIS_ACTION_CURSOR_WORD_START_NEXT] = {
- "cursor-word-start-next",
- "Move cursor words forwards",
- movement, { .i = MOVE_WORD_START_NEXT }
- },
- [VIS_ACTION_CURSOR_WORD_END_PREV] = {
- "cursor-word-end-prev",
- "Move cursor backwards to the end of word",
- movement, { .i = MOVE_WORD_END_PREV }
- },
- [VIS_ACTION_CURSOR_WORD_END_NEXT] = {
- "cursor-word-end-next",
- "Move cursor forward to the end of word",
- movement, { .i = MOVE_WORD_END_NEXT }
- },
- [VIS_ACTION_CURSOR_LONGWORD_START_PREV] = {
- "cursor-longword-start-prev",
- "Move cursor WORDS backwards",
- movement, { .i = MOVE_LONGWORD_START_PREV }
- },
- [VIS_ACTION_CURSOR_LONGWORD_START_NEXT] = {
- "cursor-longword-start-next",
- "Move cursor WORDS forwards",
- movement, { .i = MOVE_LONGWORD_START_NEXT }
- },
- [VIS_ACTION_CURSOR_LONGWORD_END_PREV] = {
- "cursor-longword-end-prev",
- "Move cursor backwards to the end of WORD",
- movement, { .i = MOVE_LONGWORD_END_PREV }
- },
- [VIS_ACTION_CURSOR_LONGWORD_END_NEXT] = {
- "cursor-longword-end-next",
- "Move cursor forward to the end of WORD",
- movement, { .i = MOVE_LONGWORD_END_NEXT }
- },
- [VIS_ACTION_CURSOR_LINE_UP] = {
- "cursor-line-up",
- "Move cursor line upwards",
- movement, { .i = MOVE_LINE_UP }
- },
- [VIS_ACTION_CURSOR_LINE_DOWN] = {
- "cursor-line-down",
- "Move cursor line downwards",
- movement, { .i = MOVE_LINE_DOWN }
- },
- [VIS_ACTION_CURSOR_LINE_START] = {
- "cursor-line-start",
- "Move cursor to first non-blank character of the line",
- movement, { .i = MOVE_LINE_START }
- },
- [VIS_ACTION_CURSOR_LINE_FINISH] = {
- "cursor-line-finish",
- "Move cursor to last non-blank character of the line",
- movement, { .i = MOVE_LINE_FINISH }
- },
- [VIS_ACTION_CURSOR_LINE_BEGIN] = {
- "cursor-line-begin",
- "Move cursor to first character of the line",
- movement, { .i = MOVE_LINE_BEGIN }
- },
- [VIS_ACTION_CURSOR_LINE_END] = {
- "cursor-line-end",
- "Move cursor to end of the line",
- movement, { .i = MOVE_LINE_LASTCHAR }
- },
- [VIS_ACTION_CURSOR_SCREEN_LINE_UP] = {
- "cursor-sceenline-up",
- "Move cursor screen/display line upwards",
- movement, { .i = MOVE_SCREEN_LINE_UP }
- },
- [VIS_ACTION_CURSOR_SCREEN_LINE_DOWN] = {
- "cursor-screenline-down",
- "Move cursor screen/display line downwards",
- movement, { .i = MOVE_SCREEN_LINE_DOWN }
- },
- [VIS_ACTION_CURSOR_SCREEN_LINE_BEGIN] = {
- "cursor-screenline-begin",
- "Move cursor to beginning of screen/display line",
- movement, { .i = MOVE_SCREEN_LINE_BEGIN }
- },
- [VIS_ACTION_CURSOR_SCREEN_LINE_MIDDLE] = {
- "cursor-screenline-middle",
- "Move cursor to middle of screen/display line",
- movement, { .i = MOVE_SCREEN_LINE_MIDDLE }
- },
- [VIS_ACTION_CURSOR_SCREEN_LINE_END] = {
- "cursor-screenline-end",
- "Move cursor to end of screen/display line",
- movement, { .i = MOVE_SCREEN_LINE_END }
- },
- [VIS_ACTION_CURSOR_BRACKET_MATCH] = {
- "cursor-match-bracket",
- "Match corresponding symbol if cursor is on a bracket character",
- movement, { .i = MOVE_BRACKET_MATCH }
- },
- [VIS_ACTION_CURSOR_PARAGRAPH_PREV] = {
- "cursor-paragraph-prev",
- "Move cursor paragraph backward",
- movement, { .i = MOVE_PARAGRAPH_PREV }
- },
- [VIS_ACTION_CURSOR_PARAGRAPH_NEXT] = {
- "cursor-paragraph-next",
- "Move cursor paragraph forward",
- movement, { .i = MOVE_PARAGRAPH_NEXT }
- },
- [VIS_ACTION_CURSOR_SENTENCE_PREV] = {
- "cursor-sentence-prev",
- "Move cursor sentence backward",
- movement, { .i = MOVE_SENTENCE_PREV }
- },
- [VIS_ACTION_CURSOR_SENTENCE_NEXT] = {
- "cursor-sentence-next",
- "Move cursor sentence forward",
- movement, { .i = MOVE_SENTENCE_NEXT }
- },
- [VIS_ACTION_CURSOR_FUNCTION_START_PREV] = {
- "cursor-function-start-prev",
- "Move cursor backwards to start of function",
- movement, { .i = MOVE_FUNCTION_START_PREV }
- },
- [VIS_ACTION_CURSOR_FUNCTION_START_NEXT] = {
- "cursor-function-start-next",
- "Move cursor forwards to start of function",
- movement, { .i = MOVE_FUNCTION_START_NEXT }
- },
- [VIS_ACTION_CURSOR_FUNCTION_END_PREV] = {
- "cursor-function-end-prev",
- "Move cursor backwards to end of function",
- movement, { .i = MOVE_FUNCTION_END_PREV }
- },
- [VIS_ACTION_CURSOR_FUNCTION_END_NEXT] = {
- "cursor-function-end-next",
- "Move cursor forwards to end of function",
- movement, { .i = MOVE_FUNCTION_END_NEXT }
- },
- [VIS_ACTION_CURSOR_COLUMN] = {
- "cursor-column",
- "Move cursor to given column of current line",
- movement, { .i = MOVE_COLUMN }
- },
- [VIS_ACTION_CURSOR_LINE_FIRST] = {
- "cursor-line-first",
- "Move cursor to given line (defaults to first)",
- gotoline, { .i = -1 }
- },
- [VIS_ACTION_CURSOR_LINE_LAST] = {
- "cursor-line-last",
- "Move cursor to given line (defaults to last)",
- gotoline, { .i = +1 }
- },
- [VIS_ACTION_CURSOR_WINDOW_LINE_TOP] = {
- "cursor-window-line-top",
- "Move cursor to top line of the window",
- movement, { .i = MOVE_WINDOW_LINE_TOP }
- },
- [VIS_ACTION_CURSOR_WINDOW_LINE_MIDDLE] = {
- "cursor-window-line-middle",
- "Move cursor to middle line of the window",
- movement, { .i = MOVE_WINDOW_LINE_MIDDLE }
- },
- [VIS_ACTION_CURSOR_WINDOW_LINE_BOTTOM] = {
- "cursor-window-line-bottom",
- "Move cursor to bottom line of the window",
- movement, { .i = MOVE_WINDOW_LINE_BOTTOM }
- },
- [VIS_ACTION_CURSOR_SEARCH_FORWARD] = {
- "cursor-search-forward",
- "Move cursor to bottom line of the window",
- movement, { .i = MOVE_SEARCH_FORWARD }
- },
- [VIS_ACTION_CURSOR_SEARCH_BACKWARD] = {
- "cursor-search-backward",
- "Move cursor to bottom line of the window",
- movement, { .i = MOVE_SEARCH_BACKWARD }
- },
- [VIS_ACTION_CURSOR_SEARCH_WORD_FORWARD] = {
- "cursor-search-word-forward",
- "Move cursor to next occurence of the word under cursor",
- movement, { .i = MOVE_SEARCH_WORD_FORWARD }
- },
- [VIS_ACTION_CURSOR_SEARCH_WORD_BACKWARD] = {
- "cursor-search-word-backward",
- "Move cursor to previous occurence of the word under cursor",
- movement, { .i = MOVE_SEARCH_WORD_BACKWARD }
- },
- [VIS_ACTION_WINDOW_PAGE_UP] = {
- "window-page-up",
- "Scroll window pages backwards (upwards)",
- wscroll, { .i = -PAGE }
- },
- [VIS_ACTION_WINDOW_HALFPAGE_UP] = {
- "window-halfpage-up",
- "Scroll window half pages backwards (upwards)",
- wscroll, { .i = -PAGE_HALF }
- },
- [VIS_ACTION_WINDOW_PAGE_DOWN] = {
- "window-page-down",
- "Scroll window pages forwards (downwards)",
- wscroll, { .i = +PAGE }
- },
- [VIS_ACTION_WINDOW_HALFPAGE_DOWN] = {
- "window-halfpage-down",
- "Scroll window half pages forwards (downwards)",
- wscroll, { .i = +PAGE_HALF }
- },
- [VIS_ACTION_MODE_NORMAL] = {
- "vis-mode-normal",
- "Enter normal mode",
- switchmode, { .i = VIS_MODE_NORMAL }
- },
- [VIS_ACTION_MODE_VISUAL] = {
- "vis-mode-visual-charwise",
- "Enter characterwise visual mode",
- switchmode, { .i = VIS_MODE_VISUAL }
- },
- [VIS_ACTION_MODE_VISUAL_LINE] = {
- "vis-mode-visual-linewise",
- "Enter linewise visual mode",
- switchmode, { .i = VIS_MODE_VISUAL_LINE }
- },
- [VIS_ACTION_MODE_INSERT] = {
- "vis-mode-insert",
- "Enter insert mode",
- switchmode, { .i = VIS_MODE_INSERT }
- },
- [VIS_ACTION_MODE_REPLACE] = {
- "vis-mode-replace",
- "Enter replace mode",
- switchmode, { .i = VIS_MODE_REPLACE }
- },
- [VIS_ACTION_MODE_OPERATOR_PENDING] = {
- "vis-mode-operator-pending",
- "Enter to operator pending mode",
- switchmode, { .i = VIS_MODE_OPERATOR }
- },
- [VIS_ACTION_DELETE_CHAR_PREV] = {
- "delete-char-prev",
- "Delete the previous character",
- delete, { .i = MOVE_CHAR_PREV }
- },
- [VIS_ACTION_DELETE_CHAR_NEXT] = {
- "delete-char-next",
- "Delete the next character",
- delete, { .i = MOVE_CHAR_NEXT }
- },
- [VIS_ACTION_DELETE_LINE_BEGIN] = {
- "delete-line-begin",
- "Delete until the start of the current line",
- delete, { .i = MOVE_LINE_BEGIN }
- },
- [VIS_ACTION_DELETE_WORD_PREV] = {
- "delete-word-prev",
- "Delete the previous WORD",
- delete, { .i = MOVE_LONGWORD_START_PREV }
- },
- [VIS_ACTION_JUMPLIST_PREV] = {
- "jumplist-prev",
- "Go to older cursor position in jump list",
- movement, { .i = MOVE_JUMPLIST_PREV }
- },
- [VIS_ACTION_JUMPLIST_NEXT] = {
- "jumplist-next",
- "Go to newer cursor position in jump list",
- movement, { .i = MOVE_JUMPLIST_NEXT }
- },
- [VIS_ACTION_CHANGELIST_PREV] = {
- "changelist-prev",
- "Go to older cursor position in change list",
- movement, { .i = MOVE_CHANGELIST_PREV }
- },
- [VIS_ACTION_CHANGELIST_NEXT] = {
- "changelist-next",
- "Go to newer cursor position in change list",
- movement, { .i = MOVE_CHANGELIST_NEXT }
- },
- [VIS_ACTION_UNDO] = {
- "editor-undo",
- "Undo last change",
- undo,
- },
- [VIS_ACTION_REDO] = {
- "editor-redo",
- "Redo last change",
- redo,
- },
- [VIS_ACTION_EARLIER] = {
- "editor-earlier",
- "Goto older text state",
- earlier,
- },
- [VIS_ACTION_LATER] = {
- "editor-later",
- "Goto newer text state",
- later,
- },
- [VIS_ACTION_MACRO_RECORD] = {
- "macro-record",
- "Record macro into given register",
- macro_record,
- },
- [VIS_ACTION_MACRO_REPLAY] = {
- "macro-replay",
- "Replay macro, execute the content of the given register",
- macro_replay,
- },
- [VIS_ACTION_MARK_SET] = {
- "mark-set",
- "Set given mark at current cursor position",
- mark_set,
- },
- [VIS_ACTION_MARK_GOTO] = {
- "mark-goto",
- "Goto the position of the given mark",
- mark_motion, { .i = MOVE_MARK }
- },
- [VIS_ACTION_MARK_GOTO_LINE] = {
- "mark-goto-line",
- "Goto first non-blank character of the line containing the given mark",
- mark_motion, { .i = MOVE_MARK_LINE }
- },
- [VIS_ACTION_REDRAW] = {
- "editor-redraw",
- "Redraw current editor content",
- call, { .f = vis_draw }
- },
- [VIS_ACTION_REPLACE_CHAR] = {
- "replace-char",
- "Replace the character under the cursor",
- replace,
- },
- [VIS_ACTION_TOTILL_REPEAT] = {
- "totill-repeat",
- "Repeat latest to/till motion",
- movement, { .i = MOVE_TOTILL_REPEAT }
- },
- [VIS_ACTION_TOTILL_REVERSE] = {
- "totill-reverse",
- "Repeat latest to/till motion but in opposite direction",
- movement, { .i = MOVE_TOTILL_REVERSE }
- },
- [VIS_ACTION_SEARCH_FORWARD] = {
- "search-forward",
- "Search forward",
- prompt_search, { .s = "/" }
- },
- [VIS_ACTION_SEARCH_BACKWARD] = {
- "search-backward",
- "Search backward",
- prompt_search, { .s = "?" }
- },
- [VIS_ACTION_TILL_LEFT] = {
- "till-left",
- "Till after the occurrence of character to the left",
- movement_key, { .i = MOVE_LEFT_TILL }
- },
- [VIS_ACTION_TILL_RIGHT] = {
- "till-right",
- "Till before the occurrence of character to the right",
- movement_key, { .i = MOVE_RIGHT_TILL }
- },
- [VIS_ACTION_TO_LEFT] = {
- "to-left",
- "To the first occurrence of character to the left",
- movement_key, { .i = MOVE_LEFT_TO }
- },
- [VIS_ACTION_TO_RIGHT] = {
- "to-right",
- "To the first occurrence of character to the right",
- movement_key, { .i = MOVE_RIGHT_TO }
- },
- [VIS_ACTION_REGISTER] = {
- "register",
- "Use given register for next operator",
- reg,
- },
- [VIS_ACTION_OPERATOR_CHANGE] = {
- "vis-operator-change",
- "Change operator",
- operator, { .i = OP_CHANGE }
- },
- [VIS_ACTION_OPERATOR_DELETE] = {
- "vis-operator-delete",
- "Delete operator",
- operator, { .i = OP_DELETE }
- },
- [VIS_ACTION_OPERATOR_YANK] = {
- "vis-operator-yank",
- "Yank operator",
- operator, { .i = OP_YANK }
- },
- [VIS_ACTION_OPERATOR_SHIFT_LEFT] = {
- "vis-operator-shift-left",
- "Shift left operator",
- operator, { .i = OP_SHIFT_LEFT }
- },
- [VIS_ACTION_OPERATOR_SHIFT_RIGHT] = {
- "vis-operator-shift-right",
- "Shift right operator",
- operator, { .i = OP_SHIFT_RIGHT }
- },
- [VIS_ACTION_OPERATOR_CASE_LOWER] = {
- "vis-operator-case-lower",
- "Lowercase operator",
- changecase, { .i = -1 }
- },
- [VIS_ACTION_OPERATOR_CASE_UPPER] = {
- "vis-operator-case-upper",
- "Uppercase operator",
- changecase, { .i = +1 }
- },
- [VIS_ACTION_OPERATOR_CASE_SWAP] = {
- "vis-operator-case-swap",
- "Swap case operator",
- changecase, { .i = 0 }
- },
- [VIS_ACTION_COUNT] = {
- "vis-count",
- "Count specifier",
- count,
- },
- [VIS_ACTION_INSERT_NEWLINE] = {
- "insert-newline",
- "Insert a line break (depending on file type)",
- insert_newline,
- },
- [VIS_ACTION_INSERT_TAB] = {
- "insert-tab",
- "Insert a tab (might be converted to spaces)",
- insert_tab,
- },
- [VIS_ACTION_INSERT_VERBATIM] = {
- "insert-verbatim",
- "Insert Unicode character based on code point",
- insert_verbatim,
- },
- [VIS_ACTION_INSERT_REGISTER] = {
- "insert-register",
- "Insert specified register content",
- insert_register,
- },
- [VIS_ACTION_WINDOW_NEXT] = {
- "window-next",
- "Focus next window",
- call, { .f = vis_window_next }
- },
- [VIS_ACTION_WINDOW_PREV] = {
- "window-prev",
- "Focus previous window",
- call, { .f = vis_window_prev }
- },
- [VIS_ACTION_OPEN_LINE_ABOVE] = {
- "open-line-above",
- "Begin a new line above the cursor",
- openline, { .i = MOVE_LINE_PREV }
- },
- [VIS_ACTION_OPEN_LINE_BELOW] = {
- "open-line-below",
- "Begin a new line below the cursor",
- openline, { .i = MOVE_LINE_NEXT }
- },
- [VIS_ACTION_JOIN_LINE_BELOW] = {
- "join-line-below",
- "Join line(s)",
- join, { .i = MOVE_LINE_NEXT },
- },
- [VIS_ACTION_JOIN_LINES] = {
- "join-lines",
- "Join selected lines",
- operator, { .i = OP_JOIN }
- },
- [VIS_ACTION_PROMPT_SHOW] = {
- "prompt-show",
- "Show editor command line prompt",
- prompt_cmd, { .s = "" }
- },
- [VIS_ACTION_PROMPT_BACKSPACE] = {
- "prompt-backspace",
- "Delete previous character in prompt",
- prompt_backspace
- },
- [VIS_ACTION_PROMPT_ENTER] = {
- "prompt-enter",
- "Execute current prompt content",
- prompt_enter
- },
- [VIS_ACTION_PROMPT_SHOW_VISUAL] = {
- "prompt-show-visual",
- "Show editor command line prompt in visual mode",
- prompt_cmd, { .s = "'<,'>" }
- },
- [VIS_ACTION_REPEAT] = {
- "editor-repeat",
- "Repeat latest editor command",
- repeat
- },
- [VIS_ACTION_SELECTION_FLIP] = {
- "selection-flip",
- "Flip selection, move cursor to other end",
- selection_end,
- },
- [VIS_ACTION_SELECTION_RESTORE] = {
- "selection-restore",
- "Restore last selection",
- selection_restore,
- },
- [VIS_ACTION_WINDOW_REDRAW_TOP] = {
- "window-redraw-top",
- "Redraw cursor line at the top of the window",
- window, { .w = view_redraw_top }
- },
- [VIS_ACTION_WINDOW_REDRAW_CENTER] = {
- "window-redraw-center",
- "Redraw cursor line at the center of the window",
- window, { .w = view_redraw_center }
- },
- [VIS_ACTION_WINDOW_REDRAW_BOTTOM] = {
- "window-redraw-bottom",
- "Redraw cursor line at the bottom of the window",
- window, { .w = view_redraw_bottom }
- },
- [VIS_ACTION_WINDOW_SLIDE_UP] = {
- "window-slide-up",
- "Slide window content upwards",
- wslide, { .i = -1 }
- },
- [VIS_ACTION_WINDOW_SLIDE_DOWN] = {
- "window-slide-down",
- "Slide window content downwards",
- wslide, { .i = +1 }
- },
- [VIS_ACTION_PUT_AFTER] = {
- "put-after",
- "Put text after the cursor",
- put, { .i = PUT_AFTER }
- },
- [VIS_ACTION_PUT_BEFORE] = {
- "put-before",
- "Put text before the cursor",
- put, { .i = PUT_BEFORE }
- },
- [VIS_ACTION_PUT_AFTER_END] = {
- "put-after-end",
- "Put text after the cursor, place cursor after new text",
- put, { .i = PUT_AFTER_END }
- },
- [VIS_ACTION_PUT_BEFORE_END] = {
- "put-before-end",
- "Put text before the cursor, place cursor after new text",
- put, { .i = PUT_BEFORE_END }
- },
- [VIS_ACTION_CURSOR_SELECT_WORD] = {
- "cursors-select-word",
- "Select word under cursor",
- cursors_select,
- },
- [VIS_ACTION_CURSORS_NEW_LINE_ABOVE] = {
- "cursors-new-lines-above",
- "Create a new cursor on the line above",
- cursors_new, { .i = -1 }
- },
- [VIS_ACTION_CURSORS_NEW_LINE_BELOW] = {
- "cursor-new-lines-below",
- "Create a new cursor on the line below",
- cursors_new, { .i = +1 }
- },
- [VIS_ACTION_CURSORS_NEW_LINES_BEGIN] = {
- "cursors-new-lines-begin",
- "Create a new cursor at the start of every line covered by selection",
- cursors_split, { .i = -1 }
- },
- [VIS_ACTION_CURSORS_NEW_LINES_END] = {
- "cursors-new-lines-end",
- "Create a new cursor at the end of every line covered by selection",
- cursors_split, { .i = +1 }
- },
- [VIS_ACTION_CURSORS_NEW_MATCH_NEXT] = {
- "cursors-new-match-next",
- "Select the next region matching the current selection",
- cursors_select_next
- },
- [VIS_ACTION_CURSORS_NEW_MATCH_SKIP] = {
- "cursors-new-match-skip",
- "Clear current selection, but select next match",
- cursors_select_skip,
- },
- [VIS_ACTION_CURSORS_ALIGN] = {
- "cursors-align",
- "Try to align all cursors on the same column",
- cursors_align,
- },
- [VIS_ACTION_CURSORS_REMOVE_ALL] = {
- "cursors-remove-all",
- "Remove all but the primary cursor",
- cursors_clear,
- },
- [VIS_ACTION_CURSORS_REMOVE_LAST] = {
- "cursors-remove-last",
- "Remove least recently created cursor",
- cursors_remove,
- },
- [VIS_ACTION_TEXT_OBJECT_WORD_OUTER] = {
- "text-object-word-outer",
- "A word leading and trailing whitespace included",
- textobj, { .i = TEXT_OBJ_OUTER_WORD }
- },
- [VIS_ACTION_TEXT_OBJECT_WORD_INNER] = {
- "text-object-word-inner",
- "A word leading and trailing whitespace excluded",
- textobj, { .i = TEXT_OBJ_INNER_WORD }
- },
- [VIS_ACTION_TEXT_OBJECT_LONGWORD_OUTER] = {
- "text-object-longword-outer",
- "A WORD leading and trailing whitespace included",
- textobj, { .i = TEXT_OBJ_OUTER_LONGWORD }
- },
- [VIS_ACTION_TEXT_OBJECT_LONGWORD_INNER] = {
- "text-object-longword-inner",
- "A WORD leading and trailing whitespace excluded",
- textobj, { .i = TEXT_OBJ_INNER_LONGWORD }
- },
- [VIS_ACTION_TEXT_OBJECT_SENTENCE] = {
- "text-object-sentence",
- "A sentence",
- textobj, { .i = TEXT_OBJ_SENTENCE }
- },
- [VIS_ACTION_TEXT_OBJECT_PARAGRAPH] = {
- "text-object-paragraph",
- "A paragraph",
- textobj, { .i = TEXT_OBJ_PARAGRAPH }
- },
- [VIS_ACTION_TEXT_OBJECT_SQUARE_BRACKET_OUTER] = {
- "text-object-square-bracket-outer",
- "[] block (outer variant)",
- textobj, { .i = TEXT_OBJ_OUTER_SQUARE_BRACKET }
- },
- [VIS_ACTION_TEXT_OBJECT_SQUARE_BRACKET_INNER] = {
- "text-object-square-bracket-inner",
- "[] block (inner variant)",
- textobj, { .i = TEXT_OBJ_INNER_SQUARE_BRACKET }
- },
- [VIS_ACTION_TEXT_OBJECT_PARANTHESE_OUTER] = {
- "text-object-parentheses-outer",
- "() block (outer variant)",
- textobj, { .i = TEXT_OBJ_OUTER_PARANTHESE }
- },
- [VIS_ACTION_TEXT_OBJECT_PARANTHESE_INNER] = {
- "text-object-parentheses-inner",
- "() block (inner variant)",
- textobj, { .i = TEXT_OBJ_INNER_PARANTHESE }
- },
- [VIS_ACTION_TEXT_OBJECT_ANGLE_BRACKET_OUTER] = {
- "text-object-angle-bracket-outer",
- "<> block (outer variant)",
- textobj, { .i = TEXT_OBJ_OUTER_ANGLE_BRACKET }
- },
- [VIS_ACTION_TEXT_OBJECT_ANGLE_BRACKET_INNER] = {
- "text-object-angle-bracket-inner",
- "<> block (inner variant)",
- textobj, { .i = TEXT_OBJ_INNER_ANGLE_BRACKET }
- },
- [VIS_ACTION_TEXT_OBJECT_CURLY_BRACKET_OUTER] = {
- "text-object-curly-bracket-outer",
- "{} block (outer variant)",
- textobj, { .i = TEXT_OBJ_OUTER_CURLY_BRACKET }
- },
- [VIS_ACTION_TEXT_OBJECT_CURLY_BRACKET_INNER] = {
- "text-object-curly-bracket-inner",
- "{} block (inner variant)",
- textobj, { .i = TEXT_OBJ_INNER_CURLY_BRACKET }
- },
- [VIS_ACTION_TEXT_OBJECT_QUOTE_OUTER] = {
- "text-object-quote-outer",
- "A quoted string, including the quotation marks",
- textobj, { .i = TEXT_OBJ_OUTER_QUOTE }
- },
- [VIS_ACTION_TEXT_OBJECT_QUOTE_INNER] = {
- "text-object-quote-inner",
- "A quoted string, excluding the quotation marks",
- textobj, { .i = TEXT_OBJ_INNER_QUOTE }
- },
- [VIS_ACTION_TEXT_OBJECT_SINGLE_QUOTE_OUTER] = {
- "text-object-single-quote-outer",
- "A single quoted string, including the quotation marks",
- textobj, { .i = TEXT_OBJ_OUTER_SINGLE_QUOTE }
- },
- [VIS_ACTION_TEXT_OBJECT_SINGLE_QUOTE_INNER] = {
- "text-object-single-quote-inner",
- "A single quoted string, excluding the quotation marks",
- textobj, { .i = TEXT_OBJ_INNER_SINGLE_QUOTE }
- },
- [VIS_ACTION_TEXT_OBJECT_BACKTICK_OUTER] = {
- "text-object-backtick-outer",
- "A backtick delimited string (outer variant)",
- textobj, { .i = TEXT_OBJ_OUTER_BACKTICK }
- },
- [VIS_ACTION_TEXT_OBJECT_BACKTICK_INNER] = {
- "text-object-backtick-inner",
- "A backtick delimited string (inner variant)",
- textobj, { .i = TEXT_OBJ_INNER_BACKTICK }
- },
- [VIS_ACTION_TEXT_OBJECT_ENTIRE_OUTER] = {
- "text-object-entire-outer",
- "The whole text content",
- textobj, { .i = TEXT_OBJ_OUTER_ENTIRE }
- },
- [VIS_ACTION_TEXT_OBJECT_ENTIRE_INNER] = {
- "text-object-entire-inner",
- "The whole text content, except for leading and trailing empty lines",
- textobj, { .i = TEXT_OBJ_INNER_ENTIRE }
- },
- [VIS_ACTION_TEXT_OBJECT_FUNCTION_OUTER] = {
- "text-object-function-outer",
- "A whole C-like function",
- textobj, { .i = TEXT_OBJ_OUTER_FUNCTION }
- },
- [VIS_ACTION_TEXT_OBJECT_FUNCTION_INNER] = {
- "text-object-function-inner",
- "A whole C-like function body",
- textobj, { .i = TEXT_OBJ_INNER_FUNCTION }
- },
- [VIS_ACTION_TEXT_OBJECT_LINE_OUTER] = {
- "text-object-line-outer",
- "The whole line",
- textobj, { .i = TEXT_OBJ_OUTER_LINE }
- },
- [VIS_ACTION_TEXT_OBJECT_LINE_INNER] = {
- "text-object-line-inner",
- "The whole line, excluding leading and trailing whitespace",
- textobj, { .i = TEXT_OBJ_INNER_LINE }
- },
- [VIS_ACTION_MOTION_CHARWISE] = {
- "motion-charwise",
- "Force motion to be charwise",
- motiontype, { .i = CHARWISE }
- },
- [VIS_ACTION_MOTION_LINEWISE] = {
- "motion-linewise",
- "Force motion to be linewise",
- motiontype, { .i = LINEWISE }
- },
- [VIS_ACTION_NOP] = {
- "nop",
- "Ignore key, do nothing",
- nop,
- },
-};
-
static KeyBinding basic_movement[] = {
{ "<C-z>", ACTION(EDITOR_SUSPEND) },
{ "<Left>", ACTION(CURSOR_CHAR_PREV) },
@@ -1017,8 +61,8 @@ static KeyBinding vis_movements[] = {
{ "g$", ACTION(CURSOR_SCREEN_LINE_END) },
{ "G", ACTION(CURSOR_LINE_LAST) },
{ "|", ACTION(CURSOR_COLUMN) },
- { "n", ACTION(CURSOR_SEARCH_FORWARD) },
- { "N", ACTION(CURSOR_SEARCH_BACKWARD) },
+ { "n", ACTION(CURSOR_SEARCH_NEXT) },
+ { "N", ACTION(CURSOR_SEARCH_PREV) },
{ "H", ACTION(CURSOR_WINDOW_LINE_TOP) },
{ "M", ACTION(CURSOR_WINDOW_LINE_MIDDLE) },
{ "L", ACTION(CURSOR_WINDOW_LINE_BOTTOM) },
@@ -1030,8 +74,8 @@ static KeyBinding vis_movements[] = {
{ "T", ACTION(TILL_LEFT) },
{ ";", ACTION(TOTILL_REPEAT) },
{ ",", ACTION(TOTILL_REVERSE) },
- { "/", ACTION(SEARCH_FORWARD) },
- { "?", ACTION(SEARCH_BACKWARD) },
+ { "/", ACTION(PROMPT_SEARCH_FORWARD) },
+ { "?", ACTION(PROMPT_SEARCH_BACKWARD) },
{ "`", ACTION(MARK_GOTO) },
{ "'", ACTION(MARK_GOTO_LINE) },
{ /* empty last element, array terminator */ },
@@ -1109,20 +153,6 @@ static KeyBinding vis_operators[] = {
{ /* empty last element, array terminator */ },
};
-static void vis_mode_operator_enter(Vis *vis, Mode *old) {
- vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_OPERATOR_OPTION];
-}
-
-static void vis_mode_operator_leave(Vis *vis, Mode *new) {
- vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_MOVE];
-}
-
-static void vis_mode_operator_input(Vis *vis, const char *str, size_t len) {
- /* invalid operator */
- action_reset(vis, &vis->action);
- vis_mode_set(vis, vis->mode_prev);
-}
-
static KeyBinding vis_operator_options[] = {
{ "v", ACTION(MOTION_CHARWISE) },
{ "V", ACTION(MOTION_LINEWISE) },
@@ -1219,45 +249,12 @@ static KeyBinding vis_mode_visual[] = {
{ /* empty last element, array terminator */ },
};
-static void vis_mode_visual_enter(Vis *vis, Mode *old) {
- if (!old->visual) {
- for (Cursor *c = view_cursors(vis->win->view); c; c = view_cursors_next(c))
- view_cursors_selection_start(c);
- vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_TEXTOBJ];
- }
-}
-
-static void vis_mode_visual_leave(Vis *vis, Mode *new) {
- if (!new->visual) {
- view_selections_clear(vis->win->view);
- vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_MOVE];
- }
-}
-
static KeyBinding vis_mode_visual_line[] = {
{ "v", ACTION(MODE_VISUAL) },
{ "V", ACTION(MODE_NORMAL) },
{ /* empty last element, array terminator */ },
};
-static void vis_mode_visual_line_enter(Vis *vis, Mode *old) {
- if (!old->visual) {
- for (Cursor *c = view_cursors(vis->win->view); c; c = view_cursors_next(c))
- view_cursors_selection_start(c);
- vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_TEXTOBJ];
- }
- movement(vis, NULL, &(const Arg){ .i = MOVE_LINE_END });
-}
-
-static void vis_mode_visual_line_leave(Vis *vis, Mode *new) {
- if (!new->visual) {
- view_selections_clear(vis->win->view);
- vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_MOVE];
- } else {
- view_cursor_to(vis->win->view, view_cursor_get(vis->win->view));
- }
-}
-
static KeyBinding vis_mode_readline[] = {
{ "<Backspace>", ACTION(DELETE_CHAR_PREV) },
{ "<C-h>", ALIAS("<Backspace>") },
@@ -1278,20 +275,6 @@ static KeyBinding vis_mode_prompt[] = {
{ /* empty last element, array terminator */ },
};
-static void vis_mode_prompt_input(Vis *vis, const char *str, size_t len) {
- vis_insert_key(vis, str, len);
-}
-
-static void vis_mode_prompt_enter(Vis *vis, Mode *old) {
- if (old->isuser && old != &vis_modes[VIS_MODE_PROMPT])
- vis->mode_before_prompt = old;
-}
-
-static void vis_mode_prompt_leave(Vis *vis, Mode *new) {
- if (new->isuser)
- vis_prompt_hide(vis);
-}
-
static KeyBinding vis_mode_insert[] = {
{ "<Escape>", ACTION(MODE_NORMAL) },
{ "<C-l>", ALIAS("<Escape>") },
@@ -1310,182 +293,10 @@ static KeyBinding vis_mode_insert[] = {
{ /* empty last element, array terminator */ },
};
-static void vis_mode_insert_leave(Vis *vis, Mode *old) {
- /* make sure we can recover the current state after an editing operation */
- text_snapshot(vis->win->file->text);
-}
-
-static void vis_mode_insert_idle(Vis *vis) {
- text_snapshot(vis->win->file->text);
-}
-
-static void vis_mode_insert_input(Vis *vis, const char *str, size_t len) {
- static size_t oldpos = EPOS;
- size_t pos = view_cursor_get(vis->win->view);
- if (pos != oldpos)
- buffer_truncate(&vis->buffer_repeat);
- buffer_append(&vis->buffer_repeat, str, len);
- oldpos = pos + len;
- action_reset(vis, &vis->action_prev);
- vis->action_prev.op = &ops[OP_REPEAT_INSERT];
- vis_insert_key(vis, str, len);
-}
-
static KeyBinding vis_mode_replace[] = {
{ /* empty last element, array terminator */ },
};
-static void vis_mode_replace_leave(Vis *vis, Mode *old) {
- /* make sure we can recover the current state after an editing operation */
- text_snapshot(vis->win->file->text);
-}
-
-static void vis_mode_replace_input(Vis *vis, const char *str, size_t len) {
- static size_t oldpos = EPOS;
- size_t pos = view_cursor_get(vis->win->view);
- if (pos != oldpos)
- buffer_truncate(&vis->buffer_repeat);
- buffer_append(&vis->buffer_repeat, str, len);
- oldpos = pos + len;
- action_reset(vis, &vis->action_prev);
- vis->action_prev.op = &ops[OP_REPEAT_REPLACE];
- vis_replace_key(vis, str, len);
-}
-
-/*
- * the tree of modes currently looks like this. the double line between OPERATOR-OPTION
- * and OPERATOR is only in effect once an operator is detected. that is when entering the
- * OPERATOR mode its parent is set to OPERATOR-OPTION which makes {INNER-,}TEXTOBJ
- * reachable. once the operator is processed (i.e. the OPERATOR mode is left) its parent
- * mode is reset back to MOVE.
- *
- * Similarly the +-ed line between OPERATOR and TEXTOBJ is only active within the visual
- * modes.
- *
- *
- * BASIC
- * (arrow keys etc.)
- * / |
- * /-------------------/ |
- * READLINE MOVE
- * / \ (h,j,k,l ...)
- * / \ | \-----------------\
- * / \ | |
- * INSERT PROMPT OPERATOR ++++ INNER-TEXTOBJ
- * | (history etc) (d,c,y,p ..) + (i [wsp[]()b<>{}B"'`] )
- * | | \\ + |
- * | | \\ + |
- * REPLACE NORMAL \\ + TEXTOBJ
- * | \\ + (a [wsp[]()b<>{}B"'`] )
- * | \\ + + |
- * | \\ + + |
- * VISUAL \\ OPERATOR-OPTION
- * | \\ (v,V)
- * | \\ //
- * | \\======//
- * VISUAL-LINE
- */
-
-static Mode vis_modes[] = {
- [VIS_MODE_BASIC] = {
- .name = "BASIC",
- .parent = NULL,
- .default_bindings = basic_movement,
- },
- [VIS_MODE_MOVE] = {
- .name = "MOVE",
- .parent = &vis_modes[VIS_MODE_BASIC],
- .default_bindings = vis_movements,
- },
- [VIS_MODE_TEXTOBJ] = {
- .name = "TEXT-OBJECTS",
- .parent = &vis_modes[VIS_MODE_MOVE],
- .default_bindings = vis_textobjs,
- },
- [VIS_MODE_OPERATOR_OPTION] = {
- .name = "OPERATOR-OPTION",
- .parent = &vis_modes[VIS_MODE_TEXTOBJ],
- .default_bindings = vis_operator_options,
- },
- [VIS_MODE_OPERATOR] = {
- .name = "OPERATOR",
- .parent = &vis_modes[VIS_MODE_MOVE],
- .default_bindings = vis_operators,
- .enter = vis_mode_operator_enter,
- .leave = vis_mode_operator_leave,
- .input = vis_mode_operator_input,
- },
- [VIS_MODE_NORMAL] = {
- .name = "NORMAL",
- .status = "",
- .help = "",
- .isuser = true,
- .parent = &vis_modes[VIS_MODE_OPERATOR],
- .default_bindings = vis_mode_normal,
- },
- [VIS_MODE_VISUAL] = {
- .name = "VISUAL",
- .status = "--VISUAL--",
- .help = "",
- .isuser = true,
- .parent = &vis_modes[VIS_MODE_OPERATOR],
- .default_bindings = vis_mode_visual,
- .enter = vis_mode_visual_enter,
- .leave = vis_mode_visual_leave,
- .visual = true,
- },
- [VIS_MODE_VISUAL_LINE] = {
- .name = "VISUAL LINE",
- .status = "--VISUAL LINE--",
- .help = "",
- .isuser = true,
- .parent = &vis_modes[VIS_MODE_VISUAL],
- .default_bindings = vis_mode_visual_line,
- .enter = vis_mode_visual_line_enter,
- .leave = vis_mode_visual_line_leave,
- .visual = true,
- },
- [VIS_MODE_READLINE] = {
- .name = "READLINE",
- .parent = &vis_modes[VIS_MODE_BASIC],
- .default_bindings = vis_mode_readline,
- },
- [VIS_MODE_PROMPT] = {
- .name = "PROMPT",
- .help = "",
- .isuser = true,
- .parent = &vis_modes[VIS_MODE_READLINE],
- .default_bindings = vis_mode_prompt,
- .input = vis_mode_prompt_input,
- .enter = vis_mode_prompt_enter,
- .leave = vis_mode_prompt_leave,
- },
- [VIS_MODE_INSERT] = {
- .name = "INSERT",
- .status = "--INSERT--",
- .help = "",
- .isuser = true,
- .parent = &vis_modes[VIS_MODE_READLINE],
- .default_bindings = vis_mode_insert,
- .leave = vis_mode_insert_leave,
- .input = vis_mode_insert_input,
- .idle = vis_mode_insert_idle,
- .idle_timeout = 3,
- },
- [VIS_MODE_REPLACE] = {
- .name = "REPLACE",
- .status = "--REPLACE--",
- .help = "",
- .isuser = true,
- .parent = &vis_modes[VIS_MODE_INSERT],
- .default_bindings = vis_mode_replace,
- .leave = vis_mode_replace_leave,
- .input = vis_mode_replace_input,
- .idle = vis_mode_insert_idle,
- .idle_timeout = 3,
- },
-};
-
/* Color definitions for use in the sytax highlighting rules below. A fore
* or background color of -1 specifies the default terminal color. */
enum {