terminal.nim operates on files (eg stdout) instead of strings; it makes certain use cases impossible, eg:
EDIT
operating on strings would be more flexible and lead to more orthogonal API's, eg:
styledMsgWriteln(color, title, resetStyle, s)
# instead we could have:
proc toColor(a: string, color: Style):string =
return toString(color) & a & toString(resetStyle)
msgWriteln(title.toColor(color), s)
and avoid the need for all the plethora of styledWriteLine, setForegroundColor, etc (see all the functions in terminal.nim) in fact this is what i did in my own libraries.
NOTE: maybe this was done this way because of need to support windows; however, it would be good if there'd be a simple way for application writers that don't care about windows (eg, one's personal scripts) support to have simpler APIs (such as mentioned above, via string manipulation that simply inserts terminal escape codes)
also, looks like windows now supports terminal escape codes, eg:
https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
https://stackoverflow.com/questions/388490/how-to-use-unicode-characters-in-windows-command-line
I consider the Windows solution slightly superior as it means pipelining of programs works out of the box without giving every program an option like --colors:on|off|auto... Unix is suprisingly bad at Unix'ish things.
All these attempts to make the work in a 80x20 terminal environment right from the 70ies convenient are so poor. Yes, I know you have to connect via remote SSH shell to some server that has Python, Ruby, Bash and PHP installed but cannot run X11 from the 80ies because of overhead/security and this new thing called "remote desktop" cannot be trusted. It's poor.