summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/server.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-06-04 11:43:52 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-06-04 11:43:52 +0000
commit484368b54332b70c1fa2134c6b39939e86b8afeb (patch)
tree945855293c66b90b8696e405cdab19b7b12d136a /usr.bin/tmux/server.c
parent4d710c395c58bda9fbd62bb57cabf8c2587503ab (diff)
Add support for a single "marked pane". There is one marked pane in the
server at a time; it may be toggled or cleared with select-pane -m and -M (the border is highlighted). A new target '~' or '{marked}' specifies the marked pane to commands and it is the default target for the swap-pane and join-pane -s flag (this makes them much simpler to use - mark the source pane and then change to the target pane to run swapp or joinp).
Diffstat (limited to 'usr.bin/tmux/server.c')
-rw-r--r--usr.bin/tmux/server.c94
1 files changed, 80 insertions, 14 deletions
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c
index 53d65d55a91..98cecda9379 100644
--- a/usr.bin/tmux/server.c
+++ b/usr.bin/tmux/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.125 2015/06/01 09:20:19 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.126 2015/06/04 11:43:51 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -50,19 +50,85 @@ int server_shutdown;
struct event server_ev_accept;
struct event server_ev_second;
-int server_create_socket(void);
-void server_loop(void);
-int server_should_shutdown(void);
-void server_send_shutdown(void);
-void server_clean_dead(void);
-void server_accept_callback(int, short, void *);
-void server_signal_callback(int, short, void *);
-void server_child_signal(void);
-void server_child_exited(pid_t, int);
-void server_child_stopped(pid_t, int);
-void server_second_callback(int, short, void *);
-void server_lock_server(void);
-void server_lock_sessions(void);
+struct session *marked_session;
+struct winlink *marked_winlink;
+struct window *marked_window;
+struct window_pane *marked_window_pane;
+struct layout_cell *marked_layout_cell;
+
+int server_create_socket(void);
+void server_loop(void);
+int server_should_shutdown(void);
+void server_send_shutdown(void);
+void server_clean_dead(void);
+void server_accept_callback(int, short, void *);
+void server_signal_callback(int, short, void *);
+void server_child_signal(void);
+void server_child_exited(pid_t, int);
+void server_child_stopped(pid_t, int);
+void server_second_callback(int, short, void *);
+void server_lock_server(void);
+void server_lock_sessions(void);
+
+/* Set marked pane. */
+void
+server_set_marked(struct session *s, struct winlink *wl, struct window_pane *wp)
+{
+ marked_session = s;
+ marked_winlink = wl;
+ marked_window = wl->window;
+ marked_window_pane = wp;
+ marked_layout_cell = wp->layout_cell;
+}
+
+/* Clear marked pane. */
+void
+server_clear_marked(void)
+{
+ marked_session = NULL;
+ marked_winlink = NULL;
+ marked_window = NULL;
+ marked_window_pane = NULL;
+ marked_layout_cell = NULL;
+}
+
+/* Is this the marked pane? */
+int
+server_is_marked(struct session *s, struct winlink *wl, struct window_pane *wp)
+{
+ if (s == NULL || wl == NULL || wp == NULL)
+ return (0);
+ if (marked_session != s || marked_winlink != wl)
+ return (0);
+ if (marked_window_pane != wp)
+ return (0);
+ return (server_check_marked());
+}
+
+/* Check if the marked pane is still valid. */
+int
+server_check_marked(void)
+{
+ struct winlink *wl;
+
+ if (marked_window_pane == NULL)
+ return (0);
+ if (marked_layout_cell != marked_window_pane->layout_cell)
+ return (0);
+
+ if (!session_alive(marked_session))
+ return (0);
+ RB_FOREACH(wl, winlinks, &marked_session->windows) {
+ if (wl->window == marked_window && wl == marked_winlink)
+ break;
+ }
+ if (wl == NULL)
+ return (0);
+
+ if (!window_has_pane(marked_window, marked_window_pane))
+ return (0);
+ return (window_pane_visible(marked_window_pane));
+}
/* Create server socket. */
int