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,
|
||||
nested::{
|
||||
editors::ObjCommander,
|
||||
repr_tree::{Context},
|
||||
repr_tree::{Context, ReprTree},
|
||||
edit_tree::{NestedNode}
|
||||
},
|
||||
nested_tty::{
|
||||
DisplaySegment, TTYApplication,
|
||||
TerminalCompositor, TerminalStyle, TerminalView,
|
||||
},
|
||||
r3vi::{
|
||||
buffer::singleton::*,
|
||||
buffer::{singleton::*, vec::*},
|
||||
},
|
||||
std::sync::{Arc, RwLock},
|
||||
};
|
||||
|
||||
struct ParseDigit { radix: u32 };
|
||||
/*
|
||||
struct ParseDigit { radix: u32 }
|
||||
impl Morphism for ParseDigit {
|
||||
fn new(
|
||||
ctx: &Arc<RwLock<Context>>
|
||||
|
@ -38,24 +40,25 @@ impl Morphism for ParseDigit {
|
|||
get_morphism( ) -> Morphism {
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
#[async_std::main]
|
||||
async fn main() {
|
||||
/* 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
|
||||
*/
|
||||
|
||||
let mut char_obj = ReprTree::make_leaf(
|
||||
Context::parse(&ctx, "Char"),
|
||||
SingletonBuffer::new('X').get_port().into()
|
||||
);
|
||||
|
||||
/*
|
||||
char_obj.insert_branch(
|
||||
Context::parse(&ctx, "EditTree"),
|
||||
SingletonBuffer::new(
|
||||
|
||||
NestedNode::new()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -72,12 +75,14 @@ async fn main() {
|
|||
SingletonBuffer::new(0).get_port(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
*/
|
||||
// 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
|
||||
*/
|
||||
|
||||
/*
|
||||
let mut node2 = Context::make_node(
|
||||
&ctx,
|
||||
// node type
|
||||
|
@ -86,12 +91,13 @@ async fn main() {
|
|||
SingletonBuffer::new(0).get_port(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
*/
|
||||
// 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
|
||||
*/
|
||||
/*
|
||||
let mut node3 = Context::make_node(
|
||||
&ctx,
|
||||
// node type
|
||||
|
@ -100,9 +106,9 @@ async fn main() {
|
|||
SingletonBuffer::new(0).get_port(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
*/
|
||||
// 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
|
||||
*/
|
||||
|
@ -111,16 +117,16 @@ async fn main() {
|
|||
*/
|
||||
|
||||
let ctx = ctx.clone();
|
||||
let node1 = node1.clone();
|
||||
let node2 = node2.clone();
|
||||
let node3 = node3.clone();
|
||||
// let node1 = node1.clone();
|
||||
// let node2 = node2.clone();
|
||||
// let node3 = node3.clone();
|
||||
move |ev| {
|
||||
let mut node1 = node1.clone();
|
||||
let mut node2 = node2.clone();
|
||||
let mut node3 = node3.clone();
|
||||
node1.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));
|
||||
// let mut node1 = node1.clone();
|
||||
// let mut node2 = node2.clone();
|
||||
// let mut node3 = node3.clone();
|
||||
// node1.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));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -137,7 +143,7 @@ async fn main() {
|
|||
.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
|
||||
.write()
|
||||
.unwrap()
|
||||
|
@ -147,7 +153,8 @@ async fn main() {
|
|||
.write()
|
||||
.unwrap()
|
||||
.push(node1.display_view().offset(Vector2::new(15, 2)));
|
||||
|
||||
*/
|
||||
/*
|
||||
let label2 = ctx.read().unwrap().type_term_to_str(&node2.get_type());
|
||||
compositor
|
||||
.write()
|
||||
|
@ -170,7 +177,7 @@ async fn main() {
|
|||
.write()
|
||||
.unwrap()
|
||||
.push(node3.display_view().offset(Vector2::new(25, 4)));
|
||||
|
||||
*/
|
||||
/* write the changes in the view of `term_port` to the terminal
|
||||
*/
|
||||
app.show().await.expect("output error!");
|
||||
|
|
|
@ -47,6 +47,9 @@ pub struct NestedNodeEdit {
|
|||
>,
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: rename to EditNode
|
||||
*/
|
||||
#[derive(Clone)]
|
||||
pub struct NestedNode {
|
||||
/// context
|
||||
|
|
|
@ -17,11 +17,13 @@ use {
|
|||
};
|
||||
|
||||
pub fn init_ctx( ctx: &mut Context ) {
|
||||
/*
|
||||
ctx.add_node_ctor(
|
||||
"Char",
|
||||
Arc::new(|ctx: Arc<RwLock<Context>>, _ty: TypeTerm, depth: OuterViewPort<dyn SingletonView<Item = usize>>| {
|
||||
Some(CharEditor::new_node(ctx, depth))
|
||||
}));
|
||||
*/
|
||||
}
|
||||
|
||||
pub struct CharEditor {
|
||||
|
@ -76,10 +78,12 @@ impl CharEditor {
|
|||
|
||||
NestedNode::new(
|
||||
ctx0.clone(),
|
||||
/*
|
||||
ReprTree::new_leaf(
|
||||
ctx0.read().unwrap().type_term_from_str("Char").unwrap(),
|
||||
data.get_port().into()
|
||||
),
|
||||
*/
|
||||
depth
|
||||
)
|
||||
.set_cmd( editor.clone() )
|
||||
|
|
|
@ -89,7 +89,7 @@ impl DigitEditor {
|
|||
let ed = editor.write().unwrap();
|
||||
let r = ed.radix;
|
||||
|
||||
NestedNode::new(ed.ctx.clone(), data, depth)
|
||||
NestedNode::new(ed.ctx.clone(), /*data,*/ depth)
|
||||
.set_cmd(editor.clone())
|
||||
/*
|
||||
.set_view(
|
||||
|
@ -144,6 +144,7 @@ pub struct PosIntEditor {
|
|||
|
||||
impl PosIntEditor {
|
||||
pub fn new(ctx: Arc<RwLock<Context>>, radix: u32) -> Self {
|
||||
/*
|
||||
let mut node = Context::make_node(
|
||||
&ctx,
|
||||
Context::parse(&ctx, format!("<List <Digit {}>>", radix).as_str()),
|
||||
|
@ -159,6 +160,7 @@ impl PosIntEditor {
|
|||
TypeTerm::TypeID(ctx.read().unwrap().get_typeid("BigEndian").unwrap())
|
||||
]
|
||||
));
|
||||
*/
|
||||
/*
|
||||
PTYListController::for_node( &mut node, Some(' '), None );
|
||||
PTYListStyle::for_node( &mut node,
|
||||
|
@ -177,7 +179,10 @@ impl PosIntEditor {
|
|||
*/
|
||||
PosIntEditor {
|
||||
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) {
|
||||
ctx.add_typename("ListCmd".into());
|
||||
ctx.add_list_typename("List".into());
|
||||
|
||||
/*
|
||||
ctx.add_node_ctor(
|
||||
"List", Arc::new(
|
||||
|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();
|
||||
|
||||
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();
|
||||
tail_node.goto(TreeCursor::home());
|
||||
|
||||
|
@ -322,6 +322,7 @@ impl ListEditor {
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
b.clear();
|
||||
drop(b);
|
||||
drop(item);
|
||||
|
@ -334,7 +335,7 @@ impl ListEditor {
|
|||
self.insert(
|
||||
Arc::new(RwLock::new(tail_node))
|
||||
);
|
||||
|
||||
*/
|
||||
} else {
|
||||
self.up();
|
||||
self.listlist_split();
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
pub mod list;
|
||||
//pub mod product;
|
||||
pub mod sum;
|
||||
//pub mod sum;
|
||||
|
||||
pub mod char;
|
||||
pub mod integer;
|
||||
pub mod typeterm;
|
||||
//pub mod integer;
|
||||
//pub mod typeterm;
|
||||
|
||||
|
||||
pub trait Commander {
|
||||
|
|
|
@ -55,7 +55,7 @@ impl SumEditor {
|
|||
|
||||
NestedNode::new(
|
||||
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()
|
||||
)
|
||||
// .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::Ladder".into()); // = T1~T2~...
|
||||
|
||||
/*
|
||||
ctx.add_morphism(
|
||||
MorphismType { src_tyid: Context::parse(&ctx, "<List T>"), dst_tyid: Context::parse(&ctx, "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 );
|
||||
Some(new_node)
|
||||
}));
|
||||
*/
|
||||
/*
|
||||
ctx.add_morphism(
|
||||
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 {
|
||||
ctx.read().unwrap().type_term_from_str(s).expect("could not parse type term")
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ impl MorphismBase {
|
|||
pub fn add_morphism(
|
||||
&mut self,
|
||||
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(
|
||||
GenericReprTreeMorphism {
|
||||
|
@ -82,7 +82,7 @@ impl MorphismBase {
|
|||
target_type: &TypeTerm
|
||||
) {
|
||||
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 {
|
||||
eprintln!("could not find morphism");
|
||||
}
|
||||
|
|
|
@ -219,6 +219,7 @@ impl PTYListController {
|
|||
|
||||
match cur.mode {
|
||||
ListCursorMode::Insert => {
|
||||
/* TODO
|
||||
let mut new_edit = Context::make_node(&e.ctx, e.typ.clone(), self.depth.map(|d| d+1)).unwrap();
|
||||
new_edit.goto(TreeCursor::home());
|
||||
|
||||
|
@ -231,6 +232,8 @@ impl PTYListController {
|
|||
TreeNavResult::Exit
|
||||
}
|
||||
}
|
||||
*/
|
||||
TreeNavResult::Continue
|
||||
},
|
||||
ListCursorMode::Select => {
|
||||
if let Some(item) = e.get_item_mut() {
|
||||
|
|
|
@ -16,7 +16,7 @@ use {
|
|||
atom::TerminalAtom
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
pub fn node_make_char_view(
|
||||
node: NestedNode
|
||||
) -> NestedNode {
|
||||
|
@ -81,4 +81,4 @@ pub fn node_make_tty_view(
|
|||
node
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue