mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-26 03:07:18 +02:00
Add task details scroll
This commit is contained in:
parent
d8be829dea
commit
4682fe76b0
4 changed files with 36 additions and 9 deletions
|
@ -45,6 +45,10 @@ Keybindings for task report:
|
||||||
|
|
||||||
A: task {selected} annotate {string} - Annotate current task
|
A: task {selected} annotate {string} - Annotate current task
|
||||||
|
|
||||||
|
Ctrl-e: scroll down task details - Scroll task details view down one line
|
||||||
|
|
||||||
|
Ctrl-y: scroll up task details - Scroll task details view up one line
|
||||||
|
|
||||||
!: {string} - Custom shell command
|
!: {string} - Custom shell command
|
||||||
|
|
||||||
1-9: {string} - Run user defined shortcuts
|
1-9: {string} - Run user defined shortcuts
|
||||||
|
@ -53,7 +57,6 @@ Keybindings for task report:
|
||||||
|
|
||||||
?: help - Help menu
|
?: help - Help menu
|
||||||
|
|
||||||
|
|
||||||
Keybindings for context switcher:
|
Keybindings for context switcher:
|
||||||
|
|
||||||
j: {selected+=1} - Move forward a context
|
j: {selected+=1} - Move forward a context
|
||||||
|
|
|
@ -100,6 +100,13 @@ Keybindings for task report:
|
||||||
`A`
|
`A`
|
||||||
: task {selected} annotate {string} - Annotate current task
|
: task {selected} annotate {string} - Annotate current task
|
||||||
|
|
||||||
|
Ctrl-e
|
||||||
|
: scroll down task details - Scroll task details view down one line
|
||||||
|
|
||||||
|
Ctrl-y
|
||||||
|
: scroll up task details - Scroll task details view up one line
|
||||||
|
|
||||||
|
|
||||||
`!`
|
`!`
|
||||||
: {string} - Custom shell command
|
: {string} - Custom shell command
|
||||||
|
|
||||||
|
|
29
src/app.rs
29
src/app.rs
|
@ -155,6 +155,7 @@ pub struct TTApp {
|
||||||
pub config: Config,
|
pub config: Config,
|
||||||
pub task_report_show_info: bool,
|
pub task_report_show_info: bool,
|
||||||
pub task_report_height: u16,
|
pub task_report_height: u16,
|
||||||
|
pub task_details_scroll: u16,
|
||||||
pub help_popup: Help,
|
pub help_popup: Help,
|
||||||
pub contexts: Vec<Context>,
|
pub contexts: Vec<Context>,
|
||||||
pub last_export: Option<SystemTime>,
|
pub last_export: Option<SystemTime>,
|
||||||
|
@ -179,6 +180,7 @@ impl TTApp {
|
||||||
error: "".to_string(),
|
error: "".to_string(),
|
||||||
mode: AppMode::TaskReport,
|
mode: AppMode::TaskReport,
|
||||||
task_report_height: 0,
|
task_report_height: 0,
|
||||||
|
task_details_scroll: 0,
|
||||||
task_report_show_info: c.uda_task_report_show_info,
|
task_report_show_info: c.uda_task_report_show_info,
|
||||||
config: c,
|
config: c,
|
||||||
task_report_table: TaskReportTable::new()?,
|
task_report_table: TaskReportTable::new()?,
|
||||||
|
@ -517,16 +519,27 @@ impl TTApp {
|
||||||
.output();
|
.output();
|
||||||
if let Ok(output) = output {
|
if let Ok(output) = output {
|
||||||
let data = String::from_utf8_lossy(&output.stdout);
|
let data = String::from_utf8_lossy(&output.stdout);
|
||||||
let p = Paragraph::new(Text::from(&data[..])).block(
|
self.task_details_scroll = std::cmp::min(data.lines().count() as u16, self.task_details_scroll);
|
||||||
Block::default()
|
let p = Paragraph::new(Text::from(&data[..]))
|
||||||
.borders(Borders::ALL)
|
.block(
|
||||||
.border_type(BorderType::Rounded)
|
Block::default()
|
||||||
.title(format!("Task {}", task_id)),
|
.borders(Borders::ALL)
|
||||||
);
|
.border_type(BorderType::Rounded)
|
||||||
|
.title(format!("Task {}", task_id)),
|
||||||
|
)
|
||||||
|
.scroll((self.task_details_scroll, 0));
|
||||||
f.render_widget(p, rect);
|
f.render_widget(p, rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn task_details_scroll_down(&mut self) {
|
||||||
|
self.task_details_scroll = self.task_details_scroll.saturating_sub(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn task_details_scroll_up(&mut self) {
|
||||||
|
self.task_details_scroll = self.task_details_scroll.saturating_add(1);
|
||||||
|
}
|
||||||
|
|
||||||
fn task_by_index(&self, i: usize) -> Option<Task> {
|
fn task_by_index(&self, i: usize) -> Option<Task> {
|
||||||
let tasks = &self.tasks.lock().unwrap();
|
let tasks = &self.tasks.lock().unwrap();
|
||||||
if i > tasks.len() {
|
if i > tasks.len() {
|
||||||
|
@ -1514,6 +1527,10 @@ impl TTApp {
|
||||||
self.task_report_next_page();
|
self.task_report_next_page();
|
||||||
} else if input == Key::PageUp || input == self.keyconfig.page_up {
|
} else if input == Key::PageUp || input == self.keyconfig.page_up {
|
||||||
self.task_report_previous_page();
|
self.task_report_previous_page();
|
||||||
|
} else if input == Key::Ctrl('e') {
|
||||||
|
self.task_details_scroll_up();
|
||||||
|
} else if input == Key::Ctrl('y') {
|
||||||
|
self.task_details_scroll_down();
|
||||||
} else if input == self.keyconfig.done {
|
} else if input == self.keyconfig.done {
|
||||||
match self.task_done() {
|
match self.task_done() {
|
||||||
Ok(_) => self.update(true)?,
|
Ok(_) => self.update(true)?,
|
||||||
|
|
|
@ -254,14 +254,14 @@ impl TaskReportTable {
|
||||||
},
|
},
|
||||||
"description.count" => {
|
"description.count" => {
|
||||||
let c = match task.annotations() {
|
let c = match task.annotations() {
|
||||||
Some(a) => format!("[{}]", a.iter().count()),
|
Some(a) => format!("[{}]", a.len()),
|
||||||
None => format!(""),
|
None => format!(""),
|
||||||
};
|
};
|
||||||
format!("{} {}", task.description().to_string(), c)
|
format!("{} {}", task.description().to_string(), c)
|
||||||
}
|
}
|
||||||
"description.truncated_count" => {
|
"description.truncated_count" => {
|
||||||
let c = match task.annotations() {
|
let c = match task.annotations() {
|
||||||
Some(a) => format!(" [{}]", a.iter().count()),
|
Some(a) => format!(" [{}]", a.len()),
|
||||||
None => format!(""),
|
None => format!(""),
|
||||||
};
|
};
|
||||||
let mut d = task.description().to_string();
|
let mut d = task.description().to_string();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue