call edittree_hook in morphisms already, add edittree() getter in ReprTreeExt to further simplify application code

This commit is contained in:
Michael Sippel 2024-08-09 23:00:31 +02:00
parent 7762fa4b12
commit 0bcfd7a65a
Signed by: senvas
GPG key ID: F96CF119C34B64A6
9 changed files with 49 additions and 73 deletions
examples/tty-04-posint/src

View file

@ -81,27 +81,21 @@ async fn main() {
}
);
let edittree_hex_be_list = ctx.read().unwrap()
.setup_edittree(
rt_int.descend(Context::parse(&ctx,"
<PosInt 16 BigEndian>
~ <Seq <Digit 16>>
~ <List <Digit 16>>
~ <List Char>
")).expect("descend"),
SingletonBuffer::new(0).get_port()
).unwrap().get();
let edittree_hex_be_list =
rt_int
.descend(Context::parse(&ctx, "
<PosInt 16 BigEndian>
~ <Seq~List <Digit 16>~Char>
")).unwrap()
.edittree( &ctx );
let edittree_dec_be_list = ctx.read().unwrap()
.setup_edittree(
rt_int.descend(Context::parse(&ctx,"
<PosInt 10 BigEndian>
~ <Seq <Digit 10>>
~ <List <Digit 10>>
~ <List Char>
")).expect("descend"),
SingletonBuffer::new(0).get_port()
).unwrap().get();
let edittree_dec_be_list =
rt_int
.descend(Context::parse(&ctx, "
<PosInt 10 BigEndian>
~ <Seq~List <Digit 10>~Char>
")).unwrap()
.edittree( &ctx );
let hex_digits_view = rt_int.descend(Context::parse(&ctx, "
<PosInt 16 LittleEndian>
@ -130,15 +124,15 @@ async fn main() {
/* list of both editors
*/
let mut list_editor = nested::editors::list::ListEditor::new(ctx.clone(), Context::parse(&ctx, "<Seq Char>"));
list_editor.data.push( edittree_hex_be_list.clone() );
list_editor.data.push( edittree_dec_be_list.clone() );
list_editor.data.push( edittree_hex_be_list.get() );
list_editor.data.push( edittree_dec_be_list.get() );
let mut edittree = list_editor.into_node(SingletonBuffer::new(0).get_port());
/* cursors are a bit screwed initially so fix them up
* TODO: how to fix this generally?
*/
edittree_hex_be_list.write().unwrap().goto(TreeCursor::none());
edittree_dec_be_list.write().unwrap().goto(TreeCursor::none());
edittree_hex_be_list.get().write().unwrap().goto(TreeCursor::none());
edittree_dec_be_list.get().write().unwrap().goto(TreeCursor::none());
edittree.goto(TreeCursor{
leaf_mode: nested::editors::list::ListCursorMode::Insert,
tree_addr: vec![0,0]