From 5dd90a7808c2a1ed8f7ba901765d2e42858b2192 Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 20 Jul 2020 11:38:20 +0530 Subject: switch to crossterm backend --- Cargo.lock | 160 ++++++++++++++++++++++++++++++++++++++++++++++++------------ Cargo.toml | 2 +- src/main.rs | 4 +- 3 files changed, 132 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 63d34ea..6ff6a8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -130,6 +130,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 +186,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,6 +230,7 @@ dependencies = [ "ahash 0.3.8", "cfg-if", "crossbeam-channel", + "crossterm", "cursive_core", "enumset", "lazy_static", @@ -205,7 +240,6 @@ dependencies = [ "ncurses", "signal-hook", "term_size", - "termion", "unicode-segmentation", "unicode-width", ] @@ -530,6 +564,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" @@ -564,12 +607,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" @@ -578,7 +635,7 @@ checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" dependencies = [ "lazycell", "log", - "mio", + "mio 0.6.22", "slab", ] @@ -594,6 +651,16 @@ dependencies = [ "ws2_32-sys", ] +[[package]] +name = "miow" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" +dependencies = [ + "socket2", + "winapi 0.3.9", +] + [[package]] name = "ncurses" version = "5.99.0" @@ -628,12 +695,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" @@ -697,12 +773,6 @@ 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" @@ -712,6 +782,30 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "parking_lot" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +dependencies = [ + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "smallvec", + "winapi 0.3.9", +] + [[package]] name = "pkg-config" version = "0.3.18" @@ -748,15 +842,6 @@ 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" @@ -795,6 +880,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" @@ -833,6 +924,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "604508c1418b99dfe1925ca9224829bb2a8a9a04dda655cc01fcad46f4ab05ed" dependencies = [ "libc", + "mio 0.7.0", "signal-hook-registry", ] @@ -852,6 +944,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" @@ -891,18 +1001,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "termion" -version = "1.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22cec9d8978d906be5ac94bceb5a010d885c626c4c8855721a4dbd20e3ac905" -dependencies = [ - "libc", - "numtoa", - "redox_syscall", - "redox_termios", -] - [[package]] name = "textwrap" version = "0.11.0" diff --git a/Cargo.toml b/Cargo.toml index 0240b65..7659d9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ notify = "4.0" [dependencies.cursive] version = "0.15" -features = ["termion-backend"] +features = ["crossterm-backend"] [dependencies.chrono] version = "0.4" diff --git a/src/main.rs b/src/main.rs index d96119e..fb16aaa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ use crate::command::{open_command_window, Command}; use crate::utils::{load_configuration_file, AppConfig}; use clap::{App as ClapApp, Arg}; -use cursive::termion; +use cursive::crossterm; use cursive::views::{LinearLayout, NamedView}; use lazy_static::lazy_static; @@ -50,7 +50,7 @@ fn main() { ), } } else { - let mut s = termion().unwrap(); + let mut s = crossterm().unwrap(); let app = App::load_state(); let layout = NamedView::new( "Frame", -- cgit v1.2.3 From 02bba52346d948e90fbc1b351486f0f1307c243d Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 21 Jul 2020 08:38:48 +0530 Subject: remove ncurses dependency --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 7659d9a..4b35c96 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ notify = "4.0" [dependencies.cursive] version = "0.15" +default-features = false features = ["crossterm-backend"] [dependencies.chrono] -- cgit v1.2.3 From 9dfe454cd8bc816522446e7e3b9f45630c886112 Mon Sep 17 00:00:00 2001 From: Guillaume Hormiere Date: Wed, 22 Jul 2020 00:38:01 +0200 Subject: Add list command for shell script purpose Usage dijo -l for printing the habit names list Add check on habit add to avoid duplicate habits --- src/app/impl_self.rs | 21 ++++++++++++++++++++- src/main.rs | 14 ++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs index 95f1871..38162ee 100644 --- a/src/app/impl_self.rs +++ b/src/app/impl_self.rs @@ -33,8 +33,27 @@ impl App { }; } + pub fn list_habit(&self) -> Vec { + let mut habits_names: Vec = vec![]; + for h in self.habits.iter() { + habits_names.push(h.name()) + } + return habits_names; + } + pub fn add_habit(&mut self, h: Box) { - self.habits.push(h); + if self + .habits + .iter() + .filter(|hab| hab.name() == h.name()) + .count() + > 0 + { + self.message + .set_message(format!("Habit `{}` allready exist", h.name())) + } else { + self.habits.push(h); + } } pub fn delete_by_name(&mut self, name: &str) { diff --git a/src/main.rs b/src/main.rs index d96119e..050a296 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,6 +33,14 @@ fn main() { .value_name("CMD") .help("run a dijo command"), ) + .arg( + Arg::with_name("list") + .short("l") + .long("list") + .takes_value(false) + .help("list dijo habits") + .conflicts_with("command"), + ) .get_matches(); if let Some(c) = matches.value_of("command") { let command = Command::from_string(c); @@ -49,6 +57,12 @@ fn main() { "Commands other than `track-up` and `track-down` are currently not supported!" ), } + } else if matches.is_present("list") { + let app = App::load_state(); + let _habit_names = app.list_habit(); + for h in _habit_names { + println!("{}", h); + } } else { let mut s = termion().unwrap(); let app = App::load_state(); -- cgit v1.2.3 From a0c57162b2026e37220e31a39d821c2a2e31cc51 Mon Sep 17 00:00:00 2001 From: Guillaume Hormiere Date: Wed, 22 Jul 2020 22:26:19 +0200 Subject: Use immutable vector instead of mutable one and change the message kind to Error Apply code review --- src/app/impl_self.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs index 38162ee..8a84cb2 100644 --- a/src/app/impl_self.rs +++ b/src/app/impl_self.rs @@ -34,10 +34,7 @@ impl App { } pub fn list_habit(&self) -> Vec { - let mut habits_names: Vec = vec![]; - for h in self.habits.iter() { - habits_names.push(h.name()) - } + let habits_names = self.habits.iter().map(|x| x.name()).collect::>(); return habits_names; } @@ -49,6 +46,7 @@ impl App { .count() > 0 { + self.message.set_kind(MessageKind::Error); self.message .set_message(format!("Habit `{}` allready exist", h.name())) } else { -- cgit v1.2.3 From f5940ea5fc507ec34d686a888a1aa1aba50be277 Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 23 Jul 2020 10:06:34 +0530 Subject: fix tiemzones in statusline --- src/app/impl_self.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs index cf0e97f..1ed19e6 100644 --- a/src/app/impl_self.rs +++ b/src/app/impl_self.rs @@ -128,7 +128,7 @@ impl App { let completed = total - remaining; let timestamp = if self.view_month_offset == 0 { - format!("{}", Local::now().date().format("%d/%b/%y"),) + format!("{}", Local::now().naive_local().date().format("%d/%b/%y"),) } else { let months = self.view_month_offset; format!("{}", format!("{} months ago", months),) -- cgit v1.2.3 From 59b40932d4602fc7bf84f123930f9a0eb187f4a1 Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 23 Jul 2020 10:07:21 +0530 Subject: bump to v0.2.0! --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bda3c1e..a299289 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -260,7 +260,7 @@ dependencies = [ [[package]] name = "dijo" -version = "0.1.5" +version = "0.2.0" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 3f297b8..f215503 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dijo" -version = "0.1.5" +version = "0.2.0" authors = ["Akshay "] edition = "2018" description = "Scriptable, curses-based, digital habit tracker" -- cgit v1.2.3 From b0b6c04a052955834f0603df79db7a0a517a9b9d Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 23 Jul 2020 13:19:15 +0530 Subject: move duplicate check to command parsing block --- src/app/impl_self.rs | 25 +++++++------------------ src/main.rs | 4 +--- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs index 1dfe268..a806dc5 100644 --- a/src/app/impl_self.rs +++ b/src/app/impl_self.rs @@ -33,25 +33,8 @@ impl App { }; } - pub fn list_habit(&self) -> Vec { - let habits_names = self.habits.iter().map(|x| x.name()).collect::>(); - return habits_names; - } - pub fn add_habit(&mut self, h: Box) { - if self - .habits - .iter() - .filter(|hab| hab.name() == h.name()) - .count() - > 0 - { - self.message.set_kind(MessageKind::Error); - self.message - .set_message(format!("Habit `{}` allready exist", h.name())) - } else { - self.habits.push(h); - } + self.habits.push(h); } pub fn list_habits(&self) -> Vec { @@ -234,6 +217,12 @@ impl App { match result { Ok(c) => match c { Command::Add(name, goal, auto) => { + if let Some(_) = self.habits.iter().find(|x| x.name() == name) { + self.message.set_kind(MessageKind::Error); + self.message + .set_message(format!("Habit `{}` already exist", &name)); + return; + } let kind = if goal == Some(1) { "bit" } else { "count" }; if kind == "count" { self.add_habit(Box::new(Count::new(name, goal.unwrap_or(0), auto))); diff --git a/src/main.rs b/src/main.rs index 050a296..5523073 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,9 +58,7 @@ fn main() { ), } } else if matches.is_present("list") { - let app = App::load_state(); - let _habit_names = app.list_habit(); - for h in _habit_names { + for h in App::load_state().list_habits() { println!("{}", h); } } else { -- cgit v1.2.3 From 7322949561fdbdc36a811b1368222fb5a2bf050a Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 20 Jul 2020 11:38:20 +0530 Subject: switch to crossterm backend --- Cargo.lock | 180 +++++++++++++++++++++++++++++++++++++++++++++--------------- Cargo.toml | 2 +- src/main.rs | 4 +- 3 files changed, 139 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a299289..25e21e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -124,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" @@ -152,12 +161,12 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "crossbeam-channel" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cced8691919c02aac3cb0a1bc2e9b73d89e832bf9a06fc579d4e71b68a2da061" +checksum = "09ee0cc8804d5393478d743b035099520087a5186f3b93fa58cec08fa62407b6" dependencies = [ + "cfg-if", "crossbeam-utils", - "maybe-uninit", ] [[package]] @@ -171,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" @@ -190,13 +224,13 @@ dependencies = [ "ahash 0.3.8", "cfg-if", "crossbeam-channel", + "crossterm", "cursive_core", "enumset", "lazy_static", "libc", "log", "signal-hook", - "termion", "unicode-segmentation", "unicode-width", ] @@ -521,6 +555,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" @@ -530,12 +573,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "mio" version = "0.6.22" @@ -549,12 +586,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" @@ -563,7 +614,7 @@ checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" dependencies = [ "lazycell", "log", - "mio", + "mio 0.6.22", "slab", ] @@ -579,6 +630,16 @@ dependencies = [ "ws2_32-sys", ] +[[package]] +name = "miow" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" +dependencies = [ + "socket2", + "winapi 0.3.9", +] + [[package]] name = "net2" version = "0.2.34" @@ -602,12 +663,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" @@ -671,12 +741,6 @@ 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" @@ -686,6 +750,30 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "parking_lot" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +dependencies = [ + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "smallvec", + "winapi 0.3.9", +] + [[package]] name = "proc-macro-hack" version = "0.5.16" @@ -694,9 +782,9 @@ checksum = "7e0456befd48169b9f13ef0f0ad46d492cf9d2dbb918bcf38e01eed4ce3ec5e4" [[package]] name = "proc-macro2" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" +checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" dependencies = [ "unicode-xid", ] @@ -716,15 +804,6 @@ 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" @@ -763,6 +842,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" @@ -801,6 +886,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "604508c1418b99dfe1925ca9224829bb2a8a9a04dda655cc01fcad46f4ab05ed" dependencies = [ "libc", + "mio 0.7.0", "signal-hook-registry", ] @@ -820,6 +906,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" @@ -840,27 +944,15 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "syn" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cae2873c940d92e697597c5eee105fb570cd5689c695806f672883653349b" +checksum = "fb7f4c519df8c117855e19dd8cc851e89eb746fe7a73f0157e0d95fdec5369b0" dependencies = [ "proc-macro2", "quote", "unicode-xid", ] -[[package]] -name = "termion" -version = "1.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22cec9d8978d906be5ac94bceb5a010d885c626c4c8855721a4dbd20e3ac905" -dependencies = [ - "libc", - "numtoa", - "redox_syscall", - "redox_termios", -] - [[package]] name = "textwrap" version = "0.11.0" diff --git a/Cargo.toml b/Cargo.toml index f215503..c587196 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ notify = "4.0" [dependencies.cursive] version = "0.15" default-features = false -features = ["termion-backend"] +features = ["crossterm-backend"] [dependencies.chrono] version = "0.4" diff --git a/src/main.rs b/src/main.rs index 5523073..3e35ebc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ use crate::command::{open_command_window, Command}; use crate::utils::{load_configuration_file, AppConfig}; use clap::{App as ClapApp, Arg}; -use cursive::termion; +use cursive::crossterm; use cursive::views::{LinearLayout, NamedView}; use lazy_static::lazy_static; @@ -62,7 +62,7 @@ fn main() { println!("{}", h); } } else { - let mut s = termion().unwrap(); + let mut s = crossterm().unwrap(); let app = App::load_state(); let layout = NamedView::new( "Frame", -- cgit v1.2.3 From d1d1aeb3d5aaa75f262467c5e683e76ce7a844ab Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko Date: Thu, 23 Jul 2020 11:48:56 +0300 Subject: add windows to github actions --- .github/workflows/main.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8ccbae..e2995b8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -82,3 +82,38 @@ jobs: asset_name: dijo-x86_64-apple tag: ${{ github.ref }} overwrite: true + + build-windows: + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Cache Rust dependencies + uses: actions/cache@v1.0.1 + with: + path: target + key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.OS }}-build- + - name: Install latest rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: beta + target: x86_64-pc-windows-msvc + default: true + override: true + + - name: Build for windows + run: | + cargo build --all --release + strip target/release/dijo + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v1-release + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: target/release/dijo + asset_name: dijo-x86_64-windows + tag: ${{ github.ref }} + overwrite: true -- cgit v1.2.3 From 2f47f50b0382491099391185c6a2702b1370b206 Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 23 Jul 2020 22:39:28 +0530 Subject: remove dependency on rustc v1.45, bump to v0.2.1 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/command.rs | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c4f9734..0488f71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -295,7 +295,7 @@ dependencies = [ [[package]] name = "dijo" -version = "0.2.0" +version = "0.2.1" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index a0872ce..f4a31c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dijo" -version = "0.2.0" +version = "0.2.1" authors = ["Akshay "] edition = "2018" description = "Scriptable, curses-based, digital habit tracker" diff --git a/src/command.rs b/src/command.rs index 38d48e9..0372065 100644 --- a/src/command.rs +++ b/src/command.rs @@ -61,8 +61,7 @@ pub fn open_command_window(s: &mut Cursive) { let completion = get_habit_completion(word, &habit_list); eprintln!("{:?} | {:?}", completion, contents); if let Some(c) = completion { - let cb = - view.set_content(format!("{}", contents) + c.strip_prefix(word).unwrap()); + let cb = view.set_content(format!("{}", contents) + &c[word.len()..]); return Some(EventResult::Consumed(Some(cb))); }; return None; -- cgit v1.2.3 From d7c303dda4750a432478c94b3ed41bca1352d839 Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 23 Jul 2020 23:06:22 +0530 Subject: enable feature based compilation to support windows --- .github/workflows/main.yml | 6 +++--- Cargo.toml | 5 ++++- src/main.rs | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e2995b8..5c3e6f9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,7 +39,7 @@ jobs: && sudo apt-get install -y \ libdbus-1-dev - name: Build - run: cargo build --all --release && strip target/release/dijo + run: cargo build -all --no-default-features --features unix --release && strip target/release/dijo - name: Upload binaries to release uses: svenstaro/upload-release-action@v1-release @@ -72,7 +72,7 @@ jobs: override: true - name: Build for mac - run: cargo build --all --release && strip target/release/dijo + run: cargo build --all --no-default-features --features unix --release && strip target/release/dijo - name: Upload binaries to release uses: svenstaro/upload-release-action@v1-release @@ -106,7 +106,7 @@ jobs: - name: Build for windows run: | - cargo build --all --release + cargo build --all --no-default-features --features windows --release strip target/release/dijo - name: Upload binaries to release diff --git a/Cargo.toml b/Cargo.toml index f4a31c9..6443a4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,10 @@ notify = "4.0" [dependencies.cursive] version = "0.15" default-features = false -features = ["termion-backend", "crossterm-backend"] + +[features] +unix = ["cursive/termion-backend"] +windows = ["cursive/crossterm-backend"] [dependencies.chrono] version = "0.4" diff --git a/src/main.rs b/src/main.rs index dec3156..609738e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ use crate::utils::{load_configuration_file, AppConfig}; use clap::{App as ClapApp, Arg}; -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "macos"))] use cursive::termion; #[cfg(target_os = "windows")] @@ -71,7 +71,7 @@ fn main() { #[cfg(target_os = "windows")] let mut s = crossterm().unwrap(); - #[cfg(target_os = "linux")] + #[cfg(any(target_os = "linux", target_os = "macos"))] let mut s = termion().unwrap(); let app = App::load_state(); -- cgit v1.2.3