update to latest reedline, change config point name, enable output without ansi (#458)

This commit is contained in:
Darren Schroeder 2021-12-09 16:06:26 -06:00 committed by GitHub
parent 3dc19d4179
commit 5c27ffa42e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 7 deletions

3
Cargo.lock generated
View File

@ -2368,12 +2368,13 @@ dependencies = [
[[package]] [[package]]
name = "reedline" name = "reedline"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/nushell/reedline?branch=main#2bc7046066f3d3f2a9a538fc3d546adf1e5d4b28" source = "git+https://github.com/nushell/reedline?branch=main#6884ec4062a1b2184a6d47553101d3575d4e8b61"
dependencies = [ dependencies = [
"chrono", "chrono",
"crossterm", "crossterm",
"nu-ansi-term 0.39.0 (registry+https://github.com/rust-lang/crates.io-index)", "nu-ansi-term 0.39.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde", "serde",
"strip-ansi-escapes",
"unicode-segmentation", "unicode-segmentation",
"unicode-width", "unicode-width",
] ]

View File

@ -15,7 +15,7 @@ pub struct Config {
pub animate_prompt: bool, pub animate_prompt: bool,
pub float_precision: i64, pub float_precision: i64,
pub filesize_format: String, pub filesize_format: String,
pub without_color: bool, pub use_ansi_coloring: bool,
} }
impl Default for Config { impl Default for Config {
@ -30,7 +30,7 @@ impl Default for Config {
animate_prompt: ANIMATE_PROMPT_DEFAULT, animate_prompt: ANIMATE_PROMPT_DEFAULT,
float_precision: 4, float_precision: 4,
filesize_format: "auto".into(), filesize_format: "auto".into(),
without_color: false, use_ansi_coloring: true,
} }
} }
} }
@ -93,8 +93,8 @@ impl Value {
"float_precision" => { "float_precision" => {
config.float_precision = value.as_integer()?; config.float_precision = value.as_integer()?;
} }
"without_color" => { "use_ansi_coloring" => {
config.without_color = value.as_bool()?; config.use_ansi_coloring = value.as_bool()?;
} }
"filesize_format" => { "filesize_format" => {
config.filesize_format = value.as_string()?.to_lowercase(); config.filesize_format = value.as_string()?.to_lowercase();

View File

@ -954,7 +954,7 @@ impl WrappedTable {
} }
// the atty is for when people do ls from vim, there should be no coloring there // the atty is for when people do ls from vim, there should be no coloring there
if config.without_color || !atty::is(atty::Stream::Stdout) { if !config.use_ansi_coloring || !atty::is(atty::Stream::Stdout) {
// Draw the table without ansi colors // Draw the table without ansi colors
if let Ok(bytes) = strip_ansi_escapes::strip(&output) { if let Ok(bytes) = strip_ansi_escapes::strip(&output) {
String::from_utf8_lossy(&bytes).to_string() String::from_utf8_lossy(&bytes).to_string()

View File

@ -309,7 +309,10 @@ fn main() -> Result<()> {
// )) // ))
.with_validator(Box::new(NuValidator { .with_validator(Box::new(NuValidator {
engine_state: engine_state.clone(), engine_state: engine_state.clone(),
})); }))
.with_ansi_colors(config.use_ansi_coloring);
//FIXME: if config.use_ansi_coloring is false then we should
// turn off the hinter but I don't see any way to do that yet.
let mut line_editor = if let Some(history_path) = history_path.clone() { let mut line_editor = if let Some(history_path) = history_path.clone() {
line_editor line_editor