summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-04-20 15:37:33 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-04-20 15:37:33 +0000
commit25e6f945b1f12652c0ca325189ceb2cfe1c184b9 (patch)
tree052251e39b1d50414f153b2c185c544853d748c1
parent2e88a9f22fa4c9b607b4a1864d2724a3d1904c86 (diff)
Apply terminal-overrides after terminal detection, it always takes
precedence.
-rw-r--r--usr.bin/tmux/tmux.h5
-rw-r--r--usr.bin/tmux/tty-features.c9
-rw-r--r--usr.bin/tmux/tty-term.c43
-rw-r--r--usr.bin/tmux/tty.c5
4 files changed, 39 insertions, 23 deletions
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index bd4e6401771..5f96d3ff568 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.1012 2020/04/20 14:59:31 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1013 2020/04/20 15:37:32 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1997,6 +1997,7 @@ void tty_cmd_syncstart(struct tty *, const struct tty_ctx *);
extern struct tty_terms tty_terms;
u_int tty_term_ncodes(void);
void tty_term_apply(struct tty_term *, const char *, int);
+void tty_term_apply_overrides(struct tty_term *);
struct tty_term *tty_term_create(struct tty *, char *, int *, int, char **);
void tty_term_free(struct tty_term *);
int tty_term_has(struct tty_term *, enum tty_code_code);
@@ -2017,7 +2018,7 @@ const char *tty_term_describe(struct tty_term *, enum tty_code_code);
/* tty-features.c */
void tty_add_features(int *, const char *, const char *);
const char *tty_get_features(int);
-void tty_apply_features(struct tty_term *, int);
+int tty_apply_features(struct tty_term *, int);
/* tty-acs.c */
int tty_acs_needed(struct tty *);
diff --git a/usr.bin/tmux/tty-features.c b/usr.bin/tmux/tty-features.c
index 6fa18b22d8e..78ea81c9706 100644
--- a/usr.bin/tmux/tty-features.c
+++ b/usr.bin/tmux/tty-features.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty-features.c,v 1.2 2020/04/20 13:38:48 nicm Exp $ */
+/* $OpenBSD: tty-features.c,v 1.3 2020/04/20 15:37:32 nicm Exp $ */
/*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -232,7 +232,7 @@ tty_get_features(int feat)
return (s);
}
-void
+int
tty_apply_features(struct tty_term *term, int feat)
{
const struct tty_feature *tf;
@@ -240,7 +240,7 @@ tty_apply_features(struct tty_term *term, int feat)
u_int i;
if (feat == 0)
- return;
+ return (0);
log_debug("applying terminal features: %s", tty_get_features(feat));
for (i = 0; i < nitems(tty_features); i++) {
@@ -259,5 +259,8 @@ tty_apply_features(struct tty_term *term, int feat)
}
term->flags |= tf->flags;
}
+ if ((term->features | feat) == term->features)
+ return (0);
term->features |= feat;
+ return (1);
}
diff --git a/usr.bin/tmux/tty-term.c b/usr.bin/tmux/tty-term.c
index 893aca72625..d265605c16e 100644
--- a/usr.bin/tmux/tty-term.c
+++ b/usr.bin/tmux/tty-term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty-term.c,v 1.74 2020/04/20 13:38:48 nicm Exp $ */
+/* $OpenBSD: tty-term.c,v 1.75 2020/04/20 15:37:32 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -410,6 +410,30 @@ tty_term_apply(struct tty_term *term, const char *capabilities, int quiet)
}
}
+void
+tty_term_apply_overrides(struct tty_term *term)
+{
+ struct options_entry *o;
+ struct options_array_item *a;
+ union options_value *ov;
+ const char *s;
+ size_t offset;
+ char *first;
+
+ o = options_get_only(global_options, "terminal-overrides");
+ a = options_array_first(o);
+ while (a != NULL) {
+ ov = options_array_item_value(a);
+ s = ov->string;
+
+ offset = 0;
+ first = tty_term_override_next(s, &offset);
+ if (first != NULL && fnmatch(first, term->name, 0) == 0)
+ tty_term_apply(term, s + offset, 0);
+ a = options_array_next(a);
+ }
+}
+
struct tty_term *
tty_term_create(struct tty *tty, char *name, int *feat, int fd, char **cause)
{
@@ -501,20 +525,6 @@ tty_term_create(struct tty *tty, char *name, int *feat, int fd, char **cause)
a = options_array_next(a);
}
- /* Apply terminal overrides. */
- o = options_get_only(global_options, "terminal-overrides");
- a = options_array_first(o);
- while (a != NULL) {
- ov = options_array_item_value(a);
- s = ov->string;
-
- offset = 0;
- first = tty_term_override_next(s, &offset);
- if (first != NULL && fnmatch(first, term->name, 0) == 0)
- tty_term_apply(term, s + offset, 0);
- a = options_array_next(a);
- }
-
/* Delete curses data. */
del_curterm(cur_term);
@@ -544,8 +554,9 @@ tty_term_create(struct tty *tty, char *name, int *feat, int fd, char **cause)
if (tty_term_flag(term, TTYC_XT))
tty_add_features(feat, "title", ":,");
- /* Apply the features. */
+ /* Apply the features and overrides. */
tty_apply_features(term, *feat);
+ tty_term_apply_overrides(term);
/*
* Terminals without xenl (eat newline glitch) wrap at at $COLUMNS - 1
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index 975435e1a7e..0b7ddc3f4e3 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.361 2020/04/20 14:59:31 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.362 2020/04/20 15:37:32 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -469,7 +469,8 @@ tty_update_features(struct tty *tty)
{
struct client *c = tty->client;
- tty_apply_features(tty->term, c->term_features);
+ if (tty_apply_features(tty->term, c->term_features))
+ tty_term_apply_overrides(tty->term);
if (tty_use_margin(tty))
tty_puts(tty, "\033[?69h"); /* DECLRMM */