From ef2b18f1bf2c4d0c9ac6a778ffffce3d6cf7b96f Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Tue, 5 Mar 2024 22:07:37 +0900 Subject: [PATCH] Allow themes to be disabled in rline This still outputs ANSI color escapes, they're just always for color 9, which is the default color for the foreground or background. rline will always output escapes, as it's fundamentally part of how it works. If you don't want ANSI escapes, disable rline. --- src/vendor/rline.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/vendor/rline.c b/src/vendor/rline.c index 535c743..c28419e 100644 --- a/src/vendor/rline.c +++ b/src/vendor/rline.c @@ -363,19 +363,19 @@ static void recalculate_tabs(line_t * line) { */ static const char * COLOR_FG = "@9"; static const char * COLOR_BG = "@9"; -static const char * COLOR_ALT_FG = "@5"; +static const char * COLOR_ALT_FG = "@9"; static const char * COLOR_ALT_BG = "@9"; -static const char * COLOR_KEYWORD = "@4"; -static const char * COLOR_STRING = "@2"; -static const char * COLOR_COMMENT = "@5"; -static const char * COLOR_TYPE = "@3"; -static const char * COLOR_PRAGMA = "@1"; -static const char * COLOR_NUMERAL = "@1"; -static const char * COLOR_RED = "@1"; -static const char * COLOR_GREEN = "@2"; -static const char * COLOR_ESCAPE = "@2"; -static const char * COLOR_SEARCH_FG = "@0"; -static const char * COLOR_SEARCH_BG = "@3"; +static const char * COLOR_KEYWORD = "@9"; +static const char * COLOR_STRING = "@9"; +static const char * COLOR_COMMENT = "@9"; +static const char * COLOR_TYPE = "@9"; +static const char * COLOR_PRAGMA = "@9"; +static const char * COLOR_NUMERAL = "@9"; +static const char * COLOR_RED = "@9"; +static const char * COLOR_GREEN = "@9"; +static const char * COLOR_ESCAPE = "@9"; +static const char * COLOR_SEARCH_FG = "@9"; +static const char * COLOR_SEARCH_BG = "@9"; static const char * COLOR_ERROR_FG = "@9"; static const char * COLOR_ERROR_BG = "@9"; static const char * COLOR_BOLD = "@9"; @@ -2439,8 +2439,12 @@ int rline(char * buffer, int buf_size) { offset = 0; buf_size_max = buf_size; + char * noColor = getenv("NO_COLOR"); char * theme = getenv("RLINE_THEME"); - if (theme && !strcmp(theme,"sunsmoke")) { /* TODO bring back theme tables */ + if ((noColor && *noColor) || (theme && !strcmp(theme,"none"))) { + /* If NO_COLOR is set, or RLINE_THEME=none, set no theme. + * The default colors are all @9. */ + } else if (theme && !strcmp(theme,"sunsmoke")) { rline_exp_load_colorscheme_sunsmoke(); } else { rline_exp_load_colorscheme_default();