diff options
author | ToadJamb <toadjamb@gmail.com> | 2016-09-20 02:09:24 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2016-09-20 11:09:24 +0200 |
commit | 2cd5506fba7a86caf3ec9e9aba202c49cb551c5f (patch) | |
tree | 80005bb7890e3b82562bce095900aa31b8fb595c | |
parent | 742cb730976ba3739433c7f492f84504f7df6ec8 (diff) | |
download | elixir-2cd5506fba7a86caf3ec9e9aba202c49cb551c5f.tar.gz |
Add light foreground and background colors to IO.ANSI (#5231)
-rw-r--r-- | lib/elixir/lib/io/ansi.ex | 6 | ||||
-rw-r--r-- | lib/elixir/test/elixir/io/ansi_test.exs | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/elixir/lib/io/ansi.ex b/lib/elixir/lib/io/ansi.ex index 552408cb7..ab8a367eb 100644 --- a/lib/elixir/lib/io/ansi.ex +++ b/lib/elixir/lib/io/ansi.ex @@ -135,8 +135,14 @@ defmodule IO.ANSI do @doc "Sets foreground color to #{color}." defsequence color, code + 30 + @doc "Sets foreground color to light #{color}." + defsequence :"light_#{color}", code + 90 + @doc "Sets background color to #{color}." defsequence :"#{color}_background", code + 40 + + @doc "Sets background color to light #{color}." + defsequence :"light_#{color}_background", code + 100 end @doc "Default text color." diff --git a/lib/elixir/test/elixir/io/ansi_test.exs b/lib/elixir/test/elixir/io/ansi_test.exs index f22549df6..0bc883d39 100644 --- a/lib/elixir/test/elixir/io/ansi_test.exs +++ b/lib/elixir/test/elixir/io/ansi_test.exs @@ -97,6 +97,14 @@ defmodule IO.ANSITest do end end + test "colors" do + assert IO.ANSI.red == "\e[31m" + assert IO.ANSI.light_red == "\e[91m" + + assert IO.ANSI.red_background == "\e[41m" + assert IO.ANSI.light_red_background == "\e[101m" + end + test "color/1" do assert IO.ANSI.color(0) == "\e[38;5;0m" assert IO.ANSI.color(42) == "\e[38;5;42m" |