typeterm editor: outfactor TreeNav-impl into separate file

This commit is contained in:
Michael Sippel 2023-09-05 12:22:01 +02:00
parent 445fa0bd3a
commit bf69e8293b
Signed by: senvas
GPG key ID: F96CF119C34B64A6
2 changed files with 46 additions and 30 deletions

View file

@ -1,4 +1,5 @@
mod ctx;
mod nav;
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 {
fn send_cmd_obj(&mut self, co: Arc<RwLock<ReprTree>>) -> TreeNavResult {
let cur = self.get_cursor();

View 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)
}
}