mirror of
https://github.com/nushell/nushell
synced 2024-12-28 05:53:09 +00:00
Move prompt animation setting to config (#400)
This commit is contained in:
parent
ac2afab40b
commit
071066b6d9
2 changed files with 12 additions and 12 deletions
|
@ -2,6 +2,8 @@ use crate::{ShellError, Value};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
const ANIMATE_PROMPT_DEFAULT: bool = true;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub filesize_metric: bool,
|
pub filesize_metric: bool,
|
||||||
|
@ -10,6 +12,7 @@ pub struct Config {
|
||||||
pub color_config: HashMap<String, String>,
|
pub color_config: HashMap<String, String>,
|
||||||
pub use_grid_icons: bool,
|
pub use_grid_icons: bool,
|
||||||
pub footer_mode: FooterMode,
|
pub footer_mode: FooterMode,
|
||||||
|
pub animate_prompt: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
|
@ -21,6 +24,7 @@ impl Default for Config {
|
||||||
color_config: HashMap::new(),
|
color_config: HashMap::new(),
|
||||||
use_grid_icons: false,
|
use_grid_icons: false,
|
||||||
footer_mode: FooterMode::Never,
|
footer_mode: FooterMode::Never,
|
||||||
|
animate_prompt: ANIMATE_PROMPT_DEFAULT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +81,11 @@ impl Value {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
"animate_prompt" => {
|
||||||
|
let val = value.as_bool()?;
|
||||||
|
|
||||||
|
config.animate_prompt = val;
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -230,20 +230,11 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
let config = stack.get_config()?;
|
||||||
|
|
||||||
//Reset the ctrl-c handler
|
//Reset the ctrl-c handler
|
||||||
ctrlc.store(false, Ordering::SeqCst);
|
ctrlc.store(false, Ordering::SeqCst);
|
||||||
|
|
||||||
const EQ_PROMPT_ANIMATE_DEFAULT: bool = true;
|
|
||||||
// Toggle prompt animation
|
|
||||||
let animate = match std::env::var("EQ_PROMPT_ANIMATE") {
|
|
||||||
Ok(ms_str) => match ms_str.as_str() {
|
|
||||||
"ON" | "1" => true,
|
|
||||||
"OFF" | "0" => false,
|
|
||||||
_ => EQ_PROMPT_ANIMATE_DEFAULT,
|
|
||||||
},
|
|
||||||
_ => EQ_PROMPT_ANIMATE_DEFAULT,
|
|
||||||
};
|
|
||||||
|
|
||||||
let line_editor = Reedline::create()
|
let line_editor = Reedline::create()
|
||||||
.into_diagnostic()?
|
.into_diagnostic()?
|
||||||
.with_completion_action_handler(Box::new(FuzzyCompletion {
|
.with_completion_action_handler(Box::new(FuzzyCompletion {
|
||||||
|
@ -252,7 +243,7 @@ fn main() -> Result<()> {
|
||||||
.with_highlighter(Box::new(NuHighlighter {
|
.with_highlighter(Box::new(NuHighlighter {
|
||||||
engine_state: engine_state.clone(),
|
engine_state: engine_state.clone(),
|
||||||
}))
|
}))
|
||||||
.with_animation(animate)
|
.with_animation(config.animate_prompt)
|
||||||
// .with_completion_action_handler(Box::new(
|
// .with_completion_action_handler(Box::new(
|
||||||
// ListCompletionHandler::default().with_completer(Box::new(completer)),
|
// ListCompletionHandler::default().with_completer(Box::new(completer)),
|
||||||
// ))
|
// ))
|
||||||
|
|
Loading…
Reference in a new issue