pub enum Attribute {
Show 24 variants
Reset = 0,
Bold = 1,
Dim = 2,
Italic = 3,
Underlined = 4,
SlowBlink = 5,
RapidBlink = 6,
Reverse = 7,
Hidden = 8,
CrossedOut = 9,
Fraktur = 20,
NoBold = 21,
NormalIntensity = 22,
NoItalic = 23,
NoUnderline = 24,
NoBlink = 25,
NoInverse = 27,
NoHidden = 28,
NotCrossedOut = 29,
Framed = 51,
Encircled = 52,
OverLined = 53,
NotFramedOrEncircled = 54,
NotOverLined = 55,
// some variants omitted
}Expand description
Represents an attribute.
§Platform-specific Notes
- Only UNIX and Windows 10 terminals do support text attributes.
- Keep in mind that not all terminals support all attributes.
- Crossterm implements almost all attributes listed in the SGR parameters.
| Attribute | Windows | UNIX | Notes |
|---|---|---|---|
Reset | ✓ | ✓ | |
Bold | ✓ | ✓ | |
Dim | ✓ | ✓ | |
Italic | ? | ? | Not widely supported, sometimes treated as inverse. |
Underlined | ✓ | ✓ | |
SlowBlink | ? | ? | Not widely supported, sometimes treated as inverse. |
RapidBlink | ? | ? | Not widely supported. MS-DOS ANSI.SYS; 150+ per minute. |
Reverse | ✓ | ✓ | |
Hidden | ✓ | ✓ | Also known as Conceal. |
Fraktur | ✗ | ✓ | Legible characters, but marked for deletion. |
DefaultForegroundColor | ? | ? | Implementation specific (according to standard). |
DefaultBackgroundColor | ? | ? | Implementation specific (according to standard). |
Framed | ? | ? | Not widely supported. |
Encircled | ? | ? | This should turn on the encircled attribute. |
OverLined | ? | ? | This should draw a line at the top of the text. |
§Examples
Basic usage:
use crossterm_style::Attribute;
println!(
"{} Underlined {} No Underline",
Attribute::Underlined,
Attribute::NoUnderline
);Style existing text:
use crossterm_style::Styler;
println!("{}", "Bold text".bold());
println!("{}", "Underlined text".underlined());
println!("{}", "Negative text".negative());Variants§
Reset = 0
Resets all the attributes.
Bold = 1
Increases the text intensity.
Dim = 2
Decreases the text intensity.
Italic = 3
Emphasises the text.
Underlined = 4
Underlines the text.
SlowBlink = 5
Makes the text blinking (< 150 per minute).
RapidBlink = 6
Makes the text blinking (>= 150 per minute).
Reverse = 7
Swaps foreground and background colors.
Hidden = 8
Hides the text (also known as Conceal).
CrossedOut = 9
Crosses the text.
Fraktur = 20
Sets the Fraktur typeface.
Mostly used for mathematical alphanumeric symbols.
NoBold = 21
Turns off the Bold attribute.
NormalIntensity = 22
Switches the text back to normal intensity (no bold, italic).
NoItalic = 23
Turns off the Italic attribute.
NoUnderline = 24
Turns off the Underlined attribute.
NoBlink = 25
Turns off the text blinking (SlowBlink or RapidBlink).
NoInverse = 27
Turns off the Reverse attribute.
NoHidden = 28
Turns off the Hidden attribute.
NotCrossedOut = 29
Turns off the CrossedOut attribute.
Framed = 51
Makes the text framed.
Encircled = 52
Makes the text encircled.
OverLined = 53
Draws a line at the top of the text.
NotFramedOrEncircled = 54
Turns off the Frame and Encircled attributes.
NotOverLined = 55
Turns off the OverLined attribute.