From 3eace50dfb39317fb08e5a95d6126b787c567a17 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 18 Jul 2020 14:14:40 +0530 Subject: switch to termion backend for strikethrough and stable refresh rate --- Cargo.toml | 2 +- src/app.rs | 12 +++++++----- src/main.rs | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 69a1958..17fb40f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ notify = "4.0" [dependencies.cursive] version = "0.15" -features = ["crossterm-backend"] +features = ["termion-backend"] [dependencies.chrono] version = "0.4" diff --git a/src/app.rs b/src/app.rs index e8273e3..52c7f5f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,17 +1,17 @@ use std::default::Default; use std::f64; -use std::time::Duration; use std::fs::{File, OpenOptions}; use std::io::prelude::*; use std::path::PathBuf; use std::sync::mpsc::{channel, Receiver}; +use std::time::Duration; use chrono::Local; use cursive::direction::{Absolute, Direction}; use cursive::event::{Event, EventResult, Key}; use cursive::view::View; use cursive::{Printer, Vec2}; -use notify::{watcher, RecursiveMode, Watcher, DebouncedEvent, INotifyWatcher}; +use notify::{watcher, DebouncedEvent, INotifyWatcher, RecursiveMode, Watcher}; use crate::habit::{Bit, Count, HabitWrapper, TrackEvent, ViewMode}; use crate::utils; @@ -40,9 +40,11 @@ impl App { pub fn new() -> Self { let (tx, rx) = channel(); let mut watcher = watcher(tx, Duration::from_secs(1)).unwrap(); - watcher.watch(utils::auto_habit_file(), RecursiveMode::Recursive).unwrap_or_else(|e| { - panic!("Unable to start file watcher: {}", e); - }); + watcher + .watch(utils::auto_habit_file(), RecursiveMode::Recursive) + .unwrap_or_else(|e| { + panic!("Unable to start file watcher: {}", e); + }); return App { habits: vec![], focus: 0, diff --git a/src/main.rs b/src/main.rs index 3efecd6..dc6081d 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::ncurses; +use cursive::termion; use cursive::views::NamedView; use lazy_static::lazy_static; @@ -44,7 +44,7 @@ fn main() { eprintln!("Invalid or unsupported command!"); } } else { - let mut s = ncurses().unwrap(); + let mut s = termion().unwrap(); let app = App::load_state(); s.add_layer(NamedView::new("Main", app)); s.add_global_callback(':', |s| open_command_window(s)); -- cgit v1.2.3