mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Only show the first member of session groups in tree mode (-G flag
disables).
This commit is contained in:
parent
3887d95bca
commit
c1f62f1fde
@ -30,8 +30,8 @@ const struct cmd_entry cmd_choose_tree_entry = {
|
|||||||
.name = "choose-tree",
|
.name = "choose-tree",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "F:f:NO:st:w", 0, 1 },
|
.args = { "F:Gf:NO:st:w", 0, 1 },
|
||||||
.usage = "[-Nsw] [-F format] [-f filter] [-O sort-order] "
|
.usage = "[-GNsw] [-F format] [-f filter] [-O sort-order] "
|
||||||
CMD_TARGET_PANE_USAGE,
|
CMD_TARGET_PANE_USAGE,
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
41
format.c
41
format.c
@ -572,8 +572,38 @@ format_cb_pane_tabs(struct format_tree *ft, struct format_entry *fe)
|
|||||||
evbuffer_add(buffer, ",", 1);
|
evbuffer_add(buffer, ",", 1);
|
||||||
evbuffer_add_printf(buffer, "%u", i);
|
evbuffer_add_printf(buffer, "%u", i);
|
||||||
}
|
}
|
||||||
size = EVBUFFER_LENGTH(buffer);
|
if ((size = EVBUFFER_LENGTH(buffer)) != 0)
|
||||||
xasprintf(&fe->value, "%.*s", size, EVBUFFER_DATA(buffer));
|
xasprintf(&fe->value, "%.*s", size, EVBUFFER_DATA(buffer));
|
||||||
|
evbuffer_free(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Callback for session_group_others. */
|
||||||
|
static void
|
||||||
|
format_cb_session_group_others(struct format_tree *ft, struct format_entry *fe)
|
||||||
|
{
|
||||||
|
struct session *s = ft->s;
|
||||||
|
struct session_group *sg;
|
||||||
|
struct session *loop;
|
||||||
|
struct evbuffer *buffer;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
if (s == NULL)
|
||||||
|
return;
|
||||||
|
sg = session_group_contains(s);
|
||||||
|
if (sg == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
buffer = evbuffer_new();
|
||||||
|
TAILQ_FOREACH(loop, &sg->sessions, gentry) {
|
||||||
|
if (loop == s)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (EVBUFFER_LENGTH(buffer) > 0)
|
||||||
|
evbuffer_add(buffer, ",", 1);
|
||||||
|
evbuffer_add_printf(buffer, "%s", loop->name);
|
||||||
|
}
|
||||||
|
if ((size = EVBUFFER_LENGTH(buffer)) != 0)
|
||||||
|
xasprintf(&fe->value, "%.*s", size, EVBUFFER_DATA(buffer));
|
||||||
evbuffer_free(buffer);
|
evbuffer_free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1253,8 +1283,13 @@ format_defaults_session(struct format_tree *ft, struct session *s)
|
|||||||
|
|
||||||
sg = session_group_contains(s);
|
sg = session_group_contains(s);
|
||||||
format_add(ft, "session_grouped", "%d", sg != NULL);
|
format_add(ft, "session_grouped", "%d", sg != NULL);
|
||||||
if (sg != NULL)
|
if (sg != NULL) {
|
||||||
format_add(ft, "session_group", "%s", sg->name);
|
format_add(ft, "session_group", "%s", sg->name);
|
||||||
|
format_add(ft, "session_group_size", "%u",
|
||||||
|
session_group_count (sg));
|
||||||
|
format_add_cb(ft, "session_group_others",
|
||||||
|
format_cb_session_group_others);
|
||||||
|
}
|
||||||
|
|
||||||
format_add_tv(ft, "session_created", &s->creation_time);
|
format_add_tv(ft, "session_created", &s->creation_time);
|
||||||
format_add_tv(ft, "session_last_attached", &s->last_attached_time);
|
format_add_tv(ft, "session_last_attached", &s->last_attached_time);
|
||||||
|
@ -39,10 +39,6 @@ static struct winlink *session_next_alert(struct winlink *);
|
|||||||
static struct winlink *session_previous_alert(struct winlink *);
|
static struct winlink *session_previous_alert(struct winlink *);
|
||||||
|
|
||||||
static void session_group_remove(struct session *);
|
static void session_group_remove(struct session *);
|
||||||
static u_int session_group_count(struct session_group *);
|
|
||||||
static void session_group_synchronize1(struct session *, struct session *);
|
|
||||||
|
|
||||||
static u_int session_group_count(struct session_group *);
|
|
||||||
static void session_group_synchronize1(struct session *, struct session *);
|
static void session_group_synchronize1(struct session *, struct session *);
|
||||||
|
|
||||||
RB_GENERATE(sessions, session, entry, session_cmp);
|
RB_GENERATE(sessions, session, entry, session_cmp);
|
||||||
@ -624,7 +620,7 @@ session_group_remove(struct session *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Count number of sessions in session group. */
|
/* Count number of sessions in session group. */
|
||||||
static u_int
|
u_int
|
||||||
session_group_count(struct session_group *sg)
|
session_group_count(struct session_group *sg)
|
||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
7
tmux.1
7
tmux.1
@ -1428,7 +1428,7 @@ starts without the preview.
|
|||||||
This command works only if at least one client is attached.
|
This command works only if at least one client is attached.
|
||||||
.It Xo
|
.It Xo
|
||||||
.Ic choose-tree
|
.Ic choose-tree
|
||||||
.Op Fl Nsw
|
.Op Fl GNsw
|
||||||
.Op Fl F Ar format
|
.Op Fl F Ar format
|
||||||
.Op Fl f Ar filter
|
.Op Fl f Ar filter
|
||||||
.Op Fl O Ar sort-order
|
.Op Fl O Ar sort-order
|
||||||
@ -1484,6 +1484,9 @@ If a filter would lead to an empty list, it is ignored.
|
|||||||
specifies the format for each item in the tree.
|
specifies the format for each item in the tree.
|
||||||
.Fl N
|
.Fl N
|
||||||
starts without the preview.
|
starts without the preview.
|
||||||
|
.Fl G
|
||||||
|
includes all sessions in any session groups in the tree rather than only the
|
||||||
|
first.
|
||||||
This command works only if at least one client is attached.
|
This command works only if at least one client is attached.
|
||||||
.It Xo
|
.It Xo
|
||||||
.Ic display-panes
|
.Ic display-panes
|
||||||
@ -3710,6 +3713,8 @@ The following variables are available, where appropriate:
|
|||||||
.It Li "session_format" Ta "" Ta "1 if format is for a session (not assuming the current)"
|
.It Li "session_format" Ta "" Ta "1 if format is for a session (not assuming the current)"
|
||||||
.It Li "session_last_attached" Ta "" Ta "Time session last attached"
|
.It Li "session_last_attached" Ta "" Ta "Time session last attached"
|
||||||
.It Li "session_group" Ta "" Ta "Name of session group"
|
.It Li "session_group" Ta "" Ta "Name of session group"
|
||||||
|
.It Li "session_group_size" Ta "" Ta "Size of session group"
|
||||||
|
.It Li "session_group_others" Ta "" Ta "List of other sessions in group"
|
||||||
.It Li "session_grouped" Ta "" Ta "1 if session in a group"
|
.It Li "session_grouped" Ta "" Ta "1 if session in a group"
|
||||||
.It Li "session_height" Ta "" Ta "Height of session"
|
.It Li "session_height" Ta "" Ta "Height of session"
|
||||||
.It Li "session_id" Ta "" Ta "Unique session ID"
|
.It Li "session_id" Ta "" Ta "Unique session ID"
|
||||||
|
1
tmux.h
1
tmux.h
@ -2335,6 +2335,7 @@ struct session_group *session_group_new(const char *);
|
|||||||
void session_group_add(struct session_group *, struct session *);
|
void session_group_add(struct session_group *, struct session *);
|
||||||
void session_group_synchronize_to(struct session *);
|
void session_group_synchronize_to(struct session *);
|
||||||
void session_group_synchronize_from(struct session *);
|
void session_group_synchronize_from(struct session *);
|
||||||
|
u_int session_group_count(struct session_group *);
|
||||||
void session_renumber_windows(struct session *);
|
void session_renumber_windows(struct session *);
|
||||||
|
|
||||||
/* utf8.c */
|
/* utf8.c */
|
||||||
|
@ -43,8 +43,12 @@ static void window_tree_key(struct window_pane *,
|
|||||||
"#{?#{==:#{window_panes},1}, \"#{pane_title}\",}" \
|
"#{?#{==:#{window_panes},1}, \"#{pane_title}\",}" \
|
||||||
"," \
|
"," \
|
||||||
"#{session_windows} windows" \
|
"#{session_windows} windows" \
|
||||||
"#{?session_grouped, (group ,}" \
|
"#{?session_grouped, " \
|
||||||
"#{session_group}#{?session_grouped,),}" \
|
"(group #{session_group}" \
|
||||||
|
"#{?session_group_others," \
|
||||||
|
" with #{session_group_others}," \
|
||||||
|
"})," \
|
||||||
|
"}" \
|
||||||
"#{?session_attached, (attached),}" \
|
"#{?session_attached, (attached),}" \
|
||||||
"}" \
|
"}" \
|
||||||
"}"
|
"}"
|
||||||
@ -91,6 +95,7 @@ struct window_tree_modedata {
|
|||||||
struct mode_tree_data *data;
|
struct mode_tree_data *data;
|
||||||
char *format;
|
char *format;
|
||||||
char *command;
|
char *command;
|
||||||
|
int squash_groups;
|
||||||
|
|
||||||
struct window_tree_itemdata **item_list;
|
struct window_tree_itemdata **item_list;
|
||||||
u_int item_size;
|
u_int item_size;
|
||||||
@ -394,6 +399,7 @@ window_tree_build(void *modedata, u_int sort_type, uint64_t *tag,
|
|||||||
{
|
{
|
||||||
struct window_tree_modedata *data = modedata;
|
struct window_tree_modedata *data = modedata;
|
||||||
struct session *s, **l;
|
struct session *s, **l;
|
||||||
|
struct session_group *sg;
|
||||||
u_int n, i;
|
u_int n, i;
|
||||||
|
|
||||||
for (i = 0; i < data->item_size; i++)
|
for (i = 0; i < data->item_size; i++)
|
||||||
@ -405,6 +411,10 @@ window_tree_build(void *modedata, u_int sort_type, uint64_t *tag,
|
|||||||
l = NULL;
|
l = NULL;
|
||||||
n = 0;
|
n = 0;
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
|
if (data->squash_groups &&
|
||||||
|
(sg = session_group_contains(s)) != NULL &&
|
||||||
|
s != TAILQ_FIRST(&sg->sessions))
|
||||||
|
continue;
|
||||||
l = xreallocarray(l, n + 1, sizeof *l);
|
l = xreallocarray(l, n + 1, sizeof *l);
|
||||||
l[n++] = s;
|
l[n++] = s;
|
||||||
}
|
}
|
||||||
@ -805,6 +815,7 @@ window_tree_init(struct window_pane *wp, struct cmd_find_state *fs,
|
|||||||
data->command = xstrdup(WINDOW_TREE_DEFAULT_COMMAND);
|
data->command = xstrdup(WINDOW_TREE_DEFAULT_COMMAND);
|
||||||
else
|
else
|
||||||
data->command = xstrdup(args->argv[0]);
|
data->command = xstrdup(args->argv[0]);
|
||||||
|
data->squash_groups = !args_has(args, 'G');
|
||||||
|
|
||||||
data->data = mode_tree_start(wp, args, window_tree_build,
|
data->data = mode_tree_start(wp, args, window_tree_build,
|
||||||
window_tree_draw, window_tree_search, data, window_tree_sort_list,
|
window_tree_draw, window_tree_search, data, window_tree_sort_list,
|
||||||
|
Loading…
Reference in New Issue
Block a user