mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 22:47:43 +02:00
Patch explore 4 (#7517)
ref #7339 - This PR updates explore to take some of the colors from nushell, namely the line colors and the ls_colors. note: Not sure why this regression appeared maybe it's a feature or it's no longer supposed to be supported? Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
use crate::nu_style::{color_from_hex, lookup_style};
|
||||
use crate::{
|
||||
nu_style::{color_from_hex, lookup_style},
|
||||
parse_nustyle, NuStyle,
|
||||
};
|
||||
use nu_ansi_term::Style;
|
||||
use nu_protocol::Value;
|
||||
use std::collections::HashMap;
|
||||
@ -9,6 +12,8 @@ pub fn lookup_ansi_color_style(s: &str) -> Style {
|
||||
.ok()
|
||||
.and_then(|c| c.map(|c| c.normal()))
|
||||
.unwrap_or_default()
|
||||
} else if s.starts_with('{') {
|
||||
color_string_to_nustyle(s.to_string())
|
||||
} else {
|
||||
lookup_style(s)
|
||||
}
|
||||
@ -36,3 +41,17 @@ pub fn get_color_map(colors: &HashMap<String, Value>) -> HashMap<String, Style>
|
||||
|
||||
hm
|
||||
}
|
||||
|
||||
fn color_string_to_nustyle(color_string: String) -> Style {
|
||||
// eprintln!("color_string: {}", &color_string);
|
||||
if color_string.is_empty() {
|
||||
return Style::default();
|
||||
}
|
||||
|
||||
let nu_style = match nu_json::from_str::<NuStyle>(&color_string) {
|
||||
Ok(s) => s,
|
||||
Err(_) => return Style::default(),
|
||||
};
|
||||
|
||||
parse_nustyle(nu_style)
|
||||
}
|
||||
|
@ -106,6 +106,7 @@ pub fn color_record_to_nustyle(value: &Value) -> Style {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parse_nustyle(NuStyle { fg, bg, attr })
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user