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.
pull/1/head
nicm 2014-10-20 22:29:25 +00:00
parent f0b69c7711
commit 45dfc5a074
68 changed files with 86 additions and 403 deletions

View File

@ -37,7 +37,6 @@ const struct cmd_entry cmd_attach_session_entry = {
"c:drt:", 0, 0, "c:drt:", 0, 0,
"[-dr] [-c working-directory] " CMD_TARGET_SESSION_USAGE, "[-dr] [-c working-directory] " CMD_TARGET_SESSION_USAGE,
CMD_CANTNEST|CMD_STARTSERVER, CMD_CANTNEST|CMD_STARTSERVER,
NULL,
cmd_attach_session_exec cmd_attach_session_exec
}; };

View File

@ -36,7 +36,6 @@ const struct cmd_entry cmd_bind_key_entry = {
"cnrt:", 1, -1, "cnrt:", 1, -1,
"[-cnr] [-t mode-table] key command [arguments]", "[-cnr] [-t mode-table] key command [arguments]",
0, 0,
NULL,
cmd_bind_key_exec cmd_bind_key_exec
}; };

View File

@ -33,7 +33,6 @@ const struct cmd_entry cmd_break_pane_entry = {
"dPF:t:", 0, 0, "dPF:t:", 0, 0,
"[-dP] [-F format] " CMD_TARGET_PANE_USAGE, "[-dP] [-F format] " CMD_TARGET_PANE_USAGE,
0, 0,
NULL,
cmd_break_pane_exec cmd_break_pane_exec
}; };

View File

@ -41,7 +41,6 @@ const struct cmd_entry cmd_capture_pane_entry = {
"[-aCeJpPq] " CMD_BUFFER_USAGE " [-E end-line] [-S start-line]" "[-aCeJpPq] " CMD_BUFFER_USAGE " [-E end-line] [-S start-line]"
CMD_TARGET_PANE_USAGE, CMD_TARGET_PANE_USAGE,
0, 0,
NULL,
cmd_capture_pane_exec cmd_capture_pane_exec
}; };

View File

@ -34,7 +34,6 @@ const struct cmd_entry cmd_choose_buffer_entry = {
"F:t:", 0, 1, "F:t:", 0, 1,
CMD_TARGET_WINDOW_USAGE " [-F format] [template]", CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
0, 0,
NULL,
cmd_choose_buffer_exec cmd_choose_buffer_exec
}; };

View File

@ -36,7 +36,6 @@ const struct cmd_entry cmd_choose_client_entry = {
"F:t:", 0, 1, "F:t:", 0, 1,
CMD_TARGET_WINDOW_USAGE " [-F format] [template]", CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
0, 0,
NULL,
cmd_choose_client_exec cmd_choose_client_exec
}; };

View File

@ -40,7 +40,6 @@ const struct cmd_entry cmd_choose_tree_entry = {
"[-suw] [-b session-template] [-c window template] [-S format] " \ "[-suw] [-b session-template] [-c window template] [-S format] " \
"[-W format] " CMD_TARGET_WINDOW_USAGE, "[-W format] " CMD_TARGET_WINDOW_USAGE,
0, 0,
NULL,
cmd_choose_tree_exec cmd_choose_tree_exec
}; };
@ -49,7 +48,6 @@ const struct cmd_entry cmd_choose_session_entry = {
"F:t:", 0, 1, "F:t:", 0, 1,
CMD_TARGET_WINDOW_USAGE " [-F format] [template]", CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
0, 0,
NULL,
cmd_choose_tree_exec cmd_choose_tree_exec
}; };
@ -58,7 +56,6 @@ const struct cmd_entry cmd_choose_window_entry = {
"F:t:", 0, 1, "F:t:", 0, 1,
CMD_TARGET_WINDOW_USAGE "[-F format] [template]", CMD_TARGET_WINDOW_USAGE "[-F format] [template]",
0, 0,
NULL,
cmd_choose_tree_exec cmd_choose_tree_exec
}; };

View File

@ -31,7 +31,6 @@ const struct cmd_entry cmd_clear_history_entry = {
"t:", 0, 0, "t:", 0, 0,
CMD_TARGET_PANE_USAGE, CMD_TARGET_PANE_USAGE,
0, 0,
NULL,
cmd_clear_history_exec cmd_clear_history_exec
}; };

View File

@ -31,7 +31,6 @@ const struct cmd_entry cmd_clock_mode_entry = {
"t:", 0, 0, "t:", 0, 0,
CMD_TARGET_PANE_USAGE, CMD_TARGET_PANE_USAGE,
0, 0,
NULL,
cmd_clock_mode_exec cmd_clock_mode_exec
}; };

View File

