Skip to content

Commit

Permalink
Allow themes to be disabled in rline
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
klange committed Mar 5, 2024
1 parent 7acf2cd commit ef2b18f
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/vendor/rline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ef2b18f

Please sign in to comment.