forked from extern/nushell
Fix busy poll with reedline (#387)
Fixes #386 Makes the changes to accept https://github.com/nushell/reedline/pull/188 Change CLI option EQ_PROMPT_ANIMATE_MS to binary EQ_PROMPT_ANIMATE
This commit is contained in:
parent
c17e1473db
commit
3916ac4165
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2125,7 +2125,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "reedline"
|
name = "reedline"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/nushell/reedline?branch=main#75d9b4b52d0ea60334ef96d49cd00002acc5720c"
|
source = "git+https://github.com/nushell/reedline?branch=main#2bc7046066f3d3f2a9a538fc3d546adf1e5d4b28"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"crossterm",
|
"crossterm",
|
||||||
|
19
src/main.rs
19
src/main.rs
@ -230,16 +230,15 @@ fn main() -> Result<()> {
|
|||||||
//Reset the ctrl-c handler
|
//Reset the ctrl-c handler
|
||||||
ctrlc.store(false, Ordering::SeqCst);
|
ctrlc.store(false, Ordering::SeqCst);
|
||||||
|
|
||||||
// Get animation milliseconds every loop, if not set, the animation
|
const EQ_PROMPT_ANIMATE_DEFAULT: bool = true;
|
||||||
// is defaulted to 1 second. If set to some non-number value,
|
// Toggle prompt animation
|
||||||
// like "OFF", then the animation is disabled. If set to some number
|
let animate = match std::env::var("EQ_PROMPT_ANIMATE") {
|
||||||
// like "5000" then the animation will run at 5 seconds.
|
Ok(ms_str) => match ms_str.as_str() {
|
||||||
let animate_ms = match std::env::var("EQ_PROMPT_ANIMATE_MS") {
|
"ON" | "1" => true,
|
||||||
Ok(ms_str) => match ms_str.parse::<u64>() {
|
"OFF" | "0" => false,
|
||||||
Ok(ms_int) => Some(ms_int),
|
_ => EQ_PROMPT_ANIMATE_DEFAULT,
|
||||||
_ => None,
|
|
||||||
},
|
},
|
||||||
_ => Some(1000),
|
_ => EQ_PROMPT_ANIMATE_DEFAULT,
|
||||||
};
|
};
|
||||||
|
|
||||||
let line_editor = Reedline::create()
|
let line_editor = Reedline::create()
|
||||||
@ -250,7 +249,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_repaint(animate_ms)
|
.with_animation(animate)
|
||||||
// .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 New Issue
Block a user