Compare commits

..

1 commit

2 changed files with 11 additions and 43 deletions

View file

@ -1,11 +1,8 @@
use { use {
laddertypes::{TypeTerm, TypeID, morphism::Morphism}, laddertypes::{TypeTerm, TypeID, morphism::Morphism},
r3vi::view::{AnyOuterViewPort, port::*, list::*}, r3vi::view::{AnyOuterViewPort, port::UpdateTask},
crate::{ crate::{
repr_tree::{ repr_tree::{ReprTree, ReprTreeExt, ReprLeaf},
ReprTree, ReprTreeExt, ReprLeaf,
context::{*}
},
}, },
std::{ std::{
sync::{Arc, RwLock}, sync::{Arc, RwLock},

View file

@ -241,52 +241,23 @@ impl ReprTree {
leaf.attach_to(src_port); leaf.attach_to(src_port);
self.leaf = Some(leaf); self.leaf = Some(leaf);
} else { } else {
self.leaf = Some(ReprLeaf::from_view(src_port)); self.leaf = Some(ReprLeaf::from_view(src_port));
} }
} }
} }
pub fn detach(&mut self, ctx: &Arc<RwLock<Context>>) { pub fn detach(&mut self, ctx: &Arc<RwLock<Context>>) {
// eprintln!("DETACH {:?}", self.get_type());
if let Some(leaf) = self.leaf.as_mut() { if let Some(leaf) = self.leaf.as_mut() {
if self.type_tag == if self.type_tag == Context::parse(&ctx, "Char") {
TypeTerm::TypeID(TYPEID_edittree) leaf.detach::<dyn SingletonView<Item = char>>();
{
leaf.detach::< dyn SingletonView<
Item = Arc<RwLock< crate::edit_tree::EditTree >>
> >();
} }
else if self.type_tag == if self.type_tag == Context::parse(&ctx, "<Vec Char>") {
TypeTerm::TypeID(TYPEID_char) leaf.detach_vec::<char>();
{
leaf.detach::< dyn SingletonView<Item = char> >();
} }
else if self.type_tag == TypeTerm::TypeID(TYPEID_u64) if self.type_tag == Context::parse(&ctx, "<List Char>") {
{ leaf.detach::<dyn ListView<char>>();
leaf.detach::< dyn SingletonView<Item = u64> >();
}
else if self.type_tag == TypeTerm::App(vec![
TypeTerm::TypeID(TYPEID_vec),
TypeTerm::TypeID(TYPEID_edittree),
]) {
leaf.detach_vec::<
Arc<RwLock< crate::edit_tree::EditTree >>
>();
}
else if self.type_tag == TypeTerm::App(vec![
TypeTerm::TypeID(TYPEID_vec),
TypeTerm::TypeID(TYPEID_char),
]) {
leaf.detach_vec::< char >();
}
else if self.type_tag == TypeTerm::App(vec![
TypeTerm::TypeID(TYPEID_vec),
TypeTerm::TypeID(TYPEID_u64),
]) {
leaf.detach_vec::< u64 >();
}
else {
eprintln!("cant detach type");
} }
} }