diff options
author | nicm <nicm> | 2014-10-20 22:29:25 +0000 |
---|---|---|
committer | nicm <nicm> | 2014-10-20 22:29:25 +0000 |
commit | 45dfc5a074e2ceae11a6d4aeae597bee1e028503 (patch) | |
tree | 9d22fe7f44eb011e6e92f4fed167d158b5c4b006 | |
parent | f0b69c771173583eee8f1457c080746ea6144c5f (diff) |
Instead of setting up the default keys by building the key struct
directly with a helper function in the cmd_entry, include a table of
bind-key commands and pass them through the command parser and a
temporary cmd_q.
As well as being smaller, this will allow default bindings to be command
sequences which will probably be needed soon.
68 files changed, 86 insertions, 403 deletions
diff --git a/cmd-attach-session.c b/cmd-attach-session.c index 94f01e4c..160f2a8f 100644 --- a/cmd-attach-session.c +++ b/cmd-attach-session.c @@ -37,7 +37,6 @@ const struct cmd_entry cmd_attach_session_entry = { "c:drt:", 0, 0, "[-dr] [-c working-directory] " CMD_TARGET_SESSION_USAGE, CMD_CANTNEST|CMD_STARTSERVER, - NULL, cmd_attach_session_exec }; diff --git a/cmd-bind-key.c b/cmd-bind-key.c index dce0bbf0..5d68d486 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -36,7 +36,6 @@ const struct cmd_entry cmd_bind_key_entry = { "cnrt:", 1, -1, "[-cnr] [-t mode-table] key command [arguments]", 0, - NULL, cmd_bind_key_exec }; diff --git a/cmd-break-pane.c b/cmd-break-pane.c index 85c5d4d9..5e7ecd02 100644 --- a/cmd-break-pane.c +++ b/cmd-break-pane.c @@ -33,7 +33,6 @@ const struct cmd_entry cmd_break_pane_entry = { "dPF:t:", 0, 0, "[-dP] [-F format] " CMD_TARGET_PANE_USAGE, 0, - NULL, cmd_break_pane_exec }; diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c index 50bddc7c..ce60b4c5 100644 --- a/cmd-capture-pane.c +++ b/cmd-capture-pane.c @@ -41,7 +41,6 @@ const struct cmd_entry cmd_capture_pane_entry = { "[-aCeJpPq] " CMD_BUFFER_USAGE " [-E end-line] [-S start-line]" CMD_TARGET_PANE_USAGE, 0, - NULL, cmd_capture_pane_exec }; diff --git a/cmd-choose-buffer.c b/cmd-choose-buffer.c index 42caa7cd..de4855ae 100644 --- a/cmd-choose-buffer.c +++ b/cmd-choose-buffer.c @@ -34,7 +34,6 @@ const struct cmd_entry cmd_choose_buffer_entry = { "F:t:", 0, 1, CMD_TARGET_WINDOW_USAGE " [-F format] [template]", 0, - NULL, cmd_choose_buffer_exec }; diff --git a/cmd-choose-client.c b/cmd-choose-client.c index 47ff1976..be3d4056 100644 --- a/cmd-choose-client.c +++ b/cmd-choose-client.c @@ -36,7 +36,6 @@ const struct cmd_entry cmd_choose_client_entry = { "F:t:", 0, 1, CMD_TARGET_WINDOW_USAGE " [-F format] [template]", 0, - NULL, cmd_choose_client_exec }; diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c index 257908e1..eee49cc2 100644 --- a/cmd-choose-tree.c +++ b/cmd-choose-tree.c @@ -40,7 +40,6 @@ const struct cmd_entry cmd_choose_tree_entry = { "[-suw] [-b session-template] [-c window template] [-S format] " \ "[-W format] " CMD_TARGET_WINDOW_USAGE, 0, - NULL, cmd_choose_tree_exec }; @@ -49,7 +48,6 @@ const struct cmd_entry cmd_choose_session_entry = { "F:t:", 0, 1, CMD_TARGET_WINDOW_USAGE " [-F format] [template]", 0, - NULL, cmd_choose_tree_exec }; @@ -58,7 +56,6 @@ const struct cmd_entry cmd_choose_window_entry = { "F:t:", 0, 1, CMD_TARGET_WINDOW_USAGE "[-F format] [template]", 0, - NULL, cmd_choose_tree_exec }; diff --git a/cmd-clear-history.c b/cmd-clear-history.c index 69885f08..e1342880 100644 --- a/cmd-clear-history.c +++ b/cmd-clear-history.c @@ -31,7 +31,6 @@ const struct cmd_entry cmd_clear_history_entry = { "t:", 0, 0, CMD_TARGET_PANE_USAGE, 0, - NULL, cmd_clear_history_exec }; diff --git a/cmd-clock-mode.c b/cmd-clock-mode.c index 09f16e17..80835813 100644 --- a/cmd-clock-mode.c +++ b/cmd-clock-mode.c @@ -31,7 +31,6 @@ const struct cmd_entry cmd_clock_mode_entry = { "t:", 0, 0, CMD_TARGET_PANE_USAGE, 0, - NULL, cmd_clock_mode_exec }; diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c index fc625f53..22b1d84e 100644 --- a/cmd-command-prompt.c +++ b/cmd-command-prompt.c @@ -29,7 +29,6 @@ * Prompt for command in client. */ -void cmd_command_prompt_key_binding(struct cmd *, int); enum cmd_retval cmd_command_prompt_exec(struct cmd *, struct cmd_q *); int cmd_command_prompt_callback(void *, const char *); @@ -40,7 +39,6 @@ const struct cmd_entry cmd_command_prompt_entry = { "I:p:t:", 0, 1, "[-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " [template]", 0, - cmd_command_prompt_key_binding, cmd_command_prompt_exec }; @@ -54,34 +52,6 @@ struct cmd_command_prompt_cdata { int idx; }; -void -cmd_command_prompt_key_binding(struct cmd *self, int key) -{ - switch (key) { - case '$': - self->args = args_create(1, "rename-session '%%'"); - args_set(self->args, 'I', "#S"); - break; - case ',': - self->args = args_create(1, "rename-window '%%'"); - args_set(self->args, 'I', "#W"); - break; - case '.': - self->args = args_create(1, "move-window -t '%%'"); - break; - case 'f': - self->args = args_create(1, "find-window '%%'"); - break; - case '\'': - self->args = args_create(1, "select-window -t ':%%'"); - args_set(self->args, 'p', "index"); - break; - default: - self->args = args_create(0); - break; - } -} - enum cmd_retval cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq) { diff --git a/cmd-confirm-before.c b/cmd-confirm-before.c index 5b8151c9..7f764670 100644 --- a/cmd-confirm-before.c +++ b/cmd-confirm-before.c @@ -26,7 +26,6 @@ * Asks for confirmation before executing a command. */ -void cmd_confirm_before_key_binding(struct cmd *, int); enum cmd_retval cmd_confirm_before_exec(struct cmd *, struct cmd_q *); int cmd_confirm_before_callback(void *, const char *); @@ -37,7 +36,6 @@ const struct cmd_entry cmd_confirm_before_entry = { "p:t:", 1, 1, "[-p prompt] " CMD_TARGET_CLIENT_USAGE " command", 0, - cmd_confirm_before_key_binding, cmd_confirm_before_exec }; @@ -46,24 +44,6 @@ struct cmd_confirm_before_data { struct client *client; }; -void -cmd_confirm_before_key_binding(struct cmd *self, int key) -{ - switch (key) { - case '&': - self->args = args_create(1, "kill-window"); - args_set(self->args, 'p', "kill-window #W? (y/n)"); - break; - case 'x': - self->args = args_create(1, "kill-pane"); - args_set(self->args, 'p', "kill-pane #P? (y/n)"); - break; - default: - self->args = args_create(0); - break; - } -} - enum cmd_retval cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq) { diff --git a/cmd-copy-mode.c b/cmd-copy-mode.c index bc9cfd62..89335296 100644 --- a/cmd-copy-mode.c +++ b/cmd-copy-mode.c @@ -24,7 +24,6 @@ * Enter copy mode. */ -void cmd_copy_mode_key_binding(struct cmd *, int); enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_q *); const struct cmd_entry cmd_copy_mode_entry = { @@ -32,18 +31,9 @@ const struct cmd_entry cmd_copy_mode_entry = { "t:u", 0, 0, "[-u] " CMD_TARGET_PANE_USAGE, 0, - cmd_copy_mode_key_binding, cmd_copy_mode_exec }; -void -cmd_copy_mode_key_binding(struct cmd *self, int key) -{ - self->args = args_create(0); - if (key == KEYC_PPAGE) - args_set(self->args, 'u', NULL); -} - enum cmd_retval cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq) { diff --git a/cmd-delete-buffer.c b/cmd-delete-buffer.c index 755d7ea3..42268b78 100644 --- a/cmd-delete-buffer.c +++ b/cmd-delete-buffer.c @@ -33,7 +33,6 @@ const struct cmd_entry cmd_delete_buffer_entry = { "b:", 0, 0, CMD_BUFFER_USAGE, 0, - NULL, cmd_delete_buffer_exec }; diff --git a/cmd-detach-client.c b/cmd-detach-client.c index d40ef5a0..d60cf47d 100644 --- a/cmd-detach-client.c +++ b/cmd-detach-client.c @@ -33,7 +33,6 @@ const struct cmd_entry cmd_detach_client_entry = { "as:t:P", 0, 0, "[-P] [-a] [-s target-session] " CMD_TARGET_CLIENT_USAGE, CMD_READONLY, - NULL, cmd_detach_client_exec }; diff --git a/cmd-display-message.c b/cmd-display-message.c index b60d732a..dc4290e9 100644 --- a/cmd-display-message.c +++ b/cmd-display-message.c @@ -35,7 +35,6 @@ const struct cmd_entry cmd_display_message_entry = { "[-p] [-c target-client] [-F format] " CMD_TARGET_PANE_USAGE " [message]", 0, - NULL, cmd_display_message_exec }; diff --git a/cmd-display-panes.c b/cmd-display-panes.c index 9160f4e7..9ce89712 100644 --- a/cmd-display-panes.c +++ b/cmd-display-panes.c @@ -31,7 +31,6 @@ const struct cmd_entry cmd_display_panes_entry = { "t:", 0, 0, CMD_TARGET_CLIENT_USAGE, 0, - NULL, cmd_display_panes_exec }; diff --git a/cmd-find-window.c b/cmd-find-window.c index ccf7f0f2..f1fc5f50 100644 --- a/cmd-find-window.c +++ b/cmd-find-window.c @@ -47,7 +47,6 @@ const struct cmd_entry cmd_find_window_entry = { "F:CNt:T", 1, 4, "[-CNT] [-F format] " CMD_TARGET_WINDOW_USAGE " match-string", 0, - NULL, cmd_find_window_exec }; diff --git a/cmd-has-session.c b/cmd-has-session.c index d7ef9be6..a873b204 100644 --- a/cmd-has-session.c +++ b/cmd-has-session.c @@ -31,7 +31,6 @@ const struct cmd_entry cmd_has_session_entry = { "t:", 0, 0, CMD_TARGET_SESSION_USAGE, 0, - NULL, cmd_has_session_exec }; diff --git a/cmd-if-shell.c b/cmd-if-shell.c index 4193944c..da0220ca 100644 --- a/cmd-if-shell.c +++ b/cmd-if-shell.c @@ -40,7 +40,6 @@ const struct cmd_entry cmd_if_shell_entry = { "bt:", 2, 3, "[-b] " CMD_TARGET_PANE_USAGE " shell-command command [command]", 0, - NULL, cmd_if_shell_exec }; diff --git a/cmd-join-pane.c b/cmd-join-pane.c index 7d7b1eea..943cdce4 100644 --- a/cmd-join-pane.c +++ b/cmd-join-pane.c @@ -29,7 +29,6 @@ * Join or move a pane into another (like split/swap/kill). */ -void cmd_join_pane_key_binding(struct cmd *, int); enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmd_q *); enum cmd_retval join_pane(struct cmd *, struct cmd_q *, int); @@ -39,7 +38,6 @@ const struct cmd_entry cmd_join_pane_entry = { "bdhvp:l:s:t:", 0, 0, "[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]", 0, - cmd_join_pane_key_binding, cmd_join_pane_exec }; @@ -48,24 +46,9 @@ const struct cmd_entry cmd_move_pane_entry = { "bdhvp:l:s:t:", 0, 0, "[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]", 0, - NULL, cmd_join_pane_exec }; -void -cmd_join_pane_key_binding(struct cmd *self, int key) -{ - switch (key) { - case '%': - self->args = args_create(0); - args_set(self->args, 'h', NULL); - break; - default: - self->args = args_create(0); - break; - } -} - enum cmd_retval cmd_join_pane_exec(struct cmd *self, struct cmd_q *cmdq) { diff --git a/cmd-kill-pane.c b/cmd-kill-pane.c index 64fd11e4..f4735fd2 100644 --- a/cmd-kill-pane.c +++ b/cmd-kill-pane.c @@ -33,7 +33,6 @@ const struct cmd_entry cmd_kill_pane_entry = { "at:", 0, 0, "[-a] " CMD_TARGET_PANE_USAGE, 0, - NULL, cmd_kill_pane_exec }; diff --git a/cmd-kill-server.c b/cmd-kill-server.c index 6f0b7494..07d94302 100644 --- a/cmd-kill-server.c +++ b/cmd-kill-server.c @@ -34,7 +34,6 @@ const struct cmd_entry cmd_kill_server_entry = { "", 0, 0, "", 0, - NULL, cmd_kill_server_exec }; @@ -43,7 +42,6 @@ const struct cmd_entry cmd_start_server_entry = { "", 0, 0, "", CMD_STARTSERVER, - NULL, cmd_kill_server_exec }; diff --git a/cmd-kill-session.c b/cmd-kill-session.c index 097189ec..d7e2a219 100644 --- a/cmd-kill-session.c +++ b/cmd-kill-session.c @@ -34,7 +34,6 @@ const struct cmd_entry cmd_kill_session_entry = { "at:", 0, 0, "[-a] " CMD_TARGET_SESSION_USAGE, 0, - NULL, cmd_kill_session_exec }; diff --git a/cmd-kill-window.c b/cmd-kill-window.c index 2f924260..dd4d7f59 100644 --- a/cmd-kill-window.c +++ b/cmd-kill-window.c @@ -31,7 +31,6 @@ const struct cmd_entry cmd_kill_window_entry = { "at:", 0, 0, "[-a] " CMD_TARGET_WINDOW_USAGE, 0, - NULL, cmd_kill_window_exec }; diff --git a/cmd-link-window.c b/cmd-link-window.c index 8bd63b7c..ee5b62a5 100644 --- a/cmd-link-window.c +++ b/cmd-link-window.c @@ -33,7 +33,6 @@ const struct cmd_entry cmd_link_window_entry = { "dks:t:", 0, 0, "[-dk] " CMD_SRCDST_WINDOW_USAGE, 0, - NULL, cmd_link_window_exec }; diff --git a/cmd-list-buffers.c b/cmd-list-buffers.c index 9d79072e..25f7e8bc 100644 --- a/cmd-list-buffers.c +++ b/cmd-list-buffers.c @@ -34,7 +34,6 @@ const struct cmd_entry cmd_list_buffers_entry = { "F:", 0, 0, "[-F format]", 0, - NULL, cmd_list_buffers_exec }; diff --git a/cmd-list-clients.c b/cmd-list-clients.c index 98c564ad..0cfbdfa7 100644 --- a/cmd-list-clients.c +++ b/cmd-list-clients.c @@ -35,7 +35,6 @@ const struct cmd_entry cmd_list_clients_entry = { "F:t:", 0, 0, "[-F format] " CMD_TARGET_SESSION_USAGE, CMD_READONLY, - NULL, cmd_list_clients_exec }; diff --git a/cmd-list-commands.c b/cmd-list-commands.c index 287df428..520feccb 100644 --- a/cmd-list-commands.c +++ b/cmd-list-commands.c @@ -31,7 +31,6 @@ const struct cmd_entry cmd_list_commands_entry = { "", 0, 0, "", 0, - NULL, cmd_list_commands_exec }; diff --git a/cmd-list-keys.c b/cmd-list-keys.c index 65e4469e..0d64f1be 100644 --- a/cmd-list-keys.c +++ b/cmd-list-keys.c @@ -34,7 +34,6 @@ const struct cmd_entry cmd_list_keys_entry = { "t:", 0, 0, "[-t key-table]", 0, - NULL, cmd_list_keys_exec }; diff --git a/cmd-list-panes.c b/cmd-list-panes.c index 07884ff2..7f62177b 100644 --- a/cmd-list-panes.c +++ b/cmd-list-panes.c @@ -40,7 +40,6 @@ const struct cmd_entry cmd_list_panes_entry = { "asF:t:", 0, 0, "[-as] [-F format] " CMD_TARGET_WINDOW_USAGE, 0, - NULL, cmd_list_panes_exec }; diff --git a/cmd-list-sessions.c b/cmd-list-sessions.c index d401608f..f0a7c538 100644 --- a/cmd-list-sessions.c +++ b/cmd-list-sessions.c @@ -35,7 +35,6 @@ const struct cmd_entry cmd_list_sessions_entry = { "F:", 0, 0, "[-F format]", 0, - NULL, cmd_list_sessions_exec }; diff --git a/cmd-list-windows.c b/cmd-list-windows.c index bc56816f..1317ecb1 100644 --- a/cmd-list-windows.c +++ b/cmd-list-windows.c @@ -38,7 +38,6 @@ const struct cmd_entry cmd_list_windows_entry = { "F:at:", 0, 0, "[-a] [-F format] " CMD_TARGET_SESSION_USAGE, 0, - NULL, cmd_list_windows_exec }; diff --git a/cmd-load-buffer.c b/cmd-load-buffer.c index 26d6297a..785a7011 100644 --- a/cmd-load-buffer.c +++ b/cmd-load-buffer.c @@ -39,7 +39,6 @@ const struct cmd_entry cmd_load_buffer_entry = { "b:", 1, 1, CMD_BUFFER_USAGE " path", 0, - NULL, cmd_load_buffer_exec }; diff --git a/cmd-lock-server.c b/cmd-lock-server.c index 757c2e3f..de76475d 100644 --- a/cmd-lock-server.c +++ b/cmd-lock-server.c @@ -31,7 +31,6 @@ const struct cmd_entry cmd_lock_server_entry = { "", 0, 0, "", 0, - NULL, cmd_lock_server_exec }; @@ -40,7 +39,6 @@ const struct cmd_entry cmd_lock_session_entry = { "t:", 0, 0, CMD_TARGET_SESSION_USAGE, 0, - NULL, cmd_lock_server_exec }; @@ -49,7 +47,6 @@ const struct cmd_entry cmd_lock_client_entry = { "t:", 0, 0, CMD_TARGET_CLIENT_USAGE, 0, - NULL, cmd_lock_server_exec }; diff --git a/cmd-move-window.c b/cmd-move-window.c index bb160e5c..eef96f1c 100644 --- a/cmd-move-window.c +++ b/cmd-move-window.c @@ -33,7 +33,6 @@ const struct cmd_entry cmd_move_window_entry = { |