Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
07b768d0be
commit
78ccae8a1b
@ -7,6 +7,9 @@ pub enum Commands {
|
|||||||
Archive,
|
Archive,
|
||||||
CreateSection { name: String },
|
CreateSection { name: String },
|
||||||
Edit,
|
Edit,
|
||||||
|
|
||||||
|
ShowAll,
|
||||||
|
HideDone,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Commands {
|
impl Commands {
|
||||||
@ -37,6 +40,8 @@ impl CommandParser {
|
|||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
}),
|
}),
|
||||||
"e" | "edit" => Some(Commands::Edit),
|
"e" | "edit" => Some(Commands::Edit),
|
||||||
|
"show-all" => Some(Commands::ShowAll),
|
||||||
|
"hide-done" => Some(Commands::HideDone),
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
None => None,
|
None => None,
|
||||||
|
@ -12,7 +12,7 @@ use super::{
|
|||||||
render_graph::summarize::SummarizeRenderGraph,
|
render_graph::summarize::SummarizeRenderGraph,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum FilterBy {
|
pub enum FilterBy {
|
||||||
NotDone,
|
NotDone,
|
||||||
None,
|
None,
|
||||||
@ -24,7 +24,7 @@ impl Default for FilterBy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone)]
|
#[derive(Default, Clone, Debug)]
|
||||||
pub struct DisplayOptions {
|
pub struct DisplayOptions {
|
||||||
pub filter_by: FilterBy,
|
pub filter_by: FilterBy,
|
||||||
}
|
}
|
||||||
@ -84,7 +84,11 @@ impl<'a> GraphExplorer<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn linearize_graph(&self) -> Option<MovementGraph> {
|
fn linearize_graph(&self) -> Option<MovementGraph> {
|
||||||
self.inner.graph.clone().map(|g| g.into())
|
tracing::trace!("current display options: {:?}", self.inner.display_options);
|
||||||
|
self.inner
|
||||||
|
.graph
|
||||||
|
.clone()
|
||||||
|
.map(|g| MovementGraph::new(g, &self.inner.display_options))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Will only incrmeent to the next level
|
/// Will only incrmeent to the next level
|
||||||
@ -223,6 +227,12 @@ impl<'a> GraphExplorer<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Commands::ShowAll => {
|
||||||
|
self.inner.display_options.filter_by = FilterBy::None;
|
||||||
|
}
|
||||||
|
Commands::HideDone => {
|
||||||
|
self.inner.display_options.filter_by = FilterBy::NotDone;
|
||||||
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +267,8 @@ impl<'a> StatefulWidget for GraphExplorer<'a> {
|
|||||||
let _height = height as usize;
|
let _height = height as usize;
|
||||||
|
|
||||||
if let Some(graph) = &state.graph {
|
if let Some(graph) = &state.graph {
|
||||||
let movement_graph: MovementGraph = graph.clone().into();
|
let movement_graph: MovementGraph =
|
||||||
|
MovementGraph::new(graph.clone(), &state.display_options);
|
||||||
let lines = movement_graph.render_graph(&state.current_position);
|
let lines = movement_graph.render_graph(&state.current_position);
|
||||||
let para = Paragraph::new(lines);
|
let para = Paragraph::new(lines);
|
||||||
para.render(area, buf);
|
para.render(area, buf);
|
||||||
|
Loading…
Reference in New Issue
Block a user