You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
object Lezduit {
@JvmStatic
funmain(args:Array<String>) {
val t =Terminal()
val style = (bold + black + strikethrough)
t.println(
cyan("You ${(green on white)("can ${style("nest")} styles")} arbitrarily")
)
t.println(
cyan("${red("Unless")} it's the first char in the string")
)
}
}
produces the following output:
The first output line is copied directly from the docs. The second line demonstrates the issue. Note the the word 'Unless' is supposed to be red. But the red() text color directive is ignored since it is applied immediately after applying the cyan() color. Adding a space (or any other character) inside the string, in front of the red() color directive causes the word 'Unless' to be rendered in red.
The use-case for this is that we have standard 'error()', 'info()', & 'debug()' functions for our CLI, that apply a particular color style (e.g. 'error()' is red). Occasionally we'd like to apply a different color to a particular piece of the output. This works unless it is the first character of the output.
Nesting rules are complicated, and I'm sure there are some use cases where the current behavior is preferred. I agree that your example is valid though. In the mean time, you can work around this by joining the parts separately red("warning ") + cyan("message")
The following code block:
produces the following output:
The first output line is copied directly from the docs. The second line demonstrates the issue. Note the the word 'Unless' is supposed to be red. But the
red()
text color directive is ignored since it is applied immediately after applying thecyan()
color. Adding a space (or any other character) inside the string, in front of thered()
color directive causes the word 'Unless' to be rendered in red.The use-case for this is that we have standard 'error()', 'info()', & 'debug()' functions for our CLI, that apply a particular color style (e.g. 'error()' is red). Occasionally we'd like to apply a different color to a particular piece of the output. This works unless it is the first character of the output.
System: Ubuntu 22.04
Terminal: Terminator 2.1.1 & GNOME Terminal 3.44.0
The text was updated successfully, but these errors were encountered: