diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-01-11 16:09:58 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-01-11 16:09:58 +0000 |
commit | a5936f0f8c862939f7dde572e6e3321e80ed2895 (patch) | |
tree | 6bf15cdef33b66035f4d23e2c955f3098974d940 /usr.bin | |
parent | 27f24acc698a0b313bd5b506cf71fc541163e526 (diff) |
Add a format for terminal type.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/format.c | 21 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 5 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 7 | ||||
-rw-r--r-- | usr.bin/tmux/tty.c | 10 |
4 files changed, 24 insertions, 19 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index a8b39ae3713..1f025c87666 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.114 2017/01/09 21:03:25 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.115 2017/01/11 16:09:57 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1119,20 +1119,25 @@ format_defaults_client(struct format_tree *ft, struct client *c) { struct session *s; const char *name; + struct tty *tty = &c->tty; + const char *types[] = TTY_TYPES; if (ft->s == NULL) ft->s = c->session; format_add(ft, "client_pid", "%ld", (long) c->pid); - format_add(ft, "client_height", "%u", c->tty.sy); - format_add(ft, "client_width", "%u", c->tty.sx); - if (c->tty.path != NULL) - format_add(ft, "client_tty", "%s", c->tty.path); - if (c->tty.termname != NULL) - format_add(ft, "client_termname", "%s", c->tty.termname); + format_add(ft, "client_height", "%u", tty->sy); + format_add(ft, "client_width", "%u", tty->sx); + if (tty->path != NULL) + format_add(ft, "client_tty", "%s", tty->path); format_add(ft, "client_control_mode", "%d", !!(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_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_key_table", "%s", c->keytable->name); - if (c->tty.flags & TTY_UTF8) + if (tty->flags & TTY_UTF8) format_add(ft, "client_utf8", "%d", 1); else format_add(ft, "client_utf8", "%d", 0); diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index debfcc769b9..6f951e11c3e 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.523 2017/01/10 10:08:59 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.524 2017/01/11 16:09:57 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 10 2017 $ +.Dd $Mdocdate: January 11 2017 $ .Dt TMUX 1 .Os .Sh NAME @@ -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_session" Ta "" Ta "Name of the client's session" .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_utf8" Ta "" Ta "1 if client supports utf8" .It Li "client_width" Ta "" Ta "Width of client" diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 754f2c7aaf4..d514e7f10b8 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.689 2017/01/11 16:05:46 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.690 2017/01/11 16:09:57 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1112,9 +1112,6 @@ struct tty { u_int rleft; u_int rright; - char *termname; - struct tty_term *term; - int fd; struct bufferevent *event; @@ -1131,6 +1128,8 @@ struct tty { #define TTY_FOCUS 0x40 int flags; + struct tty_term *term; + char *term_name; int term_flags; enum { TTY_VT100, diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index e12f0e4fce7..5c10d3beaeb 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.219 2017/01/07 15:28:13 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.220 2017/01/11 16:09:57 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -105,9 +105,9 @@ tty_init(struct tty *tty, struct client *c, int fd, char *term) memset(tty, 0, sizeof *tty); if (term == NULL || *term == '\0') - tty->termname = xstrdup("unknown"); + tty->term_name = xstrdup("unknown"); else - tty->termname = xstrdup(term); + tty->term_name = xstrdup(term); tty->fd = fd; tty->client = c; @@ -177,7 +177,7 @@ tty_set_size(struct tty *tty, u_int sx, u_int sy) int 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) { tty_close(tty); return (-1); @@ -364,7 +364,7 @@ tty_free(struct tty *tty) free(tty->ccolour); free(tty->path); - free(tty->termname); + free(tty->term_name); } void |