typeterm editor: outfactor TreeNav-impl into separate file
This commit is contained in:
parent
445fa0bd3a
commit
bf69e8293b
2 changed files with 46 additions and 30 deletions
|
@ -1,4 +1,5 @@
|
||||||
mod ctx;
|
mod ctx;
|
||||||
|
mod nav;
|
||||||
|
|
||||||
pub use ctx::init_ctx;
|
pub use ctx::init_ctx;
|
||||||
|
|
||||||
|
@ -466,36 +467,6 @@ impl TypeTermEditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TreeNav for TypeTermEditor {
|
|
||||||
fn get_cursor(&self) -> TreeCursor {
|
|
||||||
self.cur_node.get().get_cursor()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_addr_view(&self) -> OuterViewPort<dyn SequenceView<Item = isize>> {
|
|
||||||
self.cur_node.get_port().map(|x| x.get_addr_view()).to_sequence().flatten()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_mode_view(&self) -> OuterViewPort<dyn SingletonView<Item = ListCursorMode>> {
|
|
||||||
self.cur_node.get_port().map(|x| x.get_mode_view()).flatten()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_cursor_warp(&self) -> TreeCursor {
|
|
||||||
self.cur_node.get().get_cursor_warp()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_height(&self) -> usize {
|
|
||||||
self.cur_node.get().get_height()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn goby(&mut self, dir: Vector2<isize>) -> TreeNavResult {
|
|
||||||
self.cur_node.get_mut().goby(dir)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn goto(&mut self, new_cur: TreeCursor) -> TreeNavResult {
|
|
||||||
self.cur_node.get_mut().goto(new_cur)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ObjCommander for TypeTermEditor {
|
impl ObjCommander for TypeTermEditor {
|
||||||
fn send_cmd_obj(&mut self, co: Arc<RwLock<ReprTree>>) -> TreeNavResult {
|
fn send_cmd_obj(&mut self, co: Arc<RwLock<ReprTree>>) -> TreeNavResult {
|
||||||
let cur = self.get_cursor();
|
let cur = self.get_cursor();
|
||||||
|
|
45
nested/src/editors/typeterm/nav.rs
Normal file
45
nested/src/editors/typeterm/nav.rs
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
use {
|
||||||
|
r3vi::{
|
||||||
|
view::{
|
||||||
|
OuterViewPort,
|
||||||
|
singleton::*,
|
||||||
|
sequence::*
|
||||||
|
}
|
||||||
|
},
|
||||||
|
crate::{
|
||||||
|
tree::{TreeNav, TreeCursor, TreeNavResult},
|
||||||
|
editors::{typeterm::TypeTermEditor, list::ListCursorMode}
|
||||||
|
},
|
||||||
|
cgmath::Vector2
|
||||||
|
};
|
||||||
|
|
||||||
|
impl TreeNav for TypeTermEditor {
|
||||||
|
fn get_cursor(&self) -> TreeCursor {
|
||||||
|
self.cur_node.get().get_cursor()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_addr_view(&self) -> OuterViewPort<dyn SequenceView<Item = isize>> {
|
||||||
|
self.cur_node.get_port().map(|x| x.get_addr_view()).to_sequence().flatten()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_mode_view(&self) -> OuterViewPort<dyn SingletonView<Item = ListCursorMode>> {
|
||||||
|
self.cur_node.get_port().map(|x| x.get_mode_view()).flatten()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_cursor_warp(&self) -> TreeCursor {
|
||||||
|
self.cur_node.get().get_cursor_warp()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_height(&self) -> usize {
|
||||||
|
self.cur_node.get().get_height()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn goby(&mut self, dir: Vector2<isize>) -> TreeNavResult {
|
||||||
|
self.cur_node.get_mut().goby(dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn goto(&mut self, new_cur: TreeCursor) -> TreeNavResult {
|
||||||
|
self.cur_node.get_mut().goto(new_cur)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue