etch/style
This module provides utilities for styling terminal text.
Types
A type that represents text attributes like bold, italic, etc.
pub type Attribute {
Bold
Dim
Underline
Italic
Blinking
Inverse
}
Constructors
-
BoldBold text.
-
DimDim text.
-
UnderlineUnderline text.
-
ItalicItalic text.
-
BlinkingBlinking text.
-
InverseInverse (swaps foreground and background
Colors).
A type that represents a color that can be set as foreground or background.
pub type Color {
Default
Black
Grey
Red
BrightRed
Green
BrightGreen
Yellow
BrightYellow
Blue
BrightBlue
Magenta
BrightMagenta
Cyan
BrightCyan
White
BrightWhite
BrightGrey
AnsiValue(v: Int)
Rgb(r: Int, g: Int, b: Int)
}
Constructors
-
DefaultDefault terminal color.
-
BlackBlack color.
-
GreyGrey color.
-
RedRed color.
-
BrightRedBright red color.
-
GreenGreen color.
-
BrightGreenBright green color.
-
YellowYellow color.
-
BrightYellowBright yellow color.
-
BlueBlue color.
-
BrightBlueBright blue color.
-
MagentaMagenta color.
-
BrightMagentaBright magenta color.
-
CyanCyan color.
-
BrightCyanBright cyan color.
-
WhiteWhite color.
-
BrightWhiteBright white color.
-
BrightGreyBright grey color.
-
AnsiValue(v: Int)Ansi color (256 colors). See https://www.ditig.com/256-colors-cheat-sheet.
-
Rgb(r: Int, g: Int, b: Int)RGB color.
Allows to save style (foreground and background Colors)
and Attributes)
and use it later by calling with_style.
pub type Style {
Style(bg: Color, fg: Color, attributes: List(Attribute))
}
Constructors
Values
pub fn ansi(s: String, value: Int) -> String
Sets the foreground Color to the given ANSI value
and resets it afterwards.
pub fn attributes(s: String, a: List(Attribute)) -> String
Sets Attributes of a string.
pub fn black(s: String) -> String
Sets the foreground Color to black and
resets the color afterwards.
pub fn blinking(s: String) -> String
Makes the string blinking and resets this attribute afterwards.
pub fn blue(s: String) -> String
Sets the foreground Color to blue and
resets the color afterwards.
pub fn bold(s: String) -> String
Makes the string bold and resets this attribute afterwards.
pub fn bright_blue(s: String) -> String
Sets the foreground Color to bright blue and
resets the color afterwards.
pub fn bright_cyan(s: String) -> String
Sets the foreground Color to bright cyan and
resets the color afterwards.
pub fn bright_green(s: String) -> String
Sets the foreground Color to bright green and
resets the color afterwards.
pub fn bright_grey(s: String) -> String
Sets the foreground Color to bright grey and
resets the color afterwards.
pub fn bright_magenta(s: String) -> String
Sets the foreground Color to bright magenta and
resets the color afterwards.
pub fn bright_red(s: String) -> String
Sets the foreground Color to bright red and
resets the color afterwards.
pub fn bright_white(s: String) -> String
Sets the foreground Color to bright white and
resets the color afterwards.
pub fn bright_yellow(s: String) -> String
Sets the foreground Color to bright yellow and
resets the color afterwards.
pub fn cyan(s: String) -> String
Sets the foreground Color to cyan and
resets the color afterwards.
pub fn default_style() -> Style
Returns default Style with terminal’s default
foreground and background Colors)
and no Attributes.
pub fn green(s: String) -> String
Sets the foreground Color to green and
resets the color afterwards.
pub fn grey(s: String) -> String
Sets the foreground Color to grey and
resets the color afterwards.
pub fn inverse(s: String) -> String
Makes the string inverse (swaps background and foreground colors)
and resets this attribute afterwards. See Color.
pub fn italic(s: String) -> String
Makes the string italic and resets this attribute afterwards.
pub fn magenta(s: String) -> String
Sets the foreground Color to magenta and
resets the color afterwards.
pub fn on(s: String, c: Color) -> String
pub fn on_ansi(s: String, value: Int) -> String
Sets the background Color to the given ANSI value
and resets it afterwards.
pub fn on_black(s: String) -> String
Sets the background Color to black
and resets it afterwards.
pub fn on_blue(s: String) -> String
Sets the background Color to blue
and resets it afterwards.
pub fn on_bright_blue(s: String) -> String
Sets the background Color to bright blue
and resets it afterwards.
pub fn on_bright_cyan(s: String) -> String
Sets the background Color to bright cyan
and resets it afterwards.
pub fn on_bright_green(s: String) -> String
Sets the background Color to bright green
and resets it afterwards.
pub fn on_bright_grey(s: String) -> String
Sets the background Color to bright grey
and resets it afterwards.
pub fn on_bright_magenta(s: String) -> String
Sets the background Color to bright magenta
and resets it afterwards.
pub fn on_bright_red(s: String) -> String
Sets the background Color to bright red
and resets it afterwards.
pub fn on_bright_white(s: String) -> String
Sets the background Color to bright white
and resets it afterwards.
pub fn on_bright_yellow(s: String) -> String
Sets the background Color to bright yellow
and resets it afterwards.
pub fn on_cyan(s: String) -> String
Sets the background Color to cyan
and resets it afterwards.
pub fn on_green(s: String) -> String
Sets the background Color to green
and resets it afterwards.
pub fn on_grey(s: String) -> String
Sets the background Color to grey
and resets it afterwards.
pub fn on_magenta(s: String) -> String
Sets the background Color to magenta
and resets it afterwards.
pub fn on_rbg(s: String, r: Int, g: Int, b: Int) -> String
Sets the background Color to the given RBG color
and resets it afterwards.
pub fn on_red(s: String) -> String
Sets the background Color to red
and resets it afterwards.
pub fn on_white(s: String) -> String
Sets the background Color to white
and resets it afterwards.
pub fn on_yellow(s: String) -> String
Sets the background Color to yellow
and resets it afterwards.
pub fn rbg(s: String, r: Int, g: Int, b: Int) -> String
Sets the foreground Color to the given RBG color
and resets it afterwards.
pub fn red(s: String) -> String
Sets the foreground Color to red and
resets the color afterwards.
pub fn reset_background(s: String) -> String
Resets background of the string. See Color.
pub fn reset_foreground(s: String) -> String
Resets foreground of the string. See Color.
pub fn underline(s: String) -> String
Makes the string underline and resets this attribute afterwards.
pub fn white(s: String) -> String
Sets the foreground Color to white and
resets the color afterwards.
pub fn with(s: String, c: Color) -> String