@ -29,7 +29,6 @@
* Prompt for command in client. * 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 *); enum cmd_retval cmd_command_prompt_exec(struct cmd *, struct cmd_q *);
int cmd_command_prompt_callback(void *, const char *); 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:p:t:", 0, 1,
"[-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " [template]", "[-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE " [template]",
0, 0,
cmd_command_prompt_key_binding,
cmd_command_prompt_exec cmd_command_prompt_exec
}; };
@ -54,34 +52,6 @@ struct cmd_command_prompt_cdata {
int idx; 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 enum cmd_retval
cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq) cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq)
{ {

View File

@ -26,7 +26,6 @@
* Asks for confirmation before executing a command. * 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 *); enum cmd_retval cmd_confirm_before_exec(struct cmd *, struct cmd_q *);
int cmd_confirm_before_callback(void *, const char *); 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:t:", 1, 1,
"[-p prompt] " CMD_TARGET_CLIENT_USAGE " command", "[-p prompt] " CMD_TARGET_CLIENT_USAGE " command",
0, 0,
cmd_confirm_before_key_binding,
cmd_confirm_before_exec cmd_confirm_before_exec
}; };
@ -46,24 +44,6 @@ struct cmd_confirm_before_data {
struct client *client; 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 enum cmd_retval
cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq) cmd_confirm_before_exec(struct cmd *self, struct cmd_q *cmdq)
{ {

View File

@ -24,7 +24,6 @@
* Enter copy mode. * Enter copy mode.
*/ */
void cmd_copy_mode_key_binding(struct cmd *, int);
enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_q *); enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_copy_mode_entry = { const struct cmd_entry cmd_copy_mode_entry = {
@ -32,18 +31,9 @@ const struct cmd_entry cmd_copy_mode_entry = {
"t:u", 0, 0, "t:u", 0, 0,
"[-u] " CMD_TARGET_PANE_USAGE, "[-u] " CMD_TARGET_PANE_USAGE,
0, 0,
cmd_copy_mode_key_binding,
cmd_copy_mode_exec 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 enum cmd_retval
cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq) cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq)
{ {

View File

@ -33,7 +33,6 @@ const struct cmd_entry cmd_delete_buffer_entry = {
"b:", 0, 0, "b:", 0, 0,
CMD_BUFFER_USAGE, CMD_BUFFER_USAGE,
0, 0,
NULL,
cmd_delete_buffer_exec cmd_delete_buffer_exec
}; };

View File

@ -33,7 +33,6 @@ const struct cmd_entry cmd_detach_client_entry = {
"as:t:P", 0, 0, "as:t:P", 0, 0,
"[-P] [-a] [-s target-session] " CMD_TARGET_CLIENT_USAGE, "[-P] [-a] [-s target-session] " CMD_TARGET_CLIENT_USAGE,
CMD_READONLY, CMD_READONLY,
NULL,
cmd_detach_client_exec cmd_detach_client_exec
}; };

View File

@ -35,7 +35,6 @@ const struct cmd_entry cmd_display_message_entry = {
"[-p] [-c target-client] [-F format] " CMD_TARGET_PANE_USAGE "[-p] [-c target-client] [-F format] " CMD_TARGET_PANE_USAGE
" [message]", " [message]",
0, 0,
NULL,
cmd_display_message_exec cmd_display_message_exec
}; };

View File

@ -31,7 +31,6 @@ const struct cmd_entry cmd_display_panes_entry = {
"t:", 0, 0, "t:", 0, 0,
CMD_TARGET_CLIENT_USAGE, CMD_TARGET_CLIENT_USAGE,
0, 0,
NULL,
cmd_display_panes_exec cmd_display_panes_exec
}; };

View File

@ -47,7 +47,6 @@ const struct cmd_entry cmd_find_window_entry = {
"F:CNt:T", 1, 4, "F:CNt:T", 1, 4,
"[-CNT] [-F format] " CMD_TARGET_WINDOW_USAGE " match-string", "[-CNT] [-F format] " CMD_TARGET_WINDOW_USAGE " match-string",
0, 0,
NULL,
cmd_find_window_exec cmd_find_window_exec
}; };

View File

@ -31,7 +31,6 @@ const struct cmd_entry cmd_has_session_entry = {
"t:", 0, 0, "t:", 0, 0,
CMD_TARGET_SESSION_USAGE, CMD_TARGET_SESSION_USAGE,
0, 0,
NULL,
cmd_has_session_exec cmd_has_session_exec
}; };

View File

@ -40,7 +40,6 @@ const struct cmd_entry cmd_if_shell_entry = {
"bt:", 2, 3, "bt:", 2, 3,
"[-b] " CMD_TARGET_PANE_USAGE " shell-command command [command]", "[-b] " CMD_TARGET_PANE_USAGE " shell-command command [command]",
0, 0,
NULL,
cmd_if_shell_exec cmd_if_shell_exec
}; };

View File

@ -29,7 +29,6 @@
* Join or move a pane into another (like split/swap/kill). * 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 cmd_join_pane_exec(struct cmd *, struct cmd_q *);
enum cmd_retval join_pane(struct cmd *, struct cmd_q *, int); 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, "bdhvp:l:s:t:", 0, 0,
"[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]", "[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
0, 0,
cmd_join_pane_key_binding,
cmd_join_pane_exec cmd_join_pane_exec
}; };
@ -48,24 +46,9 @@ const struct cmd_entry cmd_move_pane_entry = {
"bdhvp:l:s:t:", 0, 0, "bdhvp:l:s:t:", 0, 0,
"[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]", "[-bdhv] [-p percentage|-l size] [-s src-pane] [-t dst-pane]",
0, 0,
NULL,
cmd_join_pane_exec 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 enum cmd_retval
cmd_join_pane_exec(struct cmd *self, struct cmd_q *cmdq) cmd_join_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{ {

View File

@ -33,7 +33,6 @@ const struct cmd_entry cmd_kill_pane_entry = {
"at:", 0, 0, "at:", 0, 0,
"[-a] " CMD_TARGET_PANE_USAGE, "[-a] " CMD_TARGET_PANE_USAGE,
0, 0,
NULL,
cmd_kill_pane_exec cmd_kill_pane_exec
}; };

View File

@ -34,7 +34,6 @@ const struct cmd_entry cmd_kill_server_entry = {
"", 0, 0, "", 0, 0,
"", "",
0, 0,
NULL,
cmd_kill_server_exec cmd_kill_server_exec
}; };
@ -43,7 +42,6 @@ const struct cmd_entry cmd_start_server_entry = {
"", 0, 0, "", 0, 0,
"", "",
CMD_STARTSERVER, CMD_STARTSERVER,
NULL,
cmd_kill_server_exec cmd_kill_server_exec
}; };

View File

@ -34,7 +34,6 @@ const struct cmd_entry cmd_kill_session_entry = {
"at:", 0, 0, "at:", 0, 0,
"[-a] " CMD_TARGET_SESSION_USAGE, "[-a] " CMD_TARGET_SESSION_USAGE,
0, 0,
NULL,
cmd_kill_session_exec cmd_kill_session_exec
}; };

View File

@ -31,7 +31,6 @@ const struct cmd_entry cmd_kill_window_entry = {
"at:", 0, 0, "at:", 0, 0,
"[-a] " CMD_TARGET_WINDOW_USAGE, "[-a] " CMD_TARGET_WINDOW_USAGE,
0, 0,
NULL,
cmd_kill_window_exec cmd_kill_window_exec
}; };

View File

@ -33,7 +33,6 @@ const struct cmd_entry cmd_link_window_entry = {
"dks:t:", 0, 0, "dks:t:", 0, 0,
"[-dk] " CMD_SRCDST_WINDOW_USAGE, "[-dk] " CMD_SRCDST_WINDOW_USAGE,
0, 0,
NULL,
cmd_link_window_exec cmd_link_window_exec
}; };

