minor stuff & style
This commit is contained in:
parent
7f18fd7755
commit
0a6405b08e
5 changed files with 33 additions and 38 deletions
|
@ -47,7 +47,7 @@ async fn main() {
|
|||
* / | \
|
||||
* / | \
|
||||
* / | \
|
||||
* u32 EditTree Char
|
||||
* u64 EditTree Char
|
||||
* - Editor \
|
||||
* - Display EditTree
|
||||
* / | \ - Editor
|
||||
|
@ -109,13 +109,13 @@ async fn main() {
|
|||
.map_item(|p, a| {
|
||||
a.add_style_back(TerminalStyle::fg_color(((25 * p.x % 255) as u8, 200, 0)))
|
||||
})
|
||||
.offset(Vector2::new(5, 0)));
|
||||
.offset(Vector2::new(5,0)));
|
||||
|
||||
let label_str = ctx.read().unwrap().type_term_to_str(&rt_digit.read().unwrap().get_type());
|
||||
comp.push(
|
||||
nested_tty::make_label(&label_str)
|
||||
.map_item(|_pt,atom| atom.add_style_front(TerminalStyle::fg_color((90,90,90))))
|
||||
.offset(Vector2::new(1, 1)));
|
||||
.offset(Vector2::new(1,1)));
|
||||
|
||||
comp.push(rt_digit
|
||||
.edittree( &ctx ).get().read().unwrap()
|
||||
|
|
|
@ -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| {
|
||||
let mut msg = msg.clone();
|
||||
msg.addr.insert(0, idx);
|
||||
msg
|
||||
}
|
||||
)
|
||||
let idx = *idx;
|
||||
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
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -224,37 +224,37 @@ 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()) {
|
||||
TreeNavResult::Continue => {
|
||||
drop(ne);
|
||||
e.insert(new_edittree.value.read().unwrap().clone());
|
||||
TreeNavResult::Continue
|
||||
let mut ne = new_edittree.get();
|
||||
let mut ne = ne.write().unwrap();
|
||||
match ne.send_cmd_obj(cmd_obj.clone()) {
|
||||
TreeNavResult::Continue => {
|
||||
drop(ne);
|
||||
e.insert(new_edittree.value.read().unwrap().clone());
|
||||
TreeNavResult::Continue
|
||||
}
|
||||
TreeNavResult::Exit => {
|
||||
TreeNavResult::Exit
|
||||
}
|
||||
}
|
||||
TreeNavResult::Exit => {
|
||||
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 )
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue