fix cursive for macos veilid-cli

This commit is contained in:
John Smith
2023-05-29 18:12:02 -04:00
parent 9db6f494c2
commit a2839042d6
4 changed files with 24 additions and 3 deletions

View File

@@ -16,7 +16,6 @@ rt-async-std = [ "async-std", "veilid-core/rt-async-std", "cursive/rt-async-std"
rt-tokio = [ "tokio", "tokio-util", "veilid-core/rt-tokio", "cursive/rt-tokio" ]
[dependencies]
cursive = { path = "../external/cursive/cursive", default-features = false, features = [ "crossterm", "toml", "ansi" ]}
async-std = { version = "^1.9", features = ["unstable", "attributes"], optional = true }
tokio = { version = "^1", features = ["full"], optional = true }
tokio-util = { version = "^0", features = ["compat"], optional = true}
@@ -46,6 +45,12 @@ hex = "^0"
veilid-core = { path = "../veilid-core" }
json = "^0"
[target.'cfg(not(target_os = "macos"))'.dependencies]
cursive = { path = "../external/cursive/cursive", default-features = false, features = [ "crossterm", "toml", "ansi" ]}
[target.'cfg(target_os = "macos")'.dependencies]
cursive = { path = "../external/cursive/cursive", default-features = false, features = [ "ncurses-backend", "toml", "ansi" ]}
[dev-dependencies]
serial_test = "^0"

View File

@@ -709,7 +709,10 @@ impl UI {
// Instantiate the cursive runnable
let runnable = CursiveRunnable::new(
|| -> Result<Box<dyn cursive_buffered_backend::Backend>, Box<DumbError>> {
|| -> Result<Box<dyn cursive::backend::Backend>, Box<DumbError>> {
#[cfg(target_os = "macos")]
let backend = cursive::backends::curses::n::Backend::init().unwrap();
#[cfg(not(target_os = "macos"))]
let backend = cursive::backends::crossterm::Backend::init().unwrap();
let buffered_backend = cursive_buffered_backend::BufferedBackend::new(backend);
Ok(Box::new(buffered_backend))