View File

@ -34,7 +34,6 @@ const struct cmd_entry cmd_list_buffers_entry = {
"F:", 0, 0, "F:", 0, 0,
"[-F format]", "[-F format]",
0, 0,
NULL,
cmd_list_buffers_exec cmd_list_buffers_exec
}; };

View File

@ -35,7 +35,6 @@ const struct cmd_entry cmd_list_clients_entry = {
"F:t:", 0, 0, "F:t:", 0, 0,
"[-F format] " CMD_TARGET_SESSION_USAGE, "[-F format] " CMD_TARGET_SESSION_USAGE,
CMD_READONLY, CMD_READONLY,
NULL,
cmd_list_clients_exec cmd_list_clients_exec
}; };

View File

@ -31,7 +31,6 @@ const struct cmd_entry cmd_list_commands_entry = {
"", 0, 0, "", 0, 0,
"", "",
0, 0,
NULL,
cmd_list_commands_exec cmd_list_commands_exec
}; };

View File

@ -34,7 +34,6 @@ const struct cmd_entry cmd_list_keys_entry = {
"t:", 0, 0, "t:", 0, 0,
"[-t key-table]", "[-t key-table]",
0, 0,
NULL,
cmd_list_keys_exec cmd_list_keys_exec
}; };

View File

@ -40,7 +40,6 @@ const struct cmd_entry cmd_list_panes_entry = {
"asF:t:", 0, 0, "asF:t:", 0, 0,
"[-as] [-F format] " CMD_TARGET_WINDOW_USAGE, "[-as] [-F format] " CMD_TARGET_WINDOW_USAGE,
0, 0,
NULL,
cmd_list_panes_exec cmd_list_panes_exec
}; };

View File

@ -35,7 +35,6 @@ const struct cmd_entry cmd_list_sessions_entry = {
"F:", 0, 0, "F:", 0, 0,
"[-F format]", "[-F format]",
0, 0,
NULL,
cmd_list_sessions_exec cmd_list_sessions_exec
}; };

View File

@ -38,7 +38,6 @@ const struct cmd_entry cmd_list_windows_entry = {
"F:at:", 0, 0, "F:at:", 0, 0,
"[-a] [-F format] " CMD_TARGET_SESSION_USAGE, "[-a] [-F format] " CMD_TARGET_SESSION_USAGE,
0, 0,
NULL,
cmd_list_windows_exec cmd_list_windows_exec
}; };

View File

@ -39,7 +39,6 @@ const struct cmd_entry cmd_load_buffer_entry = {
"b:", 1, 1, "b:", 1, 1,
CMD_BUFFER_USAGE " path", CMD_BUFFER_USAGE " path",
0, 0,
NULL,
cmd_load_buffer_exec cmd_load_buffer_exec
}; };

View File

@ -31,7 +31,6 @@ const struct cmd_entry cmd_lock_server_entry = {
"", 0, 0, "", 0, 0,
"", "",
0, 0,
NULL,
cmd_lock_server_exec cmd_lock_server_exec
}; };
@ -40,7 +39,6 @@ const struct cmd_entry cmd_lock_session_entry = {
"t:", 0, 0, "t:", 0, 0,
CMD_TARGET_SESSION_USAGE, CMD_TARGET_SESSION_USAGE,
0, 0,
NULL,
cmd_lock_server_exec cmd_lock_server_exec
}; };
@ -49,7 +47,6 @@ const struct cmd_entry cmd_lock_client_entry = {
"t:", 0, 0, "t:", 0, 0,
CMD_TARGET_CLIENT_USAGE, CMD_TARGET_CLIENT_USAGE,
0, 0,
NULL,
cmd_lock_server_exec cmd_lock_server_exec
}; };

View File

@ -33,7 +33,6 @@ const struct cmd_entry cmd_move_window_entry = {
"dkrs:t:", 0, 0, "dkrs:t:", 0, 0,
"[-dkr] " CMD_SRCDST_WINDOW_USAGE, "[-dkr] " CMD_SRCDST_WINDOW_USAGE,
0, 0,
NULL,
cmd_move_window_exec cmd_move_window_exec
}; };

View File

@ -40,7 +40,6 @@ const struct cmd_entry cmd_new_session_entry = {
"[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] " "[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] "
"[-y height] [command]", "[-y height] [command]",
CMD_STARTSERVER|CMD_CANTNEST, CMD_STARTSERVER|CMD_CANTNEST,
NULL,
cmd_new_session_exec cmd_new_session_exec
}; };

View File

@ -38,7 +38,6 @@ const struct cmd_entry cmd_new_window_entry = {
"[-adkP] [-c start-directory] [-F format] [-n window-name] " "[-adkP] [-c start-directory] [-F format] [-n window-name] "
CMD_TARGET_WINDOW_USAGE " [command]", CMD_TARGET_WINDOW_USAGE " [command]",
0, 0,
NULL,
cmd_new_window_exec cmd_new_window_exec
}; };

View File

@ -38,7 +38,6 @@ const struct cmd_entry cmd_paste_buffer_entry = {
"db:prs:t:", 0, 0, "db:prs:t:", 0, 0,
"[-dpr] [-s separator] " CMD_BUFFER_USAGE " " CMD_TARGET_PANE_USAGE, "[-dpr] [-s separator] " CMD_BUFFER_USAGE " " CMD_TARGET_PANE_USAGE,
0, 0,
NULL,
cmd_paste_buffer_exec cmd_paste_buffer_exec
}; };

View File

@ -41,7 +41,6 @@ const struct cmd_entry cmd_pipe_pane_entry = {
"ot:", 0, 1, "ot:", 0, 1,
"[-o] " CMD_TARGET_PANE_USAGE " [command]", "[-o] " CMD_TARGET_PANE_USAGE " [command]",
0, 0,
NULL,
cmd_pipe_pane_exec cmd_pipe_pane_exec
}; };

View File

@ -31,7 +31,6 @@ const struct cmd_entry cmd_refresh_client_entry = {
"C:St:", 0, 0, "C:St:", 0, 0,
"[-S] [-C size] " CMD_TARGET_CLIENT_USAGE, "[-S] [-C size] " CMD_TARGET_CLIENT_USAGE,
0, 0,
NULL,
cmd_refresh_client_exec cmd_refresh_client_exec
}; };

