test different style for <List Char>, add meta-chars to ctx globally to avoid deadlock
This commit is contained in:
parent
0ac4a34743
commit
e46c143dec
5 changed files with 27 additions and 36 deletions
|
@ -32,15 +32,18 @@ async fn main() {
|
|||
nested::editors::integer::editor::init_ctx( ctx.clone() );
|
||||
nested::editors::list::init_ctx( ctx.clone() );
|
||||
|
||||
|
||||
let char_type = Context::parse(&ctx, "Char");
|
||||
let digit_type = Context::parse(&ctx, "<Digit Radix>");
|
||||
let list_type = Context::parse(&ctx, "<List Item>");
|
||||
let posint_type = Context::parse(&ctx, "<PosInt Radix>");
|
||||
let item_tyid = ctx.read().unwrap().get_var_typeid("Item").unwrap();
|
||||
|
||||
ctx.write().unwrap().meta_chars.push(',');
|
||||
ctx.write().unwrap().meta_chars.push('\"');
|
||||
ctx.write().unwrap().set_edittree_hook(
|
||||
Arc::new(
|
||||
move |et: Arc<RwLock<EditTree>>, t: laddertypes::TypeTerm| {
|
||||
if let Ok(σ) = laddertypes::unify(&t, &char_type) {
|
||||
if let Ok(σ) = laddertypes::unify(&t, &char_type.clone()) {
|
||||
let mut et = et.write().unwrap();
|
||||
*et = nested_tty::editors::edittree_make_char_view(et.clone());
|
||||
}
|
||||
|
@ -48,14 +51,25 @@ async fn main() {
|
|||
let mut et = et.write().unwrap();
|
||||
*et = nested_tty::editors::edittree_make_digit_view(et.clone());
|
||||
}
|
||||
else if let Ok(σ) = laddertypes::unify(&t, &posint_type) {
|
||||
let mut et = et.write().unwrap();
|
||||
nested_tty::editors::list::PTYListStyle::for_node( &mut *et, ("0d", "", ""));
|
||||
nested_tty::editors::list::PTYListController::for_node( &mut *et, None, None );
|
||||
}
|
||||
else if let Ok(σ) = laddertypes::unify(&t, &list_type) {
|
||||
let mut et = et.write().unwrap();
|
||||
nested_tty::editors::list::PTYListStyle::for_node( &mut *et, ("(", ",", ")"));
|
||||
nested_tty::editors::list::PTYListController::for_node( &mut *et, None, None );
|
||||
*et = nested_tty::editors::edittree_make_list_edit(et.clone());
|
||||
let item_type = σ.get( &laddertypes::TypeID::Var(item_tyid) ).unwrap();
|
||||
if item_type == &char_type {
|
||||
nested_tty::editors::list::PTYListStyle::for_node( &mut *et, ("\"", "", "\""));
|
||||
nested_tty::editors::list::PTYListController::for_node( &mut *et, None, Some('\"') );
|
||||
} else {
|
||||
nested_tty::editors::list::PTYListStyle::for_node( &mut *et, ("{", ", ", "}"));
|
||||
nested_tty::editors::list::PTYListController::for_node( &mut *et, Some(','), Some('}') );
|
||||
}
|
||||
//*et = nested_tty::editors::edittree_make_list_edit(et.clone());
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
/* structure of Repr-Tree
|
||||
|
@ -91,7 +105,7 @@ async fn main() {
|
|||
let edittree_digit = ctx.read().unwrap().setup_edittree(rt_digit.clone(), r3vi::buffer::singleton::SingletonBuffer::new(0).get_port());
|
||||
|
||||
//---
|
||||
let rt_string = ReprTree::new_arc( Context::parse(&ctx, "<List <List <Digit 16>>>") );
|
||||
let rt_string = ReprTree::new_arc( Context::parse(&ctx, "<List <List Char>>") );
|
||||
let edittree = ctx.read().unwrap().setup_edittree(rt_string.clone(), r3vi::buffer::singleton::SingletonBuffer::new(0).get_port());
|
||||
|
||||
/* setup terminal
|
||||
|
|
|
@ -74,13 +74,13 @@ impl EditTree {
|
|||
editor: SingletonBuffer::new(None),
|
||||
spillbuf: Arc::new(RwLock::new(Vec::new())),
|
||||
cmd: SingletonBuffer::new(None),
|
||||
close_char: SingletonBuffer::new(None),
|
||||
close_char: SingletonBuffer::new(None),
|
||||
tree_nav: SingletonBuffer::new(None),
|
||||
},
|
||||
ctx
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn set_editor(mut self, editor: Arc<dyn Any + Send + Sync>) -> Self {
|
||||
self.ctrl.editor.set(Some(editor));
|
||||
self
|
||||
|
|
|
@ -175,7 +175,7 @@ impl ListEditor {
|
|||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_item_mut(&mut self) -> Option<MutableVecAccess<Arc<RwLock<EditTree>>>> {
|
||||
if let Some(idx) = self.cursor.get().idx {
|
||||
|
|
|
@ -139,7 +139,7 @@ impl PTYListController {
|
|||
split_char: Option<char>,
|
||||
close_char: Option<char>
|
||||
) {
|
||||
/*
|
||||
/*
|
||||
{
|
||||
let ctx = node.ctx.as_ref();
|
||||
let mut ctx = ctx.write().unwrap();
|
||||
|
@ -151,7 +151,7 @@ impl PTYListController {
|
|||
ctx.meta_chars.push(*c);
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
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() )));
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ pub fn edittree_make_digit_view(
|
|||
|
||||
node
|
||||
}
|
||||
|
||||
/*
|
||||
pub fn edittree_make_seq_view(
|
||||
mut node: EditTree
|
||||
|
@ -84,27 +85,3 @@ pub fn edittree_make_seq_view(
|
|||
node
|
||||
}
|
||||
*/
|
||||
|
||||
pub fn edittree_make_list_edit(
|
||||
mut node: EditTree
|
||||
) -> EditTree {
|
||||
list::PTYListStyle::for_node( &mut node, ("(", "", ")") );
|
||||
list::PTYListController::for_node( &mut node, None, None );
|
||||
node
|
||||
}
|
||||
/*
|
||||
pub fn edittree_make_tty_view(
|
||||
et: EditTree
|
||||
) -> EditTree {
|
||||
if et.data.read().unwrap().get_type() == &Context::parse(&node.ctx, "Char") {
|
||||
node_make_char_view( node )
|
||||
} else if et.data.read().unwrap().get_type() == &Context::parse(&node.ctx, "<Seq Char>") {
|
||||
node_make_seq_view( node )
|
||||
} else if et.data.read().unwrap().get_type() == &Context::parse(&node.ctx, "<List Char>") {
|
||||
node_make_list_edit( node )
|
||||
} else {
|
||||
eprintln!("couldnt add view");
|
||||
node
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue