Make session_attached a count and add session_many_attached flag.

This commit is contained in:
nicm 2014-03-31 21:37:55 +00:00
parent 9368914ee7
commit b11de5adc7
4 changed files with 8 additions and 5 deletions

View File

@ -401,10 +401,8 @@ format_session(struct format_tree *ft, struct session *s)
*strchr(tim, '\n') = '\0';
format_add(ft, "session_created_string", "%s", tim);
if (s->flags & SESSION_UNATTACHED)
format_add(ft, "session_attached", "%d", 0);
else
format_add(ft, "session_attached", "%d", 1);
format_add(ft, "session_attached", "%u", s->attached);
format_add(ft, "session_many_attached", "%u", s->attached > 1);
}
/* Set default format keys for a client. */

View File

@ -55,6 +55,7 @@ recalculate_sizes(void)
RB_FOREACH(s, sessions, &sessions) {
has_status = options_get_number(&s->options, "status");
s->attached = 0;
ssx = ssy = UINT_MAX;
for (j = 0; j < ARRAY_LENGTH(&clients); j++) {
c = ARRAY_ITEM(&clients, j);
@ -69,6 +70,7 @@ recalculate_sizes(void)
ssy = c->tty.sy - 1;
else if (c->tty.sy < ssy)
ssy = c->tty.sy;
s->attached++;
}
}
if (ssx == UINT_MAX || ssy == UINT_MAX) {

3
tmux.1
View File

@ -3136,13 +3136,14 @@ The following variables are available, where appropriate:
.It Li "saved_cursor_y" Ta "" Ta "Saved cursor Y in pane"
.It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane"
.It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane"
.It Li "session_attached" Ta "" Ta "1 if session attached"
.It Li "session_attached" Ta "" Ta "Number of clients session is attached to"
.It Li "session_created" Ta "" Ta "Integer time session created"
.It Li "session_created_string" Ta "" Ta "String time session created"
.It Li "session_group" Ta "" Ta "Number of session 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_id" Ta "" Ta "Unique session ID"
.It Li "session_many_attached" Ta "" Ta "1 if multiple clients attached"
.It Li "session_name" Ta "#S" Ta "Name of session"
.It Li "session_width" Ta "" Ta "Width of session"
.It Li "session_windows" Ta "" Ta "Number of windows in session"

2
tmux.h
View File

@ -1086,6 +1086,8 @@ struct session {
#define SESSION_UNATTACHED 0x1 /* not attached to any clients */
int flags;
u_int attached;
struct termios *tio;
struct environ environ;