View File

@ -33,7 +33,6 @@ const struct cmd_entry cmd_rename_session_entry = {
"t:", 1, 1, "t:", 1, 1,
CMD_TARGET_SESSION_USAGE " new-name", CMD_TARGET_SESSION_USAGE " new-name",
0, 0,
NULL,
cmd_rename_session_exec cmd_rename_session_exec
}; };

View File

@ -33,7 +33,6 @@ const struct cmd_entry cmd_rename_window_entry = {
"t:", 1, 1, "t:", 1, 1,
CMD_TARGET_WINDOW_USAGE " new-name", CMD_TARGET_WINDOW_USAGE " new-name",
0, 0,
NULL,
cmd_rename_window_exec cmd_rename_window_exec
}; };

View File

@ -26,7 +26,6 @@
* Increase or decrease pane size. * Increase or decrease pane size.
*/ */
void cmd_resize_pane_key_binding(struct cmd *, int);
enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmd_q *); enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_resize_pane_entry = { const struct cmd_entry cmd_resize_pane_entry = {
@ -34,56 +33,9 @@ const struct cmd_entry cmd_resize_pane_entry = {
"DLRt:Ux:y:Z", 0, 1, "DLRt:Ux:y:Z", 0, 1,
"[-DLRUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " [adjustment]", "[-DLRUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " [adjustment]",
0, 0,
cmd_resize_pane_key_binding,
cmd_resize_pane_exec cmd_resize_pane_exec
}; };
void
cmd_resize_pane_key_binding(struct cmd *self, int key)
{
switch (key) {
case KEYC_UP | KEYC_CTRL:
self->args = args_create(0);
args_set(self->args, 'U', NULL);
break;
case KEYC_DOWN | KEYC_CTRL:
self->args = args_create(0);
args_set(self->args, 'D', NULL);
break;
case KEYC_LEFT | KEYC_CTRL:
self->args = args_create(0);
args_set(self->args, 'L', NULL);
break;
case KEYC_RIGHT | KEYC_CTRL:
self->args = args_create(0);
args_set(self->args, 'R', NULL);
break;
case KEYC_UP | KEYC_ESCAPE:
self->args = args_create(1, "5");
args_set(self->args, 'U', NULL);
break;
case KEYC_DOWN | KEYC_ESCAPE:
self->args = args_create(1, "5");
args_set(self->args, 'D', NULL);
break;
case KEYC_LEFT | KEYC_ESCAPE:
self->args = args_create(1, "5");
args_set(self->args, 'L', NULL);
break;
case KEYC_RIGHT | KEYC_ESCAPE:
self->args = args_create(1, "5");
args_set(self->args, 'R', NULL);
break;
case 'z':
self->args = args_create(0);
args_set(self->args, 'Z', NULL);
break;
default:
self->args = args_create(0);
break;
}
}
enum cmd_retval enum cmd_retval
cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq) cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{ {

View File

@ -34,7 +34,6 @@ const struct cmd_entry cmd_respawn_window_entry = {
"kt:", 0, -1, "kt:", 0, -1,
"[-k] " CMD_TARGET_WINDOW_USAGE " [command]", "[-k] " CMD_TARGET_WINDOW_USAGE " [command]",
0, 0,
NULL,
cmd_respawn_window_exec cmd_respawn_window_exec
}; };

View File

@ -24,7 +24,6 @@
* Rotate the panes in a window. * Rotate the panes in a window.
*/ */
void cmd_rotate_window_key_binding(struct cmd *, int);
enum cmd_retval cmd_rotate_window_exec(struct cmd *, struct cmd_q *); enum cmd_retval cmd_rotate_window_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_rotate_window_entry = { const struct cmd_entry cmd_rotate_window_entry = {
@ -32,18 +31,9 @@ const struct cmd_entry cmd_rotate_window_entry = {
"Dt:U", 0, 0, "Dt:U", 0, 0,
"[-DU] " CMD_TARGET_WINDOW_USAGE, "[-DU] " CMD_TARGET_WINDOW_USAGE,
0, 0,
cmd_rotate_window_key_binding,
cmd_rotate_window_exec cmd_rotate_window_exec
}; };
void
cmd_rotate_window_key_binding(struct cmd *self, int key)
{
self->args = args_create(0);
if (key == ('o' | KEYC_ESCAPE))
args_set(self->args, 'D', NULL);
}
enum cmd_retval enum cmd_retval
cmd_rotate_window_exec(struct cmd *self, struct cmd_q *cmdq) cmd_rotate_window_exec(struct cmd *self, struct cmd_q *cmdq)
{ {

View File

@ -40,7 +40,6 @@ const struct cmd_entry cmd_run_shell_entry = {
"bt:", 1, 1, "bt:", 1, 1,
"[-b] " CMD_TARGET_PANE_USAGE " shell-command", "[-b] " CMD_TARGET_PANE_USAGE " shell-command",
0, 0,
NULL,
cmd_run_shell_exec cmd_run_shell_exec
}; };

View File

@ -39,7 +39,6 @@ const struct cmd_entry cmd_save_buffer_entry = {
"ab:", 1, 1, "ab:", 1, 1,
"[-a] " CMD_BUFFER_USAGE " path", "[-a] " CMD_BUFFER_USAGE " path",
0, 0,
NULL,
cmd_save_buffer_exec cmd_save_buffer_exec
}; };
@ -48,7 +47,6 @@ const struct cmd_entry cmd_show_buffer_entry = {
"b:", 0, 0, "b:", 0, 0,
CMD_BUFFER_USAGE, CMD_BUFFER_USAGE,
0, 0,
NULL,
cmd_save_buffer_exec cmd_save_buffer_exec
}; };

View File

@ -24,15 +24,12 @@
* Switch window to selected layout. * Switch window to selected layout.
*/ */
void cmd_select_layout_key_binding(struct cmd *, int);
enum cmd_retval cmd_select_layout_exec(struct cmd *, struct cmd_q *); enum cmd_retval cmd_select_layout_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_select_layout_entry = { const struct cmd_entry cmd_select_layout_entry = {
"select-layout", "selectl", "select-layout", "selectl",
"npt:", 0, 1, "npt:", 0, 1,
"[-np] " CMD_TARGET_WINDOW_USAGE " [layout-name]", "[-np] " CMD_TARGET_WINDOW_USAGE " [layout-name]",
0,
cmd_select_layout_key_binding,
cmd_select_layout_exec cmd_select_layout_exec
}; };
@ -41,7 +38,6 @@ const struct cmd_entry cmd_next_layout_entry = {
"t:", 0, 0, "t:", 0, 0,
CMD_TARGET_WINDOW_USAGE, CMD_TARGET_WINDOW_USAGE,
0, 0,
NULL,
cmd_select_layout_exec cmd_select_layout_exec
}; };
@ -50,35 +46,9 @@ const struct cmd_entry cmd_previous_layout_entry = {
"t:", 0, 0, "t:", 0, 0,
CMD_TARGET_WINDOW_USAGE, CMD_TARGET_WINDOW_USAGE,
0, 0,
NULL,
cmd_select_layout_exec cmd_select_layout_exec
}; };
void
cmd_select_layout_key_binding(struct cmd *self, int key)
{
switch (key) {
case '1' | KEYC_ESCAPE:
self->args = args_create(1, "even-horizontal");
break;
case '2' | KEYC_ESCAPE:
self->args = args_create(1, "even-vertical");
break;
case '3' | KEYC_ESCAPE:
self->args = args_create(1, "main-horizontal");
break;
case '4' | KEYC_ESCAPE:
self->args = args_create(1, "main-vertical");
break;
case '5' | KEYC_ESCAPE:
self->args = args_create(1, "tiled");
break;
default:
self->args = args_create(0);
break;
}
}
enum cmd_retval enum cmd_retval
cmd_select_layout_exec(struct cmd *self, struct cmd_q *cmdq) cmd_select_layout_exec(struct cmd *self, struct cmd_q *cmdq)
{ {

View File

@ -24,7 +24,6 @@
* Select pane. * Select pane.
*/ */
void cmd_select_pane_key_binding(struct cmd *, int);
enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmd_q *); enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_select_pane_entry = { const struct cmd_entry cmd_select_pane_entry = {
@ -32,7 +31,6 @@ const struct cmd_entry cmd_select_pane_entry = {
"DdeLlRt:U", 0, 0, "DdeLlRt:U", 0, 0,
"[-DdeLlRU] " CMD_TARGET_PANE_USAGE, "[-DdeLlRU] " CMD_TARGET_PANE_USAGE,
0, 0,
cmd_select_pane_key_binding,
cmd_select_pane_exec cmd_select_pane_exec
}; };
@ -41,26 +39,9 @@ const struct cmd_entry cmd_last_pane_entry = {
"det:", 0, 0, "det:", 0, 0,
"[-de] " CMD_TARGET_WINDOW_USAGE, "[-de] " CMD_TARGET_WINDOW_USAGE,
0, 0,
NULL,
cmd_select_pane_exec cmd_select_pane_exec
}; };
void
cmd_select_pane_key_binding(struct cmd *self, int key)
{
self->args = args_create(0);
if (key == KEYC_UP)
args_set(self->args, 'U', NULL);
if (key == KEYC_DOWN)
args_set(self->args, 'D', NULL);
if (key == KEYC_LEFT)
args_set(self->args, 'L', NULL);
if (key == KEYC_RIGHT)
args_set(self->args, 'R', NULL);
if (key == 'o')
args_set(self->args, 't', ":.+");
}
enum cmd_retval enum cmd_retval
cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq) cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{ {

View File

@ -26,7 +26,6 @@
* Select window by index. * Select window by index.
*/ */
void cmd_select_window_key_binding(struct cmd *, int);
enum cmd_retval cmd_select_window_exec(struct cmd *, struct cmd_q *); enum cmd_retval cmd_select_window_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_select_window_entry = { const struct cmd_entry cmd_select_window_entry = {
@ -34,7 +33,6 @@ const struct cmd_entry cmd_select_window_entry = {
"lnpTt:", 0, 0, "lnpTt:", 0, 0,
"[-lnpT] " CMD_TARGET_WINDOW_USAGE, "[-lnpT] " CMD_TARGET_WINDOW_USAGE,
0, 0,
cmd_select_window_key_binding,
cmd_select_window_exec cmd_select_window_exec
}; };
@ -43,7 +41,6 @@ const struct cmd_entry cmd_next_window_entry = {
"at:", 0, 0, "at:", 0, 0,
"[-a] " CMD_TARGET_SESSION_USAGE, "[-a] " CMD_TARGET_SESSION_USAGE,
0, 0,
cmd_select_window_key_binding,
cmd_select_window_exec cmd_select_window_exec
}; };
@ -52,7 +49,6 @@ const struct cmd_entry cmd_previous_window_entry = {
"at:", 0, 0, "at:", 0, 0,
"[-a] " CMD_TARGET_SESSION_USAGE, "[-a] " CMD_TARGET_SESSION_USAGE,
0, 0,
cmd_select_window_key_binding,
cmd_select_window_exec cmd_select_window_exec
}; };
@ -61,24 +57,9 @@ const struct cmd_entry cmd_last_window_entry = {
"t:", 0, 0, "t:", 0, 0,
CMD_TARGET_SESSION_USAGE, CMD_TARGET_SESSION_USAGE,
0, 0,
NULL,
cmd_select_window_exec cmd_select_window_exec
}; };
void
cmd_select_window_key_binding(struct cmd *self, int key)
{
char tmp[16];
self->args = args_create(0);
if (key >= '0' && key <= '9') {
xsnprintf(tmp, sizeof tmp, ":%d", key - '0');
args_set(self->args, 't', tmp);
}
if (key == ('n' | KEYC_ESCAPE) || key == ('p' | KEYC_ESCAPE))
args_set(self->args, 'a', NULL);
}
enum cmd_retval enum cmd_retval
cmd_select_window_exec(struct cmd *self, struct cmd_q *cmdq) cmd_select_window_exec(struct cmd *self, struct cmd_q *cmdq)
{ {

View File

@ -34,7 +34,6 @@ const struct cmd_entry cmd_send_keys_entry = {
"lRt:", 0, -1, "lRt:", 0, -1,
"[-lR] " CMD_TARGET_PANE_USAGE " key ...", "[-lR] " CMD_TARGET_PANE_USAGE " key ...",
0, 0,
NULL,
cmd_send_keys_exec cmd_send_keys_exec
}; };
@ -43,7 +42,6 @@ const struct cmd_entry cmd_send_prefix_entry = {
"2t:", 0, 0, "2t:", 0, 0,
"[-2] " CMD_TARGET_PANE_USAGE, "[-2] " CMD_TARGET_PANE_USAGE,
0, 0,
NULL,
cmd_send_keys_exec cmd_send_keys_exec
}; };

