mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-26 03:07:18 +02:00
Support custom shell command
This commit is contained in:
parent
c1fcdffb71
commit
cbb9e60ca8
3 changed files with 97 additions and 1 deletions
48
src/main.rs
48
src/main.rs
|
@ -114,8 +114,13 @@ fn tui_main(_config: &str) -> Result<(), Box<dyn Error>> {
|
|||
}
|
||||
app.cursor_location = app.modify.chars().count();
|
||||
}
|
||||
Key::Char('!') => {
|
||||
app.mode = AppMode::TaskSubprocess;
|
||||
app.cursor_location = app.command.chars().count();
|
||||
}
|
||||
Key::Char('l') => {
|
||||
app.mode = AppMode::TaskLog;
|
||||
app.cursor_location = app.command.chars().count();
|
||||
}
|
||||
Key::Char('a') => {
|
||||
app.mode = AppMode::TaskAdd;
|
||||
|
@ -183,6 +188,49 @@ fn tui_main(_config: &str) -> Result<(), Box<dyn Error>> {
|
|||
}
|
||||
_ => {}
|
||||
},
|
||||
AppMode::TaskSubprocess => match input {
|
||||
Key::Char('\n') => match app.task_subprocess() {
|
||||
Ok(_) => {
|
||||
app.mode = AppMode::TaskReport;
|
||||
app.update();
|
||||
}
|
||||
Err(e) => {
|
||||
app.mode = AppMode::TaskError;
|
||||
app.error = e;
|
||||
}
|
||||
},
|
||||
Key::Esc => {
|
||||
app.command = "".to_string();
|
||||
app.mode = AppMode::TaskReport;
|
||||
}
|
||||
Key::Right => {
|
||||
if app.cursor_location < app.command.chars().count() {
|
||||
app.cursor_location += 1;
|
||||
}
|
||||
}
|
||||
Key::Left => {
|
||||
if app.cursor_location > 0 {
|
||||
app.cursor_location -= 1;
|
||||
}
|
||||
}
|
||||
Key::Char(c) => {
|
||||
if app.cursor_location < app.command.chars().count() {
|
||||
app.command.insert_str(app.cursor_location, &c.to_string());
|
||||
} else {
|
||||
app.command.push(c);
|
||||
}
|
||||
app.cursor_location += 1;
|
||||
}
|
||||
Key::Backspace => {
|
||||
if app.cursor_location > 0 {
|
||||
app.cursor_location -= 1;
|
||||
let mut cs = app.command.chars().collect::<Vec<char>>();
|
||||
cs.remove(app.cursor_location);
|
||||
app.command = cs.into_iter().collect();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
AppMode::TaskLog => match input {
|
||||
Key::Char('\n') => match app.task_log() {
|
||||
Ok(_) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue