diff --git a/Cargo.lock b/Cargo.lock index 6c6bd20..0202723 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,7 +161,7 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "c3" -version = "0.2.0" +version = "0.3.0" dependencies = [ "arboard", "chrono", diff --git a/README.md b/README.md index d186184..8f36ce3 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,7 @@ A crossplatform to-do list app that uses and extends [calcurse](https://www.calc [Getting started](#getting-started) • [Installation](#installation) • -[Configuration](#configuration) • -[Integrations](#third-party-integrations) +[Usage](#configuration) @@ -22,9 +21,50 @@ cd c3 cargo build --release ``` -If you use arch linux, You can install c3 from AUR. Commands using yay would be -``` +If you use **Arch linux**, You can install c3 from AUR. Commands using yay would be +```bash yay -S c3 ``` ### Using a pre-built release -You can check out [releases](https://github.com/nimaaskarian/c3/releases) +You can check out [releases](https://github.com/nimaaskarian/c3/releases). + +## Usage +### Interactive mode +The default mode of the app is TUI mode. Keybinds are vim-like. Here they are: + +| key | action | +|---|---| +| a | add todo to bottom| +| A | add todo to top| +| e | edit todo | +| E | edit todo (move cursor to start) | +| ! | toggle show done | +| 0-9 | set todo priority | +| j | go down in todo list | +| k | go up in todo list | +| g | go top of todo list | +| G | go bottom of todo list | +| J | increase todo priority | +| K | decrease todo priority | +| d | toggle daily | +| D | delete todo | +| > | add todo note | +| t | add todo dependency | +| l | go in depedency/add todo dependency | +| h | go back to parent | +| T | delete todo dependency/note | +| x | cut todo to clipboard | +| y | yank todo to clipboard | +| p | paste todo from clipboard | +| P | enable module | +| / | search todo | +| n | search next | +| N | search previous | +| w | write changes to file | +| R | read from file (discard changes)| +#### Modules +TUI mode has a section called module. You can develop modules, and assign methods to Module trait methods. +A very simple example has been done by default for [potato-c](https://github.com/nimaaskarian/potato-c). + +Keybinds that modules can use are **space, H, L, comma, period, +, -, s, r** + diff --git a/src/tui.rs b/src/tui.rs index e44156e..f81858b 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -78,12 +78,6 @@ pub fn run(args: Args) -> io::Result<()> { let operation = app.update_return_operation()?; match operation { Operation::Restart => restart(&mut terminal)?, - Operation::Redraw => { - app.fix_index(); - terminal.draw(|frame| { - app.ui(frame, &mut list_state) - })?; - } Operation::Nothing =>{}, } } diff --git a/src/tui/app.rs b/src/tui/app.rs index 9f15a08..8c671c3 100644 --- a/src/tui/app.rs +++ b/src/tui/app.rs @@ -1,6 +1,6 @@ // vim:fileencoding=utf-8:foldmethod=marker // std{{{ -use std::{io::{self}, path::PathBuf}; +use std::{io::{self, Write}, path::PathBuf, fs::File}; //}}} // lib{{{ use tui_textarea::{Input, TextArea, CursorMove}; @@ -21,7 +21,6 @@ use crate::Args; pub enum Operation { Nothing, Restart, - Redraw, } pub struct App<'a>{ @@ -190,12 +189,14 @@ impl<'a>App<'a>{ let was_done = self.todo().unwrap().done(); self.mut_todo().unwrap().toggle_done(); self.fix_done_undone(); - let index = if was_done { - self.current_list().undone.len()-1 - } else { - self.current_list().len()-1 - }; - self.index = self.mut_current_list().reorder(index); + if self.show_done { + let index = if was_done { + self.current_list().undone.len()-1 + } else { + self.current_list().len()-1 + }; + self.index = self.mut_current_list().reorder(index); + } } #[inline] @@ -231,10 +232,13 @@ impl<'a>App<'a>{ #[inline] pub fn fix_index(&mut self) { let size = self.len(); + let mut file = File::create("log").unwrap(); + writeln!(file, "{}", self.index); self.index = match size { 0 => 0, _ => self.index.min(size-1), }; + writeln!(file, "{}", self.index); } #[inline] @@ -669,8 +673,8 @@ impl<'a>App<'a>{ if self.text_mode { return self.update_editor(); } else { - self.fix_index(); self.update_no_editor()?; + self.fix_index(); } Ok(Operation::Nothing) } @@ -693,10 +697,7 @@ impl<'a>App<'a>{ if let Key(key) = event::read()? { if key.kind == event::KeyEventKind::Press { match key.code { - Char('x') => { - self.cut_todo(); - return Ok(Operation::Redraw) - } + Char('x') => self.cut_todo(), Char('d') => self.toggle_current_daily(), Char('!') => self.toggle_show_done(), Char('y') => self.yank_todo(), @@ -723,16 +724,10 @@ impl<'a>App<'a>{ Char('t') => self.add_dependency(), Char('D') => { self.delete_todo(); - return Ok(Operation::Redraw) } Char('R') => self.read(), Char('T') => self.remove_current_dependent(), - KeyCode::Enter => { - self.toggle_current_done(); - if !self.show_done { - return Ok(Operation::Redraw) - } - }, + KeyCode::Enter => self.toggle_current_done(), Char('n') => self.search_next(), Char('N') => self.search_prev(), Char('a') => self.prepend_prompt(),