View File

@ -34,7 +34,6 @@ const struct cmd_entry cmd_set_buffer_entry = {
"ab:n:", 0, 1, "ab:n:", 0, 1,
"[-a] " CMD_BUFFER_USAGE " [-n new-buffer-name] data", "[-a] " CMD_BUFFER_USAGE " [-n new-buffer-name] data",
0, 0,
NULL,
cmd_set_buffer_exec cmd_set_buffer_exec
}; };

View File

@ -34,7 +34,6 @@ const struct cmd_entry cmd_set_environment_entry = {
"grt:u", 1, 2, "grt:u", 1, 2,
"[-gru] " CMD_TARGET_SESSION_USAGE " name [value]", "[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
0, 0,
NULL,
cmd_set_environment_exec cmd_set_environment_exec
}; };

View File

@ -69,7 +69,6 @@ const struct cmd_entry cmd_set_option_entry = {
"agoqst:uw", 1, 2, "agoqst:uw", 1, 2,
"[-agosquw] [-t target-session|target-window] option [value]", "[-agosquw] [-t target-session|target-window] option [value]",
0, 0,
NULL,
cmd_set_option_exec cmd_set_option_exec
}; };
@ -78,7 +77,6 @@ const struct cmd_entry cmd_set_window_option_entry = {
"agoqt:u", 1, 2, "agoqt:u", 1, 2,
"[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]", "[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
0, 0,
NULL,
cmd_set_option_exec cmd_set_option_exec
}; };

View File

@ -34,7 +34,6 @@ const struct cmd_entry cmd_show_environment_entry = {
"gt:", 0, 1, "gt:", 0, 1,
"[-g] " CMD_TARGET_SESSION_USAGE " [name]", "[-g] " CMD_TARGET_SESSION_USAGE " [name]",
0, 0,
NULL,
cmd_show_environment_exec cmd_show_environment_exec
}; };

View File

@ -36,7 +36,6 @@ const struct cmd_entry cmd_show_messages_entry = {
"IJTt:", 0, 0, "IJTt:", 0, 0,
"[-IJT] " CMD_TARGET_CLIENT_USAGE, "[-IJT] " CMD_TARGET_CLIENT_USAGE,
0, 0,
NULL,
cmd_show_messages_exec cmd_show_messages_exec
}; };
@ -45,7 +44,6 @@ const struct cmd_entry cmd_server_info_entry = {
"", 0, 0, "", 0, 0,
"", "",
0, 0,
NULL,
cmd_show_messages_exec cmd_show_messages_exec
}; };

View File

@ -39,7 +39,6 @@ const struct cmd_entry cmd_show_options_entry = {
"gqst:vw", 0, 1, "gqst:vw", 0, 1,
"[-gqsvw] [-t target-session|target-window] [option]", "[-gqsvw] [-t target-session|target-window] [option]",
0, 0,
NULL,
cmd_show_options_exec cmd_show_options_exec
}; };
@ -48,7 +47,6 @@ const struct cmd_entry cmd_show_window_options_entry = {
"gvt:", 0, 1, "gvt:", 0, 1,
"[-gv] " CMD_TARGET_WINDOW_USAGE " [option]", "[-gv] " CMD_TARGET_WINDOW_USAGE " [option]",
0, 0,
NULL,
cmd_show_options_exec cmd_show_options_exec
}; };

View File

@ -36,7 +36,6 @@ const struct cmd_entry cmd_source_file_entry = {
"", 1, 1, "", 1, 1,
"path", "path",
0, 0,
NULL,
cmd_source_file_exec cmd_source_file_exec
}; };

View File

