mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-27 02:23:15 +01:00
Add a helper function to convert time, and add session_activity formats
(the latter from Takatoshi Matsumoto).
This commit is contained in:
parent
02df86079b
commit
3aa72b42b2
33
format.c
33
format.c
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
int format_replace(struct format_tree *, const char *, size_t, char **,
|
int format_replace(struct format_tree *, const char *, size_t, char **,
|
||||||
size_t *, size_t *);
|
size_t *, size_t *);
|
||||||
|
char *format_time_string(time_t);
|
||||||
char *format_get_command(struct window_pane *);
|
char *format_get_command(struct window_pane *);
|
||||||
|
|
||||||
void format_defaults_pane_tabs(struct format_tree *, struct window_pane *);
|
void format_defaults_pane_tabs(struct format_tree *, struct window_pane *);
|
||||||
@ -453,6 +454,18 @@ format_get_command(struct window_pane *wp)
|
|||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get time as a string. */
|
||||||
|
char *
|
||||||
|
format_time_string(time_t t)
|
||||||
|
{
|
||||||
|
char *tim;
|
||||||
|
|
||||||
|
tim = ctime(&t);
|
||||||
|
*strchr(tim, '\n') = '\0';
|
||||||
|
|
||||||
|
return (tim);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set defaults for any of arguments that are not NULL. */
|
/* Set defaults for any of arguments that are not NULL. */
|
||||||
void
|
void
|
||||||
format_defaults(struct format_tree *ft, struct client *c, struct session *s,
|
format_defaults(struct format_tree *ft, struct client *c, struct session *s,
|
||||||
@ -480,7 +493,6 @@ void
|
|||||||
format_defaults_session(struct format_tree *ft, struct session *s)
|
format_defaults_session(struct format_tree *ft, struct session *s)
|
||||||
{
|
{
|
||||||
struct session_group *sg;
|
struct session_group *sg;
|
||||||
char *tim;
|
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
ft->s = s;
|
ft->s = s;
|
||||||
@ -498,9 +510,11 @@ format_defaults_session(struct format_tree *ft, struct session *s)
|
|||||||
|
|
||||||
t = s->creation_time.tv_sec;
|
t = s->creation_time.tv_sec;
|
||||||
format_add(ft, "session_created", "%lld", (long long) t);
|
format_add(ft, "session_created", "%lld", (long long) t);
|
||||||
tim = ctime(&t);
|
format_add(ft, "session_created_string", "%s", format_time_string(t));
|
||||||
*strchr(tim, '\n') = '\0';
|
|
||||||
format_add(ft, "session_created_string", "%s", tim);
|
t = s->activity_time.tv_sec;
|
||||||
|
format_add(ft, "session_activity", "%lld", (long long) t);
|
||||||
|
format_add(ft, "session_activity_string", "%s", format_time_string(t));
|
||||||
|
|
||||||
format_add(ft, "session_attached", "%u", s->attached);
|
format_add(ft, "session_attached", "%u", s->attached);
|
||||||
format_add(ft, "session_many_attached", "%d", s->attached > 1);
|
format_add(ft, "session_many_attached", "%d", s->attached > 1);
|
||||||
@ -510,9 +524,8 @@ format_defaults_session(struct format_tree *ft, struct session *s)
|
|||||||
void
|
void
|
||||||
format_defaults_client(struct format_tree *ft, struct client *c)
|
format_defaults_client(struct format_tree *ft, struct client *c)
|
||||||
{
|
{
|
||||||
char *tim;
|
|
||||||
time_t t;
|
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
time_t t;
|
||||||
|
|
||||||
if (ft->s == NULL)
|
if (ft->s == NULL)
|
||||||
ft->s = c->session;
|
ft->s = c->session;
|
||||||
@ -526,15 +539,11 @@ format_defaults_client(struct format_tree *ft, struct client *c)
|
|||||||
|
|
||||||
t = c->creation_time.tv_sec;
|
t = c->creation_time.tv_sec;
|
||||||
format_add(ft, "client_created", "%lld", (long long) t);
|
format_add(ft, "client_created", "%lld", (long long) t);
|
||||||
tim = ctime(&t);
|
format_add(ft, "client_created_string", "%s", format_time_string(t));
|
||||||
*strchr(tim, '\n') = '\0';
|
|
||||||
format_add(ft, "client_created_string", "%s", tim);
|
|
||||||
|
|
||||||
t = c->activity_time.tv_sec;
|
t = c->activity_time.tv_sec;
|
||||||
format_add(ft, "client_activity", "%lld", (long long) t);
|
format_add(ft, "client_activity", "%lld", (long long) t);
|
||||||
tim = ctime(&t);
|
format_add(ft, "client_activity_string", "%s", format_time_string(t));
|
||||||
*strchr(tim, '\n') = '\0';
|
|
||||||
format_add(ft, "client_activity_string", "%s", tim);
|
|
||||||
|
|
||||||
format_add(ft, "client_prefix", "%d", !!(c->flags & CLIENT_PREFIX));
|
format_add(ft, "client_prefix", "%d", !!(c->flags & CLIENT_PREFIX));
|
||||||
|
|
||||||
|
2
tmux.1
2
tmux.1
@ -3148,6 +3148,8 @@ The following variables are available, where appropriate:
|
|||||||
.It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region 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 "scroll_region_upper" Ta "" Ta "Top of scroll region in pane"
|
||||||
.It Li "session_attached" Ta "" Ta "Number of clients session is attached to"
|
.It Li "session_attached" Ta "" Ta "Number of clients session is attached to"
|
||||||
|
.It Li "session_activity" Ta "" Ta "Integer time of session last activity"
|
||||||
|
.It Li "session_activity_string" Ta "" Ta "String time of session last activity"
|
||||||
.It Li "session_created" Ta "" Ta "Integer time session created"
|
.It Li "session_created" Ta "" Ta "Integer time session created"
|
||||||
.It Li "session_created_string" Ta "" Ta "String 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_group" Ta "" Ta "Number of session group"
|
||||||
|
Loading…
Reference in New Issue
Block a user