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 \
|
* - Editor \
|
||||||
* - Display EditTree
|
* - Display EditTree
|
||||||
* / | \ - Editor
|
* / | \ - Editor
|
||||||
|
@ -109,13 +109,13 @@ async fn main() {
|
||||||
.map_item(|p, a| {
|
.map_item(|p, a| {
|
||||||
a.add_style_back(TerminalStyle::fg_color(((25 * p.x % 255) as u8, 200, 0)))
|
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());
|
let label_str = ctx.read().unwrap().type_term_to_str(&rt_digit.read().unwrap().get_type());
|
||||||
comp.push(
|
comp.push(
|
||||||
nested_tty::make_label(&label_str)
|
nested_tty::make_label(&label_str)
|
||||||
.map_item(|_pt,atom| atom.add_style_front(TerminalStyle::fg_color((90,90,90))))
|
.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
|
comp.push(rt_digit
|
||||||
.edittree( &ctx ).get().read().unwrap()
|
.edittree( &ctx ).get().read().unwrap()
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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())
|
||||||
|
|
|
@ -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 )
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue