forked from janek/mostr
feat: hide Tasks attributes for feedback logs and make column interaction 1-indexed
This commit is contained in:
parent
b66089fc94
commit
6932e1f257
|
@ -99,7 +99,7 @@ when the application is terminated regularly.
|
||||||
|
|
||||||
Dots can be repeated to move to parent tasks.
|
Dots can be repeated to move to parent tasks.
|
||||||
|
|
||||||
- `:[IND][COL]` - add property column COL at IND or end, if it already exists remove property column COL or IND
|
- `:[IND][COL]` - add property column COL at IND or end, if it already exists remove property column COL or IND (1-indexed)
|
||||||
- `*[TIME]` - add timetracking with the specified offset
|
- `*[TIME]` - add timetracking with the specified offset
|
||||||
- `>[TEXT]` - complete active task and move to parent, with optional state description
|
- `>[TEXT]` - complete active task and move to parent, with optional state description
|
||||||
- `<[TEXT]` - close active task and move to parent, with optional state description
|
- `<[TEXT]` - close active task and move to parent, with optional state description
|
||||||
|
|
24
src/main.rs
24
src/main.rs
|
@ -252,18 +252,14 @@ async fn main() {
|
||||||
|
|
||||||
Some(':') => match iter.next().and_then(|s| s.to_digit(10)) {
|
Some(':') => match iter.next().and_then(|s| s.to_digit(10)) {
|
||||||
Some(digit) => {
|
Some(digit) => {
|
||||||
let index = digit as usize;
|
let index = (digit as usize).saturating_sub(1);
|
||||||
let remaining = iter.collect::<String>().trim().to_string();
|
let remaining = iter.collect::<String>().trim().to_string();
|
||||||
if remaining.is_empty() {
|
if remaining.is_empty() {
|
||||||
tasks.properties.remove(index);
|
tasks.remove_column(index);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let value = input[2..].trim().to_string();
|
let value = input[2..].trim().to_string();
|
||||||
if tasks.properties.get(index) == Some(&value) {
|
tasks.add_or_remove_property_column_at_index(value, index);
|
||||||
tasks.properties.remove(index);
|
|
||||||
} else {
|
|
||||||
tasks.properties.insert(index, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
if arg.is_empty() {
|
if arg.is_empty() {
|
||||||
|
@ -284,15 +280,7 @@ async fn main() {
|
||||||
- `subtasks` - how many direct subtasks are complete");
|
- `subtasks` - how many direct subtasks are complete");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let pos = tasks.properties.iter().position(|s| s == arg);
|
tasks.add_or_remove_property_column(arg);
|
||||||
match pos {
|
|
||||||
None => {
|
|
||||||
tasks.properties.push(arg.to_string());
|
|
||||||
}
|
|
||||||
Some(i) => {
|
|
||||||
tasks.properties.remove(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -363,7 +351,7 @@ async fn main() {
|
||||||
}
|
}
|
||||||
if let Ok(depth) = slice.parse::<i8>() {
|
if let Ok(depth) = slice.parse::<i8>() {
|
||||||
tasks.move_to(pos);
|
tasks.move_to(pos);
|
||||||
tasks.depth = depth;
|
tasks.set_depth(depth);
|
||||||
} else {
|
} else {
|
||||||
tasks.filter_or_create(slice).map(|id| tasks.move_to(Some(id)));
|
tasks.filter_or_create(slice).map(|id| tasks.move_to(Some(id)));
|
||||||
}
|
}
|
||||||
|
@ -383,7 +371,7 @@ async fn main() {
|
||||||
}
|
}
|
||||||
if let Ok(depth) = slice.parse::<i8>() {
|
if let Ok(depth) = slice.parse::<i8>() {
|
||||||
tasks.move_to(pos);
|
tasks.move_to(pos);
|
||||||
tasks.depth = depth;
|
tasks.set_depth(depth);
|
||||||
} else {
|
} else {
|
||||||
let filtered = tasks
|
let filtered = tasks
|
||||||
.children_of(pos)
|
.children_of(pos)
|
||||||
|
|
42
src/tasks.rs
42
src/tasks.rs
|
@ -23,11 +23,11 @@ pub(crate) struct Tasks {
|
||||||
/// History of active tasks by PubKey
|
/// History of active tasks by PubKey
|
||||||
history: HashMap<PublicKey, BTreeSet<Event>>,
|
history: HashMap<PublicKey, BTreeSet<Event>>,
|
||||||
/// The task properties currently visible
|
/// The task properties currently visible
|
||||||
pub(crate) properties: Vec<String>,
|
properties: Vec<String>,
|
||||||
/// Negative: Only Leaf nodes
|
/// Negative: Only Leaf nodes
|
||||||
/// Zero: Only Active node
|
/// Zero: Only Active node
|
||||||
/// Positive: Go down the respective level
|
/// Positive: Go down the respective level
|
||||||
pub(crate) depth: i8,
|
depth: i8,
|
||||||
|
|
||||||
/// Currently active task
|
/// Currently active task
|
||||||
position: Option<EventId>,
|
position: Option<EventId>,
|
||||||
|
@ -62,9 +62,7 @@ impl Tasks {
|
||||||
sender,
|
sender,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Tasks {
|
|
||||||
// Accessors
|
// Accessors
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -183,7 +181,7 @@ impl Tasks {
|
||||||
.unwrap_or(String::new())
|
.unwrap_or(String::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn traverse_up_from(&self, id: Option<EventId>) -> ParentIterator {
|
fn traverse_up_from(&self, id: Option<EventId>) -> ParentIterator {
|
||||||
ParentIterator {
|
ParentIterator {
|
||||||
tasks: &self.tasks,
|
tasks: &self.tasks,
|
||||||
current: id,
|
current: id,
|
||||||
|
@ -593,6 +591,40 @@ impl Tasks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
|
||||||
|
pub(crate) fn set_depth(&mut self, depth: i8) {
|
||||||
|
self.depth = depth;
|
||||||
|
info!("Changed view depth to {depth}");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn remove_column(&mut self, index: usize) {
|
||||||
|
let col = self.properties.remove(index);
|
||||||
|
info!("Removed property column \"{col}\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn add_or_remove_property_column(&mut self, property: &str) {
|
||||||
|
match self.properties.iter().position(|s| s == property) {
|
||||||
|
None => {
|
||||||
|
self.properties.push(property.to_string());
|
||||||
|
info!("Added property column \"{property}\"");
|
||||||
|
}
|
||||||
|
Some(index) => {
|
||||||
|
self.properties.remove(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn add_or_remove_property_column_at_index(&mut self, property: String, index: usize) {
|
||||||
|
if self.properties.get(index) == Some(&property) {
|
||||||
|
self.properties.remove(index);
|
||||||
|
} else {
|
||||||
|
info!("Added property column \"{property}\" at position {}", index + 1);
|
||||||
|
self.properties.insert(index, property);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Formats the given seconds according to the given format.
|
/// Formats the given seconds according to the given format.
|
||||||
|
|
Loading…
Reference in New Issue