colors by depth; still has some bugs with typeterm morphings
This commit is contained in:
parent
9d190e188c
commit
84b2a6e66d
5 changed files with 27 additions and 23 deletions
|
@ -281,7 +281,7 @@ impl ListEditor {
|
||||||
self.nexd();
|
self.nexd();
|
||||||
|
|
||||||
let mut b = item.spillbuf.write().unwrap();
|
let mut b = item.spillbuf.write().unwrap();
|
||||||
let mut tail_node = Context::make_node(&self.ctx, self.typ.clone(), 0).unwrap();
|
let mut tail_node = Context::make_node(&self.ctx, self.typ.clone(), item.depth.get()).unwrap();
|
||||||
tail_node.goto(TreeCursor::home());
|
tail_node.goto(TreeCursor::home());
|
||||||
|
|
||||||
for node in b.iter() {
|
for node in b.iter() {
|
||||||
|
|
|
@ -176,7 +176,7 @@ impl PTYListController {
|
||||||
|
|
||||||
match cur.mode {
|
match cur.mode {
|
||||||
ListCursorMode::Insert => {
|
ListCursorMode::Insert => {
|
||||||
let mut new_edit = Context::make_node(&e.ctx, e.typ.clone(), self.depth).unwrap();
|
let mut new_edit = Context::make_node(&e.ctx, e.typ.clone(), self.depth+1).unwrap();
|
||||||
new_edit.goto(TreeCursor::home());
|
new_edit.goto(TreeCursor::home());
|
||||||
|
|
||||||
match new_edit.send_cmd_obj(cmd_obj.clone()) {
|
match new_edit.send_cmd_obj(cmd_obj.clone()) {
|
||||||
|
|
|
@ -39,6 +39,8 @@ pub struct TypeTermEditor {
|
||||||
close_char: SingletonBuffer<Option<char>>,
|
close_char: SingletonBuffer<Option<char>>,
|
||||||
spillbuf: Arc<RwLock<Vec<Arc<RwLock<NestedNode>>>>>,
|
spillbuf: Arc<RwLock<Vec<Arc<RwLock<NestedNode>>>>>,
|
||||||
|
|
||||||
|
depth: usize,
|
||||||
|
|
||||||
// editing/parsing state
|
// editing/parsing state
|
||||||
state: State,
|
state: State,
|
||||||
|
|
||||||
|
@ -134,28 +136,28 @@ impl TypeTermEditor {
|
||||||
|
|
||||||
let mut node = match new_state {
|
let mut node = match new_state {
|
||||||
State::Any => {
|
State::Any => {
|
||||||
Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), 0 ).unwrap()
|
Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), self.depth ).unwrap()
|
||||||
.morph( (&self.ctx, "( Type::Sym )").into() )
|
.morph( (&self.ctx, "( Type::Sym )").into() )
|
||||||
|
|
||||||
}
|
}
|
||||||
State::App => {
|
State::App => {
|
||||||
Context::make_node( &self.ctx, (&self.ctx, "( List Type )").into(), 0 ).unwrap()
|
Context::make_node( &self.ctx, (&self.ctx, "( List Type )").into(), self.depth ).unwrap()
|
||||||
.morph( (&self.ctx, "( Type::App )").into() )
|
.morph( (&self.ctx, "( Type::App )").into() )
|
||||||
}
|
}
|
||||||
State::Ladder => {
|
State::Ladder => {
|
||||||
Context::make_node( &self.ctx, (&self.ctx, "( List Type )").into(), 0 ).unwrap()
|
Context::make_node( &self.ctx, (&self.ctx, "( List Type )").into(), self.depth ).unwrap()
|
||||||
.morph( (&self.ctx, "( Type::Ladder )").into() )
|
.morph( (&self.ctx, "( Type::Ladder )").into() )
|
||||||
}
|
}
|
||||||
State::AnySymbol => {
|
State::AnySymbol => {
|
||||||
Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), 0 ).unwrap()
|
Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), self.depth ).unwrap()
|
||||||
.morph( (&self.ctx, "( Type::Sym )").into() )
|
.morph( (&self.ctx, "( Type::Sym )").into() )
|
||||||
},
|
},
|
||||||
State::FunSymbol => {
|
State::FunSymbol => {
|
||||||
Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), 0 ).unwrap()
|
Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), self.depth ).unwrap()
|
||||||
.morph( (&self.ctx, "( Type::Sym::Fun )").into() )
|
.morph( (&self.ctx, "( Type::Sym::Fun )").into() )
|
||||||
},
|
},
|
||||||
State::VarSymbol => {
|
State::VarSymbol => {
|
||||||
Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), 0 ).unwrap()
|
Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), self.depth ).unwrap()
|
||||||
.morph( (&self.ctx, "( Type::Sym::Var )").into() )
|
.morph( (&self.ctx, "( Type::Sym::Var )").into() )
|
||||||
}
|
}
|
||||||
State::Num => {
|
State::Num => {
|
||||||
|
@ -164,7 +166,7 @@ impl TypeTermEditor {
|
||||||
.morph( (&self.ctx, "( Type::Lit::Num )").into() )
|
.morph( (&self.ctx, "( Type::Lit::Num )").into() )
|
||||||
}
|
}
|
||||||
State::Char => {
|
State::Char => {
|
||||||
Context::make_node( &self.ctx, (&self.ctx, "( Char )").into(), 0 ).unwrap()
|
Context::make_node( &self.ctx, (&self.ctx, "( Char )").into(), self.depth ).unwrap()
|
||||||
.morph( (&self.ctx, "( Type::Lit::Char )").into() )
|
.morph( (&self.ctx, "( Type::Lit::Char )").into() )
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -184,7 +186,7 @@ impl TypeTermEditor {
|
||||||
let ctx : Arc<RwLock<Context>> = Arc::new(RwLock::new(Context::with_parent(Some(ctx))));
|
let ctx : Arc<RwLock<Context>> = Arc::new(RwLock::new(Context::with_parent(Some(ctx))));
|
||||||
ctx.write().unwrap().meta_chars.push('~');
|
ctx.write().unwrap().meta_chars.push('~');
|
||||||
|
|
||||||
let mut symb_node = Context::make_node( &ctx, (&ctx, "( List Char )").into(), 0 ).unwrap();
|
let mut symb_node = Context::make_node( &ctx, (&ctx, "( List Char )").into(), depth ).unwrap();
|
||||||
symb_node = symb_node.morph( (&ctx, "( Type::Sym )").into() );
|
symb_node = symb_node.morph( (&ctx, "( Type::Sym )").into() );
|
||||||
|
|
||||||
Self::with_node(
|
Self::with_node(
|
||||||
|
@ -208,7 +210,8 @@ impl TypeTermEditor {
|
||||||
state,
|
state,
|
||||||
cur_node: SingletonBuffer::new(node),
|
cur_node: SingletonBuffer::new(node),
|
||||||
close_char: SingletonBuffer::new(None),
|
close_char: SingletonBuffer::new(None),
|
||||||
spillbuf: Arc::new(RwLock::new(Vec::new()))
|
spillbuf: Arc::new(RwLock::new(Vec::new())),
|
||||||
|
depth
|
||||||
};
|
};
|
||||||
|
|
||||||
let view = editor.cur_node
|
let view = editor.cur_node
|
||||||
|
@ -399,12 +402,12 @@ impl TypeTermEditor {
|
||||||
drop(item_typterm);
|
drop(item_typterm);
|
||||||
|
|
||||||
// else create new ladder
|
// else create new ladder
|
||||||
let mut list_node = Context::make_node( &self.ctx, (&self.ctx, "( List Type )").into(), 0 ).unwrap();
|
let mut list_node = Context::make_node( &self.ctx, (&self.ctx, "( List Type )").into(), self.depth ).unwrap();
|
||||||
list_node = list_node.morph( (&self.ctx, "( Type::Ladder )").into() );
|
list_node = list_node.morph( (&self.ctx, "( Type::Ladder )").into() );
|
||||||
|
|
||||||
let mut new_node = TypeTermEditor::with_node(
|
let mut new_node = TypeTermEditor::with_node(
|
||||||
self.ctx.clone(),
|
self.ctx.clone(),
|
||||||
0,
|
self.depth,
|
||||||
list_node,
|
list_node,
|
||||||
State::Ladder
|
State::Ladder
|
||||||
);
|
);
|
||||||
|
@ -433,10 +436,12 @@ impl TypeTermEditor {
|
||||||
eprintln!("morph into ladder");
|
eprintln!("morph into ladder");
|
||||||
let old_node = self.cur_node.get().clone();
|
let old_node = self.cur_node.get().clone();
|
||||||
|
|
||||||
|
*old_node.depth.get_mut() += 1;
|
||||||
|
|
||||||
/* create a new NestedNode with TerminaltypeEditor,
|
/* create a new NestedNode with TerminaltypeEditor,
|
||||||
* that has same state & child-node as current node.
|
* that has same state & child-node as current node.
|
||||||
*/
|
*/
|
||||||
let mut old_edit_node = TypeTermEditor::new_node( self.ctx.clone(), 0 );
|
let mut old_edit_node = TypeTermEditor::new_node( self.ctx.clone(), self.depth );
|
||||||
let mut old_edit_clone = old_edit_node.get_edit::<TypeTermEditor>().unwrap();
|
let mut old_edit_clone = old_edit_node.get_edit::<TypeTermEditor>().unwrap();
|
||||||
old_edit_clone.write().unwrap().set_state( self.state );
|
old_edit_clone.write().unwrap().set_state( self.state );
|
||||||
old_edit_clone.write().unwrap().close_char.set( old_node.close_char.get() );
|
old_edit_clone.write().unwrap().close_char.set( old_node.close_char.get() );
|
||||||
|
@ -444,7 +449,7 @@ impl TypeTermEditor {
|
||||||
|
|
||||||
/* create new list-edit node for the ladder
|
/* create new list-edit node for the ladder
|
||||||
*/
|
*/
|
||||||
let mut new_node = Context::make_node( &self.ctx, (&self.ctx, "( List Type )").into(), 0 ).unwrap();
|
let mut new_node = Context::make_node( &self.ctx, (&self.ctx, "( List Type )").into(), self.depth ).unwrap();
|
||||||
new_node = new_node.morph( (&self.ctx, "( Type::Ladder )").into() );
|
new_node = new_node.morph( (&self.ctx, "( Type::Ladder )").into() );
|
||||||
|
|
||||||
/* reconfigure current node to display new_node list-editor
|
/* reconfigure current node to display new_node list-editor
|
||||||
|
|
|
@ -287,7 +287,7 @@ impl Context {
|
||||||
let _new_depth = depth;
|
let _new_depth = depth;
|
||||||
|
|
||||||
mk_node(
|
mk_node(
|
||||||
NestedNode::new(new_ctx, ReprTree::new_arc(type_term.clone()), 0),
|
NestedNode::new(new_ctx, ReprTree::new_arc(type_term.clone()), depth),
|
||||||
type_term
|
type_term
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,12 @@ pub fn bg_style_from_depth(depth: usize) -> TerminalStyle {
|
||||||
|
|
||||||
pub fn fg_style_from_depth(depth: usize) -> TerminalStyle {
|
pub fn fg_style_from_depth(depth: usize) -> TerminalStyle {
|
||||||
match depth % 6 {
|
match depth % 6 {
|
||||||
0 => TerminalStyle::fg_color((180, 180, 180)),
|
0 => TerminalStyle::fg_color((120, 120, 0)),
|
||||||
1 => TerminalStyle::fg_color((120, 120, 120)),
|
1 => TerminalStyle::fg_color((250, 165, 40)),
|
||||||
2 => TerminalStyle::fg_color((250, 165, 40)),
|
2 => TerminalStyle::fg_color((80, 180, 180)),
|
||||||
3 => TerminalStyle::fg_color((80, 180, 200)),
|
3 => TerminalStyle::fg_color((180, 240, 85)),
|
||||||
4 => TerminalStyle::fg_color((180, 240, 85)),
|
4 => TerminalStyle::fg_color((200, 190, 70)),
|
||||||
5 => TerminalStyle::fg_color((200, 190, 70)),
|
|
||||||
_ => TerminalStyle::default()
|
_ => TerminalStyle::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue