Packages

Tulip is a simple Gleam project for adding color to your terminal output. All 256 ANSI colors are supported.

Current section

Files

Jump to
tulip src tulip.erl
Raw

src/tulip.erl

-module(tulip).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([print/2, println/2]).
-spec print(integer(), binary()) -> nil.
print(Color, String) ->
gleam@io:print(
gleam@string:concat(
[<<"\x{001b}[38;5;"/utf8>>,
gleam@int:to_string(Color),
<<"m"/utf8>>,
String,
<<"\x{001b}[0m"/utf8>>]
)
).
-spec println(integer(), binary()) -> nil.
println(Color, String) ->
gleam@io:println(
gleam@string:concat(
[<<"\x{001b}[38;5;"/utf8>>,
gleam@int:to_string(Color),
<<"m"/utf8>>,
String,
<<"\x{001b}[0m"/utf8>>]
)
).