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();
|
||||
|
||||
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());
|
||||
|
||||
for node in b.iter() {
|
||||
|
|
|
@ -176,7 +176,7 @@ impl PTYListController {
|
|||
|
||||
match cur.mode {
|
||||
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());
|
||||
|
||||
match new_edit.send_cmd_obj(cmd_obj.clone()) {
|
||||
|
|
|
@ -39,6 +39,8 @@ pub struct TypeTermEditor {
|
|||
close_char: SingletonBuffer<Option<char>>,
|
||||
spillbuf: Arc<RwLock<Vec<Arc<RwLock<NestedNode>>>>>,
|
||||
|
||||
depth: usize,
|
||||
|
||||
// editing/parsing state
|
||||
state: State,
|
||||
|
||||
|
@ -134,28 +136,28 @@ impl TypeTermEditor {
|
|||
|
||||
let mut node = match new_state {
|
||||
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() )
|
||||
|
||||
}
|
||||
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() )
|
||||
}
|
||||
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() )
|
||||
}
|
||||
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() )
|
||||
},
|
||||
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() )
|
||||
},
|
||||
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() )
|
||||
}
|
||||
State::Num => {
|
||||
|
@ -164,7 +166,7 @@ impl TypeTermEditor {
|
|||
.morph( (&self.ctx, "( Type::Lit::Num )").into() )
|
||||
}
|
||||
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() )
|
||||
}
|
||||
_ => {
|
||||
|
@ -184,7 +186,7 @@ impl TypeTermEditor {
|
|||
let ctx : Arc<RwLock<Context>> = Arc::new(RwLock::new(Context::with_parent(Some(ctx))));
|
||||
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() );
|
||||
|
||||
Self::with_node(
|
||||
|
@ -208,7 +210,8 @@ impl TypeTermEditor {
|
|||
state,
|
||||
cur_node: SingletonBuffer::new(node),
|
||||
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
|
||||
|
@ -399,12 +402,12 @@ impl TypeTermEditor {
|
|||
drop(item_typterm);
|
||||
|
||||
// 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() );
|
||||
|
||||
let mut new_node = TypeTermEditor::with_node(
|
||||
self.ctx.clone(),
|
||||
0,
|
||||
self.depth,
|
||||
list_node,
|
||||
State::Ladder
|
||||
);
|
||||
|
@ -433,10 +436,12 @@ impl TypeTermEditor {
|
|||
eprintln!("morph into ladder");
|
||||
let old_node = self.cur_node.get().clone();
|
||||
|
||||
*old_node.depth.get_mut() += 1;
|
||||
|
||||
/* create a new NestedNode with TerminaltypeEditor,
|
||||
* 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();
|
||||
old_edit_clone.write().unwrap().set_state( self.state );
|
||||
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
|
||||
*/
|
||||
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() );
|
||||
|
||||
/* reconfigure current node to display new_node list-editor
|
||||
|
|
|
@ -287,7 +287,7 @@ impl Context {
|
|||
let _new_depth = depth;
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
|
|
|
@ -16,13 +16,12 @@ pub fn bg_style_from_depth(depth: usize) -> TerminalStyle {
|
|||
|
||||
pub fn fg_style_from_depth(depth: usize) -> TerminalStyle {
|
||||
match depth % 6 {
|
||||
0 => TerminalStyle::fg_color((180, 180, 180)),
|
||||
1 => TerminalStyle::fg_color((120, 120, 120)),
|
||||
2 => TerminalStyle::fg_color((250, 165, 40)),
|
||||
3 => TerminalStyle::fg_color((80, 180, 200)),
|
||||
4 => TerminalStyle::fg_color((180, 240, 85)),
|
||||
5 => TerminalStyle::fg_color((200, 190, 70)),
|
||||
0 => TerminalStyle::fg_color((120, 120, 0)),
|
||||
1 => TerminalStyle::fg_color((250, 165, 40)),
|
||||
2 => TerminalStyle::fg_color((80, 180, 180)),
|
||||
3 => TerminalStyle::fg_color((180, 240, 85)),
|
||||
4 => TerminalStyle::fg_color((200, 190, 70)),
|
||||
_ => TerminalStyle::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue