Transform a color code into an actual ANSI escape sequence
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ansi_code), | intent(in) | :: | code |
Color code to be used |
ANSI escape sequence representing the color code
pure function escape(code) result(str) !> Color code to be used type(ansi_code), intent(in) :: code !> ANSI escape sequence representing the color code character(len=:), allocatable :: str if (anycolor(code)) then str = achar(27) // "[0" ! Always reset the style if (code%style > 0) str = str // ";" // to_string(code%style) if (code%fg >= 0) str = str // ";" // to_string(code%fg) if (code%bg >= 0) str = str // ";" // to_string(code%bg) str = str // "m" else str = "" end if end function escape