3 ms·
> No colours > What? I see green. Smart ass bear. Good article as always. Colored output feels like something a syscall should handle. Something like setcolo
by LordShredda 3y ago
> No colours
> What? I see green.
Smart ass bear. Good article as always.
Colored output feels like something a syscall should handle. Something like setcolor, unsetcolor, separate from the typical printf functions. At least escape sequences are easy to detect and remove, albeit a hassle.
- zokier 3y agoTrying to remove control codes reminds me of this answer: https://superuser.com/a/1388860 https://superuser.com/a/1388860 and then I shudder and walk away.. the variety in the answers is alone a thing to wonder
- JdeBP 3y agoThe sad thing is that none of them are right. To do it properly, one effectively has to take the full state machine of a DEC VT-like terminal emulator and stick it into a filter program. Regular expressions in perl/sed/python aren't enough. There are quite a number of things that can be output to real or emulated terminals that none of these collections of regular expressions will strip correctly. And conversely, these regular expressions will wrongly strip things that, whilst odd, will actually work on real/emulated terminals, including C0 characters that take effect in the middle of control sequences.
- icedchai 3y agoIt seems a bit high level for a syscall. Perhaps you're looking for a library, like terminfo? https://stackoverflow.com/questions/42734416/how-to-set-colors-in-terminal-using-terminfo https://stackoverflow.com/questions/42734416/how-to-set-colo...