summaryrefslogtreecommitdiff
path: root/src/colors.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/colors.c')
-rw-r--r--src/colors.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/src/colors.c b/src/colors.c
index 0978c60..973ebf6 100644
--- a/src/colors.c
+++ b/src/colors.c
@@ -560,17 +560,49 @@ ColorParseError parse_color(const char *s, rgbcolor *out){
const char *color_parse_error_message(ColorParseError error){
switch(error){
case COLOR_ERR_FORMAT:
- return "Invaliid color format";
+ return "Invalid color format";
case COLOR_ERR_HEX:
- return "Invaliid hex color code";
+ return "Invalid hex color code";
case COLOR_ERR_RGB:
- return "Invaliid RGB format. Expected format: R,G,B";
+ return "Invalid RGB format. Expected format: R,G,B";
case COLOR_ERR_HSL:
- return "Invaliid HSL format. Expected format: hsl(H,S%,L%)";
- case COLOR_ERR_UNKNOWN_NAME:
- return "Unkown named color";
+ return "Invalid HSL format. Expected format: hsl(H,S%,L%)";
case COLOR_OK:
default:
return "";
}
+}
+static const char *color_mode_name(color_mode mode){
+ switch(mode){
+ case MODE_TRUECOLOR: return "Truecolor";
+ case MODE_ANSI256: return "Ansi256";
+ case MODE_ANSI16: return "Ansi16";
+ case MODE_NONE:
+ default: return "NoColor";
+ }
+}
+
+static void print_env_debug(const char *name){
+ const char *value = getenv(name);
+ if(value)
+ printf("%s: Some(\"%s\")\n", name, value);
+ else
+ printf("%s: None\n", name);
+}
+
+void print_color_debug(const colorconfig *config, bool ansi_enabled){
+ printf("Detected color mode: %s\n", color_mode_name(config->mode));
+ printf("ANSI enabled: %s\n", ansi_enabled ? "true" : "false");
+ print_env_debug("NO_COLOR");
+ print_env_debug("COLORTERM");
+ print_env_debug("TERM");
+#ifdef _WIN32
+ {
+ const char *shell = detect_windows_shell();
+ if(shell)
+ printf("Windows shell hint: Some(\"%s\")\n", shell);
+ else
+ printf("Windows shell hint: None\n");
+ }
+#endif
}