1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-12 17:50:26 +00:00
janet/examples/colors.janet
Calvin Rose 6b95326d7c First commit removing the integer number type. This should
remove some complexity and unexpected behavior around numbers in
general as all numbers are the same number type, IEEE 754 double
precision numbers. Also update examples and tests, some of which were
out of date.

Some more testing may be needed for new changes to numbers.
2018-12-27 13:05:29 -05:00

42 lines
783 B
Plaintext

# Ansi terminal colors
(def- colormap
{:black 30
:bg-black 40
:red 31
:bg-red 41
:green 32
:bg-green 42
:yellow 33
:bg-yellow 43
:blue 34
:bg-blue 44
:magenta 35
:bg-magenta 45
:cyan 36
:bg-cyan 46
:white 37
:bg-white 47
:bright-black 90
:bg-bright-black 100
:bright-red 91
:bg-bright-red 101
:bright-green 92
:bg-bright-green 102
:bright-yellow 93
:bg-bright-yellow 103
:bright-blue 94
:bg-bright-blue 104
:bright-magenta 95
:bg-bright-magenta 105
:bright-cyan 96
:bg-bright-cyan 106
:bright-white 97
:bg-bright-white 107})
(loop [[name color] :in (pairs colormap)]
(defglobal (string/slice name 1)
(fn color-wrapper [& pieces]
(string "\e[" color "m" ;pieces "\e[0m"))))