aboutsummaryrefslogtreecommitdiffhomepage
path: root/output.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-09-19 15:37:31 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-09-19 18:45:04 -0700
commit555ff00a30b70cb84a767b60e3a5c7015815feae (patch)
treeac196a147b942c345fa5ebd802ca5add774b8139 /output.cpp
parent6083c6fc725727ebb25c209931a38504f9269c5c (diff)
Initial work to support for term-24bit ("true color")
Diffstat (limited to 'output.cpp')
-rw-r--r--output.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/output.cpp b/output.cpp
index 149d9d99..3a33ba7f 100644
--- a/output.cpp
+++ b/output.cpp
@@ -107,8 +107,8 @@ static int (*out)(char c) = &writeb_internal;
*/
static wcstring current_term;
-/* Whether term256 is supported */
-static bool support_term256 = false;
+/* Whether term256 and term24bit are supported */
+static color_support_t color_support = 0;
void output_set_writer(int (*writer)(char))
@@ -125,22 +125,22 @@ int (*output_get_writer())(char)
static bool term256_support_is_native(void)
{
/* Return YES if we think the term256 support is "native" as opposed to forced. */
- return max_colors == 256;
+ return max_colors >= 256;
}
-bool output_get_supports_term256(void)
+color_support_t output_get_color_support(void)
{
- return support_term256;
+ return color_support;
}
-void output_set_supports_term256(bool val)
+void output_set_color_support(color_support_t val)
{
- support_term256 = val;
+ color_support = val;
}
unsigned char index_for_color(rgb_color_t c)
{
- if (c.is_named() || ! output_get_supports_term256())
+ if (c.is_named() || ! (output_get_color_support() & color_support_term256))
{
return c.to_name_index();
}
@@ -686,7 +686,8 @@ rgb_color_t parse_color(const wcstring &val, bool is_background)
// If we have both RGB and named colors, then prefer rgb if term256 is supported
rgb_color_t result;
- if ((!first_rgb.is_none() && output_get_supports_term256()) || first_named.is_none())
+ bool has_term256 = !! (output_get_color_support() & color_support_term256);
+ if ((!first_rgb.is_none() && has_term256) || first_named.is_none())
{
result = first_rgb;
}