summaryrefslogtreecommitdiffstats
path: root/tty-term.c
diff options
context:
space:
mode:
authornicm <nicm>2018-10-18 07:57:57 +0000
committernicm <nicm>2018-10-18 07:57:57 +0000
commitbc0e527f32642cc9eb2354d1bdc033ab6beca33b (patch)
treea6b154e707a0fad14f57ba8940f76cba024e0330 /tty-term.c
parentf7c85f3ed8f151501fb72a1c18a48d126d89c83c (diff)
Support for extended underline styles on terminals which offer them,
enabled by adding the Smulx capability with terminal-overrides (add something like ',vte*:Smulx=\E[4\:%p1%dm'). GitHub issue 1492.
Diffstat (limited to 'tty-term.c')
-rw-r--r--tty-term.c48
1 files changed, 39 insertions, 9 deletions
diff --git a/tty-term.c b/tty-term.c
index b7536487..7df9a7d1 100644
--- a/tty-term.c
+++ b/tty-term.c
@@ -253,6 +253,7 @@ static const struct tty_term_code_entry tty_term_codes[] = {
[TTYC_SMCUP] = { TTYCODE_STRING, "smcup" },
[TTYC_SMKX] = { TTYCODE_STRING, "smkx" },
[TTYC_SMSO] = { TTYCODE_STRING, "smso" },
+ [TTYC_SMULX] = { TTYCODE_STRING, "Smulx" },
[TTYC_SMUL] = { TTYCODE_STRING, "smul" },
[TTYC_SMXX] = { TTYCODE_STRING, "smxx" },
[TTYC_SS] = { TTYCODE_STRING, "Ss" },
@@ -299,25 +300,53 @@ tty_term_strip(const char *s)
return (xstrdup(buf));
}
+static char *
+tty_term_override_next(const char *s, size_t *offset)
+{
+ static char value[BUFSIZ];
+ size_t n = 0, at = *offset;
+
+ if (s[at] == '\0')
+ return (NULL);
+
+ while (s[at] != '\0') {
+ if (s[at] == ':') {
+ if (s[at + 1] == ':') {
+ value[n++] = ':';
+ at += 2;
+ } else
+ break;
+ } else {
+ value[n++] = s[at];
+ at++;
+ }
+ if (n == (sizeof value) - 1)
+ return (NULL);
+ }
+ if (s[at] != '\0')
+ *offset = at + 1;
+ else
+ *offset = at;
+ value[n] = '\0';
+ return (value);
+}
+
static void
tty_term_override(struct tty_term *term, const char *override)
{
const struct tty_term_code_entry *ent;
struct tty_code *code;
- char *next, *s, *copy, *cp, *value;
+ size_t offset = 0;
+ char *cp, *value, *s;
const char *errstr;
u_int i;
int n, remove;
- copy = next = xstrdup(override);
-
- s = strsep(&next, ":");
- if (s == NULL || next == NULL || fnmatch(s, term->name, 0) != 0) {
- free(copy);
+ s = tty_term_override_next(override, &offset);
+ if (s == NULL || fnmatch(s, term->name, 0) != 0)
return;
- }
- while ((s = strsep(&next, ":")) != NULL) {
+ while ((s = tty_term_override_next(override, &offset)) != NULL) {
if (*s == '\0')
continue;
value = NULL;
@@ -338,6 +367,8 @@ tty_term_override(struct tty_term *term, const char *override)
if (remove)
log_debug("%s override: %s@", term->name, s);
+ else if (*value == '\0')
+ log_debug("%s override: %s", term->name, s);
else
log_debug("%s override: %s=%s", term->name, s, value);
@@ -376,7 +407,6 @@ tty_term_override(struct tty_term *term, const char *override)
free(value);
}
- free(s);
}
struct tty_term *