terminal: fix fgColor/bgColor commands [backport] (#15554)
Since #8296, fgSetColor is no longer a global. These commands were probably left out from the change as an oversight, so some tests have been added to make sure this won't happen again.
This commit is contained in:
parent
0134e34e03
commit
d1af9587b8
2 changed files with 11 additions and 4 deletions
|
|
@ -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.
|
||||
|
|
|
|||
8
tests/stdlib/tterminal.nim
Normal file
8
tests/stdlib/tterminal.nim
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
discard """
|
||||
action: compile
|
||||
"""
|
||||
|
||||
import terminal, colors
|
||||
|
||||
styledEcho fgColor, colRed, "Test"
|
||||
styledEcho bgColor, colBlue, "Test"
|
||||
Loading…
Add table
Add a link
Reference in a new issue