mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-11 15:51:01 +00:00
parent
b25046e897
commit
373493be85
@ -48,9 +48,10 @@ Most modules in starship allow you to configure their display styles. This is do
|
|||||||
- `"bg:blue fg:bright-green"` sets bright green text on a blue background
|
- `"bg:blue fg:bright-green"` sets bright green text on a blue background
|
||||||
- `"bold fg:27"` sets bold text with [ANSI color](https://i.stack.imgur.com/KTSQa.png) 27
|
- `"bold fg:27"` sets bold text with [ANSI color](https://i.stack.imgur.com/KTSQa.png) 27
|
||||||
- `"underline bg:#bf5700"` sets underlined text on a burnt orange background
|
- `"underline bg:#bf5700"` sets underlined text on a burnt orange background
|
||||||
|
- `"bold italic fg:purple"` sets bold italic purple text
|
||||||
- `""` explicitly disables all styling
|
- `""` explicitly disables all styling
|
||||||
|
|
||||||
Note that what styling looks like will be controlled by your terminal emulator. For example, some terminal emulators will brighten the colors instead of bolding text, and some color themes use the same values for the normal and bright colors.
|
Note that what styling looks like will be controlled by your terminal emulator. For example, some terminal emulators will brighten the colors instead of bolding text, and some color themes use the same values for the normal and bright colors. Also, to get italic text, your terminal must support italics.
|
||||||
|
|
||||||
## Prompt
|
## Prompt
|
||||||
|
|
||||||
|
@ -174,6 +174,7 @@ impl Config for Table {
|
|||||||
- 'bg:<color>' (specifies that the color read should be a background color)
|
- 'bg:<color>' (specifies that the color read should be a background color)
|
||||||
- 'underline'
|
- 'underline'
|
||||||
- 'bold'
|
- 'bold'
|
||||||
|
- 'italic'
|
||||||
- '<color>' (see the parse_color_string doc for valid color strings)
|
- '<color>' (see the parse_color_string doc for valid color strings)
|
||||||
*/
|
*/
|
||||||
fn parse_style_string(style_string: &str) -> Option<ansi_term::Style> {
|
fn parse_style_string(style_string: &str) -> Option<ansi_term::Style> {
|
||||||
@ -201,6 +202,7 @@ fn parse_style_string(style_string: &str) -> Option<ansi_term::Style> {
|
|||||||
match token.as_str() {
|
match token.as_str() {
|
||||||
"underline" => style = style.underline(),
|
"underline" => style = style.underline(),
|
||||||
"bold" => style = style.bold(),
|
"bold" => style = style.bold(),
|
||||||
|
"italic" => style = style.italic(),
|
||||||
"dimmed" => style = style.dimmed(),
|
"dimmed" => style = style.dimmed(),
|
||||||
"none" => return Some(ansi_term::Style::new()), // Overrides other toks
|
"none" => return Some(ansi_term::Style::new()), // Overrides other toks
|
||||||
|
|
||||||
@ -339,16 +341,21 @@ mod tests {
|
|||||||
fn table_get_styles_simple() {
|
fn table_get_styles_simple() {
|
||||||
let mut table = toml::value::Table::new();
|
let mut table = toml::value::Table::new();
|
||||||
|
|
||||||
// Test for a bold underline green module (with SiLlY cApS)
|
// Test for a bold italic underline green module (with SiLlY cApS)
|
||||||
table.insert(
|
table.insert(
|
||||||
String::from("mystyle"),
|
String::from("mystyle"),
|
||||||
toml::value::Value::String(String::from("bOlD uNdErLiNe GrEeN")),
|
toml::value::Value::String(String::from("bOlD ItAlIc uNdErLiNe GrEeN")),
|
||||||
);
|
);
|
||||||
assert!(table.get_as_ansi_style("mystyle").unwrap().is_bold);
|
assert!(table.get_as_ansi_style("mystyle").unwrap().is_bold);
|
||||||
|
assert!(table.get_as_ansi_style("mystyle").unwrap().is_italic);
|
||||||
assert!(table.get_as_ansi_style("mystyle").unwrap().is_underline);
|
assert!(table.get_as_ansi_style("mystyle").unwrap().is_underline);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
table.get_as_ansi_style("mystyle").unwrap(),
|
table.get_as_ansi_style("mystyle").unwrap(),
|
||||||
ansi_term::Style::new().bold().underline().fg(Color::Green)
|
ansi_term::Style::new()
|
||||||
|
.bold()
|
||||||
|
.italic()
|
||||||
|
.underline()
|
||||||
|
.fg(Color::Green)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test a "plain" style with no formatting
|
// Test a "plain" style with no formatting
|
||||||
|
Loading…
Reference in New Issue
Block a user