TreeNav: get tree address of cursor
This commit is contained in:
parent
5753fb5af8
commit
fef4b930ae
2 changed files with 22 additions and 2 deletions
|
@ -61,13 +61,29 @@ where SubEditor: TerminalEditor + ?Sized + Send + Sync + 'static,
|
||||||
make_item_editor: FnMakeItemEditor,
|
make_item_editor: FnMakeItemEditor,
|
||||||
level: usize,
|
level: usize,
|
||||||
segment_seq: OuterViewPort<dyn SequenceView<Item = ListEditorViewSegment>>,
|
segment_seq: OuterViewPort<dyn SequenceView<Item = ListEditorViewSegment>>,
|
||||||
}
|
|
||||||
|
|
||||||
|
terminal_view: OuterViewPort<dyn TerminalView>
|
||||||
|
}
|
||||||
|
|
||||||
impl<SubEditor, FnMakeItemEditor> TreeNav for ListEditor<SubEditor, FnMakeItemEditor>
|
impl<SubEditor, FnMakeItemEditor> TreeNav for ListEditor<SubEditor, FnMakeItemEditor>
|
||||||
where SubEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static,
|
where SubEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static,
|
||||||
FnMakeItemEditor: Fn() -> Arc<RwLock<SubEditor>>
|
FnMakeItemEditor: Fn() -> Arc<RwLock<SubEditor>>
|
||||||
{
|
{
|
||||||
|
fn get_cursor(&self) -> Option<Vec<usize>> {
|
||||||
|
match self.cursor.get() {
|
||||||
|
ListEditorCursor::None => None,
|
||||||
|
ListEditorCursor::Insert(idx) => Some(vec![ idx ]),
|
||||||
|
ListEditorCursor::Select(idx) => Some(vec![ idx ]),
|
||||||
|
ListEditorCursor::Edit(idx) => match self.data.get(idx).read().unwrap().get_cursor() {
|
||||||
|
Some(mut addr) => {
|
||||||
|
addr.insert(0, idx);
|
||||||
|
Some(addr)
|
||||||
|
}
|
||||||
|
None => Some(vec![ idx ])
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn up(&mut self) -> TreeNavResult {
|
fn up(&mut self) -> TreeNavResult {
|
||||||
match self.cursor.get() {
|
match self.cursor.get() {
|
||||||
ListEditorCursor::Edit(idx) => {
|
ListEditorCursor::Edit(idx) => {
|
||||||
|
|
|
@ -33,6 +33,10 @@ pub trait TreeNav {
|
||||||
fn goto(&mut self, tree_addr: Vec<usize>) -> TreeNavResult {
|
fn goto(&mut self, tree_addr: Vec<usize>) -> TreeNavResult {
|
||||||
TreeNavResult::Exit
|
TreeNavResult::Exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_cursor(&self) -> Option<Vec<usize>> {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::terminal::{TerminalView, TerminalEditor};
|
use crate::terminal::{TerminalView, TerminalEditor};
|
||||||
|
|
Loading…
Reference in a new issue