Module terminal.text.color
Terminal text color module.
Provides utilities to set text color in terminals.
Functions
back (r[, g[, b]]) | Sets the background color and writes it to the terminal. |
fore (r[, g[, b]]) | Sets the foreground color and writes it to the terminal. |
Sequences
back_seq (r[, g[, b]]) | Creates an ansi sequence to set the background color without writing it to the terminal. |
fore_seq (r[, g[, b]]) | Creates an ansi sequence to set the foreground color without writing it to the terminal. |
Functions
- back (r[, g[, b]])
-
Sets the background color and writes it to the terminal.
Parameters:
- r integer in case of RGB, the red value, a number for extended colors, a string color for base-colors
- g number in case of RGB, the green value (optional)
- b number in case of RGB, the blue value (optional)
Returns:
-
true
- fore (r[, g[, b]])
-
Sets the foreground color and writes it to the terminal.
Parameters:
- r integer in case of RGB, the red value, a number for extended colors, a string color for base-colors
- g number in case of RGB, the green value (optional)
- b number in case of RGB, the blue value (optional)
Returns:
-
true
Sequences
- back_seq (r[, g[, b]])
-
Creates an ansi sequence to set the background color without writing it to the terminal. This function takes three color types:
- base colors: black, red, green, yellow, blue, magenta, cyan, white. Use as
color_bgs("red")
. - extended colors: a number between 0 and 255. Use as
color_bgs(123)
. - RGB colors: three numbers between 0 and 255. Use as
color_bgs(123, 123, 123)
.
Parameters:
- r integer in case of RGB, the red value, a number for extended colors, a string color for base-colors
- g number in case of RGB, the green value (optional)
- b number in case of RGB, the blue value (optional)
Returns:
-
string
ansi sequence to write to the terminal
- base colors: black, red, green, yellow, blue, magenta, cyan, white. Use as
- fore_seq (r[, g[, b]])
-
Creates an ansi sequence to set the foreground color without writing it to the terminal. This function takes three color types:
- base colors: black, red, green, yellow, blue, magenta, cyan, white. Use as
color_fgs("red")
. - extended colors: a number between 0 and 255. Use as
color_fgs(123)
. - RGB colors: three numbers between 0 and 255. Use as
color_fgs(123, 123, 123)
.
Parameters:
- r integer in case of RGB, the red value, a number for extended colors, a string color for base-colors
- g number in case of RGB, the green value (optional)
- b number in case of RGB, the blue value (optional)
Returns:
-
string
ansi sequence to write to the terminal
- base colors: black, red, green, yellow, blue, magenta, cyan, white. Use as