2009-06-01 22:58:49 +00:00
|
|
|
/* $OpenBSD$ */
|
|
|
|
|
|
|
|
/*
|
2016-01-19 15:59:12 +00:00
|
|
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
2009-06-01 22:58:49 +00:00
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "tmux.h"
|
|
|
|
|
2019-05-28 10:05:24 +00:00
|
|
|
#define DEFAULT_CLIENT_MENU \
|
|
|
|
" 'Detach' 'd' {detach-client}" \
|
|
|
|
" 'Detach & Kill' 'X' {detach-client -P}" \
|
|
|
|
" 'Detach Others' 'o' {detach-client -a}" \
|
|
|
|
" ''" \
|
|
|
|
" 'Lock' 'l' {lock-client}"
|
|
|
|
#define DEFAULT_SESSION_MENU \
|
|
|
|
" 'Next' 'n' {switch-client -n}" \
|
|
|
|
" 'Previous' 'p' {switch-client -p}" \
|
|
|
|
" ''" \
|
|
|
|
" 'Renumber' 'N' {move-window -r}" \
|
|
|
|
" 'Rename' 'n' {command-prompt -I \"#S\" \"rename-session -- '%%'\"}" \
|
|
|
|
" ''" \
|
|
|
|
" 'New Session' 's' {new-session}" \
|
|
|
|
" 'New Window' 'w' {new-window}"
|
|
|
|
#define DEFAULT_WINDOW_MENU \
|
|
|
|
" 'Swap Left' 'l' {swap-window -t:-1}" \
|
|
|
|
" 'Swap Right' 'r' {swap-window -t:+1}" \
|
|
|
|
" '#{?pane_marked_set,,-}Swap Marked' 's' {swap-window}" \
|
|
|
|
" ''" \
|
|
|
|
" 'Kill' 'X' {kill-window}" \
|
|
|
|
" 'Respawn' 'R' {respawn-window -k}" \
|
|
|
|
" '#{?pane_marked,Unmark,Mark}' 'm' {select-pane -m}" \
|
|
|
|
" 'Rename' 'n' {command-prompt -I \"#W\" \"rename-window -- '%%'\"}" \
|
|
|
|
" ''" \
|
|
|
|
" 'New After' 'w' {new-window -a}" \
|
|
|
|
" 'New At End' 'W' {new-window}"
|
|
|
|
#define DEFAULT_PANE_MENU \
|
|
|
|
" '#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}' 'C-r' {copy-mode -t=; send -Xt= search-backward \"#{q:mouse_word}\"}" \
|
|
|
|
" '#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}' 'C-y' {send-keys -l -- \"#{q:mouse_word}\"}" \
|
|
|
|
" '#{?mouse_word,Copy #[underscore]#{=/9/...:mouse_word},}' 'c' {set-buffer -- \"#{q:mouse_word}\"}" \
|
|
|
|
" '#{?mouse_line,Copy Line,}' 'l' {set-buffer -- \"#{q:mouse_line}\"}" \
|
|
|
|
" ''" \
|
|
|
|
" 'Horizontal Split' 'h' {split-window -h}" \
|
|
|
|
" 'Vertical Split' 'v' {split-window -v}" \
|
|
|
|
" ''" \
|
|
|
|
" 'Swap Up' 'u' {swap-pane -U}" \
|
|
|
|
" 'Swap Down' 'd' {swap-pane -D}" \
|
|
|
|
" '#{?pane_marked_set,,-}Swap Marked' 's' {swap-pane}" \
|
|
|
|
" ''" \
|
|
|
|
" 'Kill' 'X' {kill-pane}" \
|
|
|
|
" 'Respawn' 'R' {respawn-pane -k}" \
|
|
|
|
" '#{?pane_marked,Unmark,Mark}' 'm' {select-pane -m}" \
|
|
|
|
" '#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}"
|
|
|
|
|
|
|
|
|
2018-08-02 11:44:07 +00:00
|
|
|
static int key_bindings_cmp(struct key_binding *, struct key_binding *);
|
|
|
|
RB_GENERATE_STATIC(key_bindings, key_binding, entry, key_bindings_cmp);
|
|
|
|
static int key_table_cmp(struct key_table *, struct key_table *);
|
|
|
|
RB_GENERATE_STATIC(key_tables, key_table, entry, key_table_cmp);
|
|
|
|
static struct key_tables key_tables = RB_INITIALIZER(&key_tables);
|
|
|
|
|
|
|
|
static int
|
|
|
|
key_table_cmp(struct key_table *table1, struct key_table *table2)
|
2015-04-20 15:34:56 +00:00
|
|
|
{
|
2018-08-02 11:44:07 +00:00
|
|
|
return (strcmp(table1->name, table2->name));
|
2015-04-20 15:34:56 +00:00
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2018-08-02 11:44:07 +00:00
|
|
|
static int
|
2009-06-01 22:58:49 +00:00
|
|
|
key_bindings_cmp(struct key_binding *bd1, struct key_binding *bd2)
|
|
|
|
{
|
2015-11-12 11:05:34 +00:00
|
|
|
if (bd1->key < bd2->key)
|
|
|
|
return (-1);
|
|
|
|
if (bd1->key > bd2->key)
|
|
|
|
return (1);
|
|
|
|
return (0);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 15:34:56 +00:00
|
|
|
struct key_table *
|
|
|
|
key_bindings_get_table(const char *name, int create)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2015-04-20 15:34:56 +00:00
|
|
|
struct key_table table_find, *table;
|
|
|
|
|
|
|
|
table_find.name = name;
|
|
|
|
table = RB_FIND(key_tables, &key_tables, &table_find);
|
|
|
|
if (table != NULL || !create)
|
|
|
|
return (table);
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2015-04-20 15:34:56 +00:00
|
|
|
table = xmalloc(sizeof *table);
|
|
|
|
table->name = xstrdup(name);
|
|
|
|
RB_INIT(&table->key_bindings);
|
|
|
|
|
|
|
|
table->references = 1; /* one reference in key_tables */
|
|
|
|
RB_INSERT(key_tables, &key_tables, table);
|
|
|
|
|
|
|
|
return (table);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2018-08-02 11:44:07 +00:00
|
|
|
struct key_table *
|
|
|
|
key_bindings_first_table(void)
|
|
|
|
{
|
|
|
|
return (RB_MIN(key_tables, &key_tables));
|
|
|
|
}
|
|
|
|
|
|
|
|
struct key_table *
|
|
|
|
key_bindings_next_table(struct key_table *table)
|
|
|
|
{
|
|
|
|
return (RB_NEXT(key_tables, &key_tables, table));
|
|
|
|
}
|
|
|
|
|
2009-06-01 22:58:49 +00:00
|
|
|
void
|
2015-04-20 15:34:56 +00:00
|
|
|
key_bindings_unref_table(struct key_table *table)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
|
|
|
struct key_binding *bd;
|
2016-03-01 12:06:07 +00:00
|
|
|
struct key_binding *bd1;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2015-04-20 15:34:56 +00:00
|
|
|
if (--table->references != 0)
|
|
|
|
return;
|
|
|
|
|
2016-03-01 12:06:07 +00:00
|
|
|
RB_FOREACH_SAFE(bd, key_bindings, &table->key_bindings, bd1) {
|
2015-04-20 15:34:56 +00:00
|
|
|
RB_REMOVE(key_bindings, &table->key_bindings, bd);
|
|
|
|
cmd_list_free(bd->cmdlist);
|
|
|
|
free(bd);
|
|
|
|
}
|
|
|
|
|
|
|
|
free((void *)table->name);
|
|
|
|
free(table);
|
|
|
|
}
|
|
|
|
|
2018-08-02 11:44:07 +00:00
|
|
|
struct key_binding *
|
|
|
|
key_bindings_get(struct key_table *table, key_code key)
|
|
|
|
{
|
|
|
|
struct key_binding bd;
|
|
|
|
|
|
|
|
bd.key = key;
|
|
|
|
return (RB_FIND(key_bindings, &table->key_bindings, &bd));
|
|
|
|
}
|
|
|
|
|
|
|
|
struct key_binding *
|
|
|
|
key_bindings_first(struct key_table *table)
|
|
|
|
{
|
|
|
|
return (RB_MIN(key_bindings, &table->key_bindings));
|
|
|
|
}
|
|
|
|
|
|
|
|
struct key_binding *
|
|
|
|
key_bindings_next(__unused struct key_table *table, struct key_binding *bd)
|
|
|
|
{
|
|
|
|
return (RB_NEXT(key_bindings, &table->key_bindings, bd));
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:34:56 +00:00
|
|
|
void
|
2017-04-21 14:01:19 +00:00
|
|
|
key_bindings_add(const char *name, key_code key, int repeat,
|
2015-04-20 15:34:56 +00:00
|
|
|
struct cmd_list *cmdlist)
|
|
|
|
{
|
|
|
|
struct key_table *table;
|
|
|
|
struct key_binding bd_find, *bd;
|
|
|
|
|
|
|
|
table = key_bindings_get_table(name, 1);
|
|
|
|
|
2017-05-07 21:25:59 +00:00
|
|
|
bd_find.key = (key & ~KEYC_XTERM);
|
2015-04-20 15:34:56 +00:00
|
|
|
bd = RB_FIND(key_bindings, &table->key_bindings, &bd_find);
|
|
|
|
if (bd != NULL) {
|
|
|
|
RB_REMOVE(key_bindings, &table->key_bindings, bd);
|
|
|
|
cmd_list_free(bd->cmdlist);
|
|
|
|
free(bd);
|
|
|
|
}
|
2009-12-03 22:50:09 +00:00
|
|
|
|
2017-04-21 19:33:07 +00:00
|
|
|
bd = xcalloc(1, sizeof *bd);
|
2009-07-12 17:33:18 +00:00
|
|
|
bd->key = key;
|
2015-04-20 15:34:56 +00:00
|
|
|
RB_INSERT(key_bindings, &table->key_bindings, bd);
|
2009-12-03 22:50:09 +00:00
|
|
|
|
2017-04-21 14:01:19 +00:00
|
|
|
if (repeat)
|
|
|
|
bd->flags |= KEY_BINDING_REPEAT;
|
2009-06-01 22:58:49 +00:00
|
|
|
bd->cmdlist = cmdlist;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-11-12 11:05:34 +00:00
|
|
|
key_bindings_remove(const char *name, key_code key)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2015-04-20 15:34:56 +00:00
|
|
|
struct key_table *table;
|
|
|
|
struct key_binding bd_find, *bd;
|
|
|
|
|
|
|
|
table = key_bindings_get_table(name, 0);
|
|
|
|
if (table == NULL)
|
|
|
|
return;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2017-05-07 21:25:59 +00:00
|
|
|
bd_find.key = (key & ~KEYC_XTERM);
|
2015-04-20 15:34:56 +00:00
|
|
|
bd = RB_FIND(key_bindings, &table->key_bindings, &bd_find);
|
|
|
|
if (bd == NULL)
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
2015-04-20 15:34:56 +00:00
|
|
|
|
|
|
|
RB_REMOVE(key_bindings, &table->key_bindings, bd);
|
2014-05-14 06:21:19 +00:00
|
|
|
cmd_list_free(bd->cmdlist);
|
|
|
|
free(bd);
|
2015-04-20 15:34:56 +00:00
|
|
|
|
|
|
|
if (RB_EMPTY(&table->key_bindings)) {
|
|
|
|
RB_REMOVE(key_tables, &key_tables, table);
|
|
|
|
key_bindings_unref_table(table);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
key_bindings_remove_table(const char *name)
|
|
|
|
{
|
|
|
|
struct key_table *table;
|
2017-09-08 08:45:27 +00:00
|
|
|
struct client *c;
|
2015-04-20 15:34:56 +00:00
|
|
|
|
|
|
|
table = key_bindings_get_table(name, 0);
|
|
|
|
if (table != NULL) {
|
|
|
|
RB_REMOVE(key_tables, &key_tables, table);
|
|
|
|
key_bindings_unref_table(table);
|
|
|
|
}
|
2017-09-08 08:45:27 +00:00
|
|
|
TAILQ_FOREACH(c, &clients, entry) {
|
|
|
|
if (c->keytable == table)
|
|
|
|
server_client_set_key_table(c, NULL);
|
|
|
|
}
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
key_bindings_init(void)
|
|
|
|
{
|
2015-04-25 18:49:01 +00:00
|
|
|
static const char *defaults[] = {
|
2014-10-20 22:29:25 +00:00
|
|
|
"bind C-b send-prefix",
|
|
|
|
"bind C-o rotate-window",
|
|
|
|
"bind C-z suspend-client",
|
|
|
|
"bind Space next-layout",
|
|
|
|
"bind ! break-pane",
|
|
|
|
"bind '\"' split-window",
|
|
|
|
"bind '#' list-buffers",
|
2017-10-05 13:43:34 +00:00
|
|
|
"bind '$' command-prompt -I'#S' \"rename-session -- '%%'\"",
|
2014-10-20 22:29:25 +00:00
|
|
|
"bind % split-window -h",
|
|
|
|
"bind & confirm-before -p\"kill-window #W? (y/n)\" kill-window",
|
|
|
|
"bind \"'\" command-prompt -pindex \"select-window -t ':%%'\"",
|
|
|
|
"bind ( switch-client -p",
|
|
|
|
"bind ) switch-client -n",
|
2017-10-05 13:43:34 +00:00
|
|
|
"bind , command-prompt -I'#W' \"rename-window -- '%%'\"",
|
2014-10-20 22:29:25 +00:00
|
|
|
"bind - delete-buffer",
|
|
|
|
"bind . command-prompt \"move-window -t '%%'\"",
|
2015-06-05 08:14:16 +00:00
|
|
|
"bind 0 select-window -t:=0",
|
|
|
|
"bind 1 select-window -t:=1",
|
|
|
|
"bind 2 select-window -t:=2",
|
|
|
|
"bind 3 select-window -t:=3",
|
|
|
|
"bind 4 select-window -t:=4",
|
|
|
|
"bind 5 select-window -t:=5",
|
|
|
|
"bind 6 select-window -t:=6",
|
|
|
|
"bind 7 select-window -t:=7",
|
|
|
|
"bind 8 select-window -t:=8",
|
|
|
|
"bind 9 select-window -t:=9",
|
2014-10-20 22:29:25 +00:00
|
|
|
"bind : command-prompt",
|
|
|
|
"bind \\; last-pane",
|
2018-02-28 08:55:44 +00:00
|
|
|
"bind = choose-buffer -Z",
|
2014-10-20 22:29:25 +00:00
|
|
|
"bind ? list-keys",
|
2018-02-28 08:55:44 +00:00
|
|
|
"bind D choose-client -Z",
|
2017-11-15 19:59:27 +00:00
|
|
|
"bind E select-layout -E",
|
2014-10-20 22:29:25 +00:00
|
|
|
"bind L switch-client -l",
|
2015-06-04 11:43:51 +00:00
|
|
|
"bind M select-pane -M",
|
2014-10-20 22:29:25 +00:00
|
|
|
"bind [ copy-mode",
|
|
|
|
"bind ] paste-buffer",
|
|
|
|
"bind c new-window",
|
|
|
|
"bind d detach-client",
|
2018-08-20 15:00:42 +00:00
|
|
|
"bind f command-prompt \"find-window -Z -- '%%'\"",
|
2014-10-20 22:29:25 +00:00
|
|
|
"bind i display-message",
|
|
|
|
"bind l last-window",
|
2015-06-04 11:43:51 +00:00
|
|
|
"bind m select-pane -m",
|
2014-10-20 22:29:25 +00:00
|
|
|
"bind n next-window",
|
|
|
|
"bind o select-pane -t:.+",
|
|
|
|
"bind p previous-window",
|
|
|
|
"bind q display-panes",
|
|
|
|
"bind r refresh-client",
|
2018-02-28 08:55:44 +00:00
|
|
|
"bind s choose-tree -Zs",
|
2014-10-20 22:29:25 +00:00
|
|
|
"bind t clock-mode",
|
2018-02-28 08:55:44 +00:00
|
|
|
"bind w choose-tree -Zw",
|
2014-10-20 22:29:25 +00:00
|
|
|
"bind x confirm-before -p\"kill-pane #P? (y/n)\" kill-pane",
|
|
|
|
"bind z resize-pane -Z",
|
2019-05-27 12:16:27 +00:00
|
|
|
"bind '{' swap-pane -U",
|
|
|
|
"bind '}' swap-pane -D",
|
2014-10-20 22:29:25 +00:00
|
|
|
"bind '~' show-messages",
|
|
|
|
"bind PPage copy-mode -u",
|
|
|
|
"bind -r Up select-pane -U",
|
|
|
|
"bind -r Down select-pane -D",
|
|
|
|
"bind -r Left select-pane -L",
|
|
|
|
"bind -r Right select-pane -R",
|
|
|
|
"bind M-1 select-layout even-horizontal",
|
|
|
|
"bind M-2 select-layout even-vertical",
|
|
|
|
"bind M-3 select-layout main-horizontal",
|
|
|
|
"bind M-4 select-layout main-vertical",
|
|
|
|
"bind M-5 select-layout tiled",
|
|
|
|
"bind M-n next-window -a",
|
|
|
|
"bind M-o rotate-window -D",
|
|
|
|
"bind M-p previous-window -a",
|
Support for windows larger than visible on the attached client. This has
been a limitation for a long time.
There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.
The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.
If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.
Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).
The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.
For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..
If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.
The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.
The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.
2018-10-18 08:38:01 +00:00
|
|
|
"bind -r S-Up refresh-client -U 10",
|
|
|
|
"bind -r S-Down refresh-client -D 10",
|
|
|
|
"bind -r S-Left refresh-client -L 10",
|
|
|
|
"bind -r S-Right refresh-client -R 10",
|
|
|
|
"bind -r DC refresh-client -c",
|
2014-10-20 22:29:25 +00:00
|
|
|
"bind -r M-Up resize-pane -U 5",
|
|
|
|
"bind -r M-Down resize-pane -D 5",
|
|
|
|
"bind -r M-Left resize-pane -L 5",
|
|
|
|
"bind -r M-Right resize-pane -R 5",
|
|
|
|
"bind -r C-Up resize-pane -U",
|
|
|
|
"bind -r C-Down resize-pane -D",
|
|
|
|
"bind -r C-Left resize-pane -L",
|
|
|
|
"bind -r C-Right resize-pane -R",
|
2019-05-10 18:04:06 +00:00
|
|
|
|
2015-04-19 21:34:21 +00:00
|
|
|
"bind -n MouseDown1Pane select-pane -t=\\; send-keys -M",
|
|
|
|
"bind -n MouseDrag1Border resize-pane -M",
|
|
|
|
"bind -n MouseDown1Status select-window -t=",
|
2015-10-26 23:06:18 +00:00
|
|
|
"bind -n WheelDownStatus next-window",
|
|
|
|
"bind -n WheelUpStatus previous-window",
|
2015-04-21 15:34:32 +00:00
|
|
|
"bind -n MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= \"#{pane_in_mode}\" \"copy-mode -M\" \"send-keys -M\"' 'copy-mode -M'",
|
2019-05-12 08:58:09 +00:00
|
|
|
"bind -n WheelUpPane if -Ft= '#{mouse_any_flag}' 'send-keys -M' 'if -Ft= \"#{pane_in_mode}\" \"send-keys -M\" \"copy-mode -et=\"'",
|
2019-05-28 07:18:42 +00:00
|
|
|
|
2019-05-28 10:05:24 +00:00
|
|
|
"bind -n MouseDown3StatusRight display-menu -t= -xM -yS -T \"#[align=centre]#{client_name}\" " DEFAULT_CLIENT_MENU,
|
|
|
|
"bind -n MouseDown3StatusLeft display-menu -t= -xM -yS -T \"#[align=centre]#{session_name}\" " DEFAULT_SESSION_MENU,
|
|
|
|
"bind -n MouseDown3Status display-menu -t= -xW -yS -T \"#[align=centre]#{window_index}:#{window_name}\" " DEFAULT_WINDOW_MENU,
|
|
|
|
"bind C-m display-menu -xW -yS -T \"#[align=centre]#{window_index}:#{window_name}\" " DEFAULT_WINDOW_MENU,
|
2019-05-28 10:27:11 +00:00
|
|
|
"bind -n MouseDown3Pane if -Ft= '#{||:#{mouse_any_flag},#{pane_in_mode}}' 'select-pane -t=; send-keys -M' {display-menu -t= -xM -yM -T \"#[align=centre]#{pane_index} (#{pane_id})\" " DEFAULT_PANE_MENU "}",
|
2019-05-28 10:05:24 +00:00
|
|
|
"bind -n M-MouseDown3Pane display-menu -t= -xM -yM -T \"#[align=centre]#{pane_index} (#{pane_id})\" " DEFAULT_PANE_MENU,
|
|
|
|
"bind M-m display-menu -xP -yP -T \"#[align=centre]#{pane_index} (#{pane_id})\" " DEFAULT_PANE_MENU,
|
2016-10-11 07:23:34 +00:00
|
|
|
|
|
|
|
"bind -Tcopy-mode C-Space send -X begin-selection",
|
|
|
|
"bind -Tcopy-mode C-a send -X start-of-line",
|
|
|
|
"bind -Tcopy-mode C-c send -X cancel",
|
|
|
|
"bind -Tcopy-mode C-e send -X end-of-line",
|
|
|
|
"bind -Tcopy-mode C-f send -X cursor-right",
|
2016-12-07 09:16:13 +00:00
|
|
|
"bind -Tcopy-mode C-b send -X cursor-left",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode C-g send -X clear-selection",
|
|
|
|
"bind -Tcopy-mode C-k send -X copy-end-of-line",
|
|
|
|
"bind -Tcopy-mode C-n send -X cursor-down",
|
|
|
|
"bind -Tcopy-mode C-p send -X cursor-up",
|
2017-06-09 14:00:46 +00:00
|
|
|
"bind -Tcopy-mode C-r command-prompt -ip'(search up)' -I'#{pane_search_string}' 'send -X search-backward-incremental \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode C-s command-prompt -ip'(search down)' -I'#{pane_search_string}' 'send -X search-forward-incremental \"%%%\"'",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode C-v send -X page-down",
|
|
|
|
"bind -Tcopy-mode C-w send -X copy-selection-and-cancel",
|
|
|
|
"bind -Tcopy-mode Escape send -X cancel",
|
|
|
|
"bind -Tcopy-mode Space send -X page-down",
|
|
|
|
"bind -Tcopy-mode , send -X jump-reverse",
|
|
|
|
"bind -Tcopy-mode \\; send -X jump-again",
|
2017-06-09 14:00:46 +00:00
|
|
|
"bind -Tcopy-mode F command-prompt -1p'(jump backward)' 'send -X jump-backward \"%%%\"'",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode N send -X search-reverse",
|
|
|
|
"bind -Tcopy-mode R send -X rectangle-toggle",
|
2017-06-09 14:00:46 +00:00
|
|
|
"bind -Tcopy-mode T command-prompt -1p'(jump to backward)' 'send -X jump-to-backward \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode f command-prompt -1p'(jump forward)' 'send -X jump-forward \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode g command-prompt -p'(goto line)' 'send -X goto-line \"%%%\"'",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode n send -X search-again",
|
|
|
|
"bind -Tcopy-mode q send -X cancel",
|
2017-06-09 14:00:46 +00:00
|
|
|
"bind -Tcopy-mode t command-prompt -1p'(jump to forward)' 'send -X jump-to-forward \"%%%\"'",
|
2017-04-05 12:14:18 +00:00
|
|
|
"bind -Tcopy-mode Home send -X start-of-line",
|
|
|
|
"bind -Tcopy-mode End send -X end-of-line",
|
2016-11-24 13:46:50 +00:00
|
|
|
"bind -Tcopy-mode MouseDown1Pane select-pane",
|
|
|
|
"bind -Tcopy-mode MouseDrag1Pane select-pane\\; send -X begin-selection",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode MouseDragEnd1Pane send -X copy-selection-and-cancel",
|
2016-11-24 13:46:50 +00:00
|
|
|
"bind -Tcopy-mode WheelUpPane select-pane\\; send -N5 -X scroll-up",
|
|
|
|
"bind -Tcopy-mode WheelDownPane select-pane\\; send -N5 -X scroll-down",
|
|
|
|
"bind -Tcopy-mode DoubleClick1Pane select-pane\\; send -X select-word",
|
|
|
|
"bind -Tcopy-mode TripleClick1Pane select-pane\\; send -X select-line",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode NPage send -X page-down",
|
|
|
|
"bind -Tcopy-mode PPage send -X page-up",
|
|
|
|
"bind -Tcopy-mode Up send -X cursor-up",
|
|
|
|
"bind -Tcopy-mode Down send -X cursor-down",
|
|
|
|
"bind -Tcopy-mode Left send -X cursor-left",
|
|
|
|
"bind -Tcopy-mode Right send -X cursor-right",
|
2017-06-09 14:00:46 +00:00
|
|
|
"bind -Tcopy-mode M-1 command-prompt -Np'(repeat)' -I1 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode M-2 command-prompt -Np'(repeat)' -I2 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode M-3 command-prompt -Np'(repeat)' -I3 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode M-4 command-prompt -Np'(repeat)' -I4 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode M-5 command-prompt -Np'(repeat)' -I5 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode M-6 command-prompt -Np'(repeat)' -I6 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode M-7 command-prompt -Np'(repeat)' -I7 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode M-8 command-prompt -Np'(repeat)' -I8 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode M-9 command-prompt -Np'(repeat)' -I9 'send -N \"%%%\"'",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode M-< send -X history-top",
|
|
|
|
"bind -Tcopy-mode M-> send -X history-bottom",
|
|
|
|
"bind -Tcopy-mode M-R send -X top-line",
|
|
|
|
"bind -Tcopy-mode M-b send -X previous-word",
|
2019-04-29 06:55:21 +00:00
|
|
|
"bind -Tcopy-mode C-M-b send -X previous-matching-bracket",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode M-f send -X next-word-end",
|
2019-04-29 06:55:21 +00:00
|
|
|
"bind -Tcopy-mode C-M-f send -X next-matching-bracket",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode M-m send -X back-to-indentation",
|
|
|
|
"bind -Tcopy-mode M-r send -X middle-line",
|
|
|
|
"bind -Tcopy-mode M-v send -X page-up",
|
|
|
|
"bind -Tcopy-mode M-w send -X copy-selection-and-cancel",
|
2019-05-27 12:16:27 +00:00
|
|
|
"bind -Tcopy-mode 'M-{' send -X previous-paragraph",
|
|
|
|
"bind -Tcopy-mode 'M-}' send -X next-paragraph",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode M-Up send -X halfpage-up",
|
|
|
|
"bind -Tcopy-mode M-Down send -X halfpage-down",
|
|
|
|
"bind -Tcopy-mode C-Up send -X scroll-up",
|
|
|
|
"bind -Tcopy-mode C-Down send -X scroll-down",
|
|
|
|
|
|
|
|
"bind -Tcopy-mode-vi C-c send -X cancel",
|
|
|
|
"bind -Tcopy-mode-vi C-d send -X halfpage-down",
|
|
|
|
"bind -Tcopy-mode-vi C-e send -X scroll-down",
|
2016-12-07 09:16:13 +00:00
|
|
|
"bind -Tcopy-mode-vi C-b send -X page-up",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode-vi C-f send -X page-down",
|
|
|
|
"bind -Tcopy-mode-vi C-h send -X cursor-left",
|
|
|
|
"bind -Tcopy-mode-vi C-j send -X copy-selection-and-cancel",
|
|
|
|
"bind -Tcopy-mode-vi Enter send -X copy-selection-and-cancel",
|
|
|
|
"bind -Tcopy-mode-vi C-u send -X halfpage-up",
|
|
|
|
"bind -Tcopy-mode-vi C-v send -X rectangle-toggle",
|
|
|
|
"bind -Tcopy-mode-vi C-y send -X scroll-up",
|
|
|
|
"bind -Tcopy-mode-vi Escape send -X clear-selection",
|
|
|
|
"bind -Tcopy-mode-vi Space send -X begin-selection",
|
|
|
|
"bind -Tcopy-mode-vi '$' send -X end-of-line",
|
|
|
|
"bind -Tcopy-mode-vi , send -X jump-reverse",
|
2017-06-09 14:00:46 +00:00
|
|
|
"bind -Tcopy-mode-vi / command-prompt -p'(search down)' 'send -X search-forward \"%%%\"'",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode-vi 0 send -X start-of-line",
|
2017-06-09 14:00:46 +00:00
|
|
|
"bind -Tcopy-mode-vi 1 command-prompt -Np'(repeat)' -I1 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode-vi 2 command-prompt -Np'(repeat)' -I2 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode-vi 3 command-prompt -Np'(repeat)' -I3 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode-vi 4 command-prompt -Np'(repeat)' -I4 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode-vi 5 command-prompt -Np'(repeat)' -I5 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode-vi 6 command-prompt -Np'(repeat)' -I6 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode-vi 7 command-prompt -Np'(repeat)' -I7 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode-vi 8 command-prompt -Np'(repeat)' -I8 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode-vi 9 command-prompt -Np'(repeat)' -I9 'send -N \"%%%\"'",
|
|
|
|
"bind -Tcopy-mode-vi : command-prompt -p'(goto line)' 'send -X goto-line \"%%%\"'",
|
2016-10-12 13:03:27 +00:00
|
|
|
"bind -Tcopy-mode-vi \\; send -X jump-again",
|
2017-06-09 14:00:46 +00:00
|
|
|
"bind -Tcopy-mode-vi ? command-prompt -p'(search up)' 'send -X search-backward \"%%%\"'",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode-vi A send -X append-selection-and-cancel",
|
|
|
|
"bind -Tcopy-mode-vi B send -X previous-space",
|
|
|
|
"bind -Tcopy-mode-vi D send -X copy-end-of-line",
|
|
|
|
"bind -Tcopy-mode-vi E send -X next-space-end",
|
2017-06-09 14:00:46 +00:00
|
|
|
"bind -Tcopy-mode-vi F command-prompt -1p'(jump backward)' 'send -X jump-backward \"%%%\"'",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode-vi G send -X history-bottom",
|
|
|
|
"bind -Tcopy-mode-vi H send -X top-line",
|
|
|
|
"bind -Tcopy-mode-vi J send -X scroll-down",
|
|
|
|
"bind -Tcopy-mode-vi K send -X scroll-up",
|
|
|
|
"bind -Tcopy-mode-vi L send -X bottom-line",
|
|
|
|
"bind -Tcopy-mode-vi M send -X middle-line",
|
|
|
|
"bind -Tcopy-mode-vi N send -X search-reverse",
|
2017-06-09 14:00:46 +00:00
|
|
|
"bind -Tcopy-mode-vi T command-prompt -1p'(jump to backward)' 'send -X jump-to-backward \"%%%\"'",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode-vi V send -X select-line",
|
|
|
|
"bind -Tcopy-mode-vi W send -X next-space",
|
|
|
|
"bind -Tcopy-mode-vi ^ send -X back-to-indentation",
|
|
|
|
"bind -Tcopy-mode-vi b send -X previous-word",
|
|
|
|
"bind -Tcopy-mode-vi e send -X next-word-end",
|
2017-06-09 14:00:46 +00:00
|
|
|
"bind -Tcopy-mode-vi f command-prompt -1p'(jump forward)' 'send -X jump-forward \"%%%\"'",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode-vi g send -X history-top",
|
|
|
|
"bind -Tcopy-mode-vi h send -X cursor-left",
|
|
|
|
"bind -Tcopy-mode-vi j send -X cursor-down",
|
|
|
|
"bind -Tcopy-mode-vi k send -X cursor-up",
|
|
|
|
"bind -Tcopy-mode-vi l send -X cursor-right",
|
|
|
|
"bind -Tcopy-mode-vi n send -X search-again",
|
|
|
|
"bind -Tcopy-mode-vi o send -X other-end",
|
|
|
|
"bind -Tcopy-mode-vi q send -X cancel",
|
2017-06-09 14:00:46 +00:00
|
|
|
"bind -Tcopy-mode-vi t command-prompt -1p'(jump to forward)' 'send -X jump-to-forward \"%%%\"'",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode-vi v send -X rectangle-toggle",
|
|
|
|
"bind -Tcopy-mode-vi w send -X next-word",
|
2019-05-27 12:16:27 +00:00
|
|
|
"bind -Tcopy-mode-vi '{' send -X previous-paragraph",
|
|
|
|
"bind -Tcopy-mode-vi '}' send -X next-paragraph",
|
2019-04-29 06:55:21 +00:00
|
|
|
"bind -Tcopy-mode-vi % send -X next-matching-bracket",
|
2016-11-24 13:46:50 +00:00
|
|
|
"bind -Tcopy-mode-vi MouseDown1Pane select-pane",
|
|
|
|
"bind -Tcopy-mode-vi MouseDrag1Pane select-pane\\; send -X begin-selection",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel",
|
2016-11-24 13:46:50 +00:00
|
|
|
"bind -Tcopy-mode-vi WheelUpPane select-pane\\; send -N5 -X scroll-up",
|
|
|
|
"bind -Tcopy-mode-vi WheelDownPane select-pane\\; send -N5 -X scroll-down",
|
|
|
|
"bind -Tcopy-mode-vi DoubleClick1Pane select-pane\\; send -X select-word",
|
|
|
|
"bind -Tcopy-mode-vi TripleClick1Pane select-pane\\; send -X select-line",
|
2016-10-11 07:23:34 +00:00
|
|
|
"bind -Tcopy-mode-vi BSpace send -X cursor-left",
|
|
|
|
"bind -Tcopy-mode-vi NPage send -X page-down",
|
|
|
|
"bind -Tcopy-mode-vi PPage send -X page-up",
|
|
|
|
"bind -Tcopy-mode-vi Up send -X cursor-up",
|
|
|
|
"bind -Tcopy-mode-vi Down send -X cursor-down",
|
|
|
|
"bind -Tcopy-mode-vi Left send -X cursor-left",
|
|
|
|
"bind -Tcopy-mode-vi Right send -X cursor-right",
|
|
|
|
"bind -Tcopy-mode-vi C-Up send -X scroll-up",
|
|
|
|
"bind -Tcopy-mode-vi C-Down send -X scroll-down",
|
2009-06-01 22:58:49 +00:00
|
|
|
};
|
2019-05-23 11:13:30 +00:00
|
|
|
u_int i;
|
|
|
|
struct cmd_parse_result *pr;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2014-10-20 22:29:25 +00:00
|
|
|
for (i = 0; i < nitems(defaults); i++) {
|
2019-05-23 11:13:30 +00:00
|
|
|
pr = cmd_parse_from_string(defaults[i], NULL);
|
|
|
|
if (pr->status != CMD_PARSE_SUCCESS)
|
2017-01-24 19:53:37 +00:00
|
|
|
fatalx("bad default key: %s", defaults[i]);
|
2019-05-23 11:13:30 +00:00
|
|
|
cmdq_append(NULL, cmdq_get_command(pr->cmdlist, NULL, NULL, 0));
|
|
|
|
cmd_list_free(pr->cmdlist);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
2016-10-16 17:55:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static enum cmd_retval
|
2016-10-16 19:04:05 +00:00
|
|
|
key_bindings_read_only(struct cmdq_item *item, __unused void *data)
|
2016-10-16 17:55:14 +00:00
|
|
|
{
|
2016-10-16 19:04:05 +00:00
|
|
|
cmdq_error(item, "client is read-only");
|
2016-10-16 17:55:14 +00:00
|
|
|
return (CMD_RETURN_ERROR);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
2019-05-09 13:12:59 +00:00
|
|
|
struct cmdq_item *
|
2017-05-10 10:46:59 +00:00
|
|
|
key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item,
|
|
|
|
struct client *c, struct mouse_event *m, struct cmd_find_state *fs)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2017-02-06 15:00:41 +00:00
|
|
|
struct cmd *cmd;
|
2017-05-10 10:46:59 +00:00
|
|
|
struct cmdq_item *new_item;
|
2017-02-06 15:00:41 +00:00
|
|
|
int readonly;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2010-02-06 22:55:31 +00:00
|
|
|
readonly = 1;
|
2010-06-26 18:20:53 +00:00
|
|
|
TAILQ_FOREACH(cmd, &bd->cmdlist->list, qentry) {
|
2010-02-06 22:55:31 +00:00
|
|
|
if (!(cmd->entry->flags & CMD_READONLY))
|
|
|
|
readonly = 0;
|
|
|
|
}
|
2016-10-16 17:55:14 +00:00
|
|
|
if (!readonly && (c->flags & CLIENT_READONLY))
|
2017-05-10 10:46:59 +00:00
|
|
|
new_item = cmdq_get_callback(key_bindings_read_only, NULL);
|
2017-02-06 15:00:41 +00:00
|
|
|
else {
|
2017-05-10 10:46:59 +00:00
|
|
|
new_item = cmdq_get_command(bd->cmdlist, fs, m, 0);
|
2017-04-21 14:01:19 +00:00
|
|
|
if (bd->flags & KEY_BINDING_REPEAT)
|
2017-05-10 10:46:59 +00:00
|
|
|
new_item->shared->flags |= CMDQ_SHARED_REPEAT;
|
2017-02-06 15:00:41 +00:00
|
|
|
}
|
2017-05-10 10:46:59 +00:00
|
|
|
if (item != NULL)
|
|
|
|
cmdq_insert_after(item, new_item);
|
|
|
|
else
|
|
|
|
cmdq_append(c, new_item);
|
2019-05-09 13:12:59 +00:00
|
|
|
return (new_item);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|