@ -31,7 +31,6 @@
* Split a window (add a new pane). * Split a window (add a new pane).
*/ */
void cmd_split_window_key_binding(struct cmd *, int);
enum cmd_retval cmd_split_window_exec(struct cmd *, struct cmd_q *); enum cmd_retval cmd_split_window_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_split_window_entry = { const struct cmd_entry cmd_split_window_entry = {
@ -40,18 +39,9 @@ const struct cmd_entry cmd_split_window_entry = {
"[-dhvP] [-c start-directory] [-F format] [-p percentage|-l size] " "[-dhvP] [-c start-directory] [-F format] [-p percentage|-l size] "
CMD_TARGET_PANE_USAGE " [command]", CMD_TARGET_PANE_USAGE " [command]",
0, 0,
cmd_split_window_key_binding,
cmd_split_window_exec cmd_split_window_exec
}; };
void
cmd_split_window_key_binding(struct cmd *self, int key)
{
self->args = args_create(0);
if (key == '%')
args_set(self->args, 'h', NULL);
}
enum cmd_retval enum cmd_retval
cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq) cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
{ {

View File

@ -34,7 +34,6 @@ const struct cmd_entry cmd_suspend_client_entry = {
"t:", 0, 0, "t:", 0, 0,
CMD_TARGET_CLIENT_USAGE, CMD_TARGET_CLIENT_USAGE,
0, 0,
NULL,
cmd_suspend_client_exec cmd_suspend_client_exec
}; };

View File

@ -26,7 +26,6 @@
* Swap two panes. * Swap two panes.
*/ */
void cmd_swap_pane_key_binding(struct cmd *, int);
enum cmd_retval cmd_swap_pane_exec(struct cmd *, struct cmd_q *); enum cmd_retval cmd_swap_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_swap_pane_entry = { const struct cmd_entry cmd_swap_pane_entry = {
@ -34,20 +33,9 @@ const struct cmd_entry cmd_swap_pane_entry = {
"dDs:t:U", 0, 0, "dDs:t:U", 0, 0,
"[-dDU] " CMD_SRCDST_PANE_USAGE, "[-dDU] " CMD_SRCDST_PANE_USAGE,
0, 0,
cmd_swap_pane_key_binding,
cmd_swap_pane_exec cmd_swap_pane_exec
}; };
void
cmd_swap_pane_key_binding(struct cmd *self, int key)
{
self->args = args_create(0);
if (key == '{')
args_set(self->args, 'U', NULL);
else if (key == '}')
args_set(self->args, 'D', NULL);
}
enum cmd_retval enum cmd_retval
cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq) cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{ {

View File

@ -33,7 +33,6 @@ const struct cmd_entry cmd_swap_window_entry = {
"ds:t:", 0, 0, "ds:t:", 0, 0,
"[-d] " CMD_SRCDST_WINDOW_USAGE, "[-d] " CMD_SRCDST_WINDOW_USAGE,
0, 0,
NULL,
cmd_swap_window_exec cmd_swap_window_exec
}; };

View File

@ -27,7 +27,6 @@
* Switch client to a different session. * Switch client to a different session.
*/ */
void cmd_switch_client_key_binding(struct cmd *, int);
enum cmd_retval cmd_switch_client_exec(struct cmd *, struct cmd_q *); enum cmd_retval cmd_switch_client_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_switch_client_entry = { const struct cmd_entry cmd_switch_client_entry = {
@ -35,27 +34,9 @@ const struct cmd_entry cmd_switch_client_entry = {
"lc:npt:r", 0, 0, "lc:npt:r", 0, 0,
"[-lnpr] [-c target-client] [-t target-session]", "[-lnpr] [-c target-client] [-t target-session]",
CMD_READONLY, CMD_READONLY,
cmd_switch_client_key_binding,
cmd_switch_client_exec cmd_switch_client_exec
}; };
void
cmd_switch_client_key_binding(struct cmd *self, int key)
{
self->args = args_create(0);
switch (key) {
case '(':
args_set(self->args, 'p', NULL);
break;
case ')':
args_set(self->args, 'n', NULL);
break;
case 'L':
args_set(self->args, 'l', NULL);
break;
}
}
enum cmd_retval enum cmd_retval
cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq) cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
{ {

View File

@ -34,7 +34,6 @@ const struct cmd_entry cmd_unbind_key_entry = {
"acnt:", 0, 1, "acnt:", 0, 1,
"[-acn] [-t mode-table] key", "[-acn] [-t mode-table] key",
0, 0,
NULL,
cmd_unbind_key_exec cmd_unbind_key_exec
}; };

View File

@ -31,7 +31,6 @@ const struct cmd_entry cmd_unlink_window_entry = {
"kt:", 0, 0, "kt:", 0, 0,
"[-k] " CMD_TARGET_WINDOW_USAGE, "[-k] " CMD_TARGET_WINDOW_USAGE,
0, 0,
NULL,
cmd_unlink_window_exec cmd_unlink_window_exec
}; };

View File

@ -35,7 +35,6 @@ const struct cmd_entry cmd_wait_for_entry = {
"LSU", 1, 1, "LSU", 1, 1,
"[-L|-S|-U] channel", "[-L|-S|-U] channel",
0, 0,
NULL,
cmd_wait_for_exec cmd_wait_for_exec
}; };

View File

@ -84,107 +84,99 @@ key_bindings_remove(int key)
void void
key_bindings_init(void) key_bindings_init(void)
{ {
static const struct { static const char* defaults[] = {
int key; "bind C-b send-prefix",
int can_repeat; "bind C-o rotate-window",
const struct cmd_entry *entry; "bind C-z suspend-client",
} table[] = { "bind Space next-layout",
{ ' ', 0, &cmd_next_layout_entry }, "bind ! break-pane",
{ '!', 0, &cmd_break_pane_entry }, "bind '\"' split-window",
{ '"', 0, &cmd_split_window_entry }, "bind '#' list-buffers",
{ '#', 0, &cmd_list_buffers_entry }, "bind '$' command-prompt -I'#S' \"rename-session '%%'\"",
{ '$', 0, &cmd_command_prompt_entry }, "bind % split-window -h",
{ '%', 0, &cmd_split_window_entry }, "bind & confirm-before -p\"kill-window #W? (y/n)\" kill-window",
{ '&', 0, &cmd_confirm_before_entry }, "bind \"'\" command-prompt -pindex \"select-window -t ':%%'\"",
{ '(', 0, &cmd_switch_client_entry }, "bind ( switch-client -p",
{ ')', 0, &cmd_switch_client_entry }, "bind ) switch-client -n",
{ ',', 0, &cmd_command_prompt_entry }, "bind , command-prompt -I'#W' \"rename-window '%%'\"",
{ '-', 0, &cmd_delete_buffer_entry }, "bind - delete-buffer",
{ '.', 0, &cmd_command_prompt_entry }, "bind . command-prompt \"move-window -t '%%'\"",
{ '0', 0, &cmd_select_window_entry }, "bind 0 select-window -t:0",
{ '1', 0, &cmd_select_window_entry }, "bind 1 select-window -t:1",
{ '2', 0, &cmd_select_window_entry }, "bind 2 select-window -t:2",
{ '3', 0, &cmd_select_window_entry }, "bind 3 select-window -t:3",
{ '4', 0, &cmd_select_window_entry }, "bind 4 select-window -t:4",
{ '5', 0, &cmd_select_window_entry }, "bind 5 select-window -t:5",
{ '6', 0, &cmd_select_window_entry }, "bind 6 select-window -t:6",
{ '7', 0, &cmd_select_window_entry }, "bind 7 select-window -t:7",
{ '8', 0, &cmd_select_window_entry }, "bind 8 select-window -t:8",
{ '9', 0, &cmd_select_window_entry }, "bind 9 select-window -t:9",
{ ':', 0, &cmd_command_prompt_entry }, "bind : command-prompt",
{ ';', 0, &cmd_last_pane_entry }, "bind \\; last-pane",
{ '=', 0, &cmd_choose_buffer_entry }, "bind = choose-buffer",
{ '?', 0, &cmd_list_keys_entry }, "bind ? list-keys",
{ 'D', 0, &cmd_choose_client_entry }, "bind D choose-client",
{ 'L', 0, &cmd_switch_client_entry }, "bind L switch-client -l",
{ '[', 0, &cmd_copy_mode_entry }, "bind [ copy-mode",
{ '\'', 0, &cmd_command_prompt_entry }, "bind ] paste-buffer",
{ '\002', /* C-b */ 0, &cmd_send_prefix_entry }, "bind c new-window",
{ '\017', /* C-o */ 0, &cmd_rotate_window_entry }, "bind d detach-client",
{ '\032', /* C-z */ 0, &cmd_suspend_client_entry }, "bind f command-prompt \"find-window '%%'\"",
{ ']', 0, &cmd_paste_buffer_entry }, "bind i display-message",
{ 'c', 0, &cmd_new_window_entry }, "bind l last-window",
{ 'd', 0, &cmd_detach_client_entry }, "bind n next-window",
{ 'f', 0, &cmd_command_prompt_entry }, "bind o select-pane -t:.+",
{ 'i', 0, &cmd_display_message_entry }, "bind p previous-window",
{ 'l', 0, &cmd_last_window_entry }, "bind q display-panes",
{ 'n', 0, &cmd_next_window_entry }, "bind r refresh-client",
{ 'o', 0, &cmd_select_pane_entry }, "bind s choose-tree",
{ 'p', 0, &cmd_previous_window_entry }, "bind t clock-mode",
{ 'q', 0, &cmd_display_panes_entry }, "bind w choose-window",
{ 'r', 0, &cmd_refresh_client_entry }, "bind x confirm-before -p\"kill-pane #P? (y/n)\" kill-pane",
{ 's', 0, &cmd_choose_tree_entry }, "bind z resize-pane -Z",
{ 't', 0, &cmd_clock_mode_entry }, "bind { swap-pane -U",
{ 'w', 0, &cmd_choose_window_entry }, "bind } swap-pane -D",
{ 'x', 0, &cmd_confirm_before_entry }, "bind '~' show-messages",
{ 'z', 0, &cmd_resize_pane_entry }, "bind PPage copy-mode -u",
{ '{', 0, &cmd_swap_pane_entry }, "bind -r Up select-pane -U",
{ '}', 0, &cmd_swap_pane_entry }, "bind -r Down select-pane -D",
{ '~', 0, &cmd_show_messages_entry }, "bind -r Left select-pane -L",
{ '1' | KEYC_ESCAPE, 0, &cmd_select_layout_entry }, "bind -r Right select-pane -R",
{ '2' | KEYC_ESCAPE, 0, &cmd_select_layout_entry }, "bind M-1 select-layout even-horizontal",
{ '3' | KEYC_ESCAPE, 0, &cmd_select_layout_entry }, "bind M-2 select-layout even-vertical",
{ '4' | KEYC_ESCAPE, 0, &cmd_select_layout_entry }, "bind M-3 select-layout main-horizontal",
{ '5' | KEYC_ESCAPE, 0, &cmd_select_layout_entry }, "bind M-4 select-layout main-vertical",
{ KEYC_PPAGE, 0, &cmd_copy_mode_entry }, "bind M-5 select-layout tiled",
{ 'n' | KEYC_ESCAPE, 0, &cmd_next_window_entry }, "bind M-n next-window -a",
{ 'o' | KEYC_ESCAPE, 0, &cmd_rotate_window_entry }, "bind M-o rotate-window -D",
{ 'p' | KEYC_ESCAPE, 0, &cmd_previous_window_entry }, "bind M-p previous-window -a",
{ KEYC_UP, 1, &cmd_select_pane_entry }, "bind -r M-Up resize-pane -U 5",
{ KEYC_DOWN, 1, &cmd_select_pane_entry }, "bind -r M-Down resize-pane -D 5",
{ KEYC_LEFT, 1, &cmd_select_pane_entry }, "bind -r M-Left resize-pane -L 5",
{ KEYC_RIGHT, 1, &cmd_select_pane_entry }, "bind -r M-Right resize-pane -R 5",
{ KEYC_UP | KEYC_ESCAPE, 1, &cmd_resize_pane_entry }, "bind -r C-Up resize-pane -U",
{ KEYC_DOWN | KEYC_ESCAPE, 1, &cmd_resize_pane_entry }, "bind -r C-Down resize-pane -D",
{ KEYC_LEFT | KEYC_ESCAPE, 1, &cmd_resize_pane_entry }, "bind -r C-Left resize-pane -L",
{ KEYC_RIGHT | KEYC_ESCAPE, 1, &cmd_resize_pane_entry }, "bind -r C-Right resize-pane -R",
{ KEYC_UP | KEYC_CTRL, 1, &cmd_resize_pane_entry },
{ KEYC_DOWN | KEYC_CTRL, 1, &cmd_resize_pane_entry },
{ KEYC_LEFT | KEYC_CTRL, 1, &cmd_resize_pane_entry },
{ KEYC_RIGHT | KEYC_CTRL, 1, &cmd_resize_pane_entry },
}; };
u_int i; u_int i;
struct cmd *cmd;
struct cmd_list *cmdlist; struct cmd_list *cmdlist;
char* cause;
int error;
struct cmd_q *cmdq;
RB_INIT(&key_bindings); RB_INIT(&key_bindings);
for (i = 0; i < nitems(table); i++) { cmdq = cmdq_new (NULL);
cmdlist = xcalloc(1, sizeof *cmdlist); for (i = 0; i < nitems(defaults); i++) {
cmdlist->references = 1; error = cmd_string_parse(defaults[i], &cmdlist,
TAILQ_INIT(&cmdlist->list); "<default-keys>", i, &cause);
if (error != 0)
cmd = xcalloc(1, sizeof *cmd); fatalx("bad default key");
cmd->entry = table[i].entry; cmdq_run (cmdq, cmdlist);
if (cmd->entry->key_binding != NULL) cmd_list_free (cmdlist);
cmd->entry->key_binding(cmd, table[i].key);
else
cmd->args = args_create(0);
TAILQ_INSERT_HEAD(&cmdlist->list, cmd, qentry);
key_bindings_add(
table[i].key | KEYC_PREFIX, table[i].can_repeat, cmdlist);
} }
cmdq_free (cmdq);
} }
void void

1
tmux.h
View File

@ -1492,7 +1492,6 @@ struct cmd_entry {
#define CMD_READONLY 0x4 #define CMD_READONLY 0x4
int flags; int flags;
void (*key_binding)(struct cmd *, int);
enum cmd_retval (*exec)(struct cmd *, struct cmd_q *); enum cmd_retval (*exec)(struct cmd *, struct cmd_q *);
}; };