diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-03-17 22:35:10 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-03-17 22:35:10 +0000 |
commit | 0c3f7269cde53343e63855fa651fd174930c4b24 (patch) | |
tree | a62dffe1531568e0e9f628eed105ae55e91ecb85 /usr.bin | |
parent | 862f6b1d8710679c8d83bcf415ad46b5f15b5fe8 (diff) |
Add notify hooks for various events, the functions are currently empty
stubs but will be filled in for control mode later. From George Nachman.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-attach-session.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-join-pane.c | 5 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-new-session.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-new-window.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-rename-session.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-split-window.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/layout-custom.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/layout.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/notify.c | 59 | ||||
-rw-r--r-- | usr.bin/tmux/resize.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/server-fn.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/session.c | 18 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 12 | ||||
-rw-r--r-- | usr.bin/tmux/window.c | 3 |
15 files changed, 116 insertions, 17 deletions
diff --git a/usr.bin/tmux/Makefile b/usr.bin/tmux/Makefile index b9fdab31893..11ec70d565c 100644 --- a/usr.bin/tmux/Makefile +++ b/usr.bin/tmux/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.55 2011/08/26 10:53:16 nicm Exp $ +# $OpenBSD: Makefile,v 1.56 2012/03/17 22:35:09 nicm Exp $ PROG= tmux SRCS= arguments.c attributes.c cfg.c client.c clock.c \ @@ -31,7 +31,7 @@ SRCS= arguments.c attributes.c cfg.c client.c clock.c \ cmd-pipe-pane.c cmd-capture-pane.c cmd.c \ colour.c environ.c grid-view.c grid-utf8.c grid.c input-keys.c \ input.c key-bindings.c key-string.c format.c \ - layout-custom.c layout-set.c layout.c log.c job.c \ + layout-custom.c layout-set.c layout.c log.c job.c notify.c \ mode-key.c names.c options.c options-table.c paste.c procname.c \ resize.c screen-redraw.c screen-write.c screen.c session.c status.c \ signal.c server-fn.c server.c server-client.c server-window.c \ diff --git a/usr.bin/tmux/cmd-attach-session.c b/usr.bin/tmux/cmd-attach-session.c index 00715f7fa30..cbb9d50ea77 100644 --- a/usr.bin/tmux/cmd-attach-session.c +++ b/usr.bin/tmux/cmd-attach-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-attach-session.c,v 1.17 2012/01/21 06:13:16 nicm Exp $ */ +/* $OpenBSD: cmd-attach-session.c,v 1.18 2012/03/17 22:35:09 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -74,6 +74,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx) } ctx->curclient->session = s; + notify_attached_session_changed(ctx->curclient); session_update_activity(s); server_redraw_client(ctx->curclient); s->curw->flags &= ~WINLINK_ALERTFLAGS; @@ -98,6 +99,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx) server_write_session(s, MSG_DETACH, NULL, 0); ctx->cmdclient->session = s; + notify_attached_session_changed(ctx->cmdclient); session_update_activity(s); server_write_client(ctx->cmdclient, MSG_READY, NULL, 0); diff --git a/usr.bin/tmux/cmd-join-pane.c b/usr.bin/tmux/cmd-join-pane.c index ef14728632e..fc9e06231d0 100644 --- a/usr.bin/tmux/cmd-join-pane.c +++ b/usr.bin/tmux/cmd-join-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-join-pane.c,v 1.8 2012/03/03 08:31:18 nicm Exp $ */ +/* $OpenBSD: cmd-join-pane.c,v 1.9 2012/03/17 22:35:09 nicm Exp $ */ /* * Copyright (c) 2011 George Nachman <tmux@georgester.com> @@ -148,6 +148,8 @@ join_pane(struct cmd *self, struct cmd_ctx *ctx, int not_same_window) if (window_count_panes(src_w) == 0) server_kill_window(src_w); + else + notify_window_layout_changed(src_w); src_wp->window = dst_w; TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry); @@ -165,5 +167,6 @@ join_pane(struct cmd *self, struct cmd_ctx *ctx, int not_same_window) } else server_status_session(dst_s); + notify_window_layout_changed(dst_w); return (0); } diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index 8e60c47ddc2..c538ac936ef 100644 --- a/usr.bin/tmux/cmd-new-session.c +++ b/usr.bin/tmux/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-session.c,v 1.40 2012/02/02 00:10:11 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.41 2012/03/17 22:35:09 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -244,6 +244,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) if (old_s != NULL) ctx->cmdclient->last_session = old_s; ctx->cmdclient->session = s; + notify_attached_session_changed(ctx->cmdclient); session_update_activity(s); server_redraw_client(ctx->cmdclient); } else { @@ -251,6 +252,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) if (old_s != NULL) ctx->curclient->last_session = old_s; ctx->curclient->session = s; + notify_attached_session_changed(ctx->curclient); session_update_activity(s); server_redraw_client(ctx->curclient); } diff --git a/usr.bin/tmux/cmd-new-window.c b/usr.bin/tmux/cmd-new-window.c index 98b82739425..242e36b4ba3 100644 --- a/usr.bin/tmux/cmd-new-window.c +++ b/usr.bin/tmux/cmd-new-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-window.c,v 1.22 2012/03/04 20:52:05 nicm Exp $ */ +/* $OpenBSD: cmd-new-window.c,v 1.23 2012/03/17 22:35:09 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -89,6 +89,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) * Can't use session_detach as it will destroy session if this * makes it empty. */ + notify_window_unlinked(s, wl->window); wl->flags &= ~WINLINK_ALERTFLAGS; winlink_stack_remove(&s->lastw, wl); winlink_remove(&s->windows, wl); diff --git a/usr.bin/tmux/cmd-rename-session.c b/usr.bin/tmux/cmd-rename-session.c index 2743609be82..6e79823e6e7 100644 --- a/usr.bin/tmux/cmd-rename-session.c +++ b/usr.bin/tmux/cmd-rename-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-rename-session.c,v 1.10 2011/04/06 21:51:31 nicm Exp $ */ +/* $OpenBSD: cmd-rename-session.c,v 1.11 2012/03/17 22:35:09 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -64,6 +64,7 @@ cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx) RB_INSERT(sessions, &sessions, s); server_status_session(s); + notify_session_renamed(s); return (0); } diff --git a/usr.bin/tmux/cmd-split-window.c b/usr.bin/tmux/cmd-split-window.c index 55083d1bdad..08cf45e5ef7 100644 --- a/usr.bin/tmux/cmd-split-window.c +++ b/usr.bin/tmux/cmd-split-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-split-window.c,v 1.31 2012/03/04 20:52:05 nicm Exp $ */ +/* $OpenBSD: cmd-split-window.c,v 1.32 2012/03/17 22:35:09 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -156,6 +156,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) format_free(ft); } + notify_window_layout_changed(w); return (0); error: diff --git a/usr.bin/tmux/layout-custom.c b/usr.bin/tmux/layout-custom.c index 4a241f3481a..360ccbdb51e 100644 --- a/usr.bin/tmux/layout-custom.c +++ b/usr.bin/tmux/layout-custom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: layout-custom.c,v 1.4 2012/02/05 22:23:13 nicm Exp $ */ +/* $OpenBSD: layout-custom.c,v 1.5 2012/03/17 22:35:09 nicm Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net> @@ -172,6 +172,8 @@ layout_parse(struct window *w, const char *layout) layout_print_cell(lc, __func__, 0); + notify_window_layout_changed(w); + return (0); fail: diff --git a/usr.bin/tmux/layout.c b/usr.bin/tmux/layout.c index def54d444fe..80dbe373aa2 100644 --- a/usr.bin/tmux/layout.c +++ b/usr.bin/tmux/layout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: layout.c,v 1.9 2012/03/03 08:31:18 nicm Exp $ */ +/* $OpenBSD: layout.c,v 1.10 2012/03/17 22:35:09 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -483,6 +483,7 @@ layout_resize_pane(struct window_pane *wp, enum layout_type type, int change) /* Fix cell offsets. */ layout_fix_offsets(wp->window->layout_root); layout_fix_panes(wp->window, wp->window->sx, wp->window->sy); + notify_window_layout_changed(wp->window); } void @@ -742,4 +743,5 @@ layout_close_pane(struct window_pane *wp) layout_fix_offsets(wp->window->layout_root); layout_fix_panes(wp->window, wp->window->sx, wp->window->sy); } + notify_window_layout_changed(wp->window); } diff --git a/usr.bin/tmux/notify.c b/usr.bin/tmux/notify.c new file mode 100644 index 00000000000..59f52e1fd02 --- /dev/null +++ b/usr.bin/tmux/notify.c @@ -0,0 +1,59 @@ +/* $OpenBSD: notify.c,v 1.1 2012/03/17 22:35:09 nicm Exp $ */ + +/* + * Copyright (c) 2012 George Nachman <tmux@georgester.com> + * + * 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 "tmux.h" + +void +notify_window_layout_changed(unused struct window *w) +{ +} + +void +notify_window_unlinked(unused struct session *s, unused struct window *w) +{ +} + +void +notify_window_linked(unused struct session *s, unused struct window *w) +{ +} + +void +notify_window_renamed(unused struct window *w) +{ +} + +void +notify_attached_session_changed(unused struct client *c) +{ +} + +void +notify_session_renamed(unused struct session *s) +{ +} + +void +notify_session_created(unused struct session *s) +{ +} + +void +notify_session_closed(unused struct session *s) +{ +} diff --git a/usr.bin/tmux/resize.c b/usr.bin/tmux/resize.c index 14b3ff433b0..b28f8873ece 100644 --- a/usr.bin/tmux/resize.c +++ b/usr.bin/tmux/resize.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resize.c,v 1.7 2010/12/21 22:37:59 nicm Exp $ */ +/* $OpenBSD: resize.c,v 1.8 2012/03/17 22:35:09 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -141,5 +141,6 @@ recalculate_sizes(void) } server_redraw_window(w); + notify_window_layout_changed(w); } } diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c index 9bea2652439..3715df94bdc 100644 --- a/usr.bin/tmux/server-fn.c +++ b/usr.bin/tmux/server-fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-fn.c,v 1.54 2012/03/17 18:24:07 nicm Exp $ */ +/* $OpenBSD: server-fn.c,v 1.55 2012/03/17 22:35:09 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -293,6 +293,7 @@ server_link_window(struct session *src, struct winlink *srcwl, * Can't use session_detach as it will destroy session * if this makes it empty. */ + notify_window_unlinked(dst, dstwl->window); dstwl->flags &= ~WINLINK_ALERTFLAGS; winlink_stack_remove(&dst->lastw, dstwl); winlink_remove(&dst->windows, dstwl); @@ -419,6 +420,7 @@ server_destroy_session(struct session *s) } else { c->last_session = NULL; c->session = s_new; + notify_attached_session_changed(c); session_update_activity(s_new); server_redraw_client(c); } diff --git a/usr.bin/tmux/session.c b/usr.bin/tmux/session.c index 69956ad50bd..2476a9ae249 100644 --- a/usr.bin/tmux/session.c +++ b/usr.bin/tmux/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.32 2011/08/16 09:36:23 nicm Exp $ */ +/* $OpenBSD: session.c,v 1.33 2012/03/17 22:35:09 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -142,6 +142,7 @@ session_create(const char *name, const char *cmd, const char *cwd, } log_debug("session %s created", s->name); + notify_session_created(s); return (s); } @@ -150,9 +151,11 @@ session_create(const char *name, const char *cmd, const char *cwd, void session_destroy(struct session *s) { + struct winlink *wl; log_debug("session %s destroyed", s->name); RB_REMOVE(sessions, &sessions, s); + notify_session_closed(s); if (s->tio != NULL) xfree(s->tio); @@ -163,8 +166,11 @@ session_destroy(struct session *s) while (!TAILQ_EMPTY(&s->lastw)) winlink_stack_remove(&s->lastw, TAILQ_FIRST(&s->lastw)); - while (!RB_EMPTY(&s->windows)) - winlink_remove(&s->windows, RB_ROOT(&s->windows)); + while (!RB_EMPTY(&s->windows)) { + wl = RB_ROOT(&s->windows); + notify_window_unlinked(s, wl->window); + winlink_remove(&s->windows, wl); + } xfree(s->cwd); @@ -254,6 +260,7 @@ session_new(struct session *s, return (NULL); } winlink_set_window(wl, w); + notify_window_linked(s, w); environ_free(&env); if (options_get_number(&s->options, "set-remain-on-exit")) @@ -274,6 +281,7 @@ session_attach(struct session *s, struct window *w, int idx, char **cause) return (NULL); } winlink_set_window(wl, w); + notify_window_linked(s, w); session_group_synchronize_from(s); return (wl); @@ -288,6 +296,7 @@ session_detach(struct session *s, struct winlink *wl) session_next(s, 0); wl->flags &= ~WINLINK_ALERTFLAGS; + notify_window_unlinked(s, wl->window); winlink_stack_remove(&s->lastw, wl); winlink_remove(&s->windows, wl); session_group_synchronize_from(s); @@ -555,6 +564,7 @@ session_group_synchronize1(struct session *target, struct session *s) RB_FOREACH(wl, winlinks, ww) { wl2 = winlink_add(&s->windows, wl->idx); winlink_set_window(wl2, wl->window); + notify_window_linked(s, wl2->window); wl2->flags |= wl->flags & WINLINK_ALERTFLAGS; } @@ -576,6 +586,8 @@ session_group_synchronize1(struct session *target, struct session *s) /* Then free the old winlinks list. */ while (!RB_EMPTY(&old_windows)) { wl = RB_ROOT(&old_windows); + if (winlink_find_by_window_id(&s->windows, wl->window->id) == NULL) + notify_window_unlinked(s, wl->window); winlink_remove(&old_windows, wl); } } diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 6042c5e76b2..17615432585 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.322 2012/03/17 21:27:51 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.323 2012/03/17 22:35:09 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1396,6 +1396,16 @@ void mode_key_init_trees(void); void mode_key_init(struct mode_key_data *, struct mode_key_tree *); enum mode_key_cmd mode_key_lookup(struct mode_key_data *, int); +/* notify.c */ +void notify_window_layout_changed(struct window *); +void notify_window_unlinked(struct session *, struct window *); +void notify_window_linked(struct session *, struct window *); +void notify_window_renamed(struct window *); +void notify_attached_session_changed(struct client *); +void notify_session_renamed(struct session *); +void notify_session_created(struct session *); +void notify_session_closed(struct session *); + /* options.c */ int options_cmp(struct options_entry *, struct options_entry *); RB_PROTOTYPE(options_tree, options_entry, entry, options_cmp); diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index 57574bbf4a5..d3748847556 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.73 2012/03/17 18:24:07 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.74 2012/03/17 22:35:09 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -368,6 +368,7 @@ window_set_name(struct window *w, const char *new_name) if (w->name != NULL) xfree(w->name); w->name = xstrdup(new_name); + notify_window_renamed(w); } void |