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_SESSION_MENU \
|
|
|
|
" 'Next' 'n' {switch-client -n}" \
|
|
|
|
" 'Previous' 'p' {switch-client -p}" \
|
|
|
|
" ''" \
|
|
|
|
" 'Renumber' 'N' {move-window -r}" \
|
2021-08-27 17:25:55 +00:00
|
|
|
" 'Rename' 'n' {command-prompt -I \"#S\" {rename-session -- '%%'}}" \
|
2019-05-28 10:05:24 +00:00
|
|
|
" ''" \
|
|
|
|
" 'New Session' 's' {new-session}" \
|
|
|
|
" 'New Window' 'w' {new-window}"
|
|
|
|
#define DEFAULT_WINDOW_MENU \
|
2020-03-20 18:19:22 +00:00
|
|
|
" '#{?#{>:#{session_windows},1},,-}Swap Left' 'l' {swap-window -t:-1}" \
|
|
|
|
" '#{?#{>:#{session_windows},1},,-}Swap Right' 'r' {swap-window -t:+1}" \
|
2019-05-28 10:05:24 +00:00
|
|
|
" '#{?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}" \
|
2021-08-27 17:25:55 +00:00
|
|
|
" 'Rename' 'n' {command-prompt -FI \"#W\" {rename-window -t '#{window_id}' -- '%%'}}" \
|
2019-05-28 10:05:24 +00:00
|
|
|
" ''" \
|
|
|
|
" 'New After' 'w' {new-window -a}" \
|
|
|
|
" 'New At End' 'W' {new-window}"
|
|
|
|
#define DEFAULT_PANE_MENU \
|
2020-03-20 18:35:53 +00:00
|
|
|
" '#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Top,}' '<' {send -X history-top}" \
|
|
|
|
" '#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Bottom,}' '>' {send -X history-bottom}" \
|
2020-03-20 17:59:39 +00:00
|
|
|
" ''" \
|
2020-03-20 18:35:53 +00:00
|
|
|
" '#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}' 'C-r' {if -F '#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}' 'copy-mode -t='; send -Xt= search-backward \"#{q:mouse_word}\"}" \
|
2020-03-20 17:59:39 +00:00
|
|
|
" '#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}' 'C-y' {copy-mode -q; send-keys -l -- \"#{q:mouse_word}\"}" \
|
|
|
|
" '#{?mouse_word,Copy #[underscore]#{=/9/...:mouse_word},}' 'c' {copy-mode -q; set-buffer -- \"#{q:mouse_word}\"}" \
|
|
|
|
" '#{?mouse_line,Copy Line,}' 'l' {copy-mode -q; set-buffer -- \"#{q:mouse_line}\"}" \
|
2019-05-28 10:05:24 +00:00
|
|
|
" ''" \
|
|
|
|
" 'Horizontal Split' 'h' {split-window -h}" \
|
|
|
|
" 'Vertical Split' 'v' {split-window -v}" \
|
|
|
|
" ''" \
|
2020-03-20 18:19:22 +00:00
|
|
|
" '#{?#{>:#{window_panes},1},,-}Swap Up' 'u' {swap-pane -U}" \
|
2020-03-20 18:20:58 +00:00
|
|
|
" '#{?#{>:#{window_panes},1},,-}Swap Down' 'd' {swap-pane -D}" \
|
2019-05-28 10:05:24 +00:00
|
|
|
" '#{?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}" \
|
2020-03-20 18:22:37 +00:00
|
|
|
" '#{?#{>:#{window_panes},1},,-}#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}"
|
2019-05-28 10:05:24 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-01-05 20:39:25 +00:00
|
|
|
static void
|
2020-05-16 16:02:24 +00:00
|
|
|
key_bindings_free(struct key_binding *bd)
|
2020-01-05 20:39:25 +00:00
|
|
|
{
|
|
|
|
cmd_list_free(bd->cmdlist);
|
2020-01-27 08:53:13 +00:00
|
|
|
free((void *)bd->note);
|
2020-01-05 20:39:25 +00:00
|
|
|
free(bd);
|
|
|
|
}
|
|
|
|
|
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);
|
2020-05-16 16:02:24 +00:00
|
|
|
RB_INIT(&table->default_key_bindings);
|
2015-04-20 15:34:56 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2020-05-16 16:02:24 +00:00
|
|
|
RB_FOREACH_SAFE(bd, key_bindings, &table->key_bindings, bd1) {
|
|
|
|
RB_REMOVE(key_bindings, &table->key_bindings, bd);
|
|
|
|
key_bindings_free(bd);
|
|
|
|
}
|
|
|
|
RB_FOREACH_SAFE(bd, key_bindings, &table->default_key_bindings, bd1) {
|
|
|
|
RB_REMOVE(key_bindings, &table->default_key_bindings, bd);
|
|
|
|
key_bindings_free(bd);
|
|
|
|
}
|
2015-04-20 15:34:56 +00:00
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2020-05-16 16:02:24 +00:00
|
|
|
struct key_binding *
|
|
|
|
key_bindings_get_default(struct key_table *table, key_code key)
|
|
|
|
{
|
|
|
|
struct key_binding bd;
|
|
|
|
|
|
|
|
bd.key = key;
|
|
|
|
return (RB_FIND(key_bindings, &table->default_key_bindings, &bd));
|
|
|
|
}
|
|
|
|
|
2018-08-02 11:44:07 +00:00
|
|
|
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
|
2020-01-27 08:53:13 +00:00
|
|
|
key_bindings_add(const char *name, key_code key, const char *note, int repeat,
|
2015-04-20 15:34:56 +00:00
|
|
|
struct cmd_list *cmdlist)
|
|
|
|
{
|
|
|
|
struct key_table *table;
|
2020-01-05 20:39:25 +00:00
|
|
|
struct key_binding *bd;
|
2021-08-23 11:04:21 +00:00
|
|
|
char *s;
|
2015-04-20 15:34:56 +00:00
|
|
|
|
|
|
|
table = key_bindings_get_table(name, 1);
|
|
|
|
|
2020-05-16 16:35:13 +00:00
|
|
|
bd = key_bindings_get(table, key & ~KEYC_MASK_FLAGS);
|
2020-09-08 10:19:19 +00:00
|
|
|
if (cmdlist == NULL) {
|
|
|
|
if (bd != NULL) {
|
|
|
|
free((void *)bd->note);
|
|
|
|
if (note != NULL)
|
|
|
|
bd->note = xstrdup(note);
|
|
|
|
else
|
|
|
|
bd->note = NULL;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2020-05-16 16:02:24 +00:00
|
|
|
if (bd != NULL) {
|
|
|
|
RB_REMOVE(key_bindings, &table->key_bindings, bd);
|
|
|
|
key_bindings_free(bd);
|
|
|
|
}
|
2009-12-03 22:50:09 +00:00
|
|
|
|
2017-04-21 19:33:07 +00:00
|
|
|
bd = xcalloc(1, sizeof *bd);
|
2020-05-20 07:11:45 +00:00
|
|
|
bd->key = (key & ~KEYC_MASK_FLAGS);
|
2020-01-27 08:53:13 +00:00
|
|
|
if (note != NULL)
|
|
|
|
bd->note = xstrdup(note);
|
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;
|
2021-06-10 07:21:09 +00:00
|
|
|
|
2021-08-23 11:04:21 +00:00
|
|
|
s = cmd_list_print(bd->cmdlist, 0);
|
2021-06-10 07:21:09 +00:00
|
|
|
log_debug("%s: %#llx %s = %s", __func__, bd->key,
|
2021-08-23 11:04:21 +00:00
|
|
|
key_string_lookup_key(bd->key, 1), s);
|
|
|
|
free(s);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2020-01-05 20:39:25 +00:00
|
|
|
struct key_binding *bd;
|
2015-04-20 15:34:56 +00:00
|
|
|
|
|
|
|
table = key_bindings_get_table(name, 0);
|
|
|
|
if (table == NULL)
|
|
|
|
return;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2020-05-16 16:35:13 +00:00
|
|
|
bd = key_bindings_get(table, key & ~KEYC_MASK_FLAGS);
|
2015-04-20 15:34:56 +00:00
|
|
|
if (bd == NULL)
|
2009-06-01 22:58:49 +00:00
|
|
|
return;
|
2015-04-20 15:34:56 +00:00
|
|
|
|
2021-06-10 07:21:09 +00:00
|
|
|
log_debug("%s: %#llx %s", __func__, bd->key,
|
|
|
|
key_string_lookup_key(bd->key, 1));
|
|
|
|
|
2020-05-16 16:02:24 +00:00
|
|
|
RB_REMOVE(key_bindings, &table->key_bindings, bd);
|
|
|
|
key_bindings_free(bd);
|
|
|
|
|
|
|
|
if (RB_EMPTY(&table->key_bindings) &&
|
|
|
|
RB_EMPTY(&table->default_key_bindings)) {
|
2015-04-20 15:34:56 +00:00
|
|
|
RB_REMOVE(key_tables, &key_tables, table);
|
|
|
|
key_bindings_unref_table(table);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-16 08:18:34 +00:00
|
|
|
void
|
|
|
|
key_bindings_reset(const char *name, key_code key)
|
|
|
|
{
|
|
|
|
struct key_table *table;
|
|
|
|
struct key_binding *bd, *dd;
|
|
|
|
|
|
|
|
table = key_bindings_get_table(name, 0);
|
|
|
|
if (table == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bd = key_bindings_get(table, key & ~KEYC_MASK_FLAGS);
|
|
|
|
if (bd == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dd = key_bindings_get_default(table, bd->key);
|
|
|
|
if (dd == NULL) {
|
|
|
|
key_bindings_remove(name, bd->key);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd_list_free(bd->cmdlist);
|
|
|
|
bd->cmdlist = dd->cmdlist;
|
|
|
|
bd->cmdlist->references++;
|
|
|
|
|
|
|
|
free((void *)bd->note);
|
|
|
|
if (dd->note != NULL)
|
|
|
|
bd->note = xstrdup(dd->note);
|
|
|
|
else
|
|
|
|
bd->note = NULL;
|
|
|
|
bd->flags = dd->flags;
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:34:56 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-06-16 08:18:34 +00:00
|
|
|
void
|
|
|
|
key_bindings_reset_table(const char *name)
|
|
|
|
{
|
|
|
|
struct key_table *table;
|
|
|
|
struct key_binding *bd, *bd1;
|
|
|
|
|
|
|
|
table = key_bindings_get_table(name, 0);
|
|
|
|
if (table == NULL)
|
|
|
|
return;
|
|
|
|
if (RB_EMPTY(&table->default_key_bindings)) {
|
|
|
|
key_bindings_remove_table(name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
RB_FOREACH_SAFE(bd, key_bindings, &table->key_bindings, bd1)
|
|
|
|
key_bindings_reset(name, bd->key);
|
|
|
|
}
|
|
|
|
|
2020-05-16 16:02:24 +00:00
|
|
|
static enum cmd_retval
|
|
|
|
key_bindings_init_done(__unused struct cmdq_item *item, __unused void *data)
|
|
|
|
{
|
|
|
|
struct key_table *table;
|
|
|
|
struct key_binding *bd, *new_bd;
|
|
|
|
|
|
|
|
RB_FOREACH(table, key_tables, &key_tables) {
|
|
|
|
RB_FOREACH(bd, key_bindings, &table->key_bindings) {
|
|
|
|
new_bd = xcalloc(1, sizeof *bd);
|
|
|
|
new_bd->key = bd->key;
|
|
|
|
if (bd->note != NULL)
|
|
|
|
new_bd->note = xstrdup(bd->note);
|
|
|
|
new_bd->flags = bd->flags;
|
|
|
|
new_bd->cmdlist = bd->cmdlist;
|
|
|
|
new_bd->cmdlist->references++;
|
|
|
|
RB_INSERT(key_bindings, &table->default_key_bindings,
|
|
|
|
new_bd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (CMD_RETURN_NORMAL);
|
|
|
|
}
|
|
|
|
|
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[] = {
|
2020-03-12 13:48:32 +00:00
|
|
|
/* Prefix keys. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -N 'Send the prefix key' C-b { send-prefix }",
|
|
|
|
"bind -N 'Rotate through the panes' C-o { rotate-window }",
|
|
|
|
"bind -N 'Suspend the current client' C-z { suspend-client }",
|
|
|
|
"bind -N 'Select next layout' Space { next-layout }",
|
|
|
|
"bind -N 'Break pane to a new window' ! { break-pane }",
|
|
|
|
"bind -N 'Split window vertically' '\"' { split-window }",
|
|
|
|
"bind -N 'List all paste buffers' '#' { list-buffers }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -N 'Rename current session' '$' { command-prompt -I'#S' { rename-session -- '%%' } }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -N 'Split window horizontally' % { split-window -h }",
|
|
|
|
"bind -N 'Kill current window' & { confirm-before -p\"kill-window #W? (y/n)\" kill-window }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -N 'Prompt for window index to select' \"'\" { command-prompt -T window-target -pindex { select-window -t ':%%' } }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -N 'Switch to previous client' ( { switch-client -p }",
|
|
|
|
"bind -N 'Switch to next client' ) { switch-client -n }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -N 'Rename current window' , { command-prompt -I'#W' { rename-window -- '%%' } }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -N 'Delete the most recent paste buffer' - { delete-buffer }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -N 'Move the current window' . { command-prompt -T target { move-window -t '%%' } }",
|
|
|
|
"bind -N 'Describe key binding' '/' { command-prompt -kpkey { list-keys -1N '%%' } }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -N 'Select window 0' 0 { select-window -t:=0 }",
|
|
|
|
"bind -N 'Select window 1' 1 { select-window -t:=1 }",
|
|
|
|
"bind -N 'Select window 2' 2 { select-window -t:=2 }",
|
|
|
|
"bind -N 'Select window 3' 3 { select-window -t:=3 }",
|
|
|
|
"bind -N 'Select window 4' 4 { select-window -t:=4 }",
|
|
|
|
"bind -N 'Select window 5' 5 { select-window -t:=5 }",
|
|
|
|
"bind -N 'Select window 6' 6 { select-window -t:=6 }",
|
|
|
|
"bind -N 'Select window 7' 7 { select-window -t:=7 }",
|
|
|
|
"bind -N 'Select window 8' 8 { select-window -t:=8 }",
|
|
|
|
"bind -N 'Select window 9' 9 { select-window -t:=9 }",
|
|
|
|
"bind -N 'Prompt for a command' : { command-prompt }",
|
|
|
|
"bind -N 'Move to the previously active pane' \\; { last-pane }",
|
|
|
|
"bind -N 'Choose a paste buffer from a list' = { choose-buffer -Z }",
|
|
|
|
"bind -N 'List key bindings' ? { list-keys -N }",
|
|
|
|
"bind -N 'Choose a client from a list' D { choose-client -Z }",
|
|
|
|
"bind -N 'Spread panes out evenly' E { select-layout -E }",
|
|
|
|
"bind -N 'Switch to the last client' L { switch-client -l }",
|
|
|
|
"bind -N 'Clear the marked pane' M { select-pane -M }",
|
|
|
|
"bind -N 'Enter copy mode' [ { copy-mode }",
|
|
|
|
"bind -N 'Paste the most recent paste buffer' ] { paste-buffer -p }",
|
|
|
|
"bind -N 'Create a new window' c { new-window }",
|
|
|
|
"bind -N 'Detach the current client' d { detach-client }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -N 'Search for a pane' f { command-prompt { find-window -Z -- '%%' } }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -N 'Display window information' i { display-message }",
|
|
|
|
"bind -N 'Select the previously current window' l { last-window }",
|
|
|
|
"bind -N 'Toggle the marked pane' m { select-pane -m }",
|
|
|
|
"bind -N 'Select the next window' n { next-window }",
|
|
|
|
"bind -N 'Select the next pane' o { select-pane -t:.+ }",
|
|
|
|
"bind -N 'Customize options' C { customize-mode -Z }",
|
|
|
|
"bind -N 'Select the previous window' p { previous-window }",
|
|
|
|
"bind -N 'Display pane numbers' q { display-panes }",
|
|
|
|
"bind -N 'Redraw the current client' r { refresh-client }",
|
|
|
|
"bind -N 'Choose a session from a list' s { choose-tree -Zs }",
|
|
|
|
"bind -N 'Show a clock' t { clock-mode }",
|
|
|
|
"bind -N 'Choose a window from a list' w { choose-tree -Zw }",
|
|
|
|
"bind -N 'Kill the active pane' x { confirm-before -p\"kill-pane #P? (y/n)\" kill-pane }",
|
|
|
|
"bind -N 'Zoom the active pane' z { resize-pane -Z }",
|
|
|
|
"bind -N 'Swap the active pane with the pane above' '{' { swap-pane -U }",
|
|
|
|
"bind -N 'Swap the active pane with the pane below' '}' { swap-pane -D }",
|
|
|
|
"bind -N 'Show messages' '~' { show-messages }",
|
|
|
|
"bind -N 'Enter copy mode and scroll up' PPage { copy-mode -u }",
|
|
|
|
"bind -N 'Select the pane above the active pane' -r Up { select-pane -U }",
|
|
|
|
"bind -N 'Select the pane below the active pane' -r Down { select-pane -D }",
|
|
|
|
"bind -N 'Select the pane to the left of the active pane' -r Left { select-pane -L }",
|
|
|
|
"bind -N 'Select the pane to the right of the active pane' -r Right { select-pane -R }",
|
|
|
|
"bind -N 'Set the even-horizontal layout' M-1 { select-layout even-horizontal }",
|
|
|
|
"bind -N 'Set the even-vertical layout' M-2 { select-layout even-vertical }",
|
|
|
|
"bind -N 'Set the main-horizontal layout' M-3 { select-layout main-horizontal }",
|
|
|
|
"bind -N 'Set the main-vertical layout' M-4 { select-layout main-vertical }",
|
|
|
|
"bind -N 'Select the tiled layout' M-5 { select-layout tiled }",
|
|
|
|
"bind -N 'Select the next window with an alert' M-n { next-window -a }",
|
|
|
|
"bind -N 'Rotate through the panes in reverse' M-o { rotate-window -D }",
|
|
|
|
"bind -N 'Select the previous window with an alert' M-p { previous-window -a }",
|
|
|
|
"bind -N 'Move the visible part of the window up' -r S-Up { refresh-client -U 10 }",
|
|
|
|
"bind -N 'Move the visible part of the window down' -r S-Down { refresh-client -D 10 }",
|
|
|
|
"bind -N 'Move the visible part of the window left' -r S-Left { refresh-client -L 10 }",
|
|
|
|
"bind -N 'Move the visible part of the window right' -r S-Right { refresh-client -R 10 }",
|
|
|
|
"bind -N 'Reset so the visible part of the window follows the cursor' -r DC { refresh-client -c }",
|
|
|
|
"bind -N 'Resize the pane up by 5' -r M-Up { resize-pane -U 5 }",
|
|
|
|
"bind -N 'Resize the pane down by 5' -r M-Down { resize-pane -D 5 }",
|
|
|
|
"bind -N 'Resize the pane left by 5' -r M-Left { resize-pane -L 5 }",
|
|
|
|
"bind -N 'Resize the pane right by 5' -r M-Right { resize-pane -R 5 }",
|
|
|
|
"bind -N 'Resize the pane up' -r C-Up { resize-pane -U }",
|
|
|
|
"bind -N 'Resize the pane down' -r C-Down { resize-pane -D }",
|
|
|
|
"bind -N 'Resize the pane left' -r C-Left { resize-pane -L }",
|
|
|
|
"bind -N 'Resize the pane right' -r C-Right { resize-pane -R }",
|
2019-05-10 18:04:06 +00:00
|
|
|
|
2020-03-12 13:48:32 +00:00
|
|
|
/* Menu keys */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind < { display-menu -xW -yW -T '#[align=centre]#{window_index}:#{window_name}' " DEFAULT_WINDOW_MENU " }",
|
|
|
|
"bind > { display-menu -xP -yP -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }",
|
2020-03-12 13:48:32 +00:00
|
|
|
|
|
|
|
/* Mouse button 1 down on pane. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -n MouseDown1Pane { select-pane -t=; send -M }",
|
2020-03-12 13:48:32 +00:00
|
|
|
|
|
|
|
/* Mouse button 1 drag on pane. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -n MouseDrag1Pane { if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -M } }",
|
2020-03-12 13:48:32 +00:00
|
|
|
|
|
|
|
/* Mouse wheel up on pane. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -n WheelUpPane { if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -e } }",
|
2020-03-12 13:48:32 +00:00
|
|
|
|
|
|
|
/* Mouse button 2 down on pane. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -n MouseDown2Pane { select-pane -t=; if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { paste -p } }",
|
2020-03-12 13:48:32 +00:00
|
|
|
|
|
|
|
/* Mouse button 1 double click on pane. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -n DoubleClick1Pane { select-pane -t=; if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -H; send -X select-word; run -d0.3; send -X copy-pipe-and-cancel } }",
|
2020-03-12 13:48:32 +00:00
|
|
|
|
|
|
|
/* Mouse button 1 triple click on pane. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -n TripleClick1Pane { select-pane -t=; if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -H; send -X select-line; run -d0.3; send -X copy-pipe-and-cancel } }",
|
2020-03-12 13:48:32 +00:00
|
|
|
|
|
|
|
/* Mouse button 1 drag on border. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -n MouseDrag1Border { resize-pane -M }",
|
2020-03-12 13:48:32 +00:00
|
|
|
|
|
|
|
/* Mouse button 1 down on status line. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -n MouseDown1Status { select-window -t= }",
|
2020-03-12 13:48:32 +00:00
|
|
|
|
|
|
|
/* Mouse wheel down on status line. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -n WheelDownStatus { next-window }",
|
2020-03-12 13:48:32 +00:00
|
|
|
|
|
|
|
/* Mouse wheel up on status line. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -n WheelUpStatus { previous-window }",
|
2019-05-28 07:18:42 +00:00
|
|
|
|
2020-03-12 13:48:32 +00:00
|
|
|
/* Mouse button 3 down on status left. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -n MouseDown3StatusLeft { display-menu -t= -xM -yW -T '#[align=centre]#{session_name}' " DEFAULT_SESSION_MENU " }",
|
2020-03-12 13:48:32 +00:00
|
|
|
|
|
|
|
/* Mouse button 3 down on status line. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -n MouseDown3Status { display-menu -t= -xW -yW -T '#[align=centre]#{window_index}:#{window_name}' " DEFAULT_WINDOW_MENU "}",
|
2020-03-12 13:48:32 +00:00
|
|
|
|
|
|
|
/* Mouse button 3 down on pane. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -n MouseDown3Pane { if -Ft= '#{||:#{mouse_any_flag},#{&&:#{pane_in_mode},#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}}}' { select-pane -t=; send -M } { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " } }",
|
|
|
|
"bind -n M-MouseDown3Pane { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }",
|
2016-10-11 07:23:34 +00:00
|
|
|
|
2020-03-12 13:48:32 +00:00
|
|
|
/* Copy mode (emacs) keys. */
|
2021-08-21 17:41:19 +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 }",
|
|
|
|
"bind -Tcopy-mode C-b { send -X cursor-left }",
|
|
|
|
"bind -Tcopy-mode C-g { send -X clear-selection }",
|
|
|
|
"bind -Tcopy-mode C-k { send -X copy-pipe-end-of-line-and-cancel }",
|
|
|
|
"bind -Tcopy-mode C-n { send -X cursor-down }",
|
|
|
|
"bind -Tcopy-mode C-p { send -X cursor-up }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -Tcopy-mode C-r { command-prompt -T search -ip'(search up)' -I'#{pane_search_string}' { send -X search-backward-incremental '%%' } }",
|
|
|
|
"bind -Tcopy-mode C-s { command-prompt -T search -ip'(search down)' -I'#{pane_search_string}' { send -X search-forward-incremental '%%' } }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -Tcopy-mode C-v { send -X page-down }",
|
|
|
|
"bind -Tcopy-mode C-w { send -X copy-pipe-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 }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -Tcopy-mode F { command-prompt -1p'(jump backward)' { send -X jump-backward '%%' } }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -Tcopy-mode N { send -X search-reverse }",
|
2022-02-03 07:26:43 +00:00
|
|
|
"bind -Tcopy-mode P { send -X toggle-position }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -Tcopy-mode R { send -X rectangle-toggle }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -Tcopy-mode T { command-prompt -1p'(jump to backward)' { send -X jump-to-backward '%%' } }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -Tcopy-mode X { send -X set-mark }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"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 '%%' } }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -Tcopy-mode n { send -X search-again }",
|
|
|
|
"bind -Tcopy-mode q { send -X cancel }",
|
|
|
|
"bind -Tcopy-mode r { send -X refresh-from-pane }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -Tcopy-mode t { command-prompt -1p'(jump to forward)' { send -X jump-to-forward '%%' } }",
|
2021-08-21 17:41:19 +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",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -Tcopy-mode MouseDrag1Pane { select-pane; send -X begin-selection }",
|
|
|
|
"bind -Tcopy-mode MouseDragEnd1Pane { send -X copy-pipe-and-cancel }",
|
|
|
|
"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; run -d0.3; send -X copy-pipe-and-cancel }",
|
|
|
|
"bind -Tcopy-mode TripleClick1Pane { select-pane; send -X select-line; run -d0.3; send -X copy-pipe-and-cancel }",
|
|
|
|
"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 }",
|
2021-08-27 17:25:55 +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 '%%' } }",
|
2021-08-21 17:41:19 +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 }",
|
|
|
|
"bind -Tcopy-mode C-M-b { send -X previous-matching-bracket }",
|
|
|
|
"bind -Tcopy-mode M-f { send -X next-word-end }",
|
|
|
|
"bind -Tcopy-mode C-M-f { send -X next-matching-bracket }",
|
|
|
|
"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-pipe-and-cancel }",
|
|
|
|
"bind -Tcopy-mode M-x { send -X jump-to-mark }",
|
|
|
|
"bind -Tcopy-mode 'M-{' { send -X previous-paragraph }",
|
|
|
|
"bind -Tcopy-mode 'M-}' { send -X next-paragraph }",
|
|
|
|
"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 }",
|
2016-10-11 07:23:34 +00:00
|
|
|
|
2020-03-12 13:48:32 +00:00
|
|
|
/* Copy mode (vi) keys. */
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -Tcopy-mode-vi '#' { send -FX search-backward '#{copy_cursor_word}' }",
|
|
|
|
"bind -Tcopy-mode-vi * { send -FX search-forward '#{copy_cursor_word}' }",
|
|
|
|
"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 }",
|
|
|
|
"bind -Tcopy-mode-vi C-b { send -X page-up }",
|
|
|
|
"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-pipe-and-cancel }",
|
|
|
|
"bind -Tcopy-mode-vi Enter { send -X copy-pipe-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 }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -Tcopy-mode-vi / { command-prompt -T search -p'(search down)' { send -X search-forward '%%' } }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -Tcopy-mode-vi 0 { send -X start-of-line }",
|
2021-08-27 17:25:55 +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 '%%' } }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -Tcopy-mode-vi \\; { send -X jump-again }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -Tcopy-mode-vi ? { command-prompt -T search -p'(search up)' { send -X search-backward '%%' } }",
|
2021-08-21 17:41:19 +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-pipe-end-of-line-and-cancel }",
|
|
|
|
"bind -Tcopy-mode-vi E { send -X next-space-end }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -Tcopy-mode-vi F { command-prompt -1p'(jump backward)' { send -X jump-backward '%%' } }",
|
2021-08-21 17:41:19 +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 }",
|
2022-02-03 07:26:43 +00:00
|
|
|
"bind -Tcopy-mode-vi P { send -X toggle-position }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -Tcopy-mode-vi T { command-prompt -1p'(jump to backward)' { send -X jump-to-backward '%%' } }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -Tcopy-mode-vi V { send -X select-line }",
|
|
|
|
"bind -Tcopy-mode-vi W { send -X next-space }",
|
|
|
|
"bind -Tcopy-mode-vi X { send -X set-mark }",
|
|
|
|
"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 }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -Tcopy-mode-vi f { command-prompt -1p'(jump forward)' { send -X jump-forward '%%' } }",
|
2021-08-21 17:41:19 +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 }",
|
|
|
|
"bind -Tcopy-mode-vi r { send -X refresh-from-pane }",
|
2021-08-27 17:25:55 +00:00
|
|
|
"bind -Tcopy-mode-vi t { command-prompt -1p'(jump to forward)' { send -X jump-to-forward '%%' } }",
|
2021-08-21 17:41:19 +00:00
|
|
|
"bind -Tcopy-mode-vi v { send -X rectangle-toggle }",
|
|
|
|
"bind -Tcopy-mode-vi w { send -X next-word }",
|
|
|
|
"bind -Tcopy-mode-vi '{' { send -X previous-paragraph }",
|
|
|
|
"bind -Tcopy-mode-vi '}' { send -X next-paragraph }",
|
|
|
|
"bind -Tcopy-mode-vi % { send -X next-matching-bracket }",
|
|
|
|
"bind -Tcopy-mode-vi MouseDown1Pane { select-pane }",
|
|
|
|
"bind -Tcopy-mode-vi MouseDrag1Pane { select-pane; send -X begin-selection }",
|
|
|
|
"bind -Tcopy-mode-vi MouseDragEnd1Pane { send -X copy-pipe-and-cancel }",
|
|
|
|
"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; run -d0.3; send -X copy-pipe-and-cancel }",
|
|
|
|
"bind -Tcopy-mode-vi TripleClick1Pane { select-pane; send -X select-line; run -d0.3; send -X copy-pipe-and-cancel }",
|
|
|
|
"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 M-x { send -X jump-to-mark }",
|
|
|
|
"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);
|
2021-08-25 08:51:55 +00:00
|
|
|
if (pr->status != CMD_PARSE_SUCCESS) {
|
|
|
|
log_debug("%s", pr->error);
|
2017-01-24 19:53:37 +00:00
|
|
|
fatalx("bad default key: %s", defaults[i]);
|
2021-08-25 08:51:55 +00:00
|
|
|
}
|
2020-04-13 15:55:51 +00:00
|
|
|
cmdq_append(NULL, cmdq_get_command(pr->cmdlist, NULL));
|
2019-05-23 11:13:30 +00:00
|
|
|
cmd_list_free(pr->cmdlist);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|
2020-05-16 16:02:24 +00:00
|
|
|
cmdq_append(NULL, cmdq_get_callback(key_bindings_init_done, NULL));
|
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,
|
2020-04-13 14:46:04 +00:00
|
|
|
struct client *c, struct key_event *event, struct cmd_find_state *fs)
|
2009-06-01 22:58:49 +00:00
|
|
|
{
|
2017-05-10 10:46:59 +00:00
|
|
|
struct cmdq_item *new_item;
|
2020-04-13 15:55:51 +00:00
|
|
|
struct cmdq_state *new_state;
|
2020-04-13 14:46:04 +00:00
|
|
|
int readonly, flags = 0;
|
2009-06-01 22:58:49 +00:00
|
|
|
|
2019-11-20 11:42:51 +00:00
|
|
|
if (c == NULL || (~c->flags & CLIENT_READONLY))
|
|
|
|
readonly = 1;
|
2020-04-13 08:26:27 +00:00
|
|
|
else
|
|
|
|
readonly = cmd_list_all_have(bd->cmdlist, CMD_READONLY);
|
2019-11-20 11:42:51 +00:00
|
|
|
if (!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-04-21 14:01:19 +00:00
|
|
|
if (bd->flags & KEY_BINDING_REPEAT)
|
2020-04-13 14:46:04 +00:00
|
|
|
flags |= CMDQ_STATE_REPEAT;
|
2020-04-13 15:55:51 +00:00
|
|
|
new_state = cmdq_new_state(fs, event, flags);
|
|
|
|
new_item = cmdq_get_command(bd->cmdlist, new_state);
|
|
|
|
cmdq_free_state(new_state);
|
2017-02-06 15:00:41 +00:00
|
|
|
}
|
2017-05-10 10:46:59 +00:00
|
|
|
if (item != NULL)
|
2019-12-19 09:22:33 +00:00
|
|
|
new_item = cmdq_insert_after(item, new_item);
|
2017-05-10 10:46:59 +00:00
|
|
|
else
|
2019-12-19 09:22:33 +00:00
|
|
|
new_item = cmdq_append(c, new_item);
|
2019-05-09 13:12:59 +00:00
|
|
|
return (new_item);
|
2009-06-01 22:58:49 +00:00
|
|
|
}
|