char editor: add editor field in node
hack type term editor to support splits
This commit is contained in:
parent
0062e5ca07
commit
8e03a1711d
2 changed files with 31 additions and 20 deletions
|
@ -69,6 +69,8 @@ impl CharEditor {
|
||||||
|
|
||||||
let ctx = ctx0.clone();
|
let ctx = ctx0.clone();
|
||||||
|
|
||||||
|
let editor = Arc::new(RwLock::new(CharEditor{ ctx, data: data.clone() }));
|
||||||
|
|
||||||
NestedNode::new(0)
|
NestedNode::new(0)
|
||||||
.set_ctx(ctx0.clone())
|
.set_ctx(ctx0.clone())
|
||||||
.set_data(
|
.set_data(
|
||||||
|
@ -87,9 +89,8 @@ impl CharEditor {
|
||||||
})
|
})
|
||||||
.to_grid()
|
.to_grid()
|
||||||
)
|
)
|
||||||
.set_cmd(
|
.set_cmd( editor.clone() )
|
||||||
Arc::new(RwLock::new(CharEditor{ ctx, data }))
|
.set_editor( editor.clone() )
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -14,7 +14,7 @@ use {
|
||||||
PtySegment
|
PtySegment
|
||||||
},
|
},
|
||||||
termion::event::{Key},
|
termion::event::{Key},
|
||||||
std::{sync::{Arc, RwLock}},
|
std::{sync::{Arc, RwLock}, any::Any},
|
||||||
cgmath::{Vector2, Point2}
|
cgmath::{Vector2, Point2}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,6 +32,10 @@ enum State {
|
||||||
pub struct TypeTermEditor {
|
pub struct TypeTermEditor {
|
||||||
ctx: Arc<RwLock<Context>>,
|
ctx: Arc<RwLock<Context>>,
|
||||||
|
|
||||||
|
editor: SingletonBuffer<
|
||||||
|
Option< Arc<dyn Any + Send + Sync> >
|
||||||
|
>,
|
||||||
|
|
||||||
state: State,
|
state: State,
|
||||||
cur_node: SingletonBuffer< NestedNode >
|
cur_node: SingletonBuffer< NestedNode >
|
||||||
}
|
}
|
||||||
|
@ -63,26 +67,28 @@ impl TypeTermEditor {
|
||||||
ctx.add_morphism(pattern,
|
ctx.add_morphism(pattern,
|
||||||
Arc::new(
|
Arc::new(
|
||||||
|mut node, _dst_type:_| {
|
|mut node, _dst_type:_| {
|
||||||
//eprintln!("morphism to typeterm");
|
// eprintln!("morphism to typeterm");
|
||||||
PTYListController::for_node( &mut node, Some(' '), None );
|
PTYListController::for_node( &mut node, Some(' '), None );
|
||||||
PTYListStyle::for_node( &mut node, ("","","") );
|
PTYListStyle::for_node( &mut node, ("","","") );
|
||||||
let mut new_node = TypeTermEditor::with_node( node.ctx.clone().unwrap(), node.depth.get(), node.clone(), State::Any );
|
let mut new_node = TypeTermEditor::with_node( node.ctx.clone().unwrap(), node.depth.get(), node.clone(), State::Any );
|
||||||
|
|
||||||
let item_nodes = node.get_edit::<ListEditor>().clone().unwrap();
|
let item_editor1 = node.get_edit::<ListEditor>().clone().unwrap();
|
||||||
let item_nodes = item_nodes.read().unwrap();
|
let item_editor = item_editor1.read().unwrap();
|
||||||
|
|
||||||
for i in 0..item_nodes.data.len() {
|
for i in 0..item_editor.data.len() {
|
||||||
if let Some(x) = &item_nodes.data.get(i).read().unwrap().data {
|
let item_node = item_editor.data.get(i);
|
||||||
//eprintln!("item with {:?}", x);
|
let item_node = item_node.read().unwrap();
|
||||||
//let c = x.read().unwrap().get_view::<dyn SingletonView<Item = NestedNode>>().unwrap().get();
|
|
||||||
new_node.send_cmd_obj(
|
let item_val_editor = item_node.get_edit::<crate::editors::char::CharEditor>().clone().unwrap();
|
||||||
ReprTree::from_char(&new_node.ctx.as_ref().unwrap(), 'x')
|
let item_val_editor = item_val_editor.read().unwrap();
|
||||||
);
|
let c = item_val_editor.get();
|
||||||
//new_node.send_cmd_obj(c);
|
|
||||||
}
|
new_node.send_cmd_obj(
|
||||||
|
ReprTree::from_char(new_node.ctx.as_ref().unwrap(), c)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if item_nodes.data.len() > 0 {
|
if item_editor.data.len() > 0 {
|
||||||
new_node.goto(TreeCursor::home());
|
new_node.goto(TreeCursor::home());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +141,7 @@ impl TypeTermEditor {
|
||||||
|
|
||||||
node.goto(TreeCursor::home());
|
node.goto(TreeCursor::home());
|
||||||
|
|
||||||
|
self.editor.set(node.editor.get());
|
||||||
self.cur_node.set(node);
|
self.cur_node.set(node);
|
||||||
self.state = new_state;
|
self.state = new_state;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +154,8 @@ impl TypeTermEditor {
|
||||||
let mut editor = TypeTermEditor {
|
let mut editor = TypeTermEditor {
|
||||||
ctx: ctx.clone(),
|
ctx: ctx.clone(),
|
||||||
state,
|
state,
|
||||||
cur_node: SingletonBuffer::new(node)
|
cur_node: SingletonBuffer::new(node),
|
||||||
|
editor: SingletonBuffer::new(None)
|
||||||
};
|
};
|
||||||
|
|
||||||
let view = editor.cur_node
|
let view = editor.cur_node
|
||||||
|
@ -177,6 +185,8 @@ impl TypeTermEditor {
|
||||||
.set_cmd(editor.clone())
|
.set_cmd(editor.clone())
|
||||||
.set_editor(editor.clone());
|
.set_editor(editor.clone());
|
||||||
|
|
||||||
|
editor.write().unwrap().editor = node.editor.clone();
|
||||||
|
|
||||||
node
|
node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue