From a863834574ec02b87ff0e7245ef31f0d4543ab34 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 4 Jun 2015 11:43:51 +0000 Subject: 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). --- cmd-select-pane.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'cmd-select-pane.c') diff --git a/cmd-select-pane.c b/cmd-select-pane.c index f237e8fd..5ea4bdc3 100644 --- a/cmd-select-pane.c +++ b/cmd-select-pane.c @@ -28,8 +28,8 @@ enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmd_q *); const struct cmd_entry cmd_select_pane_entry = { "select-pane", "selectp", - "DdegLlP:Rt:U", 0, 0, - "[-DdegLlRU] [-P style] " CMD_TARGET_PANE_USAGE, + "DdegLlMmP:Rt:U", 0, 0, + "[-DdegLlMmRU] [-P style] " CMD_TARGET_PANE_USAGE, 0, cmd_select_pane_exec }; @@ -47,7 +47,8 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; struct winlink *wl; - struct window_pane *wp; + struct session *s; + struct window_pane *wp, *lastwp, *markedwp; const char *style; if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) { @@ -74,9 +75,31 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq) return (CMD_RETURN_NORMAL); } - if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL) + if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL) return (CMD_RETURN_ERROR); + if (args_has(args, 'm') || args_has(args, 'M')) { + if (args_has(args, 'm') && !window_pane_visible(wp)) + return (CMD_RETURN_NORMAL); + lastwp = marked_window_pane; + + if (args_has(args, 'M') || server_is_marked(s, wl, wp)) + server_clear_marked(); + else + server_set_marked(s, wl, wp); + markedwp = marked_window_pane; + + if (lastwp != NULL) { + server_redraw_window_borders(lastwp->window); + server_status_window(lastwp->window); + } + if (markedwp != NULL) { + server_redraw_window_borders(markedwp->window); + server_status_window(markedwp->window); + } + return (CMD_RETURN_NORMAL); + } + if (args_has(self->args, 'P') || args_has(self->args, 'g')) { if (args_has(args, 'P')) { style = args_get(args, 'P'); -- cgit