Color
Terminal color formatting - returns styled strings.
Methods
| Method | Returns | Description |
|---|---|---|
Color.red(s) | string | Red text |
Color.green(s) | string | Green text |
Color.yellow(s) | string | Yellow text |
Color.blue(s) | string | Blue text |
Color.magenta(s) | string | Magenta text |
Color.cyan(s) | string | Cyan text |
Color.gray(s) | string | Gray text |
Color.bold(s) | string | Bold text |
Color.dim(s) | string | Dim text |
Color.underline(s) | string | Underlined text |
Examples
wyn
print(Color.bold("=== My App ==="))
print(Color.red("Error: file not found"))
print(Color.yellow("Warning: deprecated"))
print(Color.green("Success!"))
print(Color.cyan("Info: ") + "server running on port 8080")
print(Color.gray("debug: gc completed"))Composing
Colors return strings, so they compose naturally:
wyn
header = Color.bold(Color.cyan("myapp"))
status = Color.green("ok")
print("${header} -- ${status}")See Also
- Gui (SDL2) - use colors in graphics
- Strings - ANSI color codes in terminal output
- Build a CLI Tool - colored output in CLI apps