mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Some new notifications, mainly for active pane and current window and
session: pane-mode-changed window-pane-changed client-session-changed session-window-changed From Joshua Brot.
This commit is contained in:
parent
ca6a121e63
commit
d98d316903
@ -129,6 +129,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
if (~item->shared->flags & CMDQ_SHARED_REPEAT)
|
if (~item->shared->flags & CMDQ_SHARED_REPEAT)
|
||||||
server_client_set_key_table(c, NULL);
|
server_client_set_key_table(c, NULL);
|
||||||
status_timer_start(c);
|
status_timer_start(c);
|
||||||
|
notify_client("client-session-changed", c);
|
||||||
session_update_activity(s, NULL);
|
session_update_activity(s, NULL);
|
||||||
gettimeofday(&s->last_attached_time, NULL);
|
gettimeofday(&s->last_attached_time, NULL);
|
||||||
|
|
||||||
|
@ -59,14 +59,27 @@ control_notify_input(struct client *c, struct window_pane *wp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
control_notify_pane_mode_changed(int pane)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
|
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
control_write(c, "%%pane-mode-changed %%%u", pane);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
control_notify_window_layout_changed(struct window *w)
|
control_notify_window_layout_changed(struct window *w)
|
||||||
{
|
{
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
const char *template;
|
const char *template;
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
template = "%layout-change #{window_id} #{window_layout} "
|
template = "%layout-change #{window_id} #{window_layout} "
|
||||||
"#{window_visible_layout} #{window_flags}";
|
"#{window_visible_layout} #{window_flags}";
|
||||||
@ -96,6 +109,20 @@ control_notify_window_layout_changed(struct window *w)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
control_notify_window_pane_changed(struct window *w)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
|
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
control_write(c, "%%window-pane-changed @%u %%%u", w->id,
|
||||||
|
w->active->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
control_notify_window_unlinked(__unused struct session *s, struct window *w)
|
control_notify_window_unlinked(__unused struct session *s, struct window *w)
|
||||||
{
|
{
|
||||||
@ -154,15 +181,27 @@ control_notify_window_renamed(struct window *w)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
control_notify_client_session_changed(struct client *c)
|
control_notify_client_session_changed(struct client *cc)
|
||||||
{
|
{
|
||||||
|
struct client *c;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
|
||||||
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL)
|
if (cc->session == NULL)
|
||||||
return;
|
return;
|
||||||
s = c->session;
|
s = cc->session;
|
||||||
|
|
||||||
control_write(c, "%%session-changed $%u %s", s->id, s->name);
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
|
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (cc == c) {
|
||||||
|
control_write(c, "%%session-changed $%u %s", s->id,
|
||||||
|
s->name);
|
||||||
|
} else {
|
||||||
|
control_write(c, "%%client-session-changed %s $%u %s",
|
||||||
|
cc->name, s->id, s->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -203,3 +242,17 @@ control_notify_session_closed(__unused struct session *s)
|
|||||||
control_write(c, "%%sessions-changed");
|
control_write(c, "%%sessions-changed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
control_notify_session_window_changed(struct session *s)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
|
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
control_write(c, "%%session-window-changed $%u @%u", s->id,
|
||||||
|
s->curw->window->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
6
notify.c
6
notify.c
@ -79,8 +79,12 @@ notify_callback(struct cmdq_item *item, void *data)
|
|||||||
|
|
||||||
log_debug("%s: %s", __func__, ne->name);
|
log_debug("%s: %s", __func__, ne->name);
|
||||||
|
|
||||||
|
if (strcmp(ne->name, "pane-mode-changed") == 0)
|
||||||
|
control_notify_pane_mode_changed(ne->pane);
|
||||||
if (strcmp(ne->name, "window-layout-changed") == 0)
|
if (strcmp(ne->name, "window-layout-changed") == 0)
|
||||||
control_notify_window_layout_changed(ne->window);
|
control_notify_window_layout_changed(ne->window);
|
||||||
|
if (strcmp(ne->name, "window-pane-changed") == 0)
|
||||||
|
control_notify_window_pane_changed(ne->window);
|
||||||
if (strcmp(ne->name, "window-unlinked") == 0)
|
if (strcmp(ne->name, "window-unlinked") == 0)
|
||||||
control_notify_window_unlinked(ne->session, ne->window);
|
control_notify_window_unlinked(ne->session, ne->window);
|
||||||
if (strcmp(ne->name, "window-linked") == 0)
|
if (strcmp(ne->name, "window-linked") == 0)
|
||||||
@ -95,6 +99,8 @@ notify_callback(struct cmdq_item *item, void *data)
|
|||||||
control_notify_session_created(ne->session);
|
control_notify_session_created(ne->session);
|
||||||
if (strcmp(ne->name, "session-closed") == 0)
|
if (strcmp(ne->name, "session-closed") == 0)
|
||||||
control_notify_session_closed(ne->session);
|
control_notify_session_closed(ne->session);
|
||||||
|
if (strcmp(ne->name, "session-window-changed") == 0)
|
||||||
|
control_notify_session_window_changed(ne->session);
|
||||||
|
|
||||||
notify_hook(item, ne);
|
notify_hook(item, ne);
|
||||||
|
|
||||||
|
@ -553,6 +553,7 @@ session_set_current(struct session *s, struct winlink *wl)
|
|||||||
s->curw = wl;
|
s->curw = wl;
|
||||||
winlink_clear_flags(wl);
|
winlink_clear_flags(wl);
|
||||||
window_update_activity(wl->window);
|
window_update_activity(wl->window);
|
||||||
|
notify_session("session-window-changed", s);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
tmux.1
19
tmux.1
@ -4231,6 +4231,11 @@ A notification will never occur inside an output block.
|
|||||||
.Pp
|
.Pp
|
||||||
The following notifications are defined:
|
The following notifications are defined:
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
|
.It Ic %client-session-changed Ar client Ar session-id Ar name
|
||||||
|
The client is now attached to the session with ID
|
||||||
|
.Ar session-id ,
|
||||||
|
which is named
|
||||||
|
.Ar name .
|
||||||
.It Ic %exit Op Ar reason
|
.It Ic %exit Op Ar reason
|
||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
@ -4253,6 +4258,10 @@ and the window flags are
|
|||||||
A window pane produced output.
|
A window pane produced output.
|
||||||
.Ar value
|
.Ar value
|
||||||
escapes non-printable characters and backslash as octal \\xxx.
|
escapes non-printable characters and backslash as octal \\xxx.
|
||||||
|
.It Ic %pane-mode-changed Ar pane-id
|
||||||
|
The pane with ID
|
||||||
|
.Ar pane-id
|
||||||
|
has changed mode.
|
||||||
.It Ic %session-changed Ar session-id Ar name
|
.It Ic %session-changed Ar session-id Ar name
|
||||||
The client is now attached to the session with ID
|
The client is now attached to the session with ID
|
||||||
.Ar session-id ,
|
.Ar session-id ,
|
||||||
@ -4261,6 +4270,11 @@ which is named
|
|||||||
.It Ic %session-renamed Ar name
|
.It Ic %session-renamed Ar name
|
||||||
The current session was renamed to
|
The current session was renamed to
|
||||||
.Ar name .
|
.Ar name .
|
||||||
|
.It Ic %session-window-changed Ar session-id Ar window-id
|
||||||
|
The session with ID
|
||||||
|
.Ar session-id
|
||||||
|
changed its active window to the window with ID
|
||||||
|
.Ar window-id .
|
||||||
.It Ic %sessions-changed
|
.It Ic %sessions-changed
|
||||||
A session was created or destroyed.
|
A session was created or destroyed.
|
||||||
.It Ic %unlinked-window-add Ar window-id
|
.It Ic %unlinked-window-add Ar window-id
|
||||||
@ -4275,6 +4289,11 @@ was linked to the current session.
|
|||||||
The window with ID
|
The window with ID
|
||||||
.Ar window-id
|
.Ar window-id
|
||||||
closed.
|
closed.
|
||||||
|
.It Ic %window-pane-changed Ar window-id Ar pane-id
|
||||||
|
The active pane in the window with ID
|
||||||
|
.Ar window-id
|
||||||
|
changed to the pane with ID
|
||||||
|
.Ar pane-id .
|
||||||
.It Ic %window-renamed Ar window-id Ar name
|
.It Ic %window-renamed Ar window-id Ar name
|
||||||
The window with ID
|
The window with ID
|
||||||
.Ar window-id
|
.Ar window-id
|
||||||
|
3
tmux.h
3
tmux.h
@ -2208,7 +2208,9 @@ void control_write_buffer(struct client *, struct evbuffer *);
|
|||||||
/* control-notify.c */
|
/* control-notify.c */
|
||||||
void control_notify_input(struct client *, struct window_pane *,
|
void control_notify_input(struct client *, struct window_pane *,
|
||||||
struct evbuffer *);
|
struct evbuffer *);
|
||||||
|
void control_notify_pane_mode_changed(int);
|
||||||
void control_notify_window_layout_changed(struct window *);
|
void control_notify_window_layout_changed(struct window *);
|
||||||
|
void control_notify_window_pane_changed(struct window *);
|
||||||
void control_notify_window_unlinked(struct session *, struct window *);
|
void control_notify_window_unlinked(struct session *, struct window *);
|
||||||
void control_notify_window_linked(struct session *, struct window *);
|
void control_notify_window_linked(struct session *, struct window *);
|
||||||
void control_notify_window_renamed(struct window *);
|
void control_notify_window_renamed(struct window *);
|
||||||
@ -2216,6 +2218,7 @@ void control_notify_client_session_changed(struct client *);
|
|||||||
void control_notify_session_renamed(struct session *);
|
void control_notify_session_renamed(struct session *);
|
||||||
void control_notify_session_created(struct session *);
|
void control_notify_session_created(struct session *);
|
||||||
void control_notify_session_closed(struct session *);
|
void control_notify_session_closed(struct session *);
|
||||||
|
void control_notify_session_window_changed(struct session *);
|
||||||
|
|
||||||
/* session.c */
|
/* session.c */
|
||||||
extern struct sessions sessions;
|
extern struct sessions sessions;
|
||||||
|
13
window.c
13
window.c
@ -355,6 +355,8 @@ window_create_spawn(const char *name, int argc, char **argv, const char *path,
|
|||||||
} else
|
} else
|
||||||
w->name = default_window_name(w);
|
w->name = default_window_name(w);
|
||||||
|
|
||||||
|
notify_window("window-pane-changed", w);
|
||||||
|
|
||||||
return (w);
|
return (w);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,11 +443,14 @@ window_set_active_pane(struct window *w, struct window_pane *wp)
|
|||||||
w->active = TAILQ_PREV(w->active, window_panes, entry);
|
w->active = TAILQ_PREV(w->active, window_panes, entry);
|
||||||
if (w->active == NULL)
|
if (w->active == NULL)
|
||||||
w->active = TAILQ_LAST(&w->panes, window_panes);
|
w->active = TAILQ_LAST(&w->panes, window_panes);
|
||||||
if (w->active == wp)
|
if (w->active == wp) {
|
||||||
|
notify_window("window-pane-changed", w);
|
||||||
return (1);
|
return (1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
w->active->active_point = next_active_point++;
|
w->active->active_point = next_active_point++;
|
||||||
w->active->flags |= PANE_CHANGED;
|
w->active->flags |= PANE_CHANGED;
|
||||||
|
notify_window("window-pane-changed", w);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,8 +626,10 @@ window_lost_pane(struct window *w, struct window_pane *wp)
|
|||||||
if (w->active == NULL)
|
if (w->active == NULL)
|
||||||
w->active = TAILQ_NEXT(wp, entry);
|
w->active = TAILQ_NEXT(wp, entry);
|
||||||
}
|
}
|
||||||
if (w->active != NULL)
|
if (w->active != NULL) {
|
||||||
w->active->flags |= PANE_CHANGED;
|
w->active->flags |= PANE_CHANGED;
|
||||||
|
notify_window("window-pane-changed", w);
|
||||||
|
}
|
||||||
} else if (wp == w->last)
|
} else if (wp == w->last)
|
||||||
w->last = NULL;
|
w->last = NULL;
|
||||||
}
|
}
|
||||||
@ -1181,6 +1188,7 @@ window_pane_set_mode(struct window_pane *wp, const struct window_mode *mode)
|
|||||||
wp->flags |= (PANE_REDRAW|PANE_CHANGED);
|
wp->flags |= (PANE_REDRAW|PANE_CHANGED);
|
||||||
|
|
||||||
server_status_window(wp->window);
|
server_status_window(wp->window);
|
||||||
|
notify_pane("pane-mode-changed", wp);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1200,6 +1208,7 @@ window_pane_reset_mode(struct window_pane *wp)
|
|||||||
wp->flags |= (PANE_REDRAW|PANE_CHANGED);
|
wp->flags |= (PANE_REDRAW|PANE_CHANGED);
|
||||||
|
|
||||||
server_status_window(wp->window);
|
server_status_window(wp->window);
|
||||||
|
notify_pane("pane-mode-changed", wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user