mirror of
https://github.com/tmux/tmux.git
synced 2024-11-10 13:48:48 +00:00
Change so that the appropriate hooks for windows and panes belong to
pane/window options rather than all being session options. This is useful for example to create a pane that is automatically closed on some condition. From Anindya Mukherjee.
This commit is contained in:
parent
ad38ef6ff4
commit
9cbe9675ea
@ -69,10 +69,10 @@ const struct cmd_entry cmd_set_hook_entry = {
|
|||||||
.name = "set-hook",
|
.name = "set-hook",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "agRt:u", 1, 2 },
|
.args = { "agpRt:uw", 1, 2 },
|
||||||
.usage = "[-agRu] " CMD_TARGET_SESSION_USAGE " hook [command]",
|
.usage = "[-agpRuw] " CMD_TARGET_PANE_USAGE " hook [command]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_set_option_exec
|
.exec = cmd_set_option_exec
|
||||||
|
@ -65,10 +65,10 @@ const struct cmd_entry cmd_show_hooks_entry = {
|
|||||||
.name = "show-hooks",
|
.name = "show-hooks",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "gt:", 0, 1 },
|
.args = { "gpt:w", 0, 1 },
|
||||||
.usage = "[-g] " CMD_TARGET_SESSION_USAGE,
|
.usage = "[-gpw] " CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, 0 },
|
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_show_options_exec
|
.exec = cmd_show_options_exec
|
||||||
|
8
notify.c
8
notify.c
@ -76,6 +76,14 @@ notify_insert_hook(struct cmdq_item *item, struct notify_entry *ne)
|
|||||||
else
|
else
|
||||||
oo = fs.s->options;
|
oo = fs.s->options;
|
||||||
o = options_get(oo, ne->name);
|
o = options_get(oo, ne->name);
|
||||||
|
if (o == NULL && fs.wp != NULL) {
|
||||||
|
oo = fs.wp->options;
|
||||||
|
o = options_get(oo, ne->name);
|
||||||
|
}
|
||||||
|
if (o == NULL && fs.wl != NULL) {
|
||||||
|
oo = fs.wl->window->options;
|
||||||
|
o = options_get(oo, ne->name);
|
||||||
|
}
|
||||||
if (o == NULL)
|
if (o == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ static const char *options_table_status_format_default[] = {
|
|||||||
OPTIONS_TABLE_STATUS_FORMAT1, OPTIONS_TABLE_STATUS_FORMAT2, NULL
|
OPTIONS_TABLE_STATUS_FORMAT1, OPTIONS_TABLE_STATUS_FORMAT2, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Helper for hook options. */
|
/* Helpers for hook options. */
|
||||||
#define OPTIONS_TABLE_HOOK(hook_name, default_value) \
|
#define OPTIONS_TABLE_HOOK(hook_name, default_value) \
|
||||||
{ .name = hook_name, \
|
{ .name = hook_name, \
|
||||||
.type = OPTIONS_TABLE_COMMAND, \
|
.type = OPTIONS_TABLE_COMMAND, \
|
||||||
@ -150,6 +150,24 @@ static const char *options_table_status_format_default[] = {
|
|||||||
.separator = "" \
|
.separator = "" \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define OPTIONS_TABLE_PANE_HOOK(hook_name, default_value) \
|
||||||
|
{ .name = hook_name, \
|
||||||
|
.type = OPTIONS_TABLE_COMMAND, \
|
||||||
|
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE, \
|
||||||
|
.flags = OPTIONS_TABLE_IS_ARRAY|OPTIONS_TABLE_IS_HOOK, \
|
||||||
|
.default_str = default_value, \
|
||||||
|
.separator = "" \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OPTIONS_TABLE_WINDOW_HOOK(hook_name, default_value) \
|
||||||
|
{ .name = hook_name, \
|
||||||
|
.type = OPTIONS_TABLE_COMMAND, \
|
||||||
|
.scope = OPTIONS_TABLE_WINDOW, \
|
||||||
|
.flags = OPTIONS_TABLE_IS_ARRAY|OPTIONS_TABLE_IS_HOOK, \
|
||||||
|
.default_str = default_value, \
|
||||||
|
.separator = "" \
|
||||||
|
}
|
||||||
|
|
||||||
/* Top-level options. */
|
/* Top-level options. */
|
||||||
const struct options_table_entry options_table[] = {
|
const struct options_table_entry options_table[] = {
|
||||||
/* Server options. */
|
/* Server options. */
|
||||||
@ -851,21 +869,21 @@ const struct options_table_entry options_table[] = {
|
|||||||
OPTIONS_TABLE_HOOK("client-detached", ""),
|
OPTIONS_TABLE_HOOK("client-detached", ""),
|
||||||
OPTIONS_TABLE_HOOK("client-resized", ""),
|
OPTIONS_TABLE_HOOK("client-resized", ""),
|
||||||
OPTIONS_TABLE_HOOK("client-session-changed", ""),
|
OPTIONS_TABLE_HOOK("client-session-changed", ""),
|
||||||
OPTIONS_TABLE_HOOK("pane-died", ""),
|
OPTIONS_TABLE_PANE_HOOK("pane-died", ""),
|
||||||
OPTIONS_TABLE_HOOK("pane-exited", ""),
|
OPTIONS_TABLE_PANE_HOOK("pane-exited", ""),
|
||||||
OPTIONS_TABLE_HOOK("pane-focus-in", ""),
|
OPTIONS_TABLE_PANE_HOOK("pane-focus-in", ""),
|
||||||
OPTIONS_TABLE_HOOK("pane-focus-out", ""),
|
OPTIONS_TABLE_PANE_HOOK("pane-focus-out", ""),
|
||||||
OPTIONS_TABLE_HOOK("pane-mode-changed", ""),
|
OPTIONS_TABLE_PANE_HOOK("pane-mode-changed", ""),
|
||||||
OPTIONS_TABLE_HOOK("pane-set-clipboard", ""),
|
OPTIONS_TABLE_PANE_HOOK("pane-set-clipboard", ""),
|
||||||
OPTIONS_TABLE_HOOK("session-closed", ""),
|
OPTIONS_TABLE_HOOK("session-closed", ""),
|
||||||
OPTIONS_TABLE_HOOK("session-created", ""),
|
OPTIONS_TABLE_HOOK("session-created", ""),
|
||||||
OPTIONS_TABLE_HOOK("session-renamed", ""),
|
OPTIONS_TABLE_HOOK("session-renamed", ""),
|
||||||
OPTIONS_TABLE_HOOK("session-window-changed", ""),
|
OPTIONS_TABLE_HOOK("session-window-changed", ""),
|
||||||
OPTIONS_TABLE_HOOK("window-layout-changed", ""),
|
OPTIONS_TABLE_WINDOW_HOOK("window-layout-changed", ""),
|
||||||
OPTIONS_TABLE_HOOK("window-linked", ""),
|
OPTIONS_TABLE_WINDOW_HOOK("window-linked", ""),
|
||||||
OPTIONS_TABLE_HOOK("window-pane-changed", ""),
|
OPTIONS_TABLE_WINDOW_HOOK("window-pane-changed", ""),
|
||||||
OPTIONS_TABLE_HOOK("window-renamed", ""),
|
OPTIONS_TABLE_WINDOW_HOOK("window-renamed", ""),
|
||||||
OPTIONS_TABLE_HOOK("window-unlinked", ""),
|
OPTIONS_TABLE_WINDOW_HOOK("window-unlinked", ""),
|
||||||
|
|
||||||
{ .name = NULL }
|
{ .name = NULL }
|
||||||
};
|
};
|
||||||
|
29
tmux.1
29
tmux.1
@ -3897,6 +3897,7 @@ hook and there are a number of hooks not associated with commands.
|
|||||||
.Pp
|
.Pp
|
||||||
Hooks are stored as array options, members of the array are executed in
|
Hooks are stored as array options, members of the array are executed in
|
||||||
order when the hook is triggered.
|
order when the hook is triggered.
|
||||||
|
Like options different hooks may be global or belong to a session, window or pane.
|
||||||
Hooks may be configured with the
|
Hooks may be configured with the
|
||||||
.Ic set-hook
|
.Ic set-hook
|
||||||
or
|
or
|
||||||
@ -3989,8 +3990,8 @@ Run when a window is unlinked from a session.
|
|||||||
Hooks are managed with these commands:
|
Hooks are managed with these commands:
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Xo Ic set-hook
|
.It Xo Ic set-hook
|
||||||
.Op Fl agRu
|
.Op Fl agpRuw
|
||||||
.Op Fl t Ar target-session
|
.Op Fl t Ar target-pane
|
||||||
.Ar hook-name
|
.Ar hook-name
|
||||||
.Ar command
|
.Ar command
|
||||||
.Xc
|
.Xc
|
||||||
@ -4002,18 +4003,8 @@ unsets) hook
|
|||||||
.Ar hook-name
|
.Ar hook-name
|
||||||
to
|
to
|
||||||
.Ar command .
|
.Ar command .
|
||||||
If
|
The flags are the same as for
|
||||||
.Fl g
|
.Ic set-option .
|
||||||
is given,
|
|
||||||
.Em hook-name
|
|
||||||
is added to the global list of hooks, otherwise it is added to the session
|
|
||||||
hooks (for
|
|
||||||
.Ar target-session
|
|
||||||
with
|
|
||||||
.Fl t ) .
|
|
||||||
.Fl a
|
|
||||||
appends to a hook.
|
|
||||||
Like options, session hooks inherit from the global ones.
|
|
||||||
.Pp
|
.Pp
|
||||||
With
|
With
|
||||||
.Fl R ,
|
.Fl R ,
|
||||||
@ -4021,12 +4012,12 @@ run
|
|||||||
.Ar hook-name
|
.Ar hook-name
|
||||||
immediately.
|
immediately.
|
||||||
.It Xo Ic show-hooks
|
.It Xo Ic show-hooks
|
||||||
.Op Fl g
|
.Op Fl gpw
|
||||||
.Op Fl t Ar target-session
|
.Op Fl t Ar target-pane
|
||||||
.Xc
|
.Xc
|
||||||
Shows the global list of hooks with
|
Shows hooks.
|
||||||
.Fl g ,
|
The flags are the same as for
|
||||||
otherwise the session hooks.
|
.Ic show-options .
|
||||||
.El
|
.El
|
||||||
.Sh MOUSE SUPPORT
|
.Sh MOUSE SUPPORT
|
||||||
If the
|
If the
|
||||||
|
Loading…
Reference in New Issue
Block a user