diff --git a/lib/experimental/colortext.nim b/lib/experimental/colortext.nim index 29e5e45ded9..2a1c42f272d 100644 --- a/lib/experimental/colortext.nim +++ b/lib/experimental/colortext.nim @@ -700,27 +700,18 @@ template coloredResult*(indentationStep: int = 2): untyped = ## ## aux(node) ## - ## Injected procs + ## Injected routines ## + ## - `addf(string, varargs)` ## - `add(string)`, `add(string, string)` ## - `addIndent(int)`, `addi(int, string)` - ## - `endResult()` - return colored result. Required for proper work - ## of the code in the compile-time context, otherwise modification - ## of the `addr result` does not work properly. - static: - when not declared(result): - {.error: "'coloredResult' template can only be called inside of the procedure returning 'ColText' as a result, or other environment that has `var result: ColText` defined."} + when not declared(result): + {.error: "'coloredResult' template can only be called in an environment " & + "where a `result` variable is available"} var outPtr {.used.}: ptr ColText = addr result - template endResult(): untyped {.used.} = - when nimvm: - return outPtr[] - - else: - return - - proc addf(format: string, args: varargs[ColText, toColText]) = + template addf(format: string, args: varargs[untyped]) {.used.} = outPtr[].addf(format, args) template add(arg: untyped): untyped {.used.} = outPtr[].add arg diff --git a/tests/stdlib/algorithm/tcolortext.nim b/tests/stdlib/algorithm/tcolortext.nim index e2337da1fc4..06dd176d341 100644 --- a/tests/stdlib/algorithm/tcolortext.nim +++ b/tests/stdlib/algorithm/tcolortext.nim @@ -50,7 +50,6 @@ let exp: int add "1" + fgRed addi 2, "2" add "]" - endResult() let col = reesc($colres()) let want = r"[ 0\e[31m1\e[39m 2]"