From bf69e8293b2713dfdc651ff97422a84f26f8fca3 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Tue, 5 Sep 2023 12:22:01 +0200 Subject: [PATCH] typeterm editor: outfactor TreeNav-impl into separate file --- nested/src/editors/typeterm/mod.rs | 31 +------------------- nested/src/editors/typeterm/nav.rs | 45 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 30 deletions(-) create mode 100644 nested/src/editors/typeterm/nav.rs diff --git a/nested/src/editors/typeterm/mod.rs b/nested/src/editors/typeterm/mod.rs index a7f51fa..4c9759a 100644 --- a/nested/src/editors/typeterm/mod.rs +++ b/nested/src/editors/typeterm/mod.rs @@ -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> { - self.cur_node.get_port().map(|x| x.get_addr_view()).to_sequence().flatten() - } - - fn get_mode_view(&self) -> OuterViewPort> { - 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) -> 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>) -> TreeNavResult { let cur = self.get_cursor(); diff --git a/nested/src/editors/typeterm/nav.rs b/nested/src/editors/typeterm/nav.rs new file mode 100644 index 0000000..a4f08cf --- /dev/null +++ b/nested/src/editors/typeterm/nav.rs @@ -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> { + self.cur_node.get_port().map(|x| x.get_addr_view()).to_sequence().flatten() + } + + fn get_mode_view(&self) -> OuterViewPort> { + 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) -> TreeNavResult { + self.cur_node.get_mut().goby(dir) + } + + fn goto(&mut self, new_cur: TreeCursor) -> TreeNavResult { + self.cur_node.get_mut().goto(new_cur) + } +} +