mirror of
https://github.com/tmux/tmux.git
synced 2024-12-12 17:38:48 +00:00
Add a format for terminal type.
This commit is contained in:
parent
7497ecd979
commit
bf6a5c056d
19
format.c
19
format.c
@ -1119,20 +1119,25 @@ format_defaults_client(struct format_tree *ft, struct client *c)
|
|||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
struct tty *tty = &c->tty;
|
||||||
|
const char *types[] = TTY_TYPES;
|
||||||
|
|
||||||
if (ft->s == NULL)
|
if (ft->s == NULL)
|
||||||
ft->s = c->session;
|
ft->s = c->session;
|
||||||
|
|
||||||
format_add(ft, "client_pid", "%ld", (long) c->pid);
|
format_add(ft, "client_pid", "%ld", (long) c->pid);
|
||||||
format_add(ft, "client_height", "%u", c->tty.sy);
|
format_add(ft, "client_height", "%u", tty->sy);
|
||||||
format_add(ft, "client_width", "%u", c->tty.sx);
|
format_add(ft, "client_width", "%u", tty->sx);
|
||||||
if (c->tty.path != NULL)
|
if (tty->path != NULL)
|
||||||
format_add(ft, "client_tty", "%s", c->tty.path);
|
format_add(ft, "client_tty", "%s", tty->path);
|
||||||
if (c->tty.termname != NULL)
|
|
||||||
format_add(ft, "client_termname", "%s", c->tty.termname);
|
|
||||||
format_add(ft, "client_control_mode", "%d",
|
format_add(ft, "client_control_mode", "%d",
|
||||||
!!(c->flags & CLIENT_CONTROL));
|
!!(c->flags & CLIENT_CONTROL));
|
||||||
|
|
||||||
|
if (tty->term_name != NULL)
|
||||||
|
format_add(ft, "client_termname", "%s", tty->term_name);
|
||||||
|
if (tty->term_name != NULL)
|
||||||
|
format_add(ft, "client_termtype", "%s", types[tty->term_type]);
|
||||||
|
|
||||||
format_add_tv(ft, "client_created", &c->creation_time);
|
format_add_tv(ft, "client_created", &c->creation_time);
|
||||||
format_add_tv(ft, "client_activity", &c->activity_time);
|
format_add_tv(ft, "client_activity", &c->activity_time);
|
||||||
|
|
||||||
@ -1143,7 +1148,7 @@ format_defaults_client(struct format_tree *ft, struct client *c)
|
|||||||
format_add(ft, "client_prefix", "%d", 1);
|
format_add(ft, "client_prefix", "%d", 1);
|
||||||
format_add(ft, "client_key_table", "%s", c->keytable->name);
|
format_add(ft, "client_key_table", "%s", c->keytable->name);
|
||||||
|
|
||||||
if (c->tty.flags & TTY_UTF8)
|
if (tty->flags & TTY_UTF8)
|
||||||
format_add(ft, "client_utf8", "%d", 1);
|
format_add(ft, "client_utf8", "%d", 1);
|
||||||
else
|
else
|
||||||
format_add(ft, "client_utf8", "%d", 0);
|
format_add(ft, "client_utf8", "%d", 0);
|
||||||
|
1
tmux.1
1
tmux.1
@ -3512,6 +3512,7 @@ The following variables are available, where appropriate:
|
|||||||
.It Li "client_readonly" Ta "" Ta "1 if client is readonly"
|
.It Li "client_readonly" Ta "" Ta "1 if client is readonly"
|
||||||
.It Li "client_session" Ta "" Ta "Name of the client's session"
|
.It Li "client_session" Ta "" Ta "Name of the client's session"
|
||||||
.It Li "client_termname" Ta "" Ta "Terminal name of client"
|
.It Li "client_termname" Ta "" Ta "Terminal name of client"
|
||||||
|
.It Li "client_termtype" Ta "" Ta "Terminal type of client"
|
||||||
.It Li "client_tty" Ta "" Ta "Pseudo terminal of client"
|
.It Li "client_tty" Ta "" Ta "Pseudo terminal of client"
|
||||||
.It Li "client_utf8" Ta "" Ta "1 if client supports utf8"
|
.It Li "client_utf8" Ta "" Ta "1 if client supports utf8"
|
||||||
.It Li "client_width" Ta "" Ta "Width of client"
|
.It Li "client_width" Ta "" Ta "Width of client"
|
||||||
|
5
tmux.h
5
tmux.h
@ -1112,9 +1112,6 @@ struct tty {
|
|||||||
u_int rleft;
|
u_int rleft;
|
||||||
u_int rright;
|
u_int rright;
|
||||||
|
|
||||||
char *termname;
|
|
||||||
struct tty_term *term;
|
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
struct bufferevent *event;
|
struct bufferevent *event;
|
||||||
|
|
||||||
@ -1131,6 +1128,8 @@ struct tty {
|
|||||||
#define TTY_FOCUS 0x40
|
#define TTY_FOCUS 0x40
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
|
struct tty_term *term;
|
||||||
|
char *term_name;
|
||||||
int term_flags;
|
int term_flags;
|
||||||
enum {
|
enum {
|
||||||
TTY_VT100,
|
TTY_VT100,
|
||||||
|
8
tty.c
8
tty.c
@ -105,9 +105,9 @@ tty_init(struct tty *tty, struct client *c, int fd, char *term)
|
|||||||
memset(tty, 0, sizeof *tty);
|
memset(tty, 0, sizeof *tty);
|
||||||
|
|
||||||
if (term == NULL || *term == '\0')
|
if (term == NULL || *term == '\0')
|
||||||
tty->termname = xstrdup("unknown");
|
tty->term_name = xstrdup("unknown");
|
||||||
else
|
else
|
||||||
tty->termname = xstrdup(term);
|
tty->term_name = xstrdup(term);
|
||||||
tty->fd = fd;
|
tty->fd = fd;
|
||||||
tty->client = c;
|
tty->client = c;
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ tty_set_size(struct tty *tty, u_int sx, u_int sy)
|
|||||||
int
|
int
|
||||||
tty_open(struct tty *tty, char **cause)
|
tty_open(struct tty *tty, char **cause)
|
||||||
{
|
{
|
||||||
tty->term = tty_term_find(tty->termname, tty->fd, cause);
|
tty->term = tty_term_find(tty->term_name, tty->fd, cause);
|
||||||
if (tty->term == NULL) {
|
if (tty->term == NULL) {
|
||||||
tty_close(tty);
|
tty_close(tty);
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -364,7 +364,7 @@ tty_free(struct tty *tty)
|
|||||||
|
|
||||||
free(tty->ccolour);
|
free(tty->ccolour);
|
||||||
free(tty->path);
|
free(tty->path);
|
||||||
free(tty->termname);
|
free(tty->term_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user