Hi I have applied this to OpenBSD now but I changed it so that killing current and killing tagged are different keys (x and X), which matches how the other modes work (for example d and D with choose-client).
It should be in GitHub later today. Thanks On Mon, Apr 09, 2018 at 10:47:59AM -0500, Matt Zagrabelny wrote: > Hey Nicholas, > Thanks for the patch. Works nicely. > -m > On Fri, Apr 6, 2018 at 4:51 AM, Nicholas Marriott > <[email protected]> wrote: > > Try this please: > > Index: cmd-kill-pane.c > =================================================================== > RCS file: /cvs/src/usr.bin/tmux/cmd-kill-pane.c,v > retrieving revision 1.25 > diff -u -p -r1.25 cmd-kill-pane.c > --- cmd-kill-pane.cA A A 22 Apr 2017 10:22:39 -0000A A A 1.25 > +++ cmd-kill-pane.cA A A 6 Apr 2018 09:48:30 -0000 > @@ -47,9 +47,8 @@ cmd_kill_pane_exec(struct cmd *self, str > A A A A struct winlinkA A A A A *wl = item->target.wl; > A A A A struct window_paneA A A *loopwp, *tmpwp, *wp = > item->target.wp; > > -A A A A server_unzoom_window(wl->window); > - > A A A A if (args_has(self->args, 'a')) { > +A A A A A A A A server_unzoom_window(wl->window); > A A A A A A A A TAILQ_FOREACH_SAFE(loopwp, &wl->window->panes, > entry, tmpwp) { > A A A A A A A A A A A A if (loopwp == wp) > A A A A A A A A A A A A A A A A continue; > @@ -60,13 +59,6 @@ cmd_kill_pane_exec(struct cmd *self, str > A A A A A A A A return (CMD_RETURN_NORMAL); > A A A A } > > -A A A A if (window_count_panes(wl->window) == 1) { > -A A A A A A A A server_kill_window(wl->window); > -A A A A A A A A recalculate_sizes(); > -A A A A } else { > -A A A A A A A A layout_close_pane(wp); > -A A A A A A A A window_remove_pane(wl->window, wp); > -A A A A A A A A server_redraw_window(wl->window); > -A A A A } > +A A A A server_kill_pane(wp); > A A A A return (CMD_RETURN_NORMAL); > A } > Index: server-fn.c > =================================================================== > RCS file: /cvs/src/usr.bin/tmux/server-fn.c,v > retrieving revision 1.113 > diff -u -p -r1.113 server-fn.c > --- server-fn.c 28 Feb 2018 08:55:44 -0000A A A 1.113 > +++ server-fn.c 6 Apr 2018 09:48:30 -0000 > @@ -178,6 +178,22 @@ server_lock_client(struct client *c) > A } > > A void > +server_kill_pane(struct window_pane *wp) > +{ > +A A A A struct windowA A *w = wp->window; > + > +A A A A if (window_count_panes(w) == 1) { > +A A A A A A A A server_kill_window(w); > +A A A A A A A A recalculate_sizes(); > +A A A A } else { > +A A A A A A A A server_unzoom_window(w); > +A A A A A A A A layout_close_pane(wp); > +A A A A A A A A window_remove_pane(w, wp); > +A A A A A A A A server_redraw_window(w); > +A A A A } > +} > + > +void > A server_kill_window(struct window *w) > A { > A A A A struct sessionA A A A A *s, *next_s, *target_s; > Index: tmux.h > =================================================================== > RCS file: /cvs/src/usr.bin/tmux/tmux.h,v > retrieving revision 1.822 > diff -u -p -r1.822 tmux.h > --- tmux.hA A A 16 Mar 2018 15:15:39 -0000A A A 1.822 > +++ tmux.hA A A 6 Apr 2018 09:48:30 -0000 > @@ -1920,6 +1920,7 @@ voidA A A A server_status_window(struct window > A voidA A server_lock(void); > A voidA A server_lock_session(struct session *); > A voidA A server_lock_client(struct client *); > +voidA A server_kill_pane(struct window_pane *); > A voidA A server_kill_window(struct window *); > A intA A A server_link_window(struct session *, > A A A A A A A struct winlink *, struct session *, int, int, int, > char **); > Index: window-tree.c > =================================================================== > RCS file: /cvs/src/usr.bin/tmux/window-tree.c,v > retrieving revision 1.29 > diff -u -p -r1.29 window-tree.c > --- window-tree.cA A A A 29 Mar 2018 08:03:51 -0000A A A 1.29 > +++ window-tree.cA A A A 6 Apr 2018 09:48:30 -0000 > @@ -18,6 +18,7 @@ > > A #include <sys/types.h> > > +#include <ctype.h> > A #include <stdlib.h> > A #include <string.h> > > @@ -860,8 +861,6 @@ window_tree_destroy(struct window_tree_m > A A A A if (--data->references != 0) > A A A A A A A A return; > > -A A A A mode_tree_free(data->data); > - > A A A A for (i = 0; i < data->item_size; i++) > A A A A A A A A window_tree_free_item(data->item_list[i]); > A A A A free(data->item_list); > @@ -881,6 +880,7 @@ window_tree_free(struct window_pane *wp) > A A A A A A A A return; > > A A A A data->dead = 1; > +A A A A mode_tree_free(data->data); > A A A A window_tree_destroy(data); > A } > > @@ -965,7 +965,7 @@ window_tree_command_callback(struct clie > A { > A A A A struct window_tree_modedataA A A *data = modedata; > > -A A A A if (s == NULL || data->dead) > +A A A A if (s == NULL || *s == '\0' || data->dead) > A A A A A A A A return (0); > > A A A A data->entered = s; > @@ -987,6 +987,62 @@ window_tree_command_free(void *modedata) > A A A A window_tree_destroy(data); > A } > > +static void > +window_tree_kill_each(__unused void* modedata, void* itemdata, > +A A __unused struct client *c, __unused key_code key) > +{ > +A A A A struct window_tree_itemdataA A A *item = itemdata; > +A A A A struct sessionA A A A A A A A A *s; > +A A A A struct winlinkA A A A A A A A A *wl; > +A A A A struct window_paneA A A A A A A *wp; > + > +A A A A window_tree_pull_item(item, &s, &wl, &wp); > + > +A A A A switch (item->type) { > +A A A A case WINDOW_TREE_NONE: > +A A A A A A A A break; > +A A A A case WINDOW_TREE_SESSION: > +A A A A A A A A if (s != NULL) { > +A A A A A A A A A A A A server_destroy_session(s); > +A A A A A A A A A A A A session_destroy(s, __func__); > +A A A A A A A A } > +A A A A A A A A break; > +A A A A case WINDOW_TREE_WINDOW: > +A A A A A A A A if (wl != NULL) > +A A A A A A A A A A A A server_kill_window(wl->window); > +A A A A A A A A break; > +A A A A case WINDOW_TREE_PANE: > +A A A A A A A A if (wp != NULL) > +A A A A A A A A A A A A server_kill_pane(wp); > +A A A A A A A A break; > +A A A A } > +} > + > +static int > +window_tree_kill_callback(struct client *c, void *modedata, const char > *s, > +A A __unused int done) > +{ > +A A A A struct window_tree_modedataA A A *data = modedata; > + > +A A A A if (s == NULL || *s == '\0' || data->dead) > +A A A A A A A A return (0); > +A A A A if (tolower((u_char) s[0]) != 'y' || s[1] != '\0') > +A A A A A A A A return (0); > + > +A A A A if (mode_tree_count_tagged(data->data) != 0) { > +A A A A A A A A mode_tree_each_tagged(data->data, > window_tree_kill_each, c, > +A A A A A A A A A A KEYC_NONE, 1); > +A A A A } else { > +A A A A A A A A window_tree_kill_each(modedata, > +A A A A A A A A A A mode_tree_get_current(data->data), c, > KEYC_NONE); > +A A A A } > + > +A A A A data->references++; > +A A A A cmdq_append(c, cmdq_get_callback(window_tree_command_done, > data)); > + > +A A A A return (0); > +} > + > A static key_code > A window_tree_mouse(struct window_tree_modedata *data, key_code key, > u_int x, > A A A struct window_tree_itemdata *item) > @@ -1054,10 +1110,13 @@ window_tree_key(struct window_pane *wp, > A { > A A A A struct window_tree_modedataA A A *data = wp->modedata; > A A A A struct window_tree_itemdataA A A *item, *new_item; > -A A A A charA A A A A A A A A A A A A A *name, > *prompt; > +A A A A charA A A A A A A A A A A A A A *name, *prompt > = NULL; > A A A A struct cmd_find_stateA A A A A A fs; > A A A A intA A A A A A A A A A A A A A A finished; > -A A A A u_intA A A A A A A A A A A A A A tagged, x, y; > +A A A A u_intA A A A A A A A A A A A A A tagged, x, y, > idx; > +A A A A struct sessionA A A A A A A A A *ns; > +A A A A struct winlinkA A A A A A A A A *nwl; > +A A A A struct window_paneA A A A A A A *nwp; > > A A A A item = mode_tree_get_current(data->data); > A A A A finished = mode_tree_key(data->data, c, &key, m, &x, &y); > @@ -1073,6 +1132,43 @@ window_tree_key(struct window_pane *wp, > A A A A A A A A break; > A A A A case '>': > A A A A A A A A data->offset++; > +A A A A A A A A break; > +A A A A case 'x': > +A A A A A A A A tagged = mode_tree_count_tagged(data->data); > +A A A A A A A A if (tagged != 0) > +A A A A A A A A A A A A xasprintf(&prompt, "Kill %u tagged? > ", tagged); > +A A A A A A A A else { > +A A A A A A A A A A A A window_tree_pull_item(item, &ns, > &nwl, &nwp); > +A A A A A A A A A A A A switch (item->type) { > +A A A A A A A A A A A A case WINDOW_TREE_NONE: > +A A A A A A A A A A A A A A A A break; > +A A A A A A A A A A A A case WINDOW_TREE_SESSION: > +A A A A A A A A A A A A A A A A if (ns != NULL) { > +A A A A A A A A A A A A A A A A A A A > A xasprintf(&prompt, "Kill session %s? ", > +A A A A A A A A A A A A A A A A A A A A A > A ns->name); > +A A A A A A A A A A A A A A A A } > +A A A A A A A A A A A A A A A A break; > +A A A A A A A A A A A A case WINDOW_TREE_WINDOW: > +A A A A A A A A A A A A A A A A if (nwl != NULL) { > +A A A A A A A A A A A A A A A A A A A > A xasprintf(&prompt, "Kill window %u? ", > +A A A A A A A A A A A A A A A A A A A A A > A nwl->idx); > +A A A A A A A A A A A A A A A A } > +A A A A A A A A A A A A A A A A break; > +A A A A A A A A A A A A case WINDOW_TREE_PANE: > +A A A A A A A A A A A A A A A A if (nwp != NULL && > +A A A A A A A A A A A A A A A A A > A window_pane_index(nwp, &idx) == 0) { > +A A A A A A A A A A A A A A A A A A A > A xasprintf(&prompt, "Kill pane %u? ", > +A A A A A A A A A A A A A A A A A A A A A A idx); > +A A A A A A A A A A A A A A A A } > +A A A A A A A A A A A A } > +A A A A A A A A } > +A A A A A A A A if (prompt == NULL) > +A A A A A A A A A A A A break; > +A A A A A A A A data->references++; > +A A A A A A A A status_prompt_set(c, prompt, "", > window_tree_kill_callback, > +A A A A A A A A A A window_tree_command_free, data, > +A A A A A A A A A A PROMPT_SINGLE|PROMPT_NOFORMAT); > +A A A A A A A A free(prompt); > A A A A A A A A break; > A A A A case ':': > A A A A A A A A tagged = mode_tree_count_tagged(data->data); > > On Thu, Apr 05, 2018 at 03:03:48PM -0500, Matt Zagrabelny wrote: > >A A On Thu, Apr 5, 2018 at 10:13 AM, Nicholas Marriott > >A A <[email protected]> wrote: > > > >A A A No we have moved away from configurable key bindings in choose > mode. > > > >A A Bummer. > >A A A > > > >A A A I don't mind having a key but it would need a confirmation > prompt. > > > >A A How about Ctrl+X for a key? Typing two keys is less likely to > result in an > >A A accidental kill of a session. > >A A -m > > -- > You received this message because you are subscribed to the Google Groups > "tmux-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "tmux-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
