wip: deactivate code to make it compileable
This commit is contained in:
parent
193b8c8cac
commit
97a5b580df
13 changed files with 71 additions and 39 deletions
|
@ -8,19 +8,21 @@ use {
|
||||||
cgmath::Vector2,
|
cgmath::Vector2,
|
||||||
nested::{
|
nested::{
|
||||||
editors::ObjCommander,
|
editors::ObjCommander,
|
||||||
repr_tree::{Context},
|
repr_tree::{Context, ReprTree},
|
||||||
|
edit_tree::{NestedNode}
|
||||||
},
|
},
|
||||||
nested_tty::{
|
nested_tty::{
|
||||||
DisplaySegment, TTYApplication,
|
DisplaySegment, TTYApplication,
|
||||||
TerminalCompositor, TerminalStyle, TerminalView,
|
TerminalCompositor, TerminalStyle, TerminalView,
|
||||||
},
|
},
|
||||||
r3vi::{
|
r3vi::{
|
||||||
buffer::singleton::*,
|
buffer::{singleton::*, vec::*},
|
||||||
},
|
},
|
||||||
std::sync::{Arc, RwLock},
|
std::sync::{Arc, RwLock},
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ParseDigit { radix: u32 };
|
/*
|
||||||
|
struct ParseDigit { radix: u32 }
|
||||||
impl Morphism for ParseDigit {
|
impl Morphism for ParseDigit {
|
||||||
fn new(
|
fn new(
|
||||||
ctx: &Arc<RwLock<Context>>
|
ctx: &Arc<RwLock<Context>>
|
||||||
|
@ -38,24 +40,25 @@ impl Morphism for ParseDigit {
|
||||||
get_morphism( ) -> Morphism {
|
get_morphism( ) -> Morphism {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#[async_std::main]
|
#[async_std::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
/* setup context & create Editor-Tree
|
/* setup context & create Editor-Tree
|
||||||
*/
|
*/
|
||||||
let ctx = Arc::new(RwLock::new(Context::default()));
|
let ctx = Arc::new(RwLock::new(Context::new()));
|
||||||
|
|
||||||
/* Create a Char-Node with editor & view
|
/* Create a Char-Node with editor & view
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let mut char_obj = ReprTree::make_leaf(
|
let mut char_obj = ReprTree::make_leaf(
|
||||||
Context::parse(&ctx, "Char"),
|
Context::parse(&ctx, "Char"),
|
||||||
SingletonBuffer::new('X').get_port().into()
|
SingletonBuffer::new('X').get_port().into()
|
||||||
);
|
);
|
||||||
|
/*
|
||||||
char_obj.insert_branch(
|
char_obj.insert_branch(
|
||||||
Context::parse(&ctx, "EditTree"),
|
Context::parse(&ctx, "EditTree"),
|
||||||
SingletonBuffer::new(
|
SingletonBuffer::new(
|
||||||
|
NestedNode::new()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -72,12 +75,14 @@ async fn main() {
|
||||||
SingletonBuffer::new(0).get_port(),
|
SingletonBuffer::new(0).get_port(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
*/
|
||||||
// add a display view to the node
|
// add a display view to the node
|
||||||
node1 = nested_tty::editors::node_make_tty_view(node1);
|
//node1 = nested_tty::editors::node_make_tty_view(node1);
|
||||||
|
|
||||||
/* Create a <List Char>-Node with editor & view
|
/* Create a <List Char>-Node with editor & view
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
let mut node2 = Context::make_node(
|
let mut node2 = Context::make_node(
|
||||||
&ctx,
|
&ctx,
|
||||||
// node type
|
// node type
|
||||||
|
@ -86,12 +91,13 @@ async fn main() {
|
||||||
SingletonBuffer::new(0).get_port(),
|
SingletonBuffer::new(0).get_port(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
*/
|
||||||
// add a display view to the node
|
// add a display view to the node
|
||||||
node2 = nested_tty::editors::node_make_tty_view(node2);
|
//node2 = nested_tty::editors::node_make_tty_view(node2);
|
||||||
|
|
||||||
/* Create a <List Char>-Node with editor & view
|
/* Create a <List Char>-Node with editor & view
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
let mut node3 = Context::make_node(
|
let mut node3 = Context::make_node(
|
||||||
&ctx,
|
&ctx,
|
||||||
// node type
|
// node type
|
||||||
|
@ -100,10 +106,10 @@ async fn main() {
|
||||||
SingletonBuffer::new(0).get_port(),
|
SingletonBuffer::new(0).get_port(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
*/
|
||||||
// add a display view to the node
|
// add a display view to the node
|
||||||
node3 = nested_tty::editors::node_make_tty_view(node3);
|
//node3 = nested_tty::editors::node_make_tty_view(node3);
|
||||||
|
|
||||||
/* setup terminal
|
/* setup terminal
|
||||||
*/
|
*/
|
||||||
let app = TTYApplication::new({
|
let app = TTYApplication::new({
|
||||||
|
@ -111,16 +117,16 @@ async fn main() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
let node1 = node1.clone();
|
// let node1 = node1.clone();
|
||||||
let node2 = node2.clone();
|
// let node2 = node2.clone();
|
||||||
let node3 = node3.clone();
|
// let node3 = node3.clone();
|
||||||
move |ev| {
|
move |ev| {
|
||||||
let mut node1 = node1.clone();
|
// let mut node1 = node1.clone();
|
||||||
let mut node2 = node2.clone();
|
// let mut node2 = node2.clone();
|
||||||
let mut node3 = node3.clone();
|
// let mut node3 = node3.clone();
|
||||||
node1.send_cmd_obj(ev.to_repr_tree(&ctx));
|
// node1.send_cmd_obj(ev.to_repr_tree(&ctx));
|
||||||
node2.send_cmd_obj(ev.to_repr_tree(&ctx));
|
// node2.send_cmd_obj(ev.to_repr_tree(&ctx));
|
||||||
node3.send_cmd_obj(ev.to_repr_tree(&ctx));
|
// node3.send_cmd_obj(ev.to_repr_tree(&ctx));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -137,7 +143,7 @@ async fn main() {
|
||||||
.offset(Vector2::new(5, 0)),
|
.offset(Vector2::new(5, 0)),
|
||||||
);
|
);
|
||||||
|
|
||||||
let label = ctx.read().unwrap().type_term_to_str(&node1.get_type());
|
/* let label = ctx.read().unwrap().type_term_to_str(&node1.get_type());
|
||||||
compositor
|
compositor
|
||||||
.write()
|
.write()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -147,7 +153,8 @@ async fn main() {
|
||||||
.write()
|
.write()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.push(node1.display_view().offset(Vector2::new(15, 2)));
|
.push(node1.display_view().offset(Vector2::new(15, 2)));
|
||||||
|
*/
|
||||||
|
/*
|
||||||
let label2 = ctx.read().unwrap().type_term_to_str(&node2.get_type());
|
let label2 = ctx.read().unwrap().type_term_to_str(&node2.get_type());
|
||||||
compositor
|
compositor
|
||||||
.write()
|
.write()
|
||||||
|
@ -170,7 +177,7 @@ async fn main() {
|
||||||
.write()
|
.write()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.push(node3.display_view().offset(Vector2::new(25, 4)));
|
.push(node3.display_view().offset(Vector2::new(25, 4)));
|
||||||
|
*/
|
||||||
/* write the changes in the view of `term_port` to the terminal
|
/* write the changes in the view of `term_port` to the terminal
|
||||||
*/
|
*/
|
||||||
app.show().await.expect("output error!");
|
app.show().await.expect("output error!");
|
||||||
|
|
|
@ -47,6 +47,9 @@ pub struct NestedNodeEdit {
|
||||||
>,
|
>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: rename to EditNode
|
||||||
|
*/
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct NestedNode {
|
pub struct NestedNode {
|
||||||
/// context
|
/// context
|
||||||
|
|
|
@ -17,11 +17,13 @@ use {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn init_ctx( ctx: &mut Context ) {
|
pub fn init_ctx( ctx: &mut Context ) {
|
||||||
|
/*
|
||||||
ctx.add_node_ctor(
|
ctx.add_node_ctor(
|
||||||
"Char",
|
"Char",
|
||||||
Arc::new(|ctx: Arc<RwLock<Context>>, _ty: TypeTerm, depth: OuterViewPort<dyn SingletonView<Item = usize>>| {
|
Arc::new(|ctx: Arc<RwLock<Context>>, _ty: TypeTerm, depth: OuterViewPort<dyn SingletonView<Item = usize>>| {
|
||||||
Some(CharEditor::new_node(ctx, depth))
|
Some(CharEditor::new_node(ctx, depth))
|
||||||
}));
|
}));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CharEditor {
|
pub struct CharEditor {
|
||||||
|
@ -76,10 +78,12 @@ impl CharEditor {
|
||||||
|
|
||||||
NestedNode::new(
|
NestedNode::new(
|
||||||
ctx0.clone(),
|
ctx0.clone(),
|
||||||
|
/*
|
||||||
ReprTree::new_leaf(
|
ReprTree::new_leaf(
|
||||||
ctx0.read().unwrap().type_term_from_str("Char").unwrap(),
|
ctx0.read().unwrap().type_term_from_str("Char").unwrap(),
|
||||||
data.get_port().into()
|
data.get_port().into()
|
||||||
),
|
),
|
||||||
|
*/
|
||||||
depth
|
depth
|
||||||
)
|
)
|
||||||
.set_cmd( editor.clone() )
|
.set_cmd( editor.clone() )
|
||||||
|
|
|
@ -89,7 +89,7 @@ impl DigitEditor {
|
||||||
let ed = editor.write().unwrap();
|
let ed = editor.write().unwrap();
|
||||||
let r = ed.radix;
|
let r = ed.radix;
|
||||||
|
|
||||||
NestedNode::new(ed.ctx.clone(), data, depth)
|
NestedNode::new(ed.ctx.clone(), /*data,*/ depth)
|
||||||
.set_cmd(editor.clone())
|
.set_cmd(editor.clone())
|
||||||
/*
|
/*
|
||||||
.set_view(
|
.set_view(
|
||||||
|
@ -144,6 +144,7 @@ pub struct PosIntEditor {
|
||||||
|
|
||||||
impl PosIntEditor {
|
impl PosIntEditor {
|
||||||
pub fn new(ctx: Arc<RwLock<Context>>, radix: u32) -> Self {
|
pub fn new(ctx: Arc<RwLock<Context>>, radix: u32) -> Self {
|
||||||
|
/*
|
||||||
let mut node = Context::make_node(
|
let mut node = Context::make_node(
|
||||||
&ctx,
|
&ctx,
|
||||||
Context::parse(&ctx, format!("<List <Digit {}>>", radix).as_str()),
|
Context::parse(&ctx, format!("<List <Digit {}>>", radix).as_str()),
|
||||||
|
@ -159,6 +160,7 @@ impl PosIntEditor {
|
||||||
TypeTerm::TypeID(ctx.read().unwrap().get_typeid("BigEndian").unwrap())
|
TypeTerm::TypeID(ctx.read().unwrap().get_typeid("BigEndian").unwrap())
|
||||||
]
|
]
|
||||||
));
|
));
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
PTYListController::for_node( &mut node, Some(' '), None );
|
PTYListController::for_node( &mut node, Some(' '), None );
|
||||||
PTYListStyle::for_node( &mut node,
|
PTYListStyle::for_node( &mut node,
|
||||||
|
@ -177,7 +179,10 @@ impl PosIntEditor {
|
||||||
*/
|
*/
|
||||||
PosIntEditor {
|
PosIntEditor {
|
||||||
radix,
|
radix,
|
||||||
digits: node
|
digits: NestedNode::new(
|
||||||
|
ctx,
|
||||||
|
r3vi::buffer::singleton::SingletonBuffer::new(0).get_port()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ use {
|
||||||
pub fn init_ctx(ctx: &mut Context) {
|
pub fn init_ctx(ctx: &mut Context) {
|
||||||
ctx.add_typename("ListCmd".into());
|
ctx.add_typename("ListCmd".into());
|
||||||
ctx.add_list_typename("List".into());
|
ctx.add_list_typename("List".into());
|
||||||
|
/*
|
||||||
ctx.add_node_ctor(
|
ctx.add_node_ctor(
|
||||||
"List", Arc::new(
|
"List", Arc::new(
|
||||||
|ctx: Arc<RwLock<Context>>, ty: TypeTerm, depth: OuterViewPort<dyn SingletonView<Item = usize>>| {
|
|ctx: Arc<RwLock<Context>>, ty: TypeTerm, depth: OuterViewPort<dyn SingletonView<Item = usize>>| {
|
||||||
|
@ -37,5 +37,6 @@ pub fn init_ctx(ctx: &mut Context) {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -307,7 +307,7 @@ impl ListEditor {
|
||||||
self.nexd();
|
self.nexd();
|
||||||
|
|
||||||
let mut b = item.edit.spillbuf.write().unwrap();
|
let mut b = item.edit.spillbuf.write().unwrap();
|
||||||
|
/* TODO
|
||||||
let mut tail_node = Context::make_node(&self.ctx, self.typ.clone(), self.depth.map(|d| d+1)).unwrap();
|
let mut tail_node = Context::make_node(&self.ctx, self.typ.clone(), self.depth.map(|d| d+1)).unwrap();
|
||||||
tail_node.goto(TreeCursor::home());
|
tail_node.goto(TreeCursor::home());
|
||||||
|
|
||||||
|
@ -322,6 +322,7 @@ impl ListEditor {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
b.clear();
|
b.clear();
|
||||||
drop(b);
|
drop(b);
|
||||||
drop(item);
|
drop(item);
|
||||||
|
@ -334,7 +335,7 @@ impl ListEditor {
|
||||||
self.insert(
|
self.insert(
|
||||||
Arc::new(RwLock::new(tail_node))
|
Arc::new(RwLock::new(tail_node))
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
} else {
|
} else {
|
||||||
self.up();
|
self.up();
|
||||||
self.listlist_split();
|
self.listlist_split();
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
pub mod list;
|
pub mod list;
|
||||||
//pub mod product;
|
//pub mod product;
|
||||||
pub mod sum;
|
//pub mod sum;
|
||||||
|
|
||||||
pub mod char;
|
pub mod char;
|
||||||
pub mod integer;
|
//pub mod integer;
|
||||||
pub mod typeterm;
|
//pub mod typeterm;
|
||||||
|
|
||||||
|
|
||||||
pub trait Commander {
|
pub trait Commander {
|
||||||
|
|
|
@ -55,7 +55,7 @@ impl SumEditor {
|
||||||
|
|
||||||
NestedNode::new(
|
NestedNode::new(
|
||||||
ctx.clone(),
|
ctx.clone(),
|
||||||
ReprTree::new_arc(TypeTerm::TypeID(ctx.read().unwrap().get_typeid("Sum").unwrap())),
|
// ReprTree::new_arc(TypeTerm::TypeID(ctx.read().unwrap().get_typeid("Sum").unwrap())),
|
||||||
r3vi::buffer::singleton::SingletonBuffer::new(0).get_port()
|
r3vi::buffer::singleton::SingletonBuffer::new(0).get_port()
|
||||||
)
|
)
|
||||||
// .set_view(view)
|
// .set_view(view)
|
||||||
|
|
|
@ -25,6 +25,7 @@ pub fn init_ctx(ctx: &mut Context) {
|
||||||
ctx.add_list_typename("Type::App".into()); // = <T1 T2 ...>
|
ctx.add_list_typename("Type::App".into()); // = <T1 T2 ...>
|
||||||
ctx.add_list_typename("Type::Ladder".into()); // = T1~T2~...
|
ctx.add_list_typename("Type::Ladder".into()); // = T1~T2~...
|
||||||
|
|
||||||
|
/*
|
||||||
ctx.add_morphism(
|
ctx.add_morphism(
|
||||||
MorphismType { src_tyid: Context::parse(&ctx, "<List T>"), dst_tyid: Context::parse(&ctx, "Type") },
|
MorphismType { src_tyid: Context::parse(&ctx, "<List T>"), dst_tyid: Context::parse(&ctx, "Type") },
|
||||||
Arc::new(move |node, _dst_type:_| {
|
Arc::new(move |node, _dst_type:_| {
|
||||||
|
@ -34,6 +35,7 @@ pub fn init_ctx(ctx: &mut Context) {
|
||||||
let new_node = TypeTermEditor::with_node( ctx, node.clone(), State::Any );
|
let new_node = TypeTermEditor::with_node( ctx, node.clone(), State::Any );
|
||||||
Some(new_node)
|
Some(new_node)
|
||||||
}));
|
}));
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
ctx.add_morphism(
|
ctx.add_morphism(
|
||||||
MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::Ladder").unwrap() },
|
MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::Ladder").unwrap() },
|
||||||
|
|
|
@ -66,6 +66,12 @@ impl Context {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn make_repr(ctx: &Arc<RwLock<Self>>, t: &TypeTerm) -> Arc<RwLock<ReprTree>> {
|
||||||
|
let rt = Arc::new(RwLock::new(ReprTree::new( TypeTerm::unit() )));
|
||||||
|
ctx.read().unwrap().morphisms.morph( rt.clone(), t );
|
||||||
|
rt
|
||||||
|
}
|
||||||
|
|
||||||
pub fn parse(ctx: &Arc<RwLock<Self>>, s: &str) -> TypeTerm {
|
pub fn parse(ctx: &Arc<RwLock<Self>>, s: &str) -> TypeTerm {
|
||||||
ctx.read().unwrap().type_term_from_str(s).expect("could not parse type term")
|
ctx.read().unwrap().type_term_from_str(s).expect("could not parse type term")
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl MorphismBase {
|
||||||
pub fn add_morphism(
|
pub fn add_morphism(
|
||||||
&mut self,
|
&mut self,
|
||||||
morph_type: MorphismType,
|
morph_type: MorphismType,
|
||||||
repr_tree_op: impl Fn( Arc<RwLock<ReprTree>>, &HashMap<TypeID, TypeTerm> ) + Send + Sync
|
repr_tree_op: impl Fn( Arc<RwLock<ReprTree>>, &HashMap<TypeID, TypeTerm> ) + Send + Sync + 'static
|
||||||
) {
|
) {
|
||||||
self.morphisms.push(
|
self.morphisms.push(
|
||||||
GenericReprTreeMorphism {
|
GenericReprTreeMorphism {
|
||||||
|
@ -82,7 +82,7 @@ impl MorphismBase {
|
||||||
target_type: &TypeTerm
|
target_type: &TypeTerm
|
||||||
) {
|
) {
|
||||||
if let Some((m, σ)) = self.find_morphism( repr_tree.read().unwrap().get_type(), target_type ) {
|
if let Some((m, σ)) = self.find_morphism( repr_tree.read().unwrap().get_type(), target_type ) {
|
||||||
(m.repr_tree_op)( repr_tree, &σ );
|
(m.repr_tree_op)( repr_tree.clone(), &σ );
|
||||||
} else {
|
} else {
|
||||||
eprintln!("could not find morphism");
|
eprintln!("could not find morphism");
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,6 +219,7 @@ impl PTYListController {
|
||||||
|
|
||||||
match cur.mode {
|
match cur.mode {
|
||||||
ListCursorMode::Insert => {
|
ListCursorMode::Insert => {
|
||||||
|
/* TODO
|
||||||
let mut new_edit = Context::make_node(&e.ctx, e.typ.clone(), self.depth.map(|d| d+1)).unwrap();
|
let mut new_edit = Context::make_node(&e.ctx, e.typ.clone(), self.depth.map(|d| d+1)).unwrap();
|
||||||
new_edit.goto(TreeCursor::home());
|
new_edit.goto(TreeCursor::home());
|
||||||
|
|
||||||
|
@ -231,6 +232,8 @@ impl PTYListController {
|
||||||
TreeNavResult::Exit
|
TreeNavResult::Exit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
TreeNavResult::Continue
|
||||||
},
|
},
|
||||||
ListCursorMode::Select => {
|
ListCursorMode::Select => {
|
||||||
if let Some(item) = e.get_item_mut() {
|
if let Some(item) = e.get_item_mut() {
|
||||||
|
|
|
@ -16,7 +16,7 @@ use {
|
||||||
atom::TerminalAtom
|
atom::TerminalAtom
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
pub fn node_make_char_view(
|
pub fn node_make_char_view(
|
||||||
node: NestedNode
|
node: NestedNode
|
||||||
) -> NestedNode {
|
) -> NestedNode {
|
||||||
|
@ -81,4 +81,4 @@ pub fn node_make_tty_view(
|
||||||
node
|
node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
Loading…
Reference in a new issue