String
/Text
/ByteString
correctly: Some things are strings of characters, some things are text, some things are bytes. Those are not the same.Only bytestring
, text
and terminfo
and the relevant validity
library.
The safe-coloured-text
library already has over 10'000 tests.
Most of them are golden tests, and ensure that the output stays correct even if the library changes.
These two strings look the same, but the second is almost twice as long:
safe-coloured-text
:
\ESC[34mTests:\ESC[m
Passed: \ESC[32m0\ESC[m
Failed: \ESC[32m0\ESC[m
Test suite took \ESC[33m 0.00 seconds\ESC[m
rainbow
:
\ESC[0m\ESC[38;5;4mTests:\ESC[0m
\ESC[0m\ESC[0m
\ESC[0m\ESC[0m
\ESC[0m\ESC[0m
\ESC[0m\ESC[0m
\ESC[0m \ESC[0m\ESC[0mPassed: \ESC[0m\ESC[0m\ESC[38;5;2m0\ESC[0m
\ESC[0m \ESC[0m\ESC[0mFailed: \ESC[0m\ESC[0m\ESC[38;5;2m0\ESC[0m
\ESC[0m \ESC[0m\ESC[0mTest suite took \ESC[0m\ESC[0m\ESC[38;5;3m 0.00 seconds\ESC[0m
\ESC[0m\ESC[0m
The safe-coloured-text
does not emit sequences if a chunk is completely plain, but it does not deal with inter-chunk inefficiencies.
This library supports outputting sequences for 24-bit colours.
My urxvt
terminal emulator doesn't even support that, so whatever, but at least it's possible.