aboutsummaryrefslogtreecommitdiff
path: root/colour.c
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-07-21 15:53:59 -0600
committerJosh Rahm <rahm@google.com>2022-07-21 15:53:59 -0600
commitb11548e3db4361cd8312ffbd27472823bdab4d62 (patch)
treea84b5cf79fb41bb60b6495c1a346bb360b224604 /colour.c
parent88ebf5544e995d85b2f1416a216ac7f44f719eed (diff)
parentab1d18d00febe161080b8e81331861481110809f (diff)
downloadrtmux-b11548e3db4361cd8312ffbd27472823bdab4d62.tar.gz
rtmux-b11548e3db4361cd8312ffbd27472823bdab4d62.tar.bz2
rtmux-b11548e3db4361cd8312ffbd27472823bdab4d62.zip
Merge remote-tracking branch 'origin/master' into rahm
Diffstat (limited to 'colour.c')
-rw-r--r--colour.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/colour.c b/colour.c
index 9ac07415..a282d182 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)
@@ -113,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);