diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2018-07-04 12:25:27 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2018-07-04 12:25:27 +0000 |
commit | e6490f6d818e471afe26ad2551f3dc3c4ecc57b4 (patch) | |
tree | 46079dfc2d96556b6d4649f26297d78e6b4318dc | |
parent | cb6468cb7a286ad48c7cfb5b817ea64c9c20123a (diff) |
Add pane focus hooks.
-rw-r--r-- | usr.bin/tmux/server-client.c | 20 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 12 |
2 files changed, 21 insertions, 11 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 7c7da257448..f8965946e70 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.250 2018/05/24 09:42:49 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.251 2018/07/04 12:25:26 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1148,10 +1148,6 @@ server_client_check_focus(struct window_pane *wp) push = wp->flags & PANE_FOCUSPUSH; wp->flags &= ~PANE_FOCUSPUSH; - /* If we don't care about focus, forget it. */ - if (!(wp->base.mode & MODE_FOCUSON)) - return; - /* If we're not the active pane in our window, we're not focused. */ if (wp->window->active != wp) goto not_focused; @@ -1175,14 +1171,20 @@ server_client_check_focus(struct window_pane *wp) } not_focused: - if (push || (wp->flags & PANE_FOCUSED)) - bufferevent_write(wp->event, "\033[O", 3); + if (push || (wp->flags & PANE_FOCUSED)) { + if (wp->base.mode & MODE_FOCUSON) + bufferevent_write(wp->event, "\033[O", 3); + notify_pane("pane-focus-out", wp); + } wp->flags &= ~PANE_FOCUSED; return; focused: - if (push || !(wp->flags & PANE_FOCUSED)) - bufferevent_write(wp->event, "\033[I", 3); + if (push || !(wp->flags & PANE_FOCUSED)) { + if (wp->base.mode & MODE_FOCUSON) + bufferevent_write(wp->event, "\033[I", 3); + notify_pane("pane-focus-in", wp); + } wp->flags |= PANE_FOCUSED; } diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 60a9ecbaeea..678a374d00a 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.602 2018/06/08 09:43:58 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.603 2018/07/04 12:25:26 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 8 2018 $ +.Dd $Mdocdate: July 4 2018 $ .Dt TMUX 1 .Os .Sh NAME @@ -3423,6 +3423,14 @@ Run when the program running in a pane exits, but is on so the pane has not closed. .It pane-exited Run when the program running in a pane exits. +.It pane-focus-in +Run when the focus enters a pane, if the +.Ic focus-events +option is on. +.It pane-focus-out +Run when the focus exits a pane, if the +.Ic focus-events +option is on. .It pane-set-clipboard Run when the terminal clipboard is set using the .Xr xterm 1 |