From 403d114d8296fe37dbdb509449a2fee2badb8d37 Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 4 Aug 2020 12:17:09 +0530 Subject: add feature to compile on windows, switch to termion --- .github/workflows/main.yml | 2 +- Cargo.lock | 190 ++++++++++++++++++++++++++++++++------------- Cargo.toml | 6 +- src/main.rs | 14 +++- 4 files changed, 153 insertions(+), 59 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2c07d9b..8786029 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -106,7 +106,7 @@ jobs: - name: Build for windows shell: bash - run: cargo build --release + run: cargo build --release --no-default-features --features "crossterm-backend" - name: Upload binaries to release uses: svenstaro/upload-release-action@v1-release diff --git a/Cargo.lock b/Cargo.lock index d53a14d..01fdb84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -91,12 +91,6 @@ dependencies = [ "constant_time_eq", ] -[[package]] -name = "cc" -version = "1.0.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" - [[package]] name = "cfg-if" version = "0.1.10" @@ -130,6 +124,15 @@ dependencies = [ "vec_map", ] +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] + [[package]] name = "const-random" version = "0.1.8" @@ -177,6 +180,31 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "crossterm" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f4919d60f26ae233e14233cc39746c8c8bb8cd7b05840ace83604917b51b6c7" +dependencies = [ + "bitflags", + "crossterm_winapi", + "lazy_static", + "libc", + "mio 0.7.0", + "parking_lot", + "signal-hook", + "winapi 0.3.9", +] + +[[package]] +name = "crossterm_winapi" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "057b7146d02fb50175fd7dbe5158f6097f33d02831f43b4ee8ae4ddf67b68f5c" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "ctor" version = "0.1.15" @@ -196,15 +224,14 @@ dependencies = [ "ahash 0.3.8", "cfg-if", "crossbeam-channel", + "crossterm", "cursive_core", "enumset", "lazy_static", "libc", "log", - "maplit", - "pancurses", "signal-hook", - "term_size", + "termion", "unicode-segmentation", "unicode-width", ] @@ -530,6 +557,15 @@ version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9" +[[package]] +name = "lock_api" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +dependencies = [ + "scopeguard", +] + [[package]] name = "log" version = "0.4.11" @@ -539,12 +575,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - [[package]] name = "mio" version = "0.6.22" @@ -558,12 +588,26 @@ dependencies = [ "kernel32-sys", "libc", "log", - "miow", + "miow 0.2.1", "net2", "slab", "winapi 0.2.8", ] +[[package]] +name = "mio" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e9971bc8349a361217a8f2a41f5d011274686bd4436465ba51730921039d7fb" +dependencies = [ + "lazy_static", + "libc", + "log", + "miow 0.3.5", + "ntapi", + "winapi 0.3.9", +] + [[package]] name = "mio-extras" version = "2.0.6" @@ -572,7 +616,7 @@ checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" dependencies = [ "lazycell", "log", - "mio", + "mio 0.6.22", "slab", ] @@ -589,14 +633,13 @@ dependencies = [ ] [[package]] -name = "ncurses" -version = "5.99.0" +name = "miow" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15699bee2f37e9f8828c7b35b2bc70d13846db453f2d507713b758fabe536b82" +checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" dependencies = [ - "cc", - "libc", - "pkg-config", + "socket2", + "winapi 0.3.9", ] [[package]] @@ -622,12 +665,21 @@ dependencies = [ "fsevent-sys", "inotify", "libc", - "mio", + "mio 0.6.22", "mio-extras", "walkdir", "winapi 0.3.9", ] +[[package]] +name = "ntapi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a31937dea023539c72ddae0e3571deadc1414b300483fa7aaec176168cfa9d2" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "num" version = "0.3.0" @@ -691,6 +743,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "numtoa" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" + [[package]] name = "owning_ref" version = "0.4.1" @@ -701,34 +759,29 @@ dependencies = [ ] [[package]] -name = "pancurses" -version = "0.16.1" +name = "parking_lot" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3058bc37c433096b2ac7afef1c5cdfae49ede0a4ffec3dfc1df1df0959d0ff0" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" dependencies = [ - "libc", - "log", - "ncurses", - "pdcurses-sys", - "winreg", + "lock_api", + "parking_lot_core", ] [[package]] -name = "pdcurses-sys" -version = "0.7.1" +name = "parking_lot_core" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084dd22796ff60f1225d4eb6329f33afaf4c85419d51d440ab6b8c6f4529166b" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" dependencies = [ - "cc", + "cfg-if", + "cloudabi", "libc", + "redox_syscall", + "smallvec", + "winapi 0.3.9", ] -[[package]] -name = "pkg-config" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" - [[package]] name = "proc-macro-hack" version = "0.5.16" @@ -759,6 +812,15 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "redox_termios" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +dependencies = [ + "redox_syscall", +] + [[package]] name = "redox_users" version = "0.3.4" @@ -797,6 +859,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + [[package]] name = "serde" version = "1.0.114" @@ -835,6 +903,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "604508c1418b99dfe1925ca9224829bb2a8a9a04dda655cc01fcad46f4ab05ed" dependencies = [ "libc", + "mio 0.7.0", "signal-hook-registry", ] @@ -854,6 +923,24 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +[[package]] +name = "smallvec" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" + +[[package]] +name = "socket2" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.9", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -884,13 +971,15 @@ dependencies = [ ] [[package]] -name = "term_size" -version = "0.3.2" +name = "termion" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" +checksum = "c22cec9d8978d906be5ac94bceb5a010d885c626c4c8855721a4dbd20e3ac905" dependencies = [ "libc", - "winapi 0.3.9", + "numtoa", + "redox_syscall", + "redox_termios", ] [[package]] @@ -1029,15 +1118,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "winreg" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27a759395c1195c4cc5cda607ef6f8f6498f64e78f7900f5de0a127a424704a" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "ws2_32-sys" version = "0.2.1" diff --git a/Cargo.toml b/Cargo.toml index 57f659b..fa7b033 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,6 @@ toml = "0.5.6" [dependencies.cursive] version = "0.15" default-features = false -features = ["pancurses-backend"] [dependencies.chrono] version = "0.4" @@ -33,3 +32,8 @@ features = ["serde"] [dependencies.serde] version = "1.0.103" features = ["derive"] + +[features] +default = ["termion-backend"] +termion-backend = ["cursive/termion-backend"] +crossterm-backend = ["cursive/crossterm-backend"] diff --git a/src/main.rs b/src/main.rs index 84fd8ee..56c521d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,13 @@ use crate::command::{open_command_window, Command}; use crate::utils::{load_configuration_file, AppConfig}; use clap::{App as ClapApp, Arg}; -use cursive::pancurses; + +#[cfg(any(feature = "termion-backend", feature = "default"))] +use cursive::termion; + +#[cfg(feature = "crossterm-backend")] +use cursive::crossterm; + use cursive::views::{LinearLayout, NamedView}; use lazy_static::lazy_static; @@ -62,7 +68,11 @@ fn main() { println!("{}", h); } } else { - let mut s = pancurses().unwrap(); + #[cfg(any(feature = "termion-backend", feature = "default"))] + let mut s = termion().unwrap(); + + #[cfg(feature = "crossterm-backend")] + let mut s = crossterm().unwrap(); let app = App::load_state(); let layout = NamedView::new( -- cgit v1.2.3