It’s unlikely that anyone will complain when they run on a non-ANSI terminal. It’s ugly to hardcode, and there certainly exist terminals today that won’t be compatible, but not many who cant find a compatible option when needed. If you really care (or if this is for professional code that others will have to maintain in the future, or if you get into more interesting terminal manipulations like full-screen addressing or …), it’s worth taking a dependency on ncurses, which can both test for capabilities and abstract away most of them for very VERY broad compatibility.
ANSI escape sequences have been common since the early ’80s, but only this millennium has it been universal enough to trust it and not try to support anything else.
BTW, I’ve found it to be worth setting up https://ethanschoonover.com/solarized/ for my editors and various terminal software I use. Much easier on the eyes than the standard 16-color palette, and reasonably compatible in terms of contrasts.
It’s unlikely that anyone will complain when they run on a non-ANSI terminal. It’s ugly to hardcode, and there certainly exist terminals today that won’t be compatible, but not many who cant find a compatible option when needed. If you really care (or if this is for professional code that others will have to maintain in the future, or if you get into more interesting terminal manipulations like full-screen addressing or …), it’s worth taking a dependency on ncurses, which can both test for capabilities and abstract away most of them for very VERY broad compatibility.
ANSI escape sequences have been common since the early ’80s, but only this millennium has it been universal enough to trust it and not try to support anything else.
BTW, I’ve found it to be worth setting up https://ethanschoonover.com/solarized/ for my editors and various terminal software I use. Much easier on the eyes than the standard 16-color palette, and reasonably compatible in terms of contrasts.