Move terminal features into a single file.

This commit is contained in:
Nicholas Marriott
2020-04-24 06:40:30 +01:00
parent ca13208b6b
commit 8650f44340
6 changed files with 60 additions and 42 deletions

View File

@ -201,7 +201,7 @@ tty_add_features(int *feat, const char *s, const char *separators)
char *next, *loop, *copy;
u_int i;
log_debug("%s: %s", __func__, s);
log_debug("adding terminal features %s", s);
loop = copy = xstrdup(s);
while ((next = strsep(&loop, separators)) != NULL) {
@ -275,3 +275,39 @@ tty_apply_features(struct tty_term *term, int feat)
term->features |= feat;
return (1);
}
void
tty_default_features(int *feat, const char *name, u_int version)
{
static struct {
const char *name;
u_int version;
const char *features;
} table[] = {
{ .name = "mintty",
.features = "256,RGB,ccolour,clipboard,cstyle,margins,overline,title"
},
{ .name = "tmux",
.features = "256,RGB,ccolour,clipboard,cstyle,overline,title,usstyle"
},
{ .name = "rxvt-unicode",
.features = "256,title"
},
{ .name = "iTerm2",
.features = "256,RGB,clipboard,cstyle,margins,sync,title"
},
{ .name = "XTerm",
.features = "256,RGB,ccolour,clipboard,cstyle,margins,rectfill,title"
}
};
u_int i;
for (i = 0; i < nitems(table); i++) {
if (strcmp(table[i].name, name) != 0)
continue;
if (version != 0 && version < table[i].version)
continue;
tty_add_features(feat, table[i].features, ",");
}
}