mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 08:47:18 +02:00
Change InputMode to AppMode
This commit is contained in:
parent
f8d213d7f9
commit
d796c69d9f
2 changed files with 12 additions and 13 deletions
24
src/app.rs
24
src/app.rs
|
@ -60,8 +60,8 @@ pub fn vague_format_date_time(dt: &Date) -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum InputMode {
|
pub enum AppMode {
|
||||||
Normal,
|
Report,
|
||||||
Command,
|
Command,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ pub struct App {
|
||||||
pub tasks: Vec<Task>,
|
pub tasks: Vec<Task>,
|
||||||
pub task_report_labels: Vec<String>,
|
pub task_report_labels: Vec<String>,
|
||||||
pub task_report_columns: Vec<String>,
|
pub task_report_columns: Vec<String>,
|
||||||
pub input_mode: InputMode,
|
pub mode: AppMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
|
@ -84,7 +84,7 @@ impl App {
|
||||||
task_report_labels: vec![],
|
task_report_labels: vec![],
|
||||||
task_report_columns: vec![],
|
task_report_columns: vec![],
|
||||||
filter: "status:pending ".to_string(),
|
filter: "status:pending ".to_string(),
|
||||||
input_mode: InputMode::Normal,
|
mode: AppMode::Report,
|
||||||
};
|
};
|
||||||
app.update();
|
app.update();
|
||||||
app
|
app
|
||||||
|
@ -104,9 +104,9 @@ impl App {
|
||||||
self.draw_task_report(f, rects[0]);
|
self.draw_task_report(f, rects[0]);
|
||||||
self.draw_task_details(f, rects[1]);
|
self.draw_task_details(f, rects[1]);
|
||||||
self.draw_command(f, rects[2]);
|
self.draw_command(f, rects[2]);
|
||||||
match self.input_mode {
|
match self.mode {
|
||||||
InputMode::Normal => (),
|
AppMode::Report => (),
|
||||||
InputMode::Command => {
|
AppMode::Command => {
|
||||||
// Make the cursor visible and ask tui-rs to put it at the specified coordinates after rendering
|
// Make the cursor visible and ask tui-rs to put it at the specified coordinates after rendering
|
||||||
f.set_cursor(
|
f.set_cursor(
|
||||||
// Put cursor past the end of the input text
|
// Put cursor past the end of the input text
|
||||||
|
@ -381,20 +381,20 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_input(&mut self, event: Key) {
|
pub fn handle_input(&mut self, event: Key) {
|
||||||
match self.input_mode {
|
match self.mode {
|
||||||
InputMode::Normal => match event {
|
AppMode::Report => match event {
|
||||||
Key::Ctrl('c') | Key::Char('q') => self.should_quit = true,
|
Key::Ctrl('c') | Key::Char('q') => self.should_quit = true,
|
||||||
Key::Char('r') => self.update(),
|
Key::Char('r') => self.update(),
|
||||||
Key::Down | Key::Char('j') => self.next(),
|
Key::Down | Key::Char('j') => self.next(),
|
||||||
Key::Up | Key::Char('k') => self.previous(),
|
Key::Up | Key::Char('k') => self.previous(),
|
||||||
Key::Char('/') => {
|
Key::Char('/') => {
|
||||||
self.input_mode = InputMode::Command;
|
self.mode = AppMode::Command;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
InputMode::Command => match event {
|
AppMode::Command => match event {
|
||||||
Key::Char('\n') | Key::Esc => {
|
Key::Char('\n') | Key::Esc => {
|
||||||
self.input_mode = InputMode::Normal;
|
self.mode = AppMode::Report;
|
||||||
}
|
}
|
||||||
Key::Char(c) => {
|
Key::Char(c) => {
|
||||||
self.filter.push(c);
|
self.filter.push(c);
|
||||||
|
|
|
@ -18,7 +18,6 @@ use tui::backend::Backend;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
use app::App;
|
use app::App;
|
||||||
use app::InputMode;
|
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
// Terminal initialization
|
// Terminal initialization
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue