typeterm editor: shorten match arms in set state
This commit is contained in:
parent
cff70f2c04
commit
070131b7fc
1 changed files with 21 additions and 38 deletions
|
@ -9,7 +9,7 @@ use {
|
||||||
},
|
},
|
||||||
crate::{
|
crate::{
|
||||||
type_system::{Context, TypeID, TypeTerm, ReprTree},
|
type_system::{Context, TypeID, TypeTerm, ReprTree},
|
||||||
editors::{list::{ListCursorMode}},
|
editors::{list::{ListCursorMode, ListEditor, ListCmd}},
|
||||||
tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor},
|
tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor},
|
||||||
commander::ObjCommander
|
commander::ObjCommander
|
||||||
},
|
},
|
||||||
|
@ -17,7 +17,7 @@ use {
|
||||||
cgmath::{Vector2}
|
cgmath::{Vector2}
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||||
pub enum State {
|
pub enum State {
|
||||||
Any,
|
Any,
|
||||||
Num,
|
Num,
|
||||||
|
@ -135,40 +135,33 @@ impl TypeTermEditor {
|
||||||
|
|
||||||
let mut node = match new_state {
|
let mut node = match new_state {
|
||||||
State::App => {
|
State::App => {
|
||||||
let mut node = Context::make_node( &self.ctx, (&self.ctx, "( List Type )").into(), 0 ).unwrap();
|
Context::make_node( &self.ctx, (&self.ctx, "( List Type )").into(), 0 ).unwrap()
|
||||||
node = node.morph( (&self.ctx, "( Type::App )").into() );
|
.morph( (&self.ctx, "( Type::App )").into() )
|
||||||
node
|
|
||||||
}
|
}
|
||||||
State::Ladder => {
|
State::Ladder => {
|
||||||
let mut node = Context::make_node( &self.ctx, (&self.ctx, "( List Type )").into(), 0 ).unwrap();
|
Context::make_node( &self.ctx, (&self.ctx, "( List Type )").into(), 0 ).unwrap()
|
||||||
node = node.morph( (&self.ctx, "( Type::Ladder )").into() );
|
.morph( (&self.ctx, "( Type::Ladder )").into() )
|
||||||
node
|
|
||||||
}
|
}
|
||||||
State::AnySymbol => {
|
State::AnySymbol => {
|
||||||
let mut node = Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), 0 ).unwrap();
|
Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), 0 ).unwrap()
|
||||||
node = node.morph( (&self.ctx, "( Type::Sym )").into() );
|
.morph( (&self.ctx, "( Type::Sym )").into() )
|
||||||
node
|
|
||||||
},
|
},
|
||||||
State::FunSymbol => {
|
State::FunSymbol => {
|
||||||
let mut node = Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), 0 ).unwrap();
|
Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), 0 ).unwrap()
|
||||||
node = node.morph( (&self.ctx, "( Type::Sym::Fun )").into() );
|
.morph( (&self.ctx, "( Type::Sym::Fun )").into() )
|
||||||
node
|
|
||||||
},
|
},
|
||||||
State::VarSymbol => {
|
State::VarSymbol => {
|
||||||
let mut node = Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), 0 ).unwrap();
|
Context::make_node( &self.ctx, (&self.ctx, "( List Char )").into(), 0 ).unwrap()
|
||||||
node = node.morph( (&self.ctx, "( Type::Sym::Var )").into() );
|
.morph( (&self.ctx, "( Type::Sym::Var )").into() )
|
||||||
node
|
|
||||||
}
|
}
|
||||||
State::Num => {
|
State::Num => {
|
||||||
let int_edit = crate::editors::integer::PosIntEditor::new(self.ctx.clone(), 10);
|
crate::editors::integer::PosIntEditor::new(self.ctx.clone(), 10)
|
||||||
let mut node = int_edit.into_node();
|
.into_node()
|
||||||
node = node.morph( (&self.ctx, "( Type::Lit::Num )").into() );
|
.morph( (&self.ctx, "( Type::Lit::Num )").into() )
|
||||||
node
|
|
||||||
}
|
}
|
||||||
State::Char => {
|
State::Char => {
|
||||||
let mut node = Context::make_node( &self.ctx, (&self.ctx, "( Char )").into(), 0 ).unwrap();
|
Context::make_node( &self.ctx, (&self.ctx, "( Char )").into(), 0 ).unwrap()
|
||||||
node = node.morph( (&self.ctx, "( Type::Lit::Char )").into() );
|
.morph( (&self.ctx, "( Type::Lit::Char )").into() )
|
||||||
node
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
old_node
|
old_node
|
||||||
|
@ -216,21 +209,11 @@ impl TypeTermEditor {
|
||||||
|
|
||||||
let view = editor.cur_node
|
let view = editor.cur_node
|
||||||
.get_port()
|
.get_port()
|
||||||
.map(
|
.map(|node| {
|
||||||
|node| {
|
node.view.clone().unwrap_or(r3vi::view::ViewPort::new().into_outer())
|
||||||
match node.view.clone() {
|
})
|
||||||
Some(v) => {
|
|
||||||
v
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
r3vi::view::ViewPort::new().into_outer()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.to_grid()
|
.to_grid()
|
||||||
.flatten();
|
.flatten();
|
||||||
|
|
||||||
let cc = editor.cur_node.get().close_char;
|
let cc = editor.cur_node.get().close_char;
|
||||||
let editor = Arc::new(RwLock::new(editor));
|
let editor = Arc::new(RwLock::new(editor));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue