summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2020-01-12 22:01:26 +0000
committerThomas Adam <thomas@xteddy.org>2020-01-12 22:01:26 +0000
commite9b129433121e5d029882981849f6b5547e52153 (patch)
tree1e5d37a7e97ad0d0f391628534a3530b3a3ba590
parent61b075a26342a5ea1b2a351ad659c7198cd23c09 (diff)
parent193e637de050e3757698812e9a87b869c87def6c (diff)
Merge branch 'obsd-master'
-rw-r--r--format.c3
-rw-r--r--tmux.11
-rw-r--r--tmux.h25
-rw-r--r--tty-keys.c44
-rw-r--r--tty-term.c2
-rw-r--r--tty.c23
6 files changed, 27 insertions, 71 deletions
diff --git a/format.c b/format.c
index 08e41271..4fff9a3e 100644
--- a/format.c
+++ b/format.c
@@ -2362,7 +2362,6 @@ 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;
@@ -2380,8 +2379,6 @@ format_defaults_client(struct format_tree *ft, struct client *c)
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);
diff --git a/tmux.1 b/tmux.1
index 1dfafd5c..af264b05 100644
--- a/tmux.1
+++ b/tmux.1
@@ -4232,7 +4232,6 @@ 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 UTF-8"
.It Li "client_width" Ta "" Ta "Width of client"
diff --git a/tmux.h b/tmux.h
index bf9b8cd1..6fd63f40 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1170,7 +1170,9 @@ struct tty_term {
struct tty_code *codes;
#define TERM_256COLOURS 0x1
-#define TERM_EARLYWRAP 0x2
+#define TERM_NOXENL 0x2
+#define TERM_DECSLRM 0x4
+#define TERM_DECFRA 0x8
int flags;
LIST_ENTRY(tty_term) entry;
@@ -1232,16 +1234,6 @@ struct tty {
struct tty_term *term;
char *term_name;
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_y;
@@ -1255,15 +1247,6 @@ struct tty {
struct event key_timer;
struct tty_key *key_tree;
};
-#define TTY_TYPES \
- { "VT100", \
- "VT101", \
- "VT102", \
- "VT220", \
- "VT320", \
- "VT420", \
- "VT520", \
- "Unknown" }
/* TTY command context. */
struct tty_ctx {
@@ -1994,7 +1977,7 @@ void tty_draw_line(struct tty *, struct window_pane *, struct screen *,
int tty_open(struct tty *, char **);
void tty_close(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 *),
struct tty_ctx *);
void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);
diff --git a/tty-keys.c b/tty-keys.c
index 6be40d0e..4644340c 100644
--- a/tty-keys.c
+++ b/tty-keys.c
@@ -1001,11 +1001,10 @@ static int
tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
size_t *size)
{
- struct client *c = tty->client;
- u_int i, n = 0;
- char tmp[64], *endptr, p[32] = { 0 }, *cp, *next;
- static const char *types[] = TTY_TYPES;
- int type;
+ struct client *c = tty->client;
+ u_int i, n = 0;
+ char tmp[64], *endptr, p[32] = { 0 }, *cp, *next;
+ int flags = 0;
*size = 0;
@@ -1038,41 +1037,20 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
cp = tmp;
while ((next = strsep(&cp, ";")) != NULL) {
p[n] = strtoul(next, &endptr, 10);
- if (*endptr != '\0' && *endptr != ';')
+ if (*endptr != '\0')
p[n] = 0;
n++;
}
- /* Store terminal type. */
- type = TTY_UNKNOWN;
+ /* Set terminal flags. */
switch (p[0]) {
- case 1:
- if (p[1] == 2)
- 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;
+ case 64: /* VT420 */
+ flags |= (TERM_DECFRA|TERM_DECSLRM);
break;
}
- for (i = 2; i < n; i++)
+ for (i = 1; i < n; i++)
log_debug("%s: DA feature: %d", c->name, p[i]);
- tty_set_type(tty, type);
-
- log_debug("%s: received DA %.*s (%s)", c->name, (int)*size, buf,
- types[type]);
+ log_debug("%s: received DA %.*s", c->name, (int)*size, buf);
+ tty_set_flags(tty, flags);
return (0);
}
diff --git a/tty-term.c b/tty-term.c
index 3ac9bc6c..085ad933 100644
--- a/tty-term.c
+++ b/tty-term.c
@@ -544,7 +544,7 @@ tty_term_find(char *name, int fd, char **cause)
* do the best possible.
*/
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. */
memset(term->acs, 0, sizeof term->acs);
diff --git a/tty.c b/tty.c
index 2d7acb17..c9843e90 100644
--- a/tty.c
+++ b/tty.c
@@ -74,7 +74,7 @@ static void tty_default_attributes(struct tty *, struct window_pane *,
u_int);
#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) \
((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->flags = 0;
-
tty->term_flags = 0;
- tty->term_type = TTY_UNKNOWN;
return (0);
}
@@ -438,9 +436,9 @@ tty_free(struct tty *tty)
}
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))
tty_puts(tty, "\033[?69h"); /* DECLRMM */
@@ -543,7 +541,7 @@ tty_putc(struct tty *tty, u_char ch)
{
const char *acs;
- if ((tty->term->flags & TERM_EARLYWRAP) &&
+ if ((tty->term->flags & TERM_NOXENL) &&
ch >= 0x20 && ch != 0x7f &&
tty->cy == tty->sy - 1 &&
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
* 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);
} else
tty->cx++;
@@ -579,7 +577,7 @@ tty_putc(struct tty *tty, u_char ch)
void
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->cx + len >= tty->sx)
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
* 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",
py + 1, px + 1, py + ny, px + nx);
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)) {
if (!ctx->wrapped ||
!tty_pane_full_width(tty, ctx) ||
- (tty->term->flags & TERM_EARLYWRAP) ||
+ (tty->term->flags & TERM_NOXENL) ||
ctx->xoff + ctx->ocx != 0 ||
ctx->yoff + ctx->ocy != tty->cy + 1 ||
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;
/* 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->cx == tty->sx - 1)
return;
@@ -2032,7 +2031,7 @@ tty_cursor_pane_unless_wrap(struct tty *tty, const struct tty_ctx *ctx,
{
if (!ctx->wrapped ||
!tty_pane_full_width(tty, ctx) ||
- (tty->term->flags & TERM_EARLYWRAP) ||
+ (tty->term->flags & TERM_NOXENL) ||
ctx->xoff + cx != 0 ||
ctx->yoff + cy != tty->cy + 1 ||
tty->cx < tty->sx ||