rename NestedNode to EditTree

This commit is contained in:
Michael Sippel 2024-01-07 20:04:23 +01:00
parent 47a35f22b7
commit 668b0b8b96
Signed by: senvas
GPG key ID: F96CF119C34B64A6
14 changed files with 84 additions and 84 deletions

View file

@ -9,7 +9,7 @@ use {
nested::{ nested::{
editors::ObjCommander, editors::ObjCommander,
repr_tree::{Context, ReprTree}, repr_tree::{Context, ReprTree},
edit_tree::{NestedNode} edit_tree::{EditTree}
}, },
nested_tty::{ nested_tty::{
DisplaySegment, TTYApplication, DisplaySegment, TTYApplication,
@ -48,8 +48,8 @@ async fn main() {
let rt_digit = ReprTree::new_arc( Context::parse(&ctx, "<Digit 10>") ); let rt_digit = ReprTree::new_arc( Context::parse(&ctx, "<Digit 10>") );
let port_char = r3vi::view::ViewPort::<dyn r3vi::view::singleton::SingletonView<Item = char>>::new(); let port_char = r3vi::view::ViewPort::<dyn r3vi::view::singleton::SingletonView<Item = char>>::new();
let port_u32 = r3vi::view::ViewPort::<dyn r3vi::view::singleton::SingletonView<Item = u32>>::new(); let port_u32 = r3vi::view::ViewPort::<dyn r3vi::view::singleton::SingletonView<Item = u32>>::new();
let port_edit = r3vi::view::ViewPort::<dyn r3vi::view::singleton::SingletonView<Item = NestedNode>>::new(); let port_edit = r3vi::view::ViewPort::<dyn r3vi::view::singleton::SingletonView<Item = EditTree>>::new();
let port_char_edit = r3vi::view::ViewPort::<dyn r3vi::view::singleton::SingletonView<Item = NestedNode>>::new(); let port_char_edit = r3vi::view::ViewPort::<dyn r3vi::view::singleton::SingletonView<Item = EditTree>>::new();
rt_digit.write().unwrap() rt_digit.write().unwrap()
.insert_leaf( .insert_leaf(
@ -85,15 +85,14 @@ async fn main() {
r3vi::buffer::singleton::SingletonBuffer::<usize>::new(0).get_port() r3vi::buffer::singleton::SingletonBuffer::<usize>::new(0).get_port()
); );
node_edit_char = nested_tty::editors::edittree_make_char_view( edittree_char ); edittree_char = nested_tty::editors::edittree_make_char_view( edittree_char );
let mut edit_char = node_edit_char.get_edit::< nested::editors::char::CharEditor >().unwrap(); let mut edit_char = edittree_char.get_edit::< nested::editors::char::CharEditor >().unwrap();
port_char.attach_to( edit_char.read().unwrap().get_port() ); port_char.attach_to( edit_char.read().unwrap().get_port() );
let buf_edit_char = r3vi::buffer::singleton::SingletonBuffer::new( node_edit_char.clone() ); let buf_edit_char = r3vi::buffer::singleton::SingletonBuffer::new( edittree_char.clone() );
port_char_edit.attach_to( buf_edit_char.get_port() ); port_char_edit.attach_to( buf_edit_char.get_port() );
// created by <Digit 10> ==> <Digit 10>~EditTree // created by <Digit 10> ==> <Digit 10>~EditTree
let mut node_edit_digit = let mut node_edit_digit =
nested::editors::integer::DigitEditor::new( nested::editors::integer::DigitEditor::new(

View file

@ -10,6 +10,6 @@ pub use {
cursor::TreeCursor, cursor::TreeCursor,
nav::{TreeNav, TreeNavResult, TreeHeightOp}, nav::{TreeNav, TreeNavResult, TreeHeightOp},
treetype::{TreeType}, treetype::{TreeType},
node::NestedNode node::EditTree
}; };

View file

@ -14,7 +14,7 @@ use {
}; };
#[derive(Clone)] #[derive(Clone)]
pub struct NestedNodeDisplay { pub struct EdittreeDisplay {
/// display view /// display view
pub view: Arc<RwLock<ReprTree>>, pub view: Arc<RwLock<ReprTree>>,
@ -26,13 +26,13 @@ pub struct NestedNodeDisplay {
} }
#[derive(Clone)] #[derive(Clone)]
pub struct NestedNodeEdit { pub struct EdittreeControl {
/// abstract editor /// abstract editor
pub editor: SingletonBuffer< pub editor: SingletonBuffer<
Option< Arc<dyn Any + Send + Sync> > Option< Arc<dyn Any + Send + Sync> >
>, >,
pub spillbuf: Arc<RwLock< Vec< Arc<RwLock< NestedNode >> > >>, pub spillbuf: Arc<RwLock< Vec< Arc<RwLock< EditTree >> > >>,
/// commander & navigation /// commander & navigation
pub cmd: SingletonBuffer< pub cmd: SingletonBuffer<
@ -51,26 +51,26 @@ pub struct NestedNodeEdit {
* TODO: rename to EditNode * TODO: rename to EditNode
*/ */
#[derive(Clone)] #[derive(Clone)]
pub struct NestedNode { pub struct EditTree {
/// context /// context
pub ctx: Arc<RwLock<Context>>, pub ctx: Arc<RwLock<Context>>,
/// viewports for terminal display /// viewports for terminal display
pub disp: NestedNodeDisplay, pub disp: EdittreeDisplay,
/// editor & commander objects /// editor & commander objects
pub edit: NestedNodeEdit pub ctrl: EdittreeControl
} }
impl NestedNode { impl EditTree {
pub fn new(ctx: Arc<RwLock<Context>>, depth: OuterViewPort<dyn SingletonView<Item = usize>>) -> Self { pub fn new(ctx: Arc<RwLock<Context>>, depth: OuterViewPort<dyn SingletonView<Item = usize>>) -> Self {
NestedNode { EditTree {
disp: NestedNodeDisplay { disp: EdittreeDisplay {
view: ReprTree::new_arc(Context::parse(&ctx, "Display")), view: ReprTree::new_arc(Context::parse(&ctx, "Display")),
diag: None, diag: None,
depth, depth,
}, },
edit: NestedNodeEdit { ctrl: EdittreeControl {
editor: SingletonBuffer::new(None), editor: SingletonBuffer::new(None),
spillbuf: Arc::new(RwLock::new(Vec::new())), spillbuf: Arc::new(RwLock::new(Vec::new())),
cmd: SingletonBuffer::new(None), cmd: SingletonBuffer::new(None),
@ -82,17 +82,17 @@ impl NestedNode {
} }
pub fn set_editor(mut self, editor: Arc<dyn Any + Send + Sync>) -> Self { pub fn set_editor(mut self, editor: Arc<dyn Any + Send + Sync>) -> Self {
self.edit.editor.set(Some(editor)); self.ctrl.editor.set(Some(editor));
self self
} }
pub fn set_cmd(mut self, cmd: Arc<RwLock<dyn ObjCommander + Send + Sync>>) -> Self { pub fn set_cmd(mut self, cmd: Arc<RwLock<dyn ObjCommander + Send + Sync>>) -> Self {
self.edit.cmd.set(Some(cmd)); self.ctrl.cmd.set(Some(cmd));
self self
} }
pub fn set_nav(mut self, nav: Arc<RwLock<dyn TreeNav + Send + Sync>>) -> Self { pub fn set_nav(mut self, nav: Arc<RwLock<dyn TreeNav + Send + Sync>>) -> Self {
self.edit.tree_nav.set(Some(nav)); self.ctrl.tree_nav.set(Some(nav));
self self
} }
@ -108,7 +108,7 @@ impl NestedNode {
} }
pub fn get_edit<T: Send + Sync + 'static>(&self) -> Option<Arc<RwLock<T>>> { pub fn get_edit<T: Send + Sync + 'static>(&self) -> Option<Arc<RwLock<T>>> {
if let Some(edit) = self.edit.editor.get() { if let Some(edit) = self.ctrl.editor.get() {
if let Ok(edit) = edit.downcast::<RwLock<T>>() { if let Ok(edit) = edit.downcast::<RwLock<T>>() {
Some(edit) Some(edit)
} else { } else {
@ -132,9 +132,9 @@ impl TreeType for NestedNode {
} }
*/ */
impl TreeNav for NestedNode { impl TreeNav for EditTree {
fn get_cursor(&self) -> TreeCursor { fn get_cursor(&self) -> TreeCursor {
if let Some(tn) = self.edit.tree_nav.get() { if let Some(tn) = self.ctrl.tree_nav.get() {
tn.read().unwrap().get_cursor() tn.read().unwrap().get_cursor()
} else { } else {
TreeCursor::default() TreeCursor::default()
@ -142,7 +142,7 @@ impl TreeNav for NestedNode {
} }
fn get_addr_view(&self) -> OuterViewPort<dyn SequenceView<Item = isize>> { fn get_addr_view(&self) -> OuterViewPort<dyn SequenceView<Item = isize>> {
if let Some(tn) = self.edit.tree_nav.get() { if let Some(tn) = self.ctrl.tree_nav.get() {
tn.read().unwrap().get_addr_view() tn.read().unwrap().get_addr_view()
} else { } else {
OuterViewPort::default() OuterViewPort::default()
@ -150,7 +150,7 @@ impl TreeNav for NestedNode {
} }
fn get_mode_view(&self) -> OuterViewPort<dyn SingletonView<Item = ListCursorMode>> { fn get_mode_view(&self) -> OuterViewPort<dyn SingletonView<Item = ListCursorMode>> {
if let Some(tn) = self.edit.tree_nav.get() { if let Some(tn) = self.ctrl.tree_nav.get() {
tn.read().unwrap().get_mode_view() tn.read().unwrap().get_mode_view()
} else { } else {
OuterViewPort::default() OuterViewPort::default()
@ -158,7 +158,7 @@ impl TreeNav for NestedNode {
} }
fn get_cursor_warp(&self) -> TreeCursor { fn get_cursor_warp(&self) -> TreeCursor {
if let Some(tn) = self.edit.tree_nav.get() { if let Some(tn) = self.ctrl.tree_nav.get() {
tn.read().unwrap().get_cursor_warp() tn.read().unwrap().get_cursor_warp()
} else { } else {
TreeCursor::default() TreeCursor::default()
@ -166,7 +166,7 @@ impl TreeNav for NestedNode {
} }
fn get_height(&self, op: &TreeHeightOp) -> usize { fn get_height(&self, op: &TreeHeightOp) -> usize {
if let Some(tn) = self.edit.tree_nav.get() { if let Some(tn) = self.ctrl.tree_nav.get() {
tn.read().unwrap().get_height( op ) tn.read().unwrap().get_height( op )
} else { } else {
0 0
@ -174,7 +174,7 @@ impl TreeNav for NestedNode {
} }
fn goby(&mut self, direction: Vector2<isize>) -> TreeNavResult { fn goby(&mut self, direction: Vector2<isize>) -> TreeNavResult {
if let Some(tn) = self.edit.tree_nav.get() { if let Some(tn) = self.ctrl.tree_nav.get() {
tn.write().unwrap().goby(direction) tn.write().unwrap().goby(direction)
} else { } else {
TreeNavResult::Exit TreeNavResult::Exit
@ -182,7 +182,7 @@ impl TreeNav for NestedNode {
} }
fn goto(&mut self, new_cursor: TreeCursor) -> TreeNavResult { fn goto(&mut self, new_cursor: TreeCursor) -> TreeNavResult {
if let Some(tn) = self.edit.tree_nav.get() { if let Some(tn) = self.ctrl.tree_nav.get() {
tn.write().unwrap().goto(new_cursor) tn.write().unwrap().goto(new_cursor)
} else { } else {
TreeNavResult::Exit TreeNavResult::Exit
@ -192,7 +192,7 @@ impl TreeNav for NestedNode {
use crate::edit_tree::nav::TreeNavCmd; use crate::edit_tree::nav::TreeNavCmd;
impl ObjCommander for NestedNode { impl ObjCommander for EditTree {
fn send_cmd_obj(&mut self, cmd_obj: Arc<RwLock<ReprTree>>) -> TreeNavResult { fn send_cmd_obj(&mut self, cmd_obj: Arc<RwLock<ReprTree>>) -> TreeNavResult {
if cmd_obj.read().unwrap().get_type() == &Context::parse(&self.ctx, "TreeNavCmd") { if cmd_obj.read().unwrap().get_type() == &Context::parse(&self.ctx, "TreeNavCmd") {
@ -211,7 +211,7 @@ impl ObjCommander for NestedNode {
} else { } else {
TreeNavResult::Exit TreeNavResult::Exit
} }
} else if let Some(cmd) = self.edit.cmd.get() { } else if let Some(cmd) = self.ctrl.cmd.get() {
// todo: filter out tree-nav cmds and send them to tree_nav // todo: filter out tree-nav cmds and send them to tree_nav
cmd.write().unwrap().send_cmd_obj(cmd_obj) cmd.write().unwrap().send_cmd_obj(cmd_obj)
} else { } else {
@ -221,7 +221,7 @@ impl ObjCommander for NestedNode {
} }
impl Diagnostics for NestedNode { impl Diagnostics for EditTree {
fn get_msg_port(&self) -> OuterViewPort<dyn SequenceView<Item = Message>> { fn get_msg_port(&self) -> OuterViewPort<dyn SequenceView<Item = Message>> {
self.get_diag() self.get_diag()
} }

View file

@ -9,7 +9,7 @@ use {
laddertypes::{TypeTerm}, laddertypes::{TypeTerm},
crate::{ crate::{
repr_tree::{Context, ReprTree}, repr_tree::{Context, ReprTree},
edit_tree::{NestedNode, TreeNavResult}, edit_tree::{EditTree, TreeNavResult},
editors::ObjCommander, editors::ObjCommander,
}, },
std::sync::Arc, std::sync::Arc,
@ -74,12 +74,12 @@ impl CharEditor {
pub fn new_edit_tree( pub fn new_edit_tree(
ctx0: Arc<RwLock<Context>>, ctx0: Arc<RwLock<Context>>,
depth: OuterViewPort<dyn SingletonView<Item = usize>> depth: OuterViewPort<dyn SingletonView<Item = usize>>
) -> NestedNode { ) -> EditTree {
let data = SingletonBuffer::new('\0'); let data = SingletonBuffer::new('\0');
let ctx = ctx0.clone(); let ctx = ctx0.clone();
let editor = Arc::new(RwLock::new(CharEditor{ ctx, data: data.clone() })); let editor = Arc::new(RwLock::new(CharEditor{ ctx, data: data.clone() }));
NestedNode::new( EditTree::new(
ctx0.clone(), ctx0.clone(),
depth depth
) )

View file

@ -14,7 +14,7 @@ use {
crate::{ crate::{
editors::{list::{ListCmd}, ObjCommander}, editors::{list::{ListCmd}, ObjCommander},
repr_tree::{Context, ReprTree}, repr_tree::{Context, ReprTree},
edit_tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor, diagnostics::{Message}}, edit_tree::{EditTree, TreeNav, TreeNavResult, TreeCursor, diagnostics::{Message}},
}, },
std::sync::Arc, std::sync::Arc,
std::sync::RwLock, std::sync::RwLock,
@ -81,13 +81,13 @@ impl DigitEditor {
} }
} }
pub fn into_node(self, depth: OuterViewPort<dyn SingletonView<Item = usize>>) -> NestedNode { pub fn into_node(self, depth: OuterViewPort<dyn SingletonView<Item = usize>>) -> EditTree {
let data = self.get_data(); let data = self.get_data();
let editor = Arc::new(RwLock::new(self)); let editor = Arc::new(RwLock::new(self));
let ed = editor.write().unwrap(); let ed = editor.write().unwrap();
let r = ed.radix; let r = ed.radix;
NestedNode::new(ed.ctx.clone(), depth) EditTree::new(ed.ctx.clone(), depth)
.set_editor(editor.clone()) .set_editor(editor.clone())
.set_cmd(editor.clone()) .set_cmd(editor.clone())
.set_diag( .set_diag(
@ -133,7 +133,7 @@ impl DigitEditor {
pub struct PosIntEditor { pub struct PosIntEditor {
radix: u32, radix: u32,
digits: NestedNode, digits: EditTree,
// todo: endianness // todo: endianness
} }
@ -175,7 +175,7 @@ impl PosIntEditor {
*/ */
PosIntEditor { PosIntEditor {
radix, radix,
digits: NestedNode::new( digits: EditTree::new(
ctx, ctx,
r3vi::buffer::singleton::SingletonBuffer::new(0).get_port() r3vi::buffer::singleton::SingletonBuffer::new(0).get_port()
) )
@ -203,7 +203,7 @@ impl PosIntEditor {
self.digits.goto(TreeCursor::none()); self.digits.goto(TreeCursor::none());
} }
pub fn into_node(self) -> NestedNode { pub fn into_node(self) -> EditTree {
self.digits self.digits
} }

View file

@ -5,7 +5,7 @@ use {
crate::{ crate::{
editors::{list::{ListEditor, ListCursor, ListCursorMode}, ObjCommander}, editors::{list::{ListEditor, ListCursor, ListCursorMode}, ObjCommander},
repr_tree::{Context, ReprTree}, repr_tree::{Context, ReprTree},
edit_tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor}, edit_tree::{EditTree, TreeNav, TreeNavResult, TreeCursor},
}, },
std::sync::{Arc, RwLock} std::sync::{Arc, RwLock}
}; };
@ -35,7 +35,7 @@ impl ObjCommander for ListEditor {
fn send_cmd_obj(&mut self, cmd_obj: Arc<RwLock<ReprTree>>) -> TreeNavResult { fn send_cmd_obj(&mut self, cmd_obj: Arc<RwLock<ReprTree>>) -> TreeNavResult {
let cmd_repr = cmd_obj.read().unwrap(); let cmd_repr = cmd_obj.read().unwrap();
if let Some(view) = cmd_repr.get_view::<dyn SingletonView<Item = NestedNode>>() { if let Some(view) = cmd_repr.get_view::<dyn SingletonView<Item = EditTree>>() {
let node = view.get(); let node = view.get();
let cur = self.cursor.get(); let cur = self.cursor.get();

View file

@ -6,7 +6,7 @@ use {
laddertypes::{TypeTerm}, laddertypes::{TypeTerm},
crate::{ crate::{
repr_tree::{Context, ReprTree}, repr_tree::{Context, ReprTree},
edit_tree::{NestedNode, TreeNav, TreeCursor, diagnostics::Diagnostics}, edit_tree::{EditTree, TreeNav, TreeCursor, diagnostics::Diagnostics},
editors::{list::{ListCursor, ListCursorMode, ListCmd}, ObjCommander}, editors::{list::{ListCursor, ListCursorMode, ListCmd}, ObjCommander},
}, },
std::sync::{Arc, RwLock} std::sync::{Arc, RwLock}
@ -18,9 +18,9 @@ pub struct ListEditor {
pub cursor: SingletonBuffer<ListCursor>, pub cursor: SingletonBuffer<ListCursor>,
// todo: (?) remove RwLock<..> around NestedNode ?? // todo: (?) remove RwLock<..> around NestedNode ??
pub data: VecBuffer< Arc<RwLock<NestedNode>> >, pub data: VecBuffer< Arc<RwLock<EditTree>> >,
pub spillbuf: Arc<RwLock<Vec<Arc<RwLock<NestedNode>>>>>, pub spillbuf: Arc<RwLock<Vec<Arc<RwLock<EditTree>>>>>,
pub(super) addr_port: OuterViewPort<dyn SequenceView<Item = isize>>, pub(super) addr_port: OuterViewPort<dyn SequenceView<Item = isize>>,
pub(super) mode_port: OuterViewPort<dyn SingletonView<Item = ListCursorMode>>, pub(super) mode_port: OuterViewPort<dyn SingletonView<Item = ListCursorMode>>,
@ -39,7 +39,7 @@ impl ListEditor {
typ: TypeTerm, typ: TypeTerm,
) -> Self { ) -> Self {
let cursor = SingletonBuffer::new(ListCursor::default()); let cursor = SingletonBuffer::new(ListCursor::default());
let data : VecBuffer<Arc<RwLock<NestedNode>>> = VecBuffer::new(); let data : VecBuffer<Arc<RwLock<EditTree>>> = VecBuffer::new();
ListEditor { ListEditor {
mode_port: cursor mode_port: cursor
@ -100,7 +100,7 @@ impl ListEditor {
} }
} }
pub fn into_node(mut self, depth: OuterViewPort<dyn SingletonView<Item = usize>>) -> NestedNode { pub fn into_node(mut self, depth: OuterViewPort<dyn SingletonView<Item = usize>>) -> EditTree {
let data = self.get_data(); let data = self.get_data();
let ctx = self.ctx.clone(); let ctx = self.ctx.clone();
@ -109,7 +109,7 @@ impl ListEditor {
let e = editor.read().unwrap(); let e = editor.read().unwrap();
let mut node = NestedNode::new(ctx, depth) let mut node = EditTree::new(ctx, depth)
.set_editor(editor.clone()) .set_editor(editor.clone())
.set_nav(editor.clone()) .set_nav(editor.clone())
.set_cmd(editor.clone()) .set_cmd(editor.clone())
@ -131,7 +131,7 @@ impl ListEditor {
.flatten() .flatten()
); );
node.edit.spillbuf = e.spillbuf.clone(); node.ctrl.spillbuf = e.spillbuf.clone();
node node
} }
@ -150,7 +150,7 @@ impl ListEditor {
self.cursor.get_port() self.cursor.get_port()
} }
pub fn get_data_port(&self) -> OuterViewPort<dyn SequenceView<Item = NestedNode>> { pub fn get_data_port(&self) -> OuterViewPort<dyn SequenceView<Item = EditTree>> {
self.data.get_port().to_sequence().map( self.data.get_port().to_sequence().map(
|x| x.read().unwrap().clone() |x| x.read().unwrap().clone()
) )
@ -164,7 +164,7 @@ impl ListEditor {
) )
} }
pub fn get_item(&self) -> Option<NestedNode> { pub fn get_item(&self) -> Option<EditTree> {
if let Some(idx) = self.cursor.get().idx { if let Some(idx) = self.cursor.get().idx {
let idx = crate::utils::modulo(idx as isize, self.data.len() as isize) as usize; let idx = crate::utils::modulo(idx as isize, self.data.len() as isize) as usize;
if idx < self.data.len() { if idx < self.data.len() {
@ -177,7 +177,7 @@ impl ListEditor {
} }
} }
pub fn get_item_mut(&mut self) -> Option<MutableVecAccess<Arc<RwLock<NestedNode>>>> { pub fn get_item_mut(&mut self) -> Option<MutableVecAccess<Arc<RwLock<EditTree>>>> {
if let Some(idx) = self.cursor.get().idx { if let Some(idx) = self.cursor.get().idx {
let idx = crate::utils::modulo(idx as isize, self.data.len() as isize) as usize; let idx = crate::utils::modulo(idx as isize, self.data.len() as isize) as usize;
if idx < self.data.len() { if idx < self.data.len() {
@ -228,7 +228,7 @@ impl ListEditor {
} }
/// insert a new element /// insert a new element
pub fn insert(&mut self, item: Arc<RwLock<NestedNode>>) { pub fn insert(&mut self, item: Arc<RwLock<EditTree>>) {
item.read().unwrap().disp.depth.0.set_view( item.read().unwrap().disp.depth.0.set_view(
self.depth.map(|d| d+1).get_view() self.depth.map(|d| d+1).get_view()
); );
@ -306,7 +306,7 @@ impl ListEditor {
self.set_leaf_mode(ListCursorMode::Insert); self.set_leaf_mode(ListCursorMode::Insert);
self.nexd(); self.nexd();
let mut b = item.edit.spillbuf.write().unwrap(); let mut b = item.ctrl.spillbuf.write().unwrap();
/* TODO /* TODO
let mut tail_node = Context::make_node(&self.ctx, self.typ.clone(), self.depth.map(|d| d+1)).unwrap(); let mut tail_node = Context::make_node(&self.ctx, self.typ.clone(), self.depth.map(|d| d+1)).unwrap();
tail_node.goto(TreeCursor::home()); tail_node.goto(TreeCursor::home());
@ -366,12 +366,12 @@ impl ListEditor {
let old_cur = pxv_editor.get_cursor(); let old_cur = pxv_editor.get_cursor();
let data = cur_editor.edit.spillbuf.read().unwrap(); let data = cur_editor.ctrl.spillbuf.read().unwrap();
for x in data.iter() { for x in data.iter() {
pxv_editor.send_cmd_obj( pxv_editor.send_cmd_obj(
ReprTree::new_leaf( ReprTree::new_leaf(
Context::parse(&self.ctx, "NestedNode"), Context::parse(&self.ctx, "NestedNode"),
SingletonBuffer::<NestedNode>::new( SingletonBuffer::<EditTree>::new(
x.read().unwrap().clone() x.read().unwrap().clone()
).get_port().into() ).get_port().into()
) )
@ -424,13 +424,13 @@ impl ListEditor {
leaf_mode: ListCursorMode::Insert leaf_mode: ListCursorMode::Insert
}); });
let data = nxd_editor.edit.spillbuf.read().unwrap(); let data = nxd_editor.ctrl.spillbuf.read().unwrap();
for x in data.iter() { for x in data.iter() {
cur_editor.send_cmd_obj( cur_editor.send_cmd_obj(
ReprTree::new_leaf( ReprTree::new_leaf(
Context::parse(&self.ctx, "NestedNode"), Context::parse(&self.ctx, "NestedNode"),
SingletonBuffer::<NestedNode>::new( SingletonBuffer::<EditTree>::new(
x.read().unwrap().clone() x.read().unwrap().clone()
).get_port().into() ).get_port().into()
) )

View file

@ -9,7 +9,7 @@ use {
}, },
crate::{ crate::{
editors::list::{ListCursor, ListCursorMode}, editors::list::{ListCursor, ListCursorMode},
edit_tree::{NestedNode} edit_tree::{EditTree}
}, },
std::sync::Arc, std::sync::Arc,
std::sync::RwLock, std::sync::RwLock,
@ -18,13 +18,13 @@ use {
pub enum ListSegment { pub enum ListSegment {
InsertCursor, InsertCursor,
Item { Item {
editor: NestedNode, editor: EditTree,
cur_dist: isize, cur_dist: isize,
} }
} }
pub struct ListSegmentSequence { pub struct ListSegmentSequence {
data: Arc<dyn SequenceView<Item = NestedNode>>, data: Arc<dyn SequenceView<Item = EditTree>>,
cursor: Arc<dyn SingletonView<Item = ListCursor>>, cursor: Arc<dyn SingletonView<Item = ListCursor>>,
cur_cursor: ListCursor, cur_cursor: ListCursor,
@ -88,7 +88,7 @@ impl SequenceView for ListSegmentSequence {
impl ListSegmentSequence { impl ListSegmentSequence {
pub fn new( pub fn new(
cursor_port: OuterViewPort<dyn SingletonView<Item = ListCursor>>, cursor_port: OuterViewPort<dyn SingletonView<Item = ListCursor>>,
data_port: OuterViewPort<dyn SequenceView<Item = NestedNode>>, data_port: OuterViewPort<dyn SequenceView<Item = EditTree>>,
) -> Arc<RwLock<Self>> { ) -> Arc<RwLock<Self>> {
let out_port = ViewPort::new(); let out_port = ViewPort::new();
let mut proj_helper = ProjectionHelper::new(out_port.update_hooks.clone()); let mut proj_helper = ProjectionHelper::new(out_port.update_hooks.clone());

View file

@ -3,7 +3,7 @@ use {
laddertypes::{TypeDict, TypeTerm, TypeID}, laddertypes::{TypeDict, TypeTerm, TypeID},
crate::{ crate::{
repr_tree::{ReprTree, MorphismType, GenericReprTreeMorphism, MorphismBase}, repr_tree::{ReprTree, MorphismType, GenericReprTreeMorphism, MorphismBase},
edit_tree::NestedNode edit_tree::EditTree
}, },
std::{ std::{
collections::HashMap, collections::HashMap,

View file

@ -99,11 +99,12 @@ impl TerminalEvent {
} }
} }
_ => { _ => {
ReprTree::new_leaf( ReprTree::new_leaf(
Context::parse(&ctx, "TerminalEvent"), Context::parse(&ctx, "TerminalEvent"),
SingletonBuffer::new(self.clone()).get_port().into() SingletonBuffer::new(self.clone()).get_port().into()
) )
} }
} }
} }
} }

View file

@ -6,7 +6,7 @@ use {
nested::{ nested::{
repr_tree::{Context, ReprTree}, repr_tree::{Context, ReprTree},
editors::list::*, editors::list::*,
edit_tree::{TreeCursor, TreeNav, TreeNavResult, NestedNode}, edit_tree::{TreeCursor, TreeNav, TreeNavResult, EditTree},
}, },
crate::{ crate::{
DisplaySegment, DisplaySegment,
@ -91,7 +91,7 @@ impl PTYListStyle {
.flatten() .flatten()
} }
pub fn for_node(node: &mut NestedNode, style: (&str, &str, &str)) { pub fn for_node(node: &mut EditTree, style: (&str, &str, &str)) {
node.disp.view node.disp.view
.write().unwrap() .write().unwrap()
.insert_branch(ReprTree::new_leaf( .insert_branch(ReprTree::new_leaf(
@ -135,7 +135,7 @@ impl PTYListController {
} }
pub fn for_node( pub fn for_node(
node: &mut NestedNode, node: &mut EditTree,
split_char: Option<char>, split_char: Option<char>,
close_char: Option<char> close_char: Option<char>
) { ) {
@ -154,11 +154,11 @@ impl PTYListController {
let editor = node.get_edit::<ListEditor>().unwrap(); let editor = node.get_edit::<ListEditor>().unwrap();
let controller = Arc::new(RwLock::new(PTYListController::from_editor( editor, split_char, close_char, node.disp.depth.clone() ))); let controller = Arc::new(RwLock::new(PTYListController::from_editor( editor, split_char, close_char, node.disp.depth.clone() )));
node.edit.cmd.set(Some(controller.clone())); node.ctrl.cmd.set(Some(controller.clone()));
node.edit.close_char.set(close_char); node.ctrl.close_char.set(close_char);
} }
pub fn get_data_port(&self) -> OuterViewPort<dyn SequenceView<Item = NestedNode>> { pub fn get_data_port(&self) -> OuterViewPort<dyn SequenceView<Item = EditTree>> {
self.editor.read().unwrap().get_data_port() self.editor.read().unwrap().get_data_port()
} }
@ -166,7 +166,7 @@ impl PTYListController {
self.editor.write().unwrap().clear(); self.editor.write().unwrap().clear();
} }
pub fn get_item(&self) -> Option<NestedNode> { pub fn get_item(&self) -> Option<EditTree> {
self.editor.read().unwrap().get_item() self.editor.read().unwrap().get_item()
} }
@ -238,7 +238,7 @@ impl PTYListController {
ListCursorMode::Select => { ListCursorMode::Select => {
if let Some(item) = e.get_item_mut() { if let Some(item) = e.get_item_mut() {
let res = item.write().unwrap().send_cmd_obj(cmd_obj.clone()); let res = item.write().unwrap().send_cmd_obj(cmd_obj.clone());
let child_close_char = item.read().unwrap().edit.close_char.get(); let child_close_char = item.read().unwrap().ctrl.close_char.get();
match res { match res {
TreeNavResult::Continue => TreeNavResult::Continue, TreeNavResult::Continue => TreeNavResult::Continue,

View file

@ -3,7 +3,7 @@ pub mod list;
use { use {
nested::{ nested::{
edit_tree::{NestedNode}, edit_tree::{EditTree},
repr_tree::{ReprTree, Context} repr_tree::{ReprTree, Context}
}, },
r3vi::{ r3vi::{
@ -18,8 +18,8 @@ use {
}; };
pub fn edittree_make_char_view( pub fn edittree_make_char_view(
node: NestedNode node: EditTree
) -> NestedNode { ) -> EditTree {
node.disp.view node.disp.view
.write().unwrap() .write().unwrap()
.insert_branch(ReprTree::new_leaf( .insert_branch(ReprTree::new_leaf(
@ -38,8 +38,8 @@ pub fn edittree_make_char_view(
} }
pub fn edittree_make_digit_view( pub fn edittree_make_digit_view(
node: NestedNode node: EditTree
) -> NestedNode { ) -> EditTree {
node.disp.view node.disp.view
.write().unwrap() .write().unwrap()
.insert_branch(ReprTree::new_leaf( .insert_branch(ReprTree::new_leaf(

View file

@ -42,7 +42,7 @@ pub trait DisplaySegment {
use nested::repr_tree::Context; use nested::repr_tree::Context;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
impl DisplaySegment for nested::edit_tree::NestedNode { impl DisplaySegment for nested::edit_tree::EditTree {
fn display_view(&self) -> OuterViewPort<dyn TerminalView> { fn display_view(&self) -> OuterViewPort<dyn TerminalView> {
if let Some( tv_repr ) = self.disp.view if let Some( tv_repr ) = self.disp.view
.read().unwrap() .read().unwrap()

View file

@ -1,7 +1,7 @@
use { use {
cgmath::Vector2, cgmath::Vector2,
nested::{ nested::{
edit_tree::NestedNode, edit_tree::EditTree,
repr_tree::{Context, ReprTree}, repr_tree::{Context, ReprTree},
}, },
crate::{ crate::{