KristofferC / Crayons.jl

Colored and styled strings for terminals.
Other
150 stars 14 forks source link

The ENV checking in `print` could be expensive #42

Open KristofferC opened 4 years ago

KristofferC commented 4 years ago

I designed that API when I was young and naive (... or something). What I am talking about is:

Alternatively, if the environment variable FORCE_COLOR exist, or Crayons.force_color(::Bool) has been enabled, color sequences are printed no matter what. Also, since relatively few terminals support full 24-bit colors, it is possible to activate 256 color mode which converts the 24-bit crayon to a 256 color crayon when printed. This is done by either defining the variable environment FORCE_256_COLORS or by calling Crayons.force_256_colors(::Bool). In addition, some systems have problems even with 256 colors, it is possible to convert to one of the 16 system colors by defining the variable FORCE_SYSTEM_COLORS or by calling Crayons.force_system_colors(::Bool).

These env variables are checked every time a Crayon is printed which is a system call etc. Should probablt deprecate these and figure out some other way of doing it.