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 \ * - Editor \
* - Display EditTree * - Display EditTree
* / | \ - Editor * / | \ - Editor

View file

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

View file

@ -42,11 +42,12 @@ impl SequenceView for ListSegmentSequence {
type Item = ListSegment; type Item = ListSegment;
fn len(&self) -> Option<usize> { fn len(&self) -> Option<usize> {
let l = self.data.len()?;
match self.cur_cursor.mode { match self.cur_cursor.mode {
ListCursorMode::Insert => { 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( pub fn setup_edittree(
&self, &self,
rt: &Arc<RwLock<ReprTree>> rt: &Arc<RwLock<ReprTree>>
// depth: OuterViewPort<dyn SingletonView<Item = usize>>
) -> Option<SingletonBuffer<Arc<RwLock<EditTree>>>> { ) -> Option<SingletonBuffer<Arc<RwLock<EditTree>>>> {
if let Some(new_edittree) = if let Some(new_edittree) =
rt.descend(self.type_term_from_str("EditTree").unwrap()) rt.descend(self.type_term_from_str("EditTree").unwrap())

View file

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