This commit is contained in:
John Smith 2022-06-26 18:04:02 -04:00
parent dc9a5ddad2
commit 1e1fb9ecbd
3 changed files with 52 additions and 10 deletions

24
Cargo.lock generated
View File

@ -1217,7 +1217,10 @@ dependencies = [
"lazy_static",
"libc",
"log",
"maplit",
"ncurses",
"signal-hook",
"term_size",
"unicode-segmentation",
"unicode-width",
]
@ -2637,6 +2640,17 @@ dependencies = [
"socket2",
]
[[package]]
name = "ncurses"
version = "5.101.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e2c5d34d72657dc4b638a1c25d40aae81e4f1c699062f72f467237920752032"
dependencies = [
"cc",
"libc",
"pkg-config",
]
[[package]]
name = "ndk"
version = "0.6.0"
@ -4329,6 +4343,16 @@ dependencies = [
"winapi",
]
[[package]]
name = "term_size"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "termcolor"
version = "1.1.3"

View File

@ -10,11 +10,16 @@ license = "LGPL-2.0-or-later OR MPL-2.0 OR (MIT AND BSD-3-Clause)"
name = "veilid-cli"
path = "src/main.rs"
[target.'cfg(unix)'.dependencies]
cursive = { path = "../external/cursive/cursive", default-features = false, features = ["ncurses-backend", "toml"]}
[target.'cfg(not(unix))'.dependencies]
cursive = { path = "../external/cursive/cursive", default-features = false, features = ["crossterm-backend", "toml"]}
[dependencies]
async-std = { version = "^1.9", features = ["unstable", "attributes"] }
async-tungstenite = { version = "^0.8", features = ["async-std-runtime"] }
async_executors = { version = "^0", default-features = false, features = [ "async_std" ]}
cursive = { path = "../external/cursive/cursive", default-features = false, features = ["crossterm-backend", "toml"]}
cursive-flexi-logger-view = { path = "../external/cursive-flexi-logger-view" }
cursive_buffered_backend = { path = "../external/cursive_buffered_backend" }
# cursive-multiplex = "0.4.0"

View File

@ -649,9 +649,20 @@ impl UI {
cursive_flexi_logger_view::resize(node_log_scrollback);
// Instantiate the cursive runnable
let runnable;
cfg_if::cfg_if! {
if #[cfg(unix)] {
runnable = CursiveRunnable::new(
|| -> Result<Box<dyn cursive_buffered_backend::Backend>, Box<DumbError>> {
let ncurses_backend = cursive::backends::curses::n::Backend::init().unwrap();
let buffered_backend =
cursive_buffered_backend::BufferedBackend::new(ncurses_backend);
// reduces flicker, but it costs cpu
let runnable = CursiveRunnable::new(
Ok(Box::new(buffered_backend))
},
);
} else {
runnable = CursiveRunnable::new(
|| -> Result<Box<dyn cursive_buffered_backend::Backend>, Box<DumbError>> {
let crossterm_backend = cursive::backends::crossterm::Backend::init().unwrap();
let buffered_backend =
@ -660,6 +671,8 @@ impl UI {
Ok(Box::new(buffered_backend))
},
);
}
}
//let runnable = cursive::default();
// Make the callback mechanism easily reachable