From 7eb496c00c313c2f8ab8debe6d154d5ac0db277b Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 31 May 2017 08:43:44 +0000 Subject: Look for setrgbf and setrgbb terminfo extensions for RGB colour. This is the most reasonable of the various (some bizarre) suggestions for capabilities. --- tty-term.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tty-term.c') diff --git a/tty-term.c b/tty-term.c index d1142ad2..38829bdd 100644 --- a/tty-term.c +++ b/tty-term.c @@ -242,6 +242,8 @@ static const struct tty_term_code_entry tty_term_codes[] = { [TTYC_SE] = { TTYCODE_STRING, "Se" }, [TTYC_SETAB] = { TTYCODE_STRING, "setab" }, [TTYC_SETAF] = { TTYCODE_STRING, "setaf" }, + [TTYC_SETRGBB] = { TTYCODE_STRING, "setrgbb" }, + [TTYC_SETRGBF] = { TTYCODE_STRING, "setrgbf" }, [TTYC_SGR0] = { TTYCODE_STRING, "sgr0" }, [TTYC_SITM] = { TTYCODE_STRING, "sitm" }, [TTYC_SMACS] = { TTYCODE_STRING, "smacs" }, @@ -521,6 +523,18 @@ tty_term_find(char *name, int fd, char **cause) code->type = TTYCODE_STRING; } + /* On terminals with RGB colour (TC), fill in setrgbf and setrgbb. */ + if (tty_term_flag(term, TTYC_TC) && + !tty_term_has(term, TTYC_SETRGBF) && + !tty_term_has(term, TTYC_SETRGBB)) { + code = &term->codes[TTYC_SETRGBF]; + code->value.string = xstrdup("\033[38;2;%p1%d;%p2%d;%p3%dm"); + code->type = TTYCODE_STRING; + code = &term->codes[TTYC_SETRGBB]; + code->value.string = xstrdup("\033[48;2;%p1%d;%p2%d;%p3%dm"); + code->type = TTYCODE_STRING; + } + return (term); error: @@ -576,6 +590,12 @@ tty_term_string2(struct tty_term *term, enum tty_code_code code, int a, int b) return (tparm((char *) tty_term_string(term, code), a, b)); } +const char * +tty_term_string3(struct tty_term *term, enum tty_code_code code, int a, int b, int c) +{ + return (tparm((char *) tty_term_string(term, code), a, b, c)); +} + const char * tty_term_ptr1(struct tty_term *term, enum tty_code_code code, const void *a) { -- cgit