minor stuff & style

This commit is contained in:
Michael Sippel 2024-09-01 23:56:04 +02:00
parent 7f18fd7755
commit 0a6405b08e
Signed by: senvas
GPG key ID: F96CF119C34B64A6
5 changed files with 33 additions and 38 deletions

View file

@ -47,7 +47,7 @@ async fn main() {
* / | \
* / | \
* / | \
* u32 EditTree Char
* u64 EditTree Char
* - Editor \
* - Display EditTree
* / | \ - Editor

View file

@ -124,23 +124,18 @@ impl ListEditor {
.set_editor(editor.clone())
.set_nav(editor.clone())
.set_cmd(editor.clone())
.set_diag(e
.get_data_port()
.set_diag(e.get_data_port()
.enumerate()
.map(|(idx, item_editor)| {
let idx = *idx;
item_editor
.get_msg_port()
.map(
move |msg| {
item_editor.get_msg_port()
.map(move |msg| {
let mut msg = msg.clone();
msg.addr.insert(0, idx);
msg
}
)
})
.flatten()
);
})
.flatten());
node.ctrl.spillbuf = e.spillbuf.clone();
node

View file

@ -42,11 +42,12 @@ impl SequenceView for ListSegmentSequence {
type Item = ListSegment;
fn len(&self) -> Option<usize> {
let l = self.data.len()?;
match self.cur_cursor.mode {
ListCursorMode::Insert => {
Some(self.data.len()? + if self.cur_cursor.idx.is_some() { 1 } else { 0 })
Some(l + if self.cur_cursor.idx.is_some() { 1 } else { 0 })
}
_ => self.data.len(),
_ => Some(l),
}
}

View file

@ -223,7 +223,6 @@ impl Context {
pub fn setup_edittree(
&self,
rt: &Arc<RwLock<ReprTree>>
// depth: OuterViewPort<dyn SingletonView<Item = usize>>
) -> Option<SingletonBuffer<Arc<RwLock<EditTree>>>> {
if let Some(new_edittree) =
rt.descend(self.type_term_from_str("EditTree").unwrap())

View file

@ -224,22 +224,24 @@ impl PTYListController {
ListCursorMode::Insert => {
let rt = ReprTree::new_arc(e.typ.clone());
let ladder = laddertypes::TypeTerm::Ladder(vec![
let src_ladder = laddertypes::TypeTerm::Ladder(vec![
rt.read().unwrap().get_type().clone()
]);
let dst_ladder = laddertypes::TypeTerm::Ladder(vec![
rt.read().unwrap().get_type().clone(),
ctx.type_term_from_str("EditTree").expect("")
]);
ctx.apply_morphism(
&rt,
&laddertypes::MorphismType {
src_type: rt.get_type(),
dst_type: ladder
src_type: src_ladder,
dst_type: dst_ladder
}
);
let new_edittree = ctx.setup_edittree( &rt );
if let Some(new_edittree) = new_edittree {
let mut ne = new_edittree.get();
let mut ne = ne.write().unwrap();
match ne.send_cmd_obj(cmd_obj.clone()) {
@ -252,9 +254,7 @@ impl PTYListController {
TreeNavResult::Exit
}
}
} else {
panic!("cant get edit tree");
TreeNavResult::Continue
}
@ -301,7 +301,7 @@ impl ObjCommander for PTYListController {
let cmd_type = cmd_obj.read().unwrap().get_type().clone();
if cmd_type == Context::parse(&e.ctx, "ListCmd").into()
|| cmd_type == Context::parse(&e.ctx, "NestedNode").into()
|| cmd_type == Context::parse(&e.ctx, "EditTree").into()
{
e.send_cmd_obj( cmd_obj )
}