diff options
author | 2020-04-22 21:01:28 +0000 | |
---|---|---|
committer | 2020-04-22 21:01:28 +0000 | |
commit | 7d0fd907d21970b41b3f32943d745bb7764ce08e (patch) | |
tree | 68835e0e9429c6e920eca0ec5ffb3c44bec12ef2 | |
parent | Add a session_marked format like window_marked. (diff) | |
download | wireguard-openbsd-7d0fd907d21970b41b3f32943d745bb7764ce08e.tar.xz wireguard-openbsd-7d0fd907d21970b41b3f32943d745bb7764ce08e.zip |
Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).
-rw-r--r-- | usr.bin/tmux/mode-tree.c | 40 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 5 | ||||
-rw-r--r-- | usr.bin/tmux/window-tree.c | 24 |
3 files changed, 57 insertions, 12 deletions
diff --git a/usr.bin/tmux/mode-tree.c b/usr.bin/tmux/mode-tree.c index 11b660010b3..9df226438d6 100644 --- a/usr.bin/tmux/mode-tree.c +++ b/usr.bin/tmux/mode-tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mode-tree.c,v 1.40 2020/04/13 18:59:41 nicm Exp $ */ +/* $OpenBSD: mode-tree.c,v 1.41 2020/04/22 21:01:28 nicm Exp $ */ /* * Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -256,8 +256,8 @@ mode_tree_expand_current(struct mode_tree_data *mtd) } } -void -mode_tree_set_current(struct mode_tree_data *mtd, uint64_t tag) +static int +mode_tree_get_tag(struct mode_tree_data *mtd, uint64_t tag, u_int *found) { u_int i; @@ -266,15 +266,41 @@ mode_tree_set_current(struct mode_tree_data *mtd, uint64_t tag) break; } if (i != mtd->line_size) { - mtd->current = i; + *found = i; + return (1); + } + return (0); +} + +void +mode_tree_expand(struct mode_tree_data *mtd, uint64_t tag) +{ + u_int found; + + if (!mode_tree_get_tag(mtd, tag, &found)) + return; + if (!mtd->line_list[found].item->expanded) { + mtd->line_list[found].item->expanded = 1; + mode_tree_build(mtd); + } +} + +int +mode_tree_set_current(struct mode_tree_data *mtd, uint64_t tag) +{ + u_int found; + + if (mode_tree_get_tag(mtd, tag, &found)) { + mtd->current = found; if (mtd->current > mtd->height - 1) mtd->offset = mtd->current - mtd->height + 1; else mtd->offset = 0; - } else { - mtd->current = 0; - mtd->offset = 0; + return (1); } + mtd->current = 0; + mtd->offset = 0; + return (0); } u_int diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 2a0fab8baba..6489e25a75a 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1014 2020/04/22 06:57:13 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1015 2020/04/22 21:01:28 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -2621,7 +2621,8 @@ typedef void (*mode_tree_each_cb)(void *, void *, struct client *, key_code); u_int mode_tree_count_tagged(struct mode_tree_data *); void *mode_tree_get_current(struct mode_tree_data *); void mode_tree_expand_current(struct mode_tree_data *); -void mode_tree_set_current(struct mode_tree_data *, uint64_t); +void mode_tree_expand(struct mode_tree_data *, uint64_t); +int mode_tree_set_current(struct mode_tree_data *, uint64_t); void mode_tree_each_tagged(struct mode_tree_data *, mode_tree_each_cb, struct client *, key_code, int); void mode_tree_down(struct mode_tree_data *, int); diff --git a/usr.bin/tmux/window-tree.c b/usr.bin/tmux/window-tree.c index a075cd1a55b..2ada0d4f400 100644 --- a/usr.bin/tmux/window-tree.c +++ b/usr.bin/tmux/window-tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-tree.c,v 1.46 2020/04/09 15:35:27 nicm Exp $ */ +/* $OpenBSD: window-tree.c,v 1.47 2020/04/22 21:01:28 nicm Exp $ */ /* * Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -37,9 +37,11 @@ static void window_tree_key(struct window_mode_entry *, #define WINDOW_TREE_DEFAULT_FORMAT \ "#{?pane_format," \ - "#{pane_current_command} \"#{pane_title}\"" \ + "#{?pane_marked,#[reverse],}" \ + "#{pane_current_command}#{?pane_active,*,}#{?pane_marked,M,} \"#{pane_title}\"" \ "," \ "#{?window_format," \ + "#{?window_marked_flag,#[reverse],}" \ "#{window_name}#{window_flags} " \ "(#{window_panes} panes)" \ "#{?#{==:#{window_panes},1}, \"#{pane_title}\",}" \ @@ -56,6 +58,7 @@ static void window_tree_key(struct window_mode_entry *, static const struct menu_item window_tree_menu_items[] = { { "Select", '\r', NULL }, { "Expand", KEYC_RIGHT, NULL }, + { "Mark", 'm', NULL }, { "", KEYC_NONE, NULL }, { "Tag", 't', NULL }, { "Tag All", '\024', NULL }, @@ -1170,7 +1173,7 @@ window_tree_key(struct window_mode_entry *wme, struct client *c, struct window_tree_modedata *data = wme->data; struct window_tree_itemdata *item, *new_item; char *name, *prompt = NULL; - struct cmd_find_state fs; + struct cmd_find_state fs, *fsp = &data->fs; int finished; u_int tagged, x, y, idx; struct session *ns; @@ -1192,6 +1195,21 @@ window_tree_key(struct window_mode_entry *wme, struct client *c, case '>': data->offset++; break; + case 'H': + mode_tree_expand(data->data, (uint64_t)fsp->s); + mode_tree_expand(data->data, (uint64_t)fsp->wl); + if (!mode_tree_set_current(data->data, (uint64_t)wme->wp)) + mode_tree_set_current(data->data, (uint64_t)fsp->wl); + break; + case 'm': + window_tree_pull_item(item, &ns, &nwl, &nwp); + server_set_marked(ns, nwl, nwp); + mode_tree_build(data->data); + break; + case 'M': + server_clear_marked(); + mode_tree_build(data->data); + break; case 'x': window_tree_pull_item(item, &ns, &nwl, &nwp); switch (item->type) { |