From f156defd5b1a7e38b8f98e6df3135b288ac61722 Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 10 Jul 2020 21:51:10 +0530 Subject: move to crossterm backend --- Cargo.toml | 5 ++++- src/main.rs | 59 ++++++++++++++--------------------------------------------- 2 files changed, 18 insertions(+), 46 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3fea17f..593963b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,12 +7,15 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cursive = "0.14" serde_json = "1.0" lazy_static = "1.4.0" erased-serde = "0.3" typetag = "0.1.4" +[dependencies.cursive] +version = "0.14" +features = ["crossterm-backend"] + [dependencies.chrono] version = "0.4" features = ["serde"] diff --git a/src/main.rs b/src/main.rs index 418ec3b..4f91990 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,63 +1,32 @@ #![allow(unused_must_use)] -use chrono::NaiveDate; - -use lazy_static::lazy_static; - -//use cursive::views::{Dialog, EditView, LinearLayout, ListView, SelectView}; -use cursive::theme::{BaseColor, Color}; -use cursive::views::NamedView; -use cursive::Cursive; - -mod habit; -use crate::habit::{Bit, Count, Habit}; +use std::default::Default; mod app; mod command; +mod habit; mod theme; -use crate::app::{App, ViewMode}; -use crate::command::{open_command_window, Command}; - +mod utils; mod views; -pub struct AppConfig { - pub true_chr: char, - pub false_chr: char, - pub future_chr: char, - - // view dimensions - pub view_width: usize, - pub view_height: usize, - - // app dimensions - pub grid_width: usize, +use crate::app::{App, ViewMode}; +use crate::command::{open_command_window, Command}; +use crate::habit::{Bit, Count, Habit}; +use crate::utils::{load_configuration_file, AppConfig}; - // color config - pub reached_color: Color, - pub todo_color: Color, - pub future_color: Color, -} +use chrono::NaiveDate; +use cursive::theme::{BaseColor, Color}; +use cursive::views::NamedView; +use cursive::Cursive; +use lazy_static::lazy_static; +use serde::{Deserialize, Serialize}; lazy_static! { pub static ref CONFIGURATION: AppConfig = load_configuration_file(); } -fn load_configuration_file() -> AppConfig { - return AppConfig { - true_chr: '·', - false_chr: '·', - future_chr: '·', - view_width: 25, - view_height: 8, - grid_width: 3, - reached_color: Color::Dark(BaseColor::Cyan), - todo_color: Color::Dark(BaseColor::Magenta), - future_color: Color::Light(BaseColor::Black), - }; -} - fn main() { - let mut s = Cursive::default(); + let mut s = Cursive::crossterm().unwrap(); // let mut gymming = Count::new("gym", 5); // gymming.insert_entry(NaiveDate::from_ymd(2020, 5, 11), 7); -- cgit v1.2.3