2009-06-02 00:58:49 +02:00
|
|
|
/* $OpenBSD$ */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2009-07-28 19:05:10 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
2009-06-02 00:58:49 +02:00
|
|
|
#include "tmux.h"
|
|
|
|
|
2009-07-28 09:03:32 +02:00
|
|
|
/*
|
|
|
|
* Mode keys. These are the key bindings used when editing (status prompt), and
|
|
|
|
* in the modes. They are split into two sets of three tables, one set of three
|
|
|
|
* for vi and the other for emacs key bindings. The three tables are for
|
|
|
|
* editing, for menu-like modes (choice, more), and for copy modes (copy,
|
|
|
|
* scroll).
|
|
|
|
*
|
|
|
|
* The fixed tables of struct mode_key_entry below are the defaults: they are
|
|
|
|
* built into a tree of struct mode_key_binding by mode_key_init_trees, which
|
|
|
|
* can then be modified.
|
|
|
|
*
|
|
|
|
* vi command mode is handled by having a mode flag in the struct which allows
|
|
|
|
* two sets of bindings to be swapped between. A couple of editing commands
|
2013-07-05 16:44:06 +02:00
|
|
|
* (any matching MODEKEYEDIT_SWITCHMODE*) are special-cased to do this.
|
2009-07-28 09:03:32 +02:00
|
|
|
*/
|
|
|
|
|
2015-05-08 18:33:29 +02:00
|
|
|
/* Entry in the default mode key tables. */
|
|
|
|
struct mode_key_entry {
|
|
|
|
int key;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editing mode for vi: 0 is edit mode, keys not in the table are
|
|
|
|
* returned as MODEKEY_OTHER; 1 is command mode, keys not in the table
|
|
|
|
* are returned as MODEKEY_NONE. This is also matched on, allowing some
|
|
|
|
* keys to be bound in edit mode.
|
|
|
|
*/
|
|
|
|
int mode;
|
|
|
|
enum mode_key_cmd cmd;
|
|
|
|
};
|
|
|
|
|
2009-07-28 09:03:32 +02:00
|
|
|
/* Edit keys command strings. */
|
2011-01-01 04:39:21 +01:00
|
|
|
const struct mode_key_cmdstr mode_key_cmdstr_edit[] = {
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYEDIT_BACKSPACE, "backspace" },
|
2009-12-03 23:50:09 +01:00
|
|
|
{ MODEKEYEDIT_CANCEL, "cancel" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYEDIT_COMPLETE, "complete" },
|
|
|
|
{ MODEKEYEDIT_CURSORLEFT, "cursor-left" },
|
|
|
|
{ MODEKEYEDIT_CURSORRIGHT, "cursor-right" },
|
|
|
|
{ MODEKEYEDIT_DELETE, "delete" },
|
2009-08-18 09:23:43 +02:00
|
|
|
{ MODEKEYEDIT_DELETELINE, "delete-line" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYEDIT_DELETETOENDOFLINE, "delete-end-of-line" },
|
2011-11-16 00:34:12 +01:00
|
|
|
{ MODEKEYEDIT_DELETEWORD, "delete-word" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYEDIT_ENDOFLINE, "end-of-line" },
|
|
|
|
{ MODEKEYEDIT_ENTER, "enter" },
|
|
|
|
{ MODEKEYEDIT_HISTORYDOWN, "history-down" },
|
|
|
|
{ MODEKEYEDIT_HISTORYUP, "history-up" },
|
2012-01-20 20:10:29 +01:00
|
|
|
{ MODEKEYEDIT_NEXTSPACE, "next-space" },
|
|
|
|
{ MODEKEYEDIT_NEXTSPACEEND, "next-space-end" },
|
2011-11-16 00:34:12 +01:00
|
|
|
{ MODEKEYEDIT_NEXTWORD, "next-word" },
|
|
|
|
{ MODEKEYEDIT_NEXTWORDEND, "next-word-end" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYEDIT_PASTE, "paste" },
|
2012-01-20 20:10:29 +01:00
|
|
|
{ MODEKEYEDIT_PREVIOUSSPACE, "previous-space" },
|
2011-11-16 00:34:12 +01:00
|
|
|
{ MODEKEYEDIT_PREVIOUSWORD, "previous-word" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYEDIT_STARTOFLINE, "start-of-line" },
|
|
|
|
{ MODEKEYEDIT_SWITCHMODE, "switch-mode" },
|
|
|
|
{ MODEKEYEDIT_SWITCHMODEAPPEND, "switch-mode-append" },
|
2012-03-04 08:38:11 +01:00
|
|
|
{ MODEKEYEDIT_SWITCHMODEAPPENDLINE, "switch-mode-append-line" },
|
|
|
|
{ MODEKEYEDIT_SWITCHMODEBEGINLINE, "switch-mode-begin-line" },
|
2013-07-05 16:44:06 +02:00
|
|
|
{ MODEKEYEDIT_SWITCHMODECHANGELINE, "switch-mode-change-line" },
|
|
|
|
{ MODEKEYEDIT_SWITCHMODESUBSTITUTE, "switch-mode-substitute" },
|
|
|
|
{ MODEKEYEDIT_SWITCHMODESUBSTITUTELINE, "switch-mode-substitute-line" },
|
2009-09-02 08:33:20 +02:00
|
|
|
{ MODEKEYEDIT_TRANSPOSECHARS, "transpose-chars" },
|
2009-07-28 19:05:10 +02:00
|
|
|
|
|
|
|
{ 0, NULL }
|
2009-07-28 09:03:32 +02:00
|
|
|
};
|
2009-12-03 23:50:09 +01:00
|
|
|
|
2009-07-28 09:03:32 +02:00
|
|
|
/* Choice keys command strings. */
|
2011-01-01 04:39:21 +01:00
|
|
|
const struct mode_key_cmdstr mode_key_cmdstr_choice[] = {
|
2012-08-11 08:45:33 +02:00
|
|
|
{ MODEKEYCHOICE_BACKSPACE, "backspace" },
|
2014-03-31 23:36:43 +02:00
|
|
|
{ MODEKEYCHOICE_BOTTOMLINE, "bottom-line"},
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYCHOICE_CANCEL, "cancel" },
|
|
|
|
{ MODEKEYCHOICE_CHOOSE, "choose" },
|
|
|
|
{ MODEKEYCHOICE_DOWN, "down" },
|
2014-03-31 23:36:43 +02:00
|
|
|
{ MODEKEYCHOICE_ENDOFLIST, "end-of-list"},
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYCHOICE_PAGEDOWN, "page-down" },
|
|
|
|
{ MODEKEYCHOICE_PAGEUP, "page-up" },
|
2010-02-01 23:15:51 +01:00
|
|
|
{ MODEKEYCHOICE_SCROLLDOWN, "scroll-down" },
|
|
|
|
{ MODEKEYCHOICE_SCROLLUP, "scroll-up" },
|
2012-08-11 08:45:33 +02:00
|
|
|
{ MODEKEYCHOICE_STARTNUMBERPREFIX, "start-number-prefix" },
|
2014-03-31 23:36:43 +02:00
|
|
|
{ MODEKEYCHOICE_STARTOFLIST, "start-of-list"},
|
|
|
|
{ MODEKEYCHOICE_TOPLINE, "top-line"},
|
2012-10-09 20:08:21 +02:00
|
|
|
{ MODEKEYCHOICE_TREE_COLLAPSE, "tree-collapse" },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ MODEKEYCHOICE_TREE_COLLAPSE_ALL, "tree-collapse-all" },
|
2012-10-09 20:08:21 +02:00
|
|
|
{ MODEKEYCHOICE_TREE_EXPAND, "tree-expand" },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ MODEKEYCHOICE_TREE_EXPAND_ALL, "tree-expand-all" },
|
|
|
|
{ MODEKEYCHOICE_TREE_TOGGLE, "tree-toggle" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYCHOICE_UP, "up" },
|
2009-07-28 19:05:10 +02:00
|
|
|
|
|
|
|
{ 0, NULL }
|
2009-07-28 09:03:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Copy keys command strings. */
|
2011-01-01 04:39:21 +01:00
|
|
|
const struct mode_key_cmdstr mode_key_cmdstr_copy[] = {
|
2014-03-31 23:39:31 +02:00
|
|
|
{ MODEKEYCOPY_APPENDSELECTION, "append-selection" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYCOPY_BACKTOINDENTATION, "back-to-indentation" },
|
2009-10-13 15:45:56 +02:00
|
|
|
{ MODEKEYCOPY_BOTTOMLINE, "bottom-line" },
|
2009-08-18 09:08:26 +02:00
|
|
|
{ MODEKEYCOPY_CANCEL, "cancel" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYCOPY_CLEARSELECTION, "clear-selection" },
|
2013-03-22 16:52:40 +01:00
|
|
|
{ MODEKEYCOPY_COPYPIPE, "copy-pipe" },
|
2011-05-18 20:06:36 +02:00
|
|
|
{ MODEKEYCOPY_COPYLINE, "copy-line" },
|
|
|
|
{ MODEKEYCOPY_COPYENDOFLINE, "copy-end-of-line" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYCOPY_COPYSELECTION, "copy-selection" },
|
|
|
|
{ MODEKEYCOPY_DOWN, "cursor-down" },
|
|
|
|
{ MODEKEYCOPY_ENDOFLINE, "end-of-line" },
|
2009-08-18 09:08:26 +02:00
|
|
|
{ MODEKEYCOPY_GOTOLINE, "goto-line" },
|
2012-11-19 11:51:25 +01:00
|
|
|
{ MODEKEYCOPY_HALFPAGEDOWN, "halfpage-down" },
|
|
|
|
{ MODEKEYCOPY_HALFPAGEUP, "halfpage-up" },
|
2010-01-25 22:33:39 +01:00
|
|
|
{ MODEKEYCOPY_HISTORYBOTTOM, "history-bottom" },
|
|
|
|
{ MODEKEYCOPY_HISTORYTOP, "history-top" },
|
2010-03-22 20:10:42 +01:00
|
|
|
{ MODEKEYCOPY_JUMP, "jump-forward" },
|
|
|
|
{ MODEKEYCOPY_JUMPAGAIN, "jump-again" },
|
|
|
|
{ MODEKEYCOPY_JUMPREVERSE, "jump-reverse" },
|
|
|
|
{ MODEKEYCOPY_JUMPBACK, "jump-backward" },
|
2011-12-04 17:18:01 +01:00
|
|
|
{ MODEKEYCOPY_JUMPTO, "jump-to-forward" },
|
|
|
|
{ MODEKEYCOPY_JUMPTOBACK, "jump-to-backward" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYCOPY_LEFT, "cursor-left" },
|
2010-02-06 18:35:01 +01:00
|
|
|
{ MODEKEYCOPY_RECTANGLETOGGLE, "rectangle-toggle" },
|
2009-10-13 15:45:56 +02:00
|
|
|
{ MODEKEYCOPY_MIDDLELINE, "middle-line" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYCOPY_NEXTPAGE, "page-down" },
|
2010-02-04 21:00:26 +01:00
|
|
|
{ MODEKEYCOPY_NEXTSPACE, "next-space" },
|
|
|
|
{ MODEKEYCOPY_NEXTSPACEEND, "next-space-end" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYCOPY_NEXTWORD, "next-word" },
|
2010-01-27 21:18:52 +01:00
|
|
|
{ MODEKEYCOPY_NEXTWORDEND, "next-word-end" },
|
2014-08-12 00:39:57 +02:00
|
|
|
{ MODEKEYCOPY_OTHEREND, "other-end" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYCOPY_PREVIOUSPAGE, "page-up" },
|
2010-02-04 21:00:26 +01:00
|
|
|
{ MODEKEYCOPY_PREVIOUSSPACE, "previous-space" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYCOPY_PREVIOUSWORD, "previous-word" },
|
|
|
|
{ MODEKEYCOPY_RIGHT, "cursor-right" },
|
2009-10-06 09:09:00 +02:00
|
|
|
{ MODEKEYCOPY_SCROLLDOWN, "scroll-down" },
|
|
|
|
{ MODEKEYCOPY_SCROLLUP, "scroll-up" },
|
2009-08-18 09:08:26 +02:00
|
|
|
{ MODEKEYCOPY_SEARCHAGAIN, "search-again" },
|
|
|
|
{ MODEKEYCOPY_SEARCHDOWN, "search-forward" },
|
2010-02-11 21:39:40 +01:00
|
|
|
{ MODEKEYCOPY_SEARCHREVERSE, "search-reverse" },
|
2009-08-18 09:08:26 +02:00
|
|
|
{ MODEKEYCOPY_SEARCHUP, "search-backward" },
|
2011-05-18 20:06:36 +02:00
|
|
|
{ MODEKEYCOPY_SELECTLINE, "select-line" },
|
2014-05-13 09:54:20 +02:00
|
|
|
{ MODEKEYCOPY_STARTNAMEDBUFFER, "start-named-buffer" },
|
2010-03-02 01:32:41 +01:00
|
|
|
{ MODEKEYCOPY_STARTNUMBERPREFIX, "start-number-prefix" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYCOPY_STARTOFLINE, "start-of-line" },
|
|
|
|
{ MODEKEYCOPY_STARTSELECTION, "begin-selection" },
|
2009-10-13 15:45:56 +02:00
|
|
|
{ MODEKEYCOPY_TOPLINE, "top-line" },
|
2009-07-28 09:03:32 +02:00
|
|
|
{ MODEKEYCOPY_UP, "cursor-up" },
|
2009-07-28 19:05:10 +02:00
|
|
|
|
|
|
|
{ 0, NULL }
|
2009-07-28 09:03:32 +02:00
|
|
|
};
|
|
|
|
|
2009-07-27 21:29:35 +02:00
|
|
|
/* vi editing keys. */
|
|
|
|
const struct mode_key_entry mode_key_vi_edit[] = {
|
2012-10-02 10:16:28 +02:00
|
|
|
{ '\003' /* C-c */, 0, MODEKEYEDIT_CANCEL },
|
|
|
|
{ '\010' /* C-h */, 0, MODEKEYEDIT_BACKSPACE },
|
|
|
|
{ '\011' /* Tab */, 0, MODEKEYEDIT_COMPLETE },
|
|
|
|
{ '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE },
|
|
|
|
{ '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD },
|
|
|
|
{ '\033' /* Escape */, 0, MODEKEYEDIT_SWITCHMODE },
|
2014-02-14 13:35:58 +01:00
|
|
|
{ '\n', 0, MODEKEYEDIT_ENTER },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ '\r', 0, MODEKEYEDIT_ENTER },
|
|
|
|
{ KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE },
|
|
|
|
{ KEYC_DC, 0, MODEKEYEDIT_DELETE },
|
|
|
|
{ KEYC_DOWN, 0, MODEKEYEDIT_HISTORYDOWN },
|
|
|
|
{ KEYC_LEFT, 0, MODEKEYEDIT_CURSORLEFT },
|
|
|
|
{ KEYC_RIGHT, 0, MODEKEYEDIT_CURSORRIGHT },
|
|
|
|
{ KEYC_UP, 0, MODEKEYEDIT_HISTORYUP },
|
|
|
|
{ KEYC_HOME, 0, MODEKEYEDIT_STARTOFLINE },
|
|
|
|
{ KEYC_END, 0, MODEKEYEDIT_ENDOFLINE },
|
2009-06-02 00:58:49 +02:00
|
|
|
|
2012-10-02 10:16:28 +02:00
|
|
|
{ '$', 1, MODEKEYEDIT_ENDOFLINE },
|
|
|
|
{ '0', 1, MODEKEYEDIT_STARTOFLINE },
|
|
|
|
{ 'A', 1, MODEKEYEDIT_SWITCHMODEAPPENDLINE },
|
|
|
|
{ 'B', 1, MODEKEYEDIT_PREVIOUSSPACE },
|
2013-07-05 16:44:06 +02:00
|
|
|
{ 'C', 1, MODEKEYEDIT_SWITCHMODECHANGELINE },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ 'D', 1, MODEKEYEDIT_DELETETOENDOFLINE },
|
|
|
|
{ 'E', 1, MODEKEYEDIT_NEXTSPACEEND },
|
|
|
|
{ 'I', 1, MODEKEYEDIT_SWITCHMODEBEGINLINE },
|
2013-07-05 16:44:06 +02:00
|
|
|
{ 'S', 1, MODEKEYEDIT_SWITCHMODESUBSTITUTELINE },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ 'W', 1, MODEKEYEDIT_NEXTSPACE },
|
|
|
|
{ 'X', 1, MODEKEYEDIT_BACKSPACE },
|
|
|
|
{ '\003' /* C-c */, 1, MODEKEYEDIT_CANCEL },
|
|
|
|
{ '\010' /* C-h */, 1, MODEKEYEDIT_BACKSPACE },
|
2014-02-14 13:35:58 +01:00
|
|
|
{ '\n', 1, MODEKEYEDIT_ENTER },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ '\r', 1, MODEKEYEDIT_ENTER },
|
|
|
|
{ '^', 1, MODEKEYEDIT_STARTOFLINE },
|
|
|
|
{ 'a', 1, MODEKEYEDIT_SWITCHMODEAPPEND },
|
|
|
|
{ 'b', 1, MODEKEYEDIT_PREVIOUSWORD },
|
|
|
|
{ 'd', 1, MODEKEYEDIT_DELETELINE },
|
|
|
|
{ 'e', 1, MODEKEYEDIT_NEXTWORDEND },
|
|
|
|
{ 'h', 1, MODEKEYEDIT_CURSORLEFT },
|
|
|
|
{ 'i', 1, MODEKEYEDIT_SWITCHMODE },
|
|
|
|
{ 'j', 1, MODEKEYEDIT_HISTORYDOWN },
|
|
|
|
{ 'k', 1, MODEKEYEDIT_HISTORYUP },
|
|
|
|
{ 'l', 1, MODEKEYEDIT_CURSORRIGHT },
|
|
|
|
{ 'p', 1, MODEKEYEDIT_PASTE },
|
2013-07-05 16:44:06 +02:00
|
|
|
{ 's', 1, MODEKEYEDIT_SWITCHMODESUBSTITUTE },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ 'w', 1, MODEKEYEDIT_NEXTWORD },
|
|
|
|
{ 'x', 1, MODEKEYEDIT_DELETE },
|
|
|
|
{ KEYC_BSPACE, 1, MODEKEYEDIT_BACKSPACE },
|
|
|
|
{ KEYC_DC, 1, MODEKEYEDIT_DELETE },
|
|
|
|
{ KEYC_DOWN, 1, MODEKEYEDIT_HISTORYDOWN },
|
|
|
|
{ KEYC_LEFT, 1, MODEKEYEDIT_CURSORLEFT },
|
|
|
|
{ KEYC_RIGHT, 1, MODEKEYEDIT_CURSORRIGHT },
|
|
|
|
{ KEYC_UP, 1, MODEKEYEDIT_HISTORYUP },
|
2009-06-02 00:58:49 +02:00
|
|
|
|
2012-10-02 10:16:28 +02:00
|
|
|
{ 0, -1, 0 }
|
2009-07-27 21:29:35 +02:00
|
|
|
};
|
2009-07-28 09:03:32 +02:00
|
|
|
struct mode_key_tree mode_key_tree_vi_edit;
|
2009-06-02 00:58:49 +02:00
|
|
|
|
2009-07-27 21:29:35 +02:00
|
|
|
/* vi choice selection keys. */
|
|
|
|
const struct mode_key_entry mode_key_vi_choice[] = {
|
2012-10-02 10:16:28 +02:00
|
|
|
{ '0' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '1' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '2' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '3' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '4' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '5' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '6' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '7' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '8' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '9' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '\002' /* C-b */, 0, MODEKEYCHOICE_PAGEUP },
|
|
|
|
{ '\003' /* C-c */, 0, MODEKEYCHOICE_CANCEL },
|
|
|
|
{ '\005' /* C-e */, 0, MODEKEYCHOICE_SCROLLDOWN },
|
|
|
|
{ '\006' /* C-f */, 0, MODEKEYCHOICE_PAGEDOWN },
|
|
|
|
{ '\031' /* C-y */, 0, MODEKEYCHOICE_SCROLLUP },
|
2014-02-14 13:35:58 +01:00
|
|
|
{ '\n', 0, MODEKEYCHOICE_CHOOSE },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ '\r', 0, MODEKEYCHOICE_CHOOSE },
|
|
|
|
{ 'j', 0, MODEKEYCHOICE_DOWN },
|
|
|
|
{ 'k', 0, MODEKEYCHOICE_UP },
|
|
|
|
{ 'q', 0, MODEKEYCHOICE_CANCEL },
|
2014-03-31 23:36:43 +02:00
|
|
|
{ KEYC_HOME, 0, MODEKEYCHOICE_STARTOFLIST },
|
|
|
|
{ 'g', 0, MODEKEYCHOICE_STARTOFLIST },
|
|
|
|
{ 'H', 0, MODEKEYCHOICE_TOPLINE },
|
|
|
|
{ 'L', 0, MODEKEYCHOICE_BOTTOMLINE },
|
|
|
|
{ 'G', 0, MODEKEYCHOICE_ENDOFLIST },
|
|
|
|
{ KEYC_END, 0, MODEKEYCHOICE_ENDOFLIST },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ KEYC_BSPACE, 0, MODEKEYCHOICE_BACKSPACE },
|
|
|
|
{ KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLDOWN },
|
|
|
|
{ KEYC_DOWN, 0, MODEKEYCHOICE_DOWN },
|
|
|
|
{ KEYC_NPAGE, 0, MODEKEYCHOICE_PAGEDOWN },
|
|
|
|
{ KEYC_PPAGE, 0, MODEKEYCHOICE_PAGEUP },
|
|
|
|
{ KEYC_UP | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLUP },
|
|
|
|
{ KEYC_UP, 0, MODEKEYCHOICE_UP },
|
|
|
|
{ ' ', 0, MODEKEYCHOICE_TREE_TOGGLE },
|
2013-07-05 16:44:06 +02:00
|
|
|
{ KEYC_LEFT, 0, MODEKEYCHOICE_TREE_COLLAPSE },
|
|
|
|
{ KEYC_RIGHT, 0, MODEKEYCHOICE_TREE_EXPAND },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ KEYC_LEFT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_COLLAPSE_ALL },
|
|
|
|
{ KEYC_RIGHT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_EXPAND_ALL },
|
2015-04-19 23:34:21 +02:00
|
|
|
{ KEYC_MOUSEDOWN1_PANE, 0, MODEKEYCHOICE_CHOOSE },
|
|
|
|
{ KEYC_MOUSEDOWN3_PANE, 0, MODEKEYCHOICE_TREE_TOGGLE },
|
|
|
|
{ KEYC_WHEELUP_PANE, 0, MODEKEYCHOICE_UP },
|
|
|
|
{ KEYC_WHEELDOWN_PANE, 0, MODEKEYCHOICE_DOWN },
|
2009-06-02 00:58:49 +02:00
|
|
|
|
2012-10-02 10:16:28 +02:00
|
|
|
{ 0, -1, 0 }
|
2009-07-27 21:29:35 +02:00
|
|
|
};
|
2009-07-28 09:03:32 +02:00
|
|
|
struct mode_key_tree mode_key_tree_vi_choice;
|
2009-06-02 00:58:49 +02:00
|
|
|
|
2009-07-27 21:29:35 +02:00
|
|
|
/* vi copy mode keys. */
|
|
|
|
const struct mode_key_entry mode_key_vi_copy[] = {
|
2012-10-02 10:16:28 +02:00
|
|
|
{ ' ', 0, MODEKEYCOPY_STARTSELECTION },
|
2014-05-13 09:54:20 +02:00
|
|
|
{ '"', 0, MODEKEYCOPY_STARTNAMEDBUFFER },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ '$', 0, MODEKEYCOPY_ENDOFLINE },
|
|
|
|
{ ',', 0, MODEKEYCOPY_JUMPREVERSE },
|
|
|
|
{ ';', 0, MODEKEYCOPY_JUMPAGAIN },
|
|
|
|
{ '/', 0, MODEKEYCOPY_SEARCHDOWN },
|
|
|
|
{ '0', 0, MODEKEYCOPY_STARTOFLINE },
|
|
|
|
{ '1', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '2', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '3', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '4', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '5', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '6', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '7', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '8', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '9', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ ':', 0, MODEKEYCOPY_GOTOLINE },
|
|
|
|
{ '?', 0, MODEKEYCOPY_SEARCHUP },
|
2014-03-31 23:39:31 +02:00
|
|
|
{ 'A', 0, MODEKEYCOPY_APPENDSELECTION },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ 'B', 0, MODEKEYCOPY_PREVIOUSSPACE },
|
|
|
|
{ 'D', 0, MODEKEYCOPY_COPYENDOFLINE },
|
|
|
|
{ 'E', 0, MODEKEYCOPY_NEXTSPACEEND },
|
|
|
|
{ 'F', 0, MODEKEYCOPY_JUMPBACK },
|
|
|
|
{ 'G', 0, MODEKEYCOPY_HISTORYBOTTOM },
|
|
|
|
{ 'H', 0, MODEKEYCOPY_TOPLINE },
|
|
|
|
{ 'J', 0, MODEKEYCOPY_SCROLLDOWN },
|
|
|
|
{ 'K', 0, MODEKEYCOPY_SCROLLUP },
|
|
|
|
{ 'L', 0, MODEKEYCOPY_BOTTOMLINE },
|
|
|
|
{ 'M', 0, MODEKEYCOPY_MIDDLELINE },
|
|
|
|
{ 'N', 0, MODEKEYCOPY_SEARCHREVERSE },
|
|
|
|
{ 'T', 0, MODEKEYCOPY_JUMPTOBACK },
|
2014-11-06 10:17:25 +01:00
|
|
|
{ 'V', 0, MODEKEYCOPY_SELECTLINE },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ 'W', 0, MODEKEYCOPY_NEXTSPACE },
|
|
|
|
{ '\002' /* C-b */, 0, MODEKEYCOPY_PREVIOUSPAGE },
|
|
|
|
{ '\003' /* C-c */, 0, MODEKEYCOPY_CANCEL },
|
|
|
|
{ '\004' /* C-d */, 0, MODEKEYCOPY_HALFPAGEDOWN },
|
|
|
|
{ '\005' /* C-e */, 0, MODEKEYCOPY_SCROLLDOWN },
|
|
|
|
{ '\006' /* C-f */, 0, MODEKEYCOPY_NEXTPAGE },
|
|
|
|
{ '\010' /* C-h */, 0, MODEKEYCOPY_LEFT },
|
|
|
|
{ '\025' /* C-u */, 0, MODEKEYCOPY_HALFPAGEUP },
|
|
|
|
{ '\031' /* C-y */, 0, MODEKEYCOPY_SCROLLUP },
|
|
|
|
{ '\033' /* Escape */, 0, MODEKEYCOPY_CLEARSELECTION },
|
2014-02-14 13:35:58 +01:00
|
|
|
{ '\n', 0, MODEKEYCOPY_COPYSELECTION },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ '\r', 0, MODEKEYCOPY_COPYSELECTION },
|
|
|
|
{ '^', 0, MODEKEYCOPY_BACKTOINDENTATION },
|
|
|
|
{ 'b', 0, MODEKEYCOPY_PREVIOUSWORD },
|
|
|
|
{ 'e', 0, MODEKEYCOPY_NEXTWORDEND },
|
|
|
|
{ 'f', 0, MODEKEYCOPY_JUMP },
|
|
|
|
{ 'g', 0, MODEKEYCOPY_HISTORYTOP },
|
|
|
|
{ 'h', 0, MODEKEYCOPY_LEFT },
|
|
|
|
{ 'j', 0, MODEKEYCOPY_DOWN },
|
|
|
|
{ 'k', 0, MODEKEYCOPY_UP },
|
|
|
|
{ 'l', 0, MODEKEYCOPY_RIGHT },
|
|
|
|
{ 'n', 0, MODEKEYCOPY_SEARCHAGAIN },
|
2013-10-23 13:31:03 +02:00
|
|
|
{ 'o', 0, MODEKEYCOPY_OTHEREND },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ 't', 0, MODEKEYCOPY_JUMPTO },
|
|
|
|
{ 'q', 0, MODEKEYCOPY_CANCEL },
|
|
|
|
{ 'v', 0, MODEKEYCOPY_RECTANGLETOGGLE },
|
|
|
|
{ 'w', 0, MODEKEYCOPY_NEXTWORD },
|
|
|
|
{ KEYC_BSPACE, 0, MODEKEYCOPY_LEFT },
|
|
|
|
{ KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLDOWN },
|
|
|
|
{ KEYC_DOWN, 0, MODEKEYCOPY_DOWN },
|
|
|
|
{ KEYC_LEFT, 0, MODEKEYCOPY_LEFT },
|
|
|
|
{ KEYC_NPAGE, 0, MODEKEYCOPY_NEXTPAGE },
|
|
|
|
{ KEYC_PPAGE, 0, MODEKEYCOPY_PREVIOUSPAGE },
|
|
|
|
{ KEYC_RIGHT, 0, MODEKEYCOPY_RIGHT },
|
|
|
|
{ KEYC_UP | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLUP },
|
|
|
|
{ KEYC_UP, 0, MODEKEYCOPY_UP },
|
2015-04-19 23:34:21 +02:00
|
|
|
{ KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP },
|
|
|
|
{ KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN },
|
|
|
|
{ KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION },
|
2009-12-03 23:50:09 +01:00
|
|
|
|
2012-10-02 10:16:28 +02:00
|
|
|
{ 0, -1, 0 }
|
2009-07-27 21:29:35 +02:00
|
|
|
};
|
2009-07-28 09:03:32 +02:00
|
|
|
struct mode_key_tree mode_key_tree_vi_copy;
|
2009-06-02 00:58:49 +02:00
|
|
|
|
2009-07-27 21:29:35 +02:00
|
|
|
/* emacs editing keys. */
|
|
|
|
const struct mode_key_entry mode_key_emacs_edit[] = {
|
2012-10-02 10:16:28 +02:00
|
|
|
{ '\001' /* C-a */, 0, MODEKEYEDIT_STARTOFLINE },
|
|
|
|
{ '\002' /* C-b */, 0, MODEKEYEDIT_CURSORLEFT },
|
|
|
|
{ '\003' /* C-c */, 0, MODEKEYEDIT_CANCEL },
|
|
|
|
{ '\004' /* C-d */, 0, MODEKEYEDIT_DELETE },
|
|
|
|
{ '\005' /* C-e */, 0, MODEKEYEDIT_ENDOFLINE },
|
|
|
|
{ '\006' /* C-f */, 0, MODEKEYEDIT_CURSORRIGHT },
|
|
|
|
{ '\010' /* C-H */, 0, MODEKEYEDIT_BACKSPACE },
|
|
|
|
{ '\011' /* Tab */, 0, MODEKEYEDIT_COMPLETE },
|
|
|
|
{ '\013' /* C-k */, 0, MODEKEYEDIT_DELETETOENDOFLINE },
|
|
|
|
{ '\016' /* C-n */, 0, MODEKEYEDIT_HISTORYDOWN },
|
|
|
|
{ '\020' /* C-p */, 0, MODEKEYEDIT_HISTORYUP },
|
|
|
|
{ '\024' /* C-t */, 0, MODEKEYEDIT_TRANSPOSECHARS },
|
|
|
|
{ '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE },
|
|
|
|
{ '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD },
|
|
|
|
{ '\031' /* C-y */, 0, MODEKEYEDIT_PASTE },
|
|
|
|
{ '\033' /* Escape */, 0, MODEKEYEDIT_CANCEL },
|
2014-02-14 13:35:58 +01:00
|
|
|
{ '\n', 0, MODEKEYEDIT_ENTER },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ '\r', 0, MODEKEYEDIT_ENTER },
|
|
|
|
{ 'b' | KEYC_ESCAPE, 0, MODEKEYEDIT_PREVIOUSWORD },
|
|
|
|
{ 'f' | KEYC_ESCAPE, 0, MODEKEYEDIT_NEXTWORDEND },
|
|
|
|
{ 'm' | KEYC_ESCAPE, 0, MODEKEYEDIT_STARTOFLINE },
|
|
|
|
{ KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE },
|
|
|
|
{ KEYC_DC, 0, MODEKEYEDIT_DELETE },
|
|
|
|
{ KEYC_DOWN, 0, MODEKEYEDIT_HISTORYDOWN },
|
|
|
|
{ KEYC_LEFT, 0, MODEKEYEDIT_CURSORLEFT },
|
|
|
|
{ KEYC_RIGHT, 0, MODEKEYEDIT_CURSORRIGHT },
|
|
|
|
{ KEYC_UP, 0, MODEKEYEDIT_HISTORYUP },
|
|
|
|
{ KEYC_HOME, 0, MODEKEYEDIT_STARTOFLINE },
|
|
|
|
{ KEYC_END, 0, MODEKEYEDIT_ENDOFLINE },
|
2009-07-27 21:29:35 +02:00
|
|
|
|
2012-10-02 10:16:28 +02:00
|
|
|
{ 0, -1, 0 }
|
2009-07-27 21:29:35 +02:00
|
|
|
};
|
2009-07-28 09:03:32 +02:00
|
|
|
struct mode_key_tree mode_key_tree_emacs_edit;
|
2009-07-27 21:29:35 +02:00
|
|
|
|
|
|
|
/* emacs choice selection keys. */
|
|
|
|
const struct mode_key_entry mode_key_emacs_choice[] = {
|
2012-10-02 10:16:28 +02:00
|
|
|
{ '0' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '1' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '2' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '3' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '4' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '5' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '6' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '7' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '8' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '9' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX },
|
|
|
|
{ '\003' /* C-c */, 0, MODEKEYCHOICE_CANCEL },
|
|
|
|
{ '\016' /* C-n */, 0, MODEKEYCHOICE_DOWN },
|
|
|
|
{ '\020' /* C-p */, 0, MODEKEYCHOICE_UP },
|
|
|
|
{ '\026' /* C-v */, 0, MODEKEYCHOICE_PAGEDOWN },
|
|
|
|
{ '\033' /* Escape */, 0, MODEKEYCHOICE_CANCEL },
|
2014-02-14 13:35:58 +01:00
|
|
|
{ '\n', 0, MODEKEYCHOICE_CHOOSE },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ '\r', 0, MODEKEYCHOICE_CHOOSE },
|
|
|
|
{ 'q', 0, MODEKEYCHOICE_CANCEL },
|
|
|
|
{ 'v' | KEYC_ESCAPE, 0, MODEKEYCHOICE_PAGEUP },
|
2014-03-31 23:36:43 +02:00
|
|
|
{ KEYC_HOME, 0, MODEKEYCHOICE_STARTOFLIST },
|
|
|
|
{ '<' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTOFLIST },
|
|
|
|
{ 'R' | KEYC_ESCAPE, 0, MODEKEYCHOICE_TOPLINE },
|
|
|
|
{ '>' | KEYC_ESCAPE, 0, MODEKEYCHOICE_ENDOFLIST },
|
|
|
|
{ KEYC_END, 0, MODEKEYCHOICE_ENDOFLIST },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ KEYC_BSPACE, 0, MODEKEYCHOICE_BACKSPACE },
|
|
|
|
{ KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLDOWN },
|
|
|
|
{ KEYC_DOWN, 0, MODEKEYCHOICE_DOWN },
|
|
|
|
{ KEYC_NPAGE, 0, MODEKEYCHOICE_PAGEDOWN },
|
|
|
|
{ KEYC_PPAGE, 0, MODEKEYCHOICE_PAGEUP },
|
|
|
|
{ KEYC_UP | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLUP },
|
|
|
|
{ KEYC_UP, 0, MODEKEYCHOICE_UP },
|
|
|
|
{ ' ', 0, MODEKEYCHOICE_TREE_TOGGLE },
|
2013-07-05 16:44:06 +02:00
|
|
|
{ KEYC_LEFT, 0, MODEKEYCHOICE_TREE_COLLAPSE },
|
|
|
|
{ KEYC_RIGHT, 0, MODEKEYCHOICE_TREE_EXPAND },
|
2012-10-02 10:16:28 +02:00
|
|
|
{ KEYC_LEFT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_COLLAPSE_ALL },
|
|
|
|
{ KEYC_RIGHT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_EXPAND_ALL },
|
2015-04-19 23:34:21 +02:00
|
|
|
{ KEYC_MOUSEDOWN1_PANE, 0, MODEKEYCHOICE_CHOOSE },
|
|
|
|
{ KEYC_MOUSEDOWN3_PANE, 0, MODEKEYCHOICE_TREE_TOGGLE },
|
|
|
|
{ KEYC_WHEELUP_PANE, 0, MODEKEYCHOICE_UP },
|
|
|
|
{ KEYC_WHEELDOWN_PANE, 0, MODEKEYCHOICE_DOWN },
|
2009-07-27 21:29:35 +02:00
|
|
|
|
2012-10-02 10:16:28 +02:00
|
|
|
{ 0, -1, 0 }
|
2009-07-27 21:29:35 +02:00
|
|
|
};
|
2009-07-28 09:03:32 +02:00
|
|
|
struct mode_key_tree mode_key_tree_emacs_choice;
|
2009-07-27 21:29:35 +02:00
|
|
|
|
|
|
|
/* emacs copy mode keys. */
|
|
|
|
const struct mode_key_entry mode_key_emacs_copy[] = {
|
2012-10-02 10:16:28 +02:00
|
|
|
{ ' ', 0, MODEKEYCOPY_NEXTPAGE },
|
|
|
|
{ ',', 0, MODEKEYCOPY_JUMPREVERSE },
|
|
|
|
{ ';', 0, MODEKEYCOPY_JUMPAGAIN },
|
|
|
|
{ '1' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '2' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '3' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '4' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '5' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '6' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '7' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '8' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '9' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
|
|
|
|
{ '<' | KEYC_ESCAPE, 0, MODEKEYCOPY_HISTORYTOP },
|
|
|
|
{ '>' | KEYC_ESCAPE, 0, MODEKEYCOPY_HISTORYBOTTOM },
|
|
|
|
{ 'F', 0, MODEKEYCOPY_JUMPBACK },
|
|
|
|
{ 'N', 0, MODEKEYCOPY_SEARCHREVERSE },
|
|
|
|
{ 'R' | KEYC_ESCAPE, 0, MODEKEYCOPY_TOPLINE },
|
|
|
|
{ 'R', 0, MODEKEYCOPY_RECTANGLETOGGLE },
|
|
|
|
{ 'T', 0, MODEKEYCOPY_JUMPTOBACK },
|
|
|
|
{ '\000' /* C-Space */, 0, MODEKEYCOPY_STARTSELECTION },
|
|
|
|
{ '\001' /* C-a */, 0, MODEKEYCOPY_STARTOFLINE },
|
|
|
|
{ '\002' /* C-b */, 0, MODEKEYCOPY_LEFT },
|
|
|
|
{ '\003' /* C-c */, 0, MODEKEYCOPY_CANCEL },
|
|
|
|
{ '\005' /* C-e */, 0, MODEKEYCOPY_ENDOFLINE },
|
|
|
|
{ '\006' /* C-f */, 0, MODEKEYCOPY_RIGHT },
|
|
|
|
{ '\007' /* C-g */, 0, MODEKEYCOPY_CLEARSELECTION },
|
|
|
|
{ '\013' /* C-k */, 0, MODEKEYCOPY_COPYENDOFLINE },
|
|
|
|
{ '\016' /* C-n */, 0, MODEKEYCOPY_DOWN },
|
|
|
|
{ '\020' /* C-p */, 0, MODEKEYCOPY_UP },
|
|
|
|
{ '\022' /* C-r */, 0, MODEKEYCOPY_SEARCHUP },
|
|
|
|
{ '\023' /* C-s */, 0, MODEKEYCOPY_SEARCHDOWN },
|
|
|
|
{ '\026' /* C-v */, 0, MODEKEYCOPY_NEXTPAGE },
|
|
|
|
{ '\027' /* C-w */, 0, MODEKEYCOPY_COPYSELECTION },
|
|
|
|
{ '\033' /* Escape */, 0, MODEKEYCOPY_CANCEL },
|
|
|
|
{ 'b' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSWORD },
|
|
|
|
{ 'f', 0, MODEKEYCOPY_JUMP },
|
|
|
|
{ 'f' | KEYC_ESCAPE, 0, MODEKEYCOPY_NEXTWORDEND },
|
|
|
|
{ 'g', 0, MODEKEYCOPY_GOTOLINE },
|
|
|
|
{ 'm' | KEYC_ESCAPE, 0, MODEKEYCOPY_BACKTOINDENTATION },
|
|
|
|
{ 'n', 0, MODEKEYCOPY_SEARCHAGAIN },
|
|
|
|
{ 'q', 0, MODEKEYCOPY_CANCEL },
|
|
|
|
{ 'r' | KEYC_ESCAPE, 0, MODEKEYCOPY_MIDDLELINE },
|
|
|
|
{ 't', 0, MODEKEYCOPY_JUMPTO },
|
|
|
|
{ 'v' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPAGE },
|
|
|
|
{ 'w' | KEYC_ESCAPE, 0, MODEKEYCOPY_COPYSELECTION },
|
|
|
|
{ KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLDOWN },
|
|
|
|
{ KEYC_DOWN | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEDOWN },
|
|
|
|
{ KEYC_DOWN, 0, MODEKEYCOPY_DOWN },
|
|
|
|
{ KEYC_LEFT, 0, MODEKEYCOPY_LEFT },
|
|
|
|
{ KEYC_NPAGE, 0, MODEKEYCOPY_NEXTPAGE },
|
|
|
|
{ KEYC_PPAGE, 0, MODEKEYCOPY_PREVIOUSPAGE },
|
|
|
|
{ KEYC_RIGHT, 0, MODEKEYCOPY_RIGHT },
|
|
|
|
{ KEYC_UP | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLUP },
|
|
|
|
{ KEYC_UP | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEUP },
|
|
|
|
{ KEYC_UP, 0, MODEKEYCOPY_UP },
|
2015-04-19 23:34:21 +02:00
|
|
|
{ KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP },
|
|
|
|
{ KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN },
|
|
|
|
{ KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION },
|
2009-07-27 21:29:35 +02:00
|
|
|
|
2012-10-02 10:16:28 +02:00
|
|
|
{ 0, -1, 0 }
|
2009-07-27 21:29:35 +02:00
|
|
|
};
|
2009-07-28 09:03:32 +02:00
|
|
|
struct mode_key_tree mode_key_tree_emacs_copy;
|
|
|
|
|
|
|
|
/* Table mapping key table names to default settings and trees. */
|
|
|
|
const struct mode_key_table mode_key_tables[] = {
|
|
|
|
{ "vi-edit", mode_key_cmdstr_edit,
|
|
|
|
&mode_key_tree_vi_edit, mode_key_vi_edit },
|
|
|
|
{ "vi-choice", mode_key_cmdstr_choice,
|
|
|
|
&mode_key_tree_vi_choice, mode_key_vi_choice },
|
|
|
|
{ "vi-copy", mode_key_cmdstr_copy,
|
|
|
|
&mode_key_tree_vi_copy, mode_key_vi_copy },
|
|
|
|
{ "emacs-edit", mode_key_cmdstr_edit,
|
|
|
|
&mode_key_tree_emacs_edit, mode_key_emacs_edit },
|
|
|
|
{ "emacs-choice", mode_key_cmdstr_choice,
|
|
|
|
&mode_key_tree_emacs_choice, mode_key_emacs_choice },
|
|
|
|
{ "emacs-copy", mode_key_cmdstr_copy,
|
|
|
|
&mode_key_tree_emacs_copy, mode_key_emacs_copy },
|
|
|
|
|
|
|
|
{ NULL, NULL, NULL, NULL }
|
|
|
|
};
|
|
|
|
|
2012-01-21 12:12:13 +01:00
|
|
|
RB_GENERATE(mode_key_tree, mode_key_binding, entry, mode_key_cmp);
|
2009-07-28 09:03:32 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
mode_key_cmp(struct mode_key_binding *mbind1, struct mode_key_binding *mbind2)
|
|
|
|
{
|
|
|
|
if (mbind1->mode != mbind2->mode)
|
|
|
|
return (mbind1->mode - mbind2->mode);
|
|
|
|
return (mbind1->key - mbind2->key);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
2011-01-01 04:39:21 +01:00
|
|
|
mode_key_tostring(const struct mode_key_cmdstr *cmdstr, enum mode_key_cmd cmd)
|
2009-07-28 09:03:32 +02:00
|
|
|
{
|
|
|
|
for (; cmdstr->name != NULL; cmdstr++) {
|
|
|
|
if (cmdstr->cmd == cmd)
|
|
|
|
return (cmdstr->name);
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
2009-06-02 00:58:49 +02:00
|
|
|
|
2009-07-28 19:05:10 +02:00
|
|
|
enum mode_key_cmd
|
2011-01-01 04:39:21 +01:00
|
|
|
mode_key_fromstring(const struct mode_key_cmdstr *cmdstr, const char *name)
|
2009-07-28 19:05:10 +02:00
|
|
|
{
|
|
|
|
for (; cmdstr->name != NULL; cmdstr++) {
|
|
|
|
if (strcasecmp(cmdstr->name, name) == 0)
|
|
|
|
return (cmdstr->cmd);
|
|
|
|
}
|
|
|
|
return (MODEKEY_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct mode_key_table *
|
|
|
|
mode_key_findtable(const char *name)
|
|
|
|
{
|
|
|
|
const struct mode_key_table *mtab;
|
2009-12-03 23:50:09 +01:00
|
|
|
|
2009-07-28 19:05:10 +02:00
|
|
|
for (mtab = mode_key_tables; mtab->name != NULL; mtab++) {
|
|
|
|
if (strcasecmp(name, mtab->name) == 0)
|
|
|
|
return (mtab);
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2009-07-27 21:29:35 +02:00
|
|
|
void
|
2009-07-28 09:03:32 +02:00
|
|
|
mode_key_init_trees(void)
|
2009-07-27 21:29:35 +02:00
|
|
|
{
|
2009-07-28 09:03:32 +02:00
|
|
|
const struct mode_key_table *mtab;
|
|
|
|
const struct mode_key_entry *ment;
|
|
|
|
struct mode_key_binding *mbind;
|
|
|
|
|
|
|
|
for (mtab = mode_key_tables; mtab->name != NULL; mtab++) {
|
2012-01-21 12:12:13 +01:00
|
|
|
RB_INIT(mtab->tree);
|
2009-07-28 09:03:32 +02:00
|
|
|
for (ment = mtab->table; ment->mode != -1; ment++) {
|
|
|
|
mbind = xmalloc(sizeof *mbind);
|
|
|
|
mbind->key = ment->key;
|
|
|
|
mbind->mode = ment->mode;
|
|
|
|
mbind->cmd = ment->cmd;
|
2013-03-22 16:52:40 +01:00
|
|
|
mbind->arg = NULL;
|
2012-01-21 12:12:13 +01:00
|
|
|
RB_INSERT(mode_key_tree, mtab->tree, mbind);
|
2009-07-28 09:03:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mode_key_init(struct mode_key_data *mdata, struct mode_key_tree *mtree)
|
|
|
|
{
|
|
|
|
mdata->tree = mtree;
|
2009-07-27 21:29:35 +02:00
|
|
|
mdata->mode = 0;
|
2009-06-02 00:58:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
enum mode_key_cmd
|
2013-03-22 16:52:40 +01:00
|
|
|
mode_key_lookup(struct mode_key_data *mdata, int key, const char **arg)
|
2009-06-02 00:58:49 +02:00
|
|
|
{
|
2009-07-28 09:03:32 +02:00
|
|
|
struct mode_key_binding *mbind, mtmp;
|
|
|
|
|
|
|
|
mtmp.key = key;
|
|
|
|
mtmp.mode = mdata->mode;
|
2012-01-21 12:12:13 +01:00
|
|
|
if ((mbind = RB_FIND(mode_key_tree, mdata->tree, &mtmp)) == NULL) {
|
2009-07-28 09:03:32 +02:00
|
|
|
if (mdata->mode != 0)
|
|
|
|
return (MODEKEY_NONE);
|
|
|
|
return (MODEKEY_OTHER);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mbind->cmd) {
|
|
|
|
case MODEKEYEDIT_SWITCHMODE:
|
|
|
|
case MODEKEYEDIT_SWITCHMODEAPPEND:
|
2012-03-04 08:38:11 +01:00
|
|
|
case MODEKEYEDIT_SWITCHMODEAPPENDLINE:
|
|
|
|
case MODEKEYEDIT_SWITCHMODEBEGINLINE:
|
2013-07-05 16:44:06 +02:00
|
|
|
case MODEKEYEDIT_SWITCHMODECHANGELINE:
|
|
|
|
case MODEKEYEDIT_SWITCHMODESUBSTITUTE:
|
|
|
|
case MODEKEYEDIT_SWITCHMODESUBSTITUTELINE:
|
2009-07-28 09:03:32 +02:00
|
|
|
mdata->mode = 1 - mdata->mode;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
default:
|
2013-03-22 16:52:40 +01:00
|
|
|
if (arg != NULL)
|
|
|
|
*arg = mbind->arg;
|
2009-07-28 09:03:32 +02:00
|
|
|
return (mbind->cmd);
|
2009-07-27 21:29:35 +02:00
|
|
|
}
|
2009-06-02 00:58:49 +02:00
|
|
|
}
|