diff --git a/lib/pure/terminal.nim b/lib/pure/terminal.nim index 43b1592328..ac62aacad1 100644 --- a/lib/pure/terminal.nim +++ b/lib/pure/terminal.nim @@ -689,10 +689,9 @@ template styledEchoProcessArg(f: File, color: Color) = template styledEchoProcessArg(f: File, cmd: TerminalCmd) = when cmd == resetStyle: resetAttributes(f) - when cmd == fgColor: - fgSetColor = true - when cmd == bgColor: - fgSetColor = false + elif cmd in {fgColor, bgColor}: + let term = getTerminal() + term.fgSetColor = cmd == fgColor macro styledWrite*(f: File, m: varargs[typed]): untyped = ## Similar to ``write``, but treating terminal style arguments specially. diff --git a/tests/stdlib/tterminal.nim b/tests/stdlib/tterminal.nim new file mode 100644 index 0000000000..364c8d82e7 --- /dev/null +++ b/tests/stdlib/tterminal.nim @@ -0,0 +1,8 @@ +discard """ + action: compile +""" + +import terminal, colors + +styledEcho fgColor, colRed, "Test" +styledEcho bgColor, colBlue, "Test"