From 197a116f5a2146309c4c6fecbd9d08d36f2be750 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 25 Oct 2021 21:21:16 +0000 Subject: Add a way to force a colour to RGB and a format to display it. --- colour.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'colour.c') diff --git a/colour.c b/colour.c index 9ac07415..92bbd71e 100644 --- a/colour.c +++ b/colour.c @@ -105,6 +105,21 @@ colour_split_rgb(int c, u_char *r, u_char *g, u_char *b) *b = c & 0xff; } +/* Force colour to RGB if not already. */ +int +colour_force_rgb(int c) +{ + if (c & COLOUR_FLAG_RGB) + return (c); + if (c & COLOUR_FLAG_256) + return (colour_256toRGB(c)); + if (c >= 0 && c <= 7) + return (colour_256toRGB(c)); + if (c >= 90 & c <= 97) + return (colour_256toRGB(8 + c - 90)); + return (-1); +} + /* Convert colour to a string. */ const char * colour_tostring(int c) -- cgit From 4fe5aa99fb203ddb25089955d8814e1065e11a60 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 1 Nov 2021 07:48:04 +0000 Subject: Fix a comparison, from Ben Boeckel, and a crash when opening completion menu, from Anindya Mukherjee. --- colour.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'colour.c') diff --git a/colour.c b/colour.c index 92bbd71e..6ede25da 100644 --- a/colour.c +++ b/colour.c @@ -115,7 +115,7 @@ colour_force_rgb(int c) return (colour_256toRGB(c)); if (c >= 0 && c <= 7) return (colour_256toRGB(c)); - if (c >= 90 & c <= 97) + if (c >= 90 && c <= 97) return (colour_256toRGB(8 + c - 90)); return (-1); } -- cgit From 938130bc6925808681cbc003a392ccce2a4455c1 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 24 Mar 2022 12:07:25 +0000 Subject: Add unit (milliseconds) to escape-time, show unset colours as "none" rather than "invalid" and don't show the same text twice for user options in customize mode. --- colour.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'colour.c') diff --git a/colour.c b/colour.c index 6ede25da..a282d182 100644 --- a/colour.c +++ b/colour.c @@ -128,7 +128,7 @@ colour_tostring(int c) u_char r, g, b; if (c == -1) - return ("invalid"); + return ("none"); if (c & COLOUR_FLAG_RGB) { colour_split_rgb(c, &r, &g, &b); -- cgit