diff --git a/CHANGELOG.md b/CHANGELOG.md index cd28558d..8bcbc75b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ All notable changes to this project will be documented in this file. ## Unreleased - ??? +- Support the `NO_COLOR` environment variable to turn off VT100 color codes in repl (and in scripts). - Disallow using `(splice x)` in contexts where it doesn't make sense rather than silently coercing to `x`. - Change the names of `:user8` and `:user9` sigals to `:interrupt` and `:await` - Change the names of `:user8` and `:user9` fiber statuses to `:interrupted` and `:suspended`. diff --git a/janet.1 b/janet.1 index 0557ada3..0c946b2b 100644 --- a/janet.1 +++ b/janet.1 @@ -183,6 +183,10 @@ default repl. .BR \-n Disable ANSI colors in the repl. Has no effect if no repl is run. +.TP +.BR \-N +Enable ANSI colors in the repl. Has no effect if no repl is run. + .TP .BR \-r Open a REPL (Read Eval Print Loop) after executing all sources. By default, if Janet is called with no @@ -268,5 +272,11 @@ This variable does nothing in the default configuration of Janet, as PRF is disa cannot be defined for this variable to have an effect. .RE +.B NO_COLOR +.RS +Turn off color by default in the repl and in the error handler of scripts. This can be changed at runtime +via dynamic bindings *err-color* and *pretty-format*, or via the command line parameters -n and -N. +.RE + .SH AUTHOR Written by Calvin Rose diff --git a/src/boot/boot.janet b/src/boot/boot.janet index 5a89d832..c120abb0 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -3855,6 +3855,7 @@ (if-let [jp (getenv-alias "JANET_PATH")] (setdyn *syspath* jp)) (if-let [jprofile (getenv-alias "JANET_PROFILE")] (setdyn *profilepath* jprofile)) + (set colorize (not (getenv-alias "NO_COLOR"))) (defn- get-lint-level [i] @@ -3883,6 +3884,7 @@ -c source output : Compile janet source code into an image -i : Load the script argument as an image file instead of source code -n : Disable ANSI color output in the REPL + -N : Enable ANSI color output in the REPL -l lib : Use a module before processing more arguments -w level : Set the lint warning level - default is "normal" -x level : Set the lint error level - default is "none" @@ -3898,6 +3900,7 @@ "i" (fn [&] (set expect-image true) 1) "k" (fn [&] (set compile-only true) (set exit-on-error false) 1) "n" (fn [&] (set colorize false) 1) + "N" (fn [&] (set colorize true) 1) "m" (fn [i &] (setdyn *syspath* (in args (+ i 1))) 2) "c" (fn c-switch [i &] (def path (in args (+ i 1)))