nu-table: Use config color scheme in kv tables and table -e (#10720)

fix #10712
cc: @fdncred
This commit is contained in:
Maxim Zhiburt
2023-10-15 00:25:00 +00:00
committed by GitHub
parent 1f62024a15
commit 4e5a1ced13
3 changed files with 26 additions and 19 deletions

View File

@ -30,6 +30,20 @@ pub fn create_nu_table_config(
}
}
pub fn nu_value_to_string_colored(val: &Value, cfg: &Config, style: &StyleComputer) -> String {
let (mut text, value_style) = nu_value_to_string(val, cfg, style);
if let Some(color) = value_style.color_style {
text = color.paint(text).to_string();
}
if matches!(val, Value::String { .. }) {
text = clean_charset(&text);
colorize_space_str(&mut text, style);
}
text
}
pub fn nu_value_to_string(val: &Value, cfg: &Config, style: &StyleComputer) -> NuText {
let float_precision = cfg.float_precision as usize;
let text = val.into_abbreviated_string(cfg);