The terminal type was never as much use as I expected so remove it in

favour of a couple of flags for the features used (DECSLRM and DECFRA).
Also rename the flag for no xenl to be more obvious while here.
pull/2067/head
nicm 2020-01-12 21:07:07 +00:00
parent deb734c7f6
commit 193e637de0
6 changed files with 25 additions and 69 deletions

View File

@ -2346,7 +2346,6 @@ 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; 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;
@ -2364,8 +2363,6 @@ format_defaults_client(struct format_tree *ft, struct client *c)
if (tty->term_name != NULL) if (tty->term_name != NULL)
format_add(ft, "client_termname", "%s", tty->term_name); 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);

1
tmux.1
View File

@ -4227,7 +4227,6 @@ 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 UTF-8" .It Li "client_utf8" Ta "" Ta "1 if client supports UTF-8"
.It Li "client_width" Ta "" Ta "Width of client" .It Li "client_width" Ta "" Ta "Width of client"

25
tmux.h
View File

@ -1168,7 +1168,9 @@ struct tty_term {
struct tty_code *codes; struct tty_code *codes;
#define TERM_256COLOURS 0x1 #define TERM_256COLOURS 0x1
#define TERM_EARLYWRAP 0x2 #define TERM_NOXENL 0x2
#define TERM_DECSLRM 0x4
#define TERM_DECFRA 0x8
int flags; int flags;
LIST_ENTRY(tty_term) entry; LIST_ENTRY(tty_term) entry;
@ -1230,16 +1232,6 @@ struct tty {
struct tty_term *term; struct tty_term *term;
char *term_name; char *term_name;
int term_flags; int term_flags;
enum {
TTY_VT100,
TTY_VT101,
TTY_VT102,
TTY_VT220,
TTY_VT320,
TTY_VT420,
TTY_VT520,
TTY_UNKNOWN
} term_type;
u_int mouse_last_x; u_int mouse_last_x;
u_int mouse_last_y; u_int mouse_last_y;
@ -1253,15 +1245,6 @@ struct tty {
struct event key_timer; struct event key_timer;
struct tty_key *key_tree; struct tty_key *key_tree;
}; };
#define TTY_TYPES \
{ "VT100", \
"VT101", \
"VT102", \
"VT220", \
"VT320", \
"VT420", \
"VT520", \
"Unknown" }
/* TTY command context. */ /* TTY command context. */
struct tty_ctx { struct tty_ctx {
@ -1992,7 +1975,7 @@ void tty_draw_line(struct tty *, struct window_pane *, struct screen *,
int tty_open(struct tty *, char **); int tty_open(struct tty *, char **);
void tty_close(struct tty *); void tty_close(struct tty *);
void tty_free(struct tty *); void tty_free(struct tty *);
void tty_set_type(struct tty *, int); void tty_set_flags(struct tty *, int);
void tty_write(void (*)(struct tty *, const struct tty_ctx *), void tty_write(void (*)(struct tty *, const struct tty_ctx *),
struct tty_ctx *); struct tty_ctx *);
void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *); void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);

View File

@ -1001,11 +1001,10 @@ static int
tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len, tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
size_t *size) size_t *size)
{ {
struct client *c = tty->client; struct client *c = tty->client;
u_int i, n = 0; u_int i, n = 0;
char tmp[64], *endptr, p[32] = { 0 }, *cp, *next; char tmp[64], *endptr, p[32] = { 0 }, *cp, *next;
static const char *types[] = TTY_TYPES; int flags = 0;
int type;
*size = 0; *size = 0;
@ -1043,36 +1042,15 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
n++; n++;
} }
/* Store terminal type. */ /* Set terminal flags. */
type = TTY_UNKNOWN;
switch (p[0]) { switch (p[0]) {
case 1: case 64: /* VT420 */
if (p[1] == 2) flags |= (TERM_DECFRA|TERM_DECSLRM);
type = TTY_VT100;
else if (p[1] == 0)
type = TTY_VT101;
break;
case 6:
type = TTY_VT102;
break;
case 62:
type = TTY_VT220;
break;
case 63:
type = TTY_VT320;
break;
case 64:
type = TTY_VT420;
break;
case 65:
type = TTY_VT520;
break; break;
} }
for (i = 1; i < n; i++) for (i = 1; i < n; i++)
log_debug("%s: DA feature: %d", c->name, p[i]); log_debug("%s: DA feature: %d", c->name, p[i]);
tty_set_type(tty, type); log_debug("%s: received DA %.*s", c->name, (int)*size, buf);
tty_set_flags(tty, flags);
log_debug("%s: received DA %.*s (%s)", c->name, (int)*size, buf,
types[type]);
return (0); return (0);
} }

View File

@ -538,7 +538,7 @@ tty_term_find(char *name, int fd, char **cause)
* do the best possible. * do the best possible.
*/ */
if (!tty_term_flag(term, TTYC_XENL)) if (!tty_term_flag(term, TTYC_XENL))
term->flags |= TERM_EARLYWRAP; term->flags |= TERM_NOXENL;
/* Generate ACS table. If none is present, use nearest ASCII. */ /* Generate ACS table. If none is present, use nearest ASCII. */
memset(term->acs, 0, sizeof term->acs); memset(term->acs, 0, sizeof term->acs);

23
tty.c
View File

@ -74,7 +74,7 @@ static void tty_default_attributes(struct tty *, struct window_pane *,
u_int); u_int);
#define tty_use_margin(tty) \ #define tty_use_margin(tty) \
((tty)->term_type == TTY_VT420) ((tty->term->flags|tty->term_flags) & TERM_DECSLRM)
#define tty_pane_full_width(tty, ctx) \ #define tty_pane_full_width(tty, ctx) \
((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx) ((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx)
@ -115,9 +115,7 @@ tty_init(struct tty *tty, struct client *c, int fd, char *term)
tty->ccolour = xstrdup(""); tty->ccolour = xstrdup("");
tty->flags = 0; tty->flags = 0;
tty->term_flags = 0; tty->term_flags = 0;
tty->term_type = TTY_UNKNOWN;
return (0); return (0);
} }
@ -438,9 +436,9 @@ tty_free(struct tty *tty)
} }
void void
tty_set_type(struct tty *tty, int type) tty_set_flags(struct tty *tty, int flags)
{ {
tty->term_type = type; tty->term_flags |= flags;
if (tty_use_margin(tty)) if (tty_use_margin(tty))
tty_puts(tty, "\033[?69h"); /* DECLRMM */ tty_puts(tty, "\033[?69h"); /* DECLRMM */
@ -543,7 +541,7 @@ tty_putc(struct tty *tty, u_char ch)
{ {
const char *acs; const char *acs;
if ((tty->term->flags & TERM_EARLYWRAP) && if ((tty->term->flags & TERM_NOXENL) &&
ch >= 0x20 && ch != 0x7f && ch >= 0x20 && ch != 0x7f &&
tty->cy == tty->sy - 1 && tty->cy == tty->sy - 1 &&
tty->cx + 1 >= tty->sx) tty->cx + 1 >= tty->sx)
@ -569,7 +567,7 @@ tty_putc(struct tty *tty, u_char ch)
* where we think it should be after a line wrap - this * where we think it should be after a line wrap - this
* means it works on sensible terminals as well. * means it works on sensible terminals as well.
*/ */
if (tty->term->flags & TERM_EARLYWRAP) if (tty->term->flags & TERM_NOXENL)
tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx); tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx);
} else } else
tty->cx++; tty->cx++;
@ -579,7 +577,7 @@ tty_putc(struct tty *tty, u_char ch)
void void
tty_putn(struct tty *tty, const void *buf, size_t len, u_int width) tty_putn(struct tty *tty, const void *buf, size_t len, u_int width)
{ {
if ((tty->term->flags & TERM_EARLYWRAP) && if ((tty->term->flags & TERM_NOXENL) &&
tty->cy == tty->sy - 1 && tty->cy == tty->sy - 1 &&
tty->cx + len >= tty->sx) tty->cx + len >= tty->sx)
len = tty->sx - tty->cx - 1; len = tty->sx - tty->cx - 1;
@ -1129,7 +1127,8 @@ tty_clear_area(struct tty *tty, struct window_pane *wp, u_int py, u_int ny,
* background colour isn't default (because it doesn't work * background colour isn't default (because it doesn't work
* after SGR 0). * after SGR 0).
*/ */
if (tty->term_type == TTY_VT420 && !COLOUR_DEFAULT(bg)) { if (((tty->term->flags|tty->term_flags) & TERM_DECFRA) &&
!COLOUR_DEFAULT(bg)) {
xsnprintf(tmp, sizeof tmp, "\033[32;%u;%u;%u;%u$x", xsnprintf(tmp, sizeof tmp, "\033[32;%u;%u;%u;%u$x",
py + 1, px + 1, py + ny, px + nx); py + 1, px + 1, py + ny, px + nx);
tty_puts(tty, tmp); tty_puts(tty, tmp);
@ -1824,7 +1823,7 @@ tty_cmd_cells(struct tty *tty, const struct tty_ctx *ctx)
ctx->xoff + ctx->ocx + ctx->num > ctx->ox + ctx->sx)) { ctx->xoff + ctx->ocx + ctx->num > ctx->ox + ctx->sx)) {
if (!ctx->wrapped || if (!ctx->wrapped ||
!tty_pane_full_width(tty, ctx) || !tty_pane_full_width(tty, ctx) ||
(tty->term->flags & TERM_EARLYWRAP) || (tty->term->flags & TERM_NOXENL) ||
ctx->xoff + ctx->ocx != 0 || ctx->xoff + ctx->ocx != 0 ||
ctx->yoff + ctx->ocy != tty->cy + 1 || ctx->yoff + ctx->ocy != tty->cy + 1 ||
tty->cx < tty->sx || tty->cx < tty->sx ||
@ -1873,7 +1872,7 @@ tty_cell(struct tty *tty, const struct grid_cell *gc, struct window_pane *wp)
const struct grid_cell *gcp; const struct grid_cell *gcp;
/* Skip last character if terminal is stupid. */ /* Skip last character if terminal is stupid. */
if ((tty->term->flags & TERM_EARLYWRAP) && if ((tty->term->flags & TERM_NOXENL) &&
tty->cy == tty->sy - 1 && tty->cy == tty->sy - 1 &&
tty->cx == tty->sx - 1) tty->cx == tty->sx - 1)
return; return;
@ -2032,7 +2031,7 @@ tty_cursor_pane_unless_wrap(struct tty *tty, const struct tty_ctx *ctx,
{ {
if (!ctx->wrapped || if (!ctx->wrapped ||
!tty_pane_full_width(tty, ctx) || !tty_pane_full_width(tty, ctx) ||
(tty->term->flags & TERM_EARLYWRAP) || (tty->term->flags & TERM_NOXENL) ||
ctx->xoff + cx != 0 || ctx->xoff + cx != 0 ||
ctx->yoff + cy != tty->cy + 1 || ctx->yoff + cy != tty->cy + 1 ||
tty->cx < tty->sx || tty->cx < tty->sx ||