diff --git a/lib/elixir/src/elixir.app.src b/lib/elixir/src/elixir.app.src index fa177fc626..05a67b436b 100644 --- a/lib/elixir/src/elixir.app.src +++ b/lib/elixir/src/elixir.app.src @@ -6,7 +6,6 @@ {applications, [kernel,stdlib,compiler]}, {mod, {elixir,[]}}, {env, [ - {ansi_enabled, false}, {ansi_syntax_colors, [ {atom, cyan}, {binary, default_color}, diff --git a/lib/elixir/src/elixir.erl b/lib/elixir/src/elixir.erl index af88e46165..4de9d056bc 100644 --- a/lib/elixir/src/elixir.erl +++ b/lib/elixir/src/elixir.erl @@ -50,6 +50,14 @@ start(_Type, _Args) -> false -> ok end, + case application:get_env(elixir, ansi_enabled) of + {ok, _} -> ok; + undefined -> + %% Remove prim_tty module check as well as checks from scripts on Erlang/OTP 26 + ANSIEnabled = erlang:module_loaded(prim_tty) andalso prim_tty:isatty(stdout), + application:set_env(elixir, ansi_enabled, ANSIEnabled) + end, + Tokenizer = case code:ensure_loaded('Elixir.String.Tokenizer') of {module, Mod} -> Mod; _ -> elixir_tokenizer diff --git a/lib/elixir/src/elixir_errors.erl b/lib/elixir/src/elixir_errors.erl index a54c3442dd..d3f5b28efa 100644 --- a/lib/elixir/src/elixir_errors.erl +++ b/lib/elixir/src/elixir_errors.erl @@ -218,15 +218,15 @@ send_diagnostic(Type, Line, File, Message) -> ok. warning_prefix() -> - case application:get_env(elixir, ansi_enabled) of - {ok, true} -> <<"\e[33mwarning: \e[0m">>; - _ -> <<"warning: ">> + case application:get_env(elixir, ansi_enabled, false) of + true -> <<"\e[33mwarning: \e[0m">>; + false -> <<"warning: ">> end. error_prefix() -> - case application:get_env(elixir, ansi_enabled) of - {ok, true} -> <<"\e[31merror: \e[0m">>; - _ -> <<"error: ">> + case application:get_env(elixir, ansi_enabled, false) of + true -> <<"\e[31merror: \e[0m">>; + false -> <<"error: ">> end. env_format(Meta, #{file := EnvFile} = E) -> diff --git a/lib/iex/lib/iex.ex b/lib/iex/lib/iex.ex index d8f0fdf7c7..6aa64b1c68 100644 --- a/lib/iex/lib/iex.ex +++ b/lib/iex/lib/iex.ex @@ -25,10 +25,11 @@ defmodule IEx do aren't explicitly documented and where the function name is in the form of `__foo__`. - Autocomplete may not be available on some Windows shells. You may need - to pass the `--werl` option when starting IEx, such as `iex --werl` - (or `iex.bat --werl` if using PowerShell). `--werl` may be permanently - enabled by setting the `IEX_WITH_WERL` environment variable to `1`. + Autocomplete is available by default on Windows shells from Erlang/OTP 26. + In earlier versions, you may need to pass the `--werl` option when starting + IEx, such as `iex --werl` (or `iex.bat --werl` if using PowerShell). + `--werl` may be permanently enabled by setting the `IEX_WITH_WERL` + environment variable to `1`. ## Encoding and coloring @@ -40,9 +41,10 @@ defmodule IEx do PowerShell). Similarly, ANSI coloring is enabled by default on most Unix terminals. - They are also available on Windows consoles from Windows 10, although - it must be explicitly enabled for the current user in the registry by - running the following command: + They are also available on Windows consoles from Windows 10 and on + Erlang/OTP 26 or later. For earlier Erlang/OTP versions, you can + explicitly enable it for the current user in the registry by running + the following command: $ reg add HKCU\Console /v VirtualTerminalLevel /t REG_DWORD /d 1