Compare commits
No commits in common. "e86070da500ca3a45ef55a14a82b3c03f0cbe03c" and "ab51ea5d3d8bcd0d83d7deb8e7be6088435df7b5" have entirely different histories.
e86070da50
...
ab51ea5d3d
10 changed files with 462 additions and 646 deletions
|
@ -32,177 +32,6 @@ use {
|
||||||
std::sync::{Arc, RwLock},
|
std::sync::{Arc, RwLock},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn rebuild_projections(
|
|
||||||
ctx: Arc<RwLock<Context>>,
|
|
||||||
repr_tree: Arc<RwLock<ReprTree>>,
|
|
||||||
morph_types: Vec< (laddertypes::TypeTerm, laddertypes::TypeTerm) >
|
|
||||||
) {
|
|
||||||
repr_tree.write().unwrap().detach(&ctx);
|
|
||||||
for (src_type, dst_type) in morph_types.iter() {
|
|
||||||
ctx.read().unwrap().morphisms.apply_morphism(
|
|
||||||
repr_tree.clone(),
|
|
||||||
&src_type,
|
|
||||||
&dst_type
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn setup_le_master(ctx: &Arc<RwLock<Context>>, rt_int: &Arc<RwLock<ReprTree>>) {
|
|
||||||
rebuild_projections(
|
|
||||||
ctx.clone(),
|
|
||||||
rt_int.clone(),
|
|
||||||
vec![
|
|
||||||
// Little Endian Editor
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ EditTree",
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char>"
|
|
||||||
),
|
|
||||||
|
|
||||||
// Convert Endianness
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char>",
|
|
||||||
"ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char>"
|
|
||||||
),
|
|
||||||
|
|
||||||
// Big Endian Editor
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char>",
|
|
||||||
"ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char ~ EditTree>"
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char ~ EditTree>",
|
|
||||||
"ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char ~ EditTree> ~ <Vec EditTree>"
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char ~ EditTree> ~ <Vec EditTree>",
|
|
||||||
"ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ EditTree"
|
|
||||||
),
|
|
||||||
].into_iter()
|
|
||||||
.map(|(s,d)| (Context::parse(&ctx, s), Context::parse(&ctx, d)))
|
|
||||||
.collect()
|
|
||||||
);
|
|
||||||
/*
|
|
||||||
|
|
||||||
/*
|
|
||||||
* map seq of chars to seq of u64 digits
|
|
||||||
* and add this projection to the ReprTree
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
|
||||||
let mut chars_view = rt_int.descend(Context::parse(&ctx, "
|
|
||||||
<PosInt 16 BigEndian>
|
|
||||||
~ <Seq <Digit 16>>
|
|
||||||
~ <List <Digit 16>~Char>
|
|
||||||
")).expect("cant descend")
|
|
||||||
.read().unwrap()
|
|
||||||
.get_port::<dyn ListView<char>>()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mut digits_view = chars_view
|
|
||||||
.to_sequence()
|
|
||||||
.filter_map(
|
|
||||||
|digit_char|
|
|
||||||
|
|
||||||
/* TODO: call morphism for each item
|
|
||||||
*/
|
|
||||||
match digit_char.to_digit(16) {
|
|
||||||
Some(d) => Some(d as u64),
|
|
||||||
None => None
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
rt_int.attach_leaf_to(Context::parse(&ctx, "
|
|
||||||
<PosInt 16 BigEndian>
|
|
||||||
~ <Seq <Digit 16>
|
|
||||||
~ ℤ_2^64
|
|
||||||
~ machine.UInt64 >
|
|
||||||
"),
|
|
||||||
digits_view.clone()
|
|
||||||
);
|
|
||||||
|
|
||||||
//ΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛ
|
|
||||||
//
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
fn setup_be_master(ctx: &Arc<RwLock<Context>>, rt_int: &Arc<RwLock<ReprTree>>) {
|
|
||||||
rebuild_projections(
|
|
||||||
ctx.clone(),
|
|
||||||
rt_int.clone(),
|
|
||||||
vec![
|
|
||||||
// Big Endian Editor
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ EditTree",
|
|
||||||
"ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char>"
|
|
||||||
),
|
|
||||||
|
|
||||||
// Convert Endianness
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char>",
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char>"
|
|
||||||
),
|
|
||||||
|
|
||||||
// Big Endian Editor
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char>",
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char ~ EditTree>"
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char ~ EditTree>",
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char ~ EditTree> ~ <Vec EditTree>"
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char ~ EditTree> ~ <Vec EditTree>",
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ EditTree"
|
|
||||||
),
|
|
||||||
].into_iter()
|
|
||||||
.map(|(s,d)| (Context::parse(&ctx, s), Context::parse(&ctx, d)))
|
|
||||||
.collect()
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
/*
|
|
||||||
* map seq of chars to seq of u64 digits
|
|
||||||
* and add this projection to the ReprTree
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
|
||||||
let mut chars_view = rt_int.descend(Context::parse(&ctx, "
|
|
||||||
<PosInt 16 BigEndian>
|
|
||||||
~ <Seq <Digit 16>>
|
|
||||||
~ <List <Digit 16>~Char>
|
|
||||||
")).expect("cant descend")
|
|
||||||
.read().unwrap()
|
|
||||||
.get_port::<dyn ListView<char>>()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mut digits_view = chars_view
|
|
||||||
.to_sequence()
|
|
||||||
.filter_map(
|
|
||||||
|digit_char|
|
|
||||||
|
|
||||||
/* TODO: call morphism for each item
|
|
||||||
*/
|
|
||||||
match digit_char.to_digit(16) {
|
|
||||||
Some(d) => Some(d as u64),
|
|
||||||
None => None
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
rt_int.attach_leaf_to(Context::parse(&ctx, "
|
|
||||||
<PosInt 16 BigEndian>
|
|
||||||
~ <Seq <Digit 16>
|
|
||||||
~ ℤ_2^64
|
|
||||||
~ machine.UInt64 >
|
|
||||||
"),
|
|
||||||
digits_view.clone()
|
|
||||||
);
|
|
||||||
|
|
||||||
//ΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛ
|
|
||||||
//
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_std::main]
|
#[async_std::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
/* setup context
|
/* setup context
|
||||||
|
@ -220,84 +49,143 @@ async fn main() {
|
||||||
|
|
||||||
/* Add a specific Representation-Path (big-endian hexadecimal)
|
/* Add a specific Representation-Path (big-endian hexadecimal)
|
||||||
*/
|
*/
|
||||||
let mut digits_be = VecBuffer::with_data(vec![ 'c', 'f', 'f' ]);
|
rt_int.create_branch(
|
||||||
|
Context::parse(&ctx, "<PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16>~Char>")
|
||||||
|
);
|
||||||
|
rt_int.create_branch(
|
||||||
|
Context::parse(&ctx, "<PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16>~Char>")
|
||||||
|
);
|
||||||
|
rt_int.create_branch(
|
||||||
|
Context::parse(&ctx, "<PosInt 10 BigEndian> ~ <Seq <Digit 10>> ~ <List <Digit 10>~Char>")
|
||||||
|
);
|
||||||
|
|
||||||
|
eprintln!("make big endian hex repr");
|
||||||
|
let mut b = VecBuffer::with_data(vec![ 'c', 'f', 'f' ]);
|
||||||
rt_int.insert_leaf(
|
rt_int.insert_leaf(
|
||||||
Context::parse(&ctx, "<PosInt 16 BigEndian>~<Seq <Digit 16>>~<List <Digit 16>>~<List Char>~<Vec Char>"),
|
Context::parse(&ctx, "<PosInt 16 BigEndian>~<Seq <Digit 16>>~<List <Digit 16>>~<List Char>"),
|
||||||
nested::repr_tree::ReprLeaf::from_vec_buffer( digits_be.clone() )
|
nested::repr_tree::ReprLeaf::from_view( b.get_port().to_list() )
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut digits_le = VecBuffer::with_data(vec!['3', '2', '1']);
|
let mut b_le = VecBuffer::with_data(vec!['3', '2', '1']);
|
||||||
rt_int.insert_leaf(
|
rt_int.insert_leaf(
|
||||||
Context::parse(&ctx, "<PosInt 16 LittleEndian>~<Seq <Digit 16>>~<List <Digit 16>>~<List Char>~<Vec Char>"),
|
Context::parse(&ctx, "<PosInt 16 LittleEndian>~<Seq <Digit 16>>~<List <Digit 16>>~<List Char>"),
|
||||||
nested::repr_tree::ReprLeaf::from_vec_buffer( digits_le.clone() )
|
nested::repr_tree::ReprLeaf::from_view( b_le.get_port().to_list() )
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut digits_le_editvec = VecBuffer::<Arc<RwLock<EditTree>>>::new();
|
ctx.read().unwrap().morphisms.apply_morphism(
|
||||||
rt_int.insert_leaf(
|
|
||||||
Context::parse(&ctx, "
|
|
||||||
<PosInt 16 LittleEndian>
|
|
||||||
~ <Seq <Digit 16>>
|
|
||||||
~ <List <Digit 16>
|
|
||||||
~ Char
|
|
||||||
~ EditTree>
|
|
||||||
~ <Vec EditTree>
|
|
||||||
"),
|
|
||||||
nested::repr_tree::ReprLeaf::from_vec_buffer( digits_le_editvec.clone() )
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut digits_be_editvec = VecBuffer::<Arc<RwLock<EditTree>>>::new();
|
|
||||||
rt_int.insert_leaf(
|
|
||||||
Context::parse(&ctx, "
|
|
||||||
<PosInt 16 BigEndian>
|
|
||||||
~ <Seq <Digit 16>>
|
|
||||||
~ <List <Digit 16>
|
|
||||||
~ Char
|
|
||||||
~ EditTree>
|
|
||||||
~ <Vec EditTree>
|
|
||||||
"),
|
|
||||||
nested::repr_tree::ReprLeaf::from_vec_buffer( digits_be_editvec.clone() )
|
|
||||||
);
|
|
||||||
|
|
||||||
/* initially copy values from Vec to EditTree...
|
|
||||||
*/
|
|
||||||
rebuild_projections(
|
|
||||||
ctx.clone(),
|
|
||||||
rt_int.clone(),
|
|
||||||
// master representation
|
|
||||||
vec![
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ <Vec Char>",
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char>"
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char>",
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char ~ EditTree>"
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ <List EditTree>",
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ <List EditTree> ~ <Vec EditTree>"
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ <List EditTree> ~ <Vec EditTree>",
|
|
||||||
"ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ EditTree"
|
|
||||||
),
|
|
||||||
].into_iter()
|
|
||||||
.map(|(s,d)| (Context::parse(&ctx, s), Context::parse(&ctx, d)))
|
|
||||||
.collect()
|
|
||||||
);
|
|
||||||
|
|
||||||
setup_le_master(&ctx, &rt_int);
|
|
||||||
|
|
||||||
let edittree_hex_le_list = ctx.read().unwrap()
|
|
||||||
.setup_edittree(
|
|
||||||
rt_int.descend(Context::parse(&ctx, "
|
rt_int.descend(Context::parse(&ctx, "
|
||||||
<PosInt 16 LittleEndian>
|
<PosInt 16 LittleEndian>
|
||||||
~ <Seq <Digit 16>>
|
~ <Seq <Digit 16>>
|
||||||
~ <List <Digit 16>>
|
~ <List <Digit 16>>
|
||||||
~ <List Char>
|
~ <List Char>
|
||||||
")).expect("descend"),
|
")).expect("descend"),
|
||||||
|
&Context::parse(&ctx, "<List Char>"),
|
||||||
|
&Context::parse(&ctx, "<List Char~EditTree>")
|
||||||
|
);
|
||||||
|
ctx.read().unwrap().morphisms.apply_morphism(
|
||||||
|
rt_int.descend(Context::parse(&ctx, "
|
||||||
|
<PosInt 16 LittleEndian>
|
||||||
|
~ <Seq <Digit 16> >
|
||||||
|
~ <List <Digit 16>~Char~EditTree >
|
||||||
|
")).expect("descend"),
|
||||||
|
&Context::parse(&ctx, "<List EditTree>"),
|
||||||
|
&Context::parse(&ctx, "<List EditTree>~<Vec EditTree>")
|
||||||
|
);
|
||||||
|
ctx.read().unwrap().morphisms.apply_morphism(
|
||||||
|
rt_int.descend(Context::parse(&ctx, "
|
||||||
|
<PosInt 16 LittleEndian>
|
||||||
|
~ <Seq <Digit 16>>
|
||||||
|
~ <List <Digit 16>~Char>
|
||||||
|
")).expect("descend"),
|
||||||
|
&Context::parse(&ctx, "<List Char>~<List EditTree>~<Vec EditTree>"),
|
||||||
|
&Context::parse(&ctx, "<List Char>~EditTree")
|
||||||
|
);
|
||||||
|
ctx.read().unwrap().morphisms.apply_morphism(
|
||||||
|
rt_int.descend(Context::parse(&ctx, "
|
||||||
|
<PosInt 16 LittleEndian>
|
||||||
|
~ <Seq <Digit 16>>
|
||||||
|
~ <List <Digit 16>~Char >
|
||||||
|
")).expect("descend"),
|
||||||
|
&Context::parse(&ctx, "<List Char>~EditTree"),
|
||||||
|
&Context::parse(&ctx, "<List Char>")
|
||||||
|
);
|
||||||
|
ctx.read().unwrap().morphisms.apply_morphism(
|
||||||
|
rt_int.clone(),
|
||||||
|
&Context::parse(&ctx, "
|
||||||
|
ℕ
|
||||||
|
~ <PosInt 16 LittleEndian>
|
||||||
|
~ <Seq <Digit 16>>
|
||||||
|
~ <List <Digit 16>>
|
||||||
|
~ <List Char>
|
||||||
|
"),
|
||||||
|
&Context::parse(&ctx, "
|
||||||
|
ℕ
|
||||||
|
~ <PosInt 16 BigEndian>
|
||||||
|
~ <Seq <Digit 16>>
|
||||||
|
~ <List <Digit 16>>
|
||||||
|
~ <List Char>
|
||||||
|
")
|
||||||
|
);
|
||||||
|
ctx.read().unwrap().morphisms.apply_morphism(
|
||||||
|
rt_int.clone(),
|
||||||
|
&Context::parse(&ctx, "
|
||||||
|
ℕ
|
||||||
|
~ <PosInt 16 BigEndian>
|
||||||
|
~ <Seq <Digit 16>>
|
||||||
|
~ <List <Digit 16>>
|
||||||
|
~ <List Char>
|
||||||
|
"),
|
||||||
|
&Context::parse(&ctx, "
|
||||||
|
ℕ
|
||||||
|
~ <PosInt 16 LittleEndian>
|
||||||
|
~ <Seq <Digit 16>>
|
||||||
|
~ <List <Digit 16>>
|
||||||
|
~ <List Char>
|
||||||
|
")
|
||||||
|
);
|
||||||
|
|
||||||
|
let edittree_hex_le_list = ctx.read().unwrap()
|
||||||
|
.setup_edittree(
|
||||||
|
rt_int.descend(Context::parse(&ctx,"
|
||||||
|
<PosInt 16 LittleEndian>
|
||||||
|
~ <Seq <Digit 16>>
|
||||||
|
~ <List <Digit 16>~Char >
|
||||||
|
")).expect("descend"),
|
||||||
SingletonBuffer::new(0).get_port()
|
SingletonBuffer::new(0).get_port()
|
||||||
).unwrap();
|
);
|
||||||
|
|
||||||
|
ctx.read().unwrap().morphisms.apply_morphism(
|
||||||
|
rt_int.descend(Context::parse(&ctx, "
|
||||||
|
<PosInt 16 BigEndian>~<Seq <Digit 16>>~<List <Digit 16>~Char>
|
||||||
|
")).expect("descend"),
|
||||||
|
&Context::parse(&ctx, "<List Char>"),
|
||||||
|
&Context::parse(&ctx, "<List Char~EditTree>")
|
||||||
|
);
|
||||||
|
ctx.read().unwrap().morphisms.apply_morphism(
|
||||||
|
rt_int.descend(Context::parse(&ctx, "
|
||||||
|
<PosInt 16 BigEndian>~<Seq <Digit 16>>~<List <Digit 16>~Char~EditTree>
|
||||||
|
")).expect("descend"),
|
||||||
|
&Context::parse(&ctx, "<List EditTree>"),
|
||||||
|
&Context::parse(&ctx, "<List EditTree>~<Vec EditTree>")
|
||||||
|
);
|
||||||
|
ctx.read().unwrap().morphisms.apply_morphism(
|
||||||
|
rt_int.descend(Context::parse(&ctx, "
|
||||||
|
<PosInt 16 BigEndian>~<Seq <Digit 16>>~<List <Digit 16>~Char>
|
||||||
|
")).expect("descend"),
|
||||||
|
&Context::parse(&ctx, "<List Char>~<List EditTree>~<Vec EditTree>"),
|
||||||
|
&Context::parse(&ctx, "<List Char>~EditTree")
|
||||||
|
);
|
||||||
|
ctx.read().unwrap().morphisms.apply_morphism(
|
||||||
|
rt_int.descend(Context::parse(&ctx, "
|
||||||
|
<PosInt 16 BigEndian>~<Seq <Digit 16>>~<List <Digit 16>~Char>
|
||||||
|
")).expect("descend"),
|
||||||
|
&Context::parse(&ctx, "<List Char>~EditTree"),
|
||||||
|
&Context::parse(&ctx, "<List Char>")
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Setup an Editor for the big-endian hexadecimal representation
|
||||||
|
* (this will add the representation `<List <Digit 16>>~EditTree` to the ReprTree)
|
||||||
|
*/
|
||||||
let edittree_hex_be_list = ctx.read().unwrap()
|
let edittree_hex_be_list = ctx.read().unwrap()
|
||||||
.setup_edittree(
|
.setup_edittree(
|
||||||
rt_int.descend(Context::parse(&ctx, "
|
rt_int.descend(Context::parse(&ctx, "
|
||||||
|
@ -305,9 +193,119 @@ async fn main() {
|
||||||
~ <Seq <Digit 16>>
|
~ <Seq <Digit 16>>
|
||||||
~ <List <Digit 16>>
|
~ <List <Digit 16>>
|
||||||
~ <List Char>
|
~ <List Char>
|
||||||
")).expect("descend"),
|
")).expect("cant descend reprtree"),
|
||||||
SingletonBuffer::new(0).get_port()
|
SingletonBuffer::new(0).get_port()
|
||||||
).unwrap();
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* map seq of chars to seq of u64 digits
|
||||||
|
* and add this projection to the ReprTree
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
||||||
|
let mut chars_view = rt_int.descend(Context::parse(&ctx, "
|
||||||
|
<PosInt 16 BigEndian>
|
||||||
|
~ <Seq <Digit 16>>
|
||||||
|
~ <List <Digit 16>~Char>
|
||||||
|
")).expect("cant descend")
|
||||||
|
.read().unwrap()
|
||||||
|
.get_port::<dyn ListView<char>>()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let mut digits_view = chars_view
|
||||||
|
.to_sequence()
|
||||||
|
.filter_map(
|
||||||
|
|digit_char|
|
||||||
|
|
||||||
|
/* TODO: call morphism for each item
|
||||||
|
*/
|
||||||
|
match digit_char.to_digit(16) {
|
||||||
|
Some(d) => Some(d as u64),
|
||||||
|
None => None
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
rt_int.insert_leaf(Context::parse(&ctx, "
|
||||||
|
<PosInt 16 BigEndian>
|
||||||
|
~ <Seq <Digit 16>
|
||||||
|
~ ℤ_2^64
|
||||||
|
~ machine.UInt64 >
|
||||||
|
"),
|
||||||
|
nested::repr_tree::ReprLeaf::from_view( digits_view.clone() )
|
||||||
|
);
|
||||||
|
//ΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛ
|
||||||
|
//
|
||||||
|
|
||||||
|
/* convert to little endian
|
||||||
|
*/
|
||||||
|
ctx.read().unwrap().morphisms.apply_morphism(
|
||||||
|
rt_int.clone(),
|
||||||
|
&Context::parse(&ctx, "
|
||||||
|
ℕ
|
||||||
|
~ <PosInt 16 BigEndian>
|
||||||
|
~ <Seq <Digit 16>
|
||||||
|
~ ℤ_2^64
|
||||||
|
~ machine.UInt64 >
|
||||||
|
"),
|
||||||
|
&Context::parse(&ctx, "
|
||||||
|
ℕ
|
||||||
|
~ <PosInt 16 LittleEndian>
|
||||||
|
~ <Seq <Digit 16>
|
||||||
|
~ ℤ_2^64
|
||||||
|
~ machine.UInt64 >
|
||||||
|
")
|
||||||
|
);
|
||||||
|
|
||||||
|
/* convert to decimal
|
||||||
|
*/
|
||||||
|
ctx.read().unwrap().morphisms.apply_morphism(
|
||||||
|
rt_int.clone(),
|
||||||
|
&Context::parse(&ctx, "ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16>~ℤ_2^64~machine.UInt64>"),
|
||||||
|
&Context::parse(&ctx, "ℕ ~ <PosInt 10 LittleEndian> ~ <Seq <Digit 10>~ℤ_2^64~machine.UInt64>")
|
||||||
|
);
|
||||||
|
|
||||||
|
/* convert back to big endian
|
||||||
|
*/
|
||||||
|
ctx.read().unwrap().morphisms.apply_morphism(
|
||||||
|
rt_int.clone(),
|
||||||
|
&Context::parse(&ctx, "ℕ ~ <PosInt 10 LittleEndian> ~ <Seq <Digit 10>~ℤ_2^64~machine.UInt64>"),
|
||||||
|
&Context::parse(&ctx, "ℕ ~ <PosInt 10 BigEndian> ~ <Seq <Digit 10>~ℤ_2^64~machine.UInt64>")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/* map seq of u64 digits to seq of chars
|
||||||
|
* and add this projection to the ReprTree
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
||||||
|
let dec_digits_view =
|
||||||
|
rt_int.descend(Context::parse(&ctx, "
|
||||||
|
< PosInt 10 BigEndian >
|
||||||
|
~ < Seq <Digit 10>
|
||||||
|
~ ℤ_2^64
|
||||||
|
~ machine.UInt64 >
|
||||||
|
")).expect("cant descend repr tree")
|
||||||
|
.read().unwrap()
|
||||||
|
.get_port::<dyn SequenceView<Item = u64>>().unwrap()
|
||||||
|
.map(|digit| TerminalAtom::from(char::from_digit(*digit as u32, 10)))
|
||||||
|
.to_grid_horizontal();
|
||||||
|
//ΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛ
|
||||||
|
//
|
||||||
|
//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
||||||
|
let hex_digits_view =
|
||||||
|
rt_int.descend(Context::parse(&ctx, "
|
||||||
|
< PosInt 16 BigEndian >
|
||||||
|
~ < Seq <Digit 16>
|
||||||
|
~ ℤ_2^64
|
||||||
|
~ machine.UInt64 >
|
||||||
|
")).expect("cant descend")
|
||||||
|
.read().unwrap()
|
||||||
|
.view_seq::< u64 >()
|
||||||
|
.map(|digit| TerminalAtom::from(char::from_digit(*digit as u32, 16)))
|
||||||
|
.to_grid_horizontal();
|
||||||
|
//ΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛΛ
|
||||||
|
//
|
||||||
|
|
||||||
/* list of both editors
|
/* list of both editors
|
||||||
*/
|
*/
|
||||||
|
@ -323,7 +321,7 @@ async fn main() {
|
||||||
edittree_hex_le_list.get().goto(TreeCursor::none());
|
edittree_hex_le_list.get().goto(TreeCursor::none());
|
||||||
edittree.goto(TreeCursor{
|
edittree.goto(TreeCursor{
|
||||||
leaf_mode: nested::editors::list::ListCursorMode::Insert,
|
leaf_mode: nested::editors::list::ListCursorMode::Insert,
|
||||||
tree_addr: vec![1,0]
|
tree_addr: vec![0,0]
|
||||||
});
|
});
|
||||||
let edittree = Arc::new(RwLock::new(edittree));
|
let edittree = Arc::new(RwLock::new(edittree));
|
||||||
|
|
||||||
|
@ -333,31 +331,7 @@ async fn main() {
|
||||||
/* event handler
|
/* event handler
|
||||||
*/
|
*/
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
let rt_int = rt_int.clone();
|
|
||||||
let last_idx = RwLock::new(1);
|
|
||||||
move |ev| {
|
move |ev| {
|
||||||
|
|
||||||
let cur = edittree.read().unwrap().get_cursor();
|
|
||||||
if cur.tree_addr.len() > 0 {
|
|
||||||
match cur.tree_addr[0] {
|
|
||||||
0 => {
|
|
||||||
let mut li = last_idx.write().unwrap();
|
|
||||||
if *li != 0 {
|
|
||||||
setup_be_master(&ctx, &rt_int);
|
|
||||||
*li = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1 => {
|
|
||||||
let mut li = last_idx.write().unwrap();
|
|
||||||
if *li != 1 {
|
|
||||||
setup_le_master(&ctx, &rt_int);
|
|
||||||
*li = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_=>{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
edittree.write().unwrap().send_cmd_obj(ev.to_repr_tree(&ctx));
|
edittree.write().unwrap().send_cmd_obj(ev.to_repr_tree(&ctx));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -392,18 +366,15 @@ async fn main() {
|
||||||
|
|
||||||
/* project the seq of u64 representations to a view
|
/* project the seq of u64 representations to a view
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
comp.push(nested_tty::make_label("dec: ").offset(Vector2::new(3,7)));
|
comp.push(nested_tty::make_label("dec: ").offset(Vector2::new(3,7)));
|
||||||
comp.push(dec_digits_view.offset(Vector2::new(8,7)).map_item(|_,a| {
|
comp.push(dec_digits_view.offset(Vector2::new(8,7)).map_item(|_,a| {
|
||||||
a.add_style_back(TerminalStyle::fg_color((30,90,200)))
|
a.add_style_back(TerminalStyle::fg_color((30,90,200)))
|
||||||
}));
|
}));
|
||||||
*/
|
|
||||||
/*
|
|
||||||
comp.push(nested_tty::make_label("hex: ").offset(Vector2::new(3,8)));
|
comp.push(nested_tty::make_label("hex: ").offset(Vector2::new(3,8)));
|
||||||
comp.push(hex_digits_view.offset(Vector2::new(8,8)).map_item(|_,a| {
|
comp.push(hex_digits_view.offset(Vector2::new(8,8)).map_item(|_,a| {
|
||||||
a.add_style_back(TerminalStyle::fg_color((200, 200, 30)))
|
a.add_style_back(TerminalStyle::fg_color((200, 200, 30)))
|
||||||
}));
|
}));
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write the changes in the view of `term_port` to the terminal
|
/* write the changes in the view of `term_port` to the terminal
|
||||||
|
|
|
@ -32,17 +32,16 @@ pub fn init_ctx( ctx: Arc<RwLock<Context>> ) {
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
move |rt, σ| {
|
move |rt, σ| {
|
||||||
{
|
{
|
||||||
let mut b = rt.write().unwrap().singleton_buffer::<char>();
|
let mut rt = rt.write().unwrap();
|
||||||
if let Some(buf) = b {
|
if let Some(buf) = rt.singleton_buffer::<char>() {
|
||||||
// buffer already exists
|
// buffer already exists
|
||||||
} else {
|
} else {
|
||||||
// create char buffer
|
// create char buffer
|
||||||
rt.write().unwrap().insert_leaf(
|
rt.insert_leaf(
|
||||||
vec![].into_iter(),
|
vec![].into_iter(),
|
||||||
ReprLeaf::from_singleton_buffer(
|
ReprLeaf::from_singleton_buffer(
|
||||||
SingletonBuffer::new('\0')
|
SingletonBuffer::new('\0')
|
||||||
)
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,9 +53,12 @@ pub fn init_ctx( ctx: Arc<RwLock<Context>> ) {
|
||||||
SingletonBuffer::<usize>::new(0).get_port()
|
SingletonBuffer::<usize>::new(0).get_port()
|
||||||
);
|
);
|
||||||
|
|
||||||
rt.insert_leaf(
|
rt.write().unwrap()
|
||||||
|
.insert_branch(
|
||||||
|
ReprTree::from_singleton_buffer(
|
||||||
Context::parse(&ctx, "EditTree"),
|
Context::parse(&ctx, "EditTree"),
|
||||||
ReprLeaf::from_singleton_buffer(SingletonBuffer::new(edittree))
|
SingletonBuffer::new(edittree)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,6 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
|
||||||
ctx.write().unwrap().add_varname("SrcRadix");
|
ctx.write().unwrap().add_varname("SrcRadix");
|
||||||
ctx.write().unwrap().add_varname("DstRadix");
|
ctx.write().unwrap().add_varname("DstRadix");
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MACHINE INT, SEQ
|
|
||||||
*/
|
|
||||||
let morphism_type =
|
let morphism_type =
|
||||||
MorphismType {
|
MorphismType {
|
||||||
src_type: Context::parse(&ctx, "
|
src_type: Context::parse(&ctx, "
|
||||||
|
@ -53,22 +49,21 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
|
||||||
.apply_substitution(&|k|σ.get(k).cloned())
|
.apply_substitution(&|k|σ.get(k).cloned())
|
||||||
.clone()
|
.clone()
|
||||||
).expect("cant descend")
|
).expect("cant descend")
|
||||||
|
.read().unwrap()
|
||||||
.view_seq::< u64 >();
|
.view_seq::< u64 >();
|
||||||
|
|
||||||
src_rt.attach_leaf_to(Context::parse(&ctx, "
|
src_rt.insert_leaf(Context::parse(&ctx, "
|
||||||
<PosInt Radix LittleEndian>
|
<PosInt Radix LittleEndian>
|
||||||
~ <Seq <Digit Radix>
|
~ <Seq <Digit Radix>
|
||||||
~ ℤ_2^64
|
~ ℤ_2^64
|
||||||
~ machine.UInt64 >
|
~ machine.UInt64 >
|
||||||
").apply_substitution(&|k|σ.get(k).cloned()).clone(),
|
").apply_substitution(&|k|σ.get(k).cloned()).clone(),
|
||||||
src_digits.reverse()
|
ReprLeaf::from_view( src_digits.reverse() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
/* MACHINE INT, LIST
|
|
||||||
*/
|
|
||||||
let morphism_type = MorphismType {
|
let morphism_type = MorphismType {
|
||||||
src_type: Context::parse(&ctx, "
|
src_type: Context::parse(&ctx, "
|
||||||
ℕ
|
ℕ
|
||||||
|
@ -100,15 +95,16 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
|
||||||
")
|
")
|
||||||
.apply_substitution(&|k|σ.get(k).cloned()).clone()
|
.apply_substitution(&|k|σ.get(k).cloned()).clone()
|
||||||
).expect("cant descend")
|
).expect("cant descend")
|
||||||
|
.read().unwrap()
|
||||||
.get_port::< dyn ListView<u64> >().unwrap();
|
.get_port::< dyn ListView<u64> >().unwrap();
|
||||||
|
|
||||||
src_rt.attach_leaf_to(
|
src_rt.insert_leaf(
|
||||||
Context::parse(&ctx, "
|
Context::parse(&ctx, "
|
||||||
<PosInt Radix LittleEndian>
|
<PosInt Radix LittleEndian>
|
||||||
~ <Seq <Digit Radix>>
|
~ <Seq <Digit Radix>>
|
||||||
~ <List <Digit Radix> ~ ℤ_2^64 ~ machine.UInt64>
|
~ <List <Digit Radix> ~ ℤ_2^64 ~ machine.UInt64>
|
||||||
").apply_substitution(&|k| σ.get(k).cloned()).clone(),
|
").apply_substitution(&|k| σ.get(k).cloned()).clone(),
|
||||||
src_digits.reverse()
|
ReprLeaf::from_view( src_digits.reverse() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,23 +132,22 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
|
||||||
{
|
{
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
move |src_rt, σ| {
|
move |src_rt, σ| {
|
||||||
let radix = σ.get( &laddertypes::TypeID::Var(ctx.read().unwrap().get_var_typeid("Radix").unwrap()) );
|
|
||||||
let src_digits = src_rt.descend(Context::parse(&ctx, "
|
let src_digits = src_rt.descend(Context::parse(&ctx, "
|
||||||
<PosInt Radix BigEndian>
|
<PosInt Radix BigEndian>
|
||||||
~ <Seq <Digit Radix>>
|
~ <Seq <Digit Radix>>
|
||||||
~ <List <Digit Radix>~Char >
|
~ <List <Digit Radix>~Char >
|
||||||
").apply_substitution(&|k|σ.get(k).cloned()).clone()
|
").apply_substitution(&|k|σ.get(k).cloned()).clone()
|
||||||
).expect("cant descend")
|
).expect("cant descend")
|
||||||
|
.read().unwrap()
|
||||||
.get_port::< dyn ListView<char> >().unwrap();
|
.get_port::< dyn ListView<char> >().unwrap();
|
||||||
|
|
||||||
let rev_port = src_digits.reverse();
|
src_rt.insert_leaf(
|
||||||
src_rt.attach_leaf_to(
|
|
||||||
Context::parse(&ctx, "
|
Context::parse(&ctx, "
|
||||||
< PosInt Radix LittleEndian >
|
< PosInt Radix LittleEndian >
|
||||||
~ < Seq <Digit Radix> >
|
~ < Seq <Digit Radix> >
|
||||||
~ < List <Digit Radix>~Char >
|
~ < List <Digit Radix>~Char >
|
||||||
").apply_substitution(&|k| σ.get(k).cloned()).clone(),
|
").apply_substitution(&|k| σ.get(k).cloned()).clone(),
|
||||||
rev_port
|
ReprLeaf::from_view( src_digits.reverse() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,13 +176,20 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
|
||||||
")
|
")
|
||||||
.apply_substitution(&|k|σ.get(k).cloned()).clone()
|
.apply_substitution(&|k|σ.get(k).cloned()).clone()
|
||||||
).expect("cant descend")
|
).expect("cant descend")
|
||||||
|
.read().unwrap()
|
||||||
.view_seq::< u64 >();
|
.view_seq::< u64 >();
|
||||||
|
|
||||||
src_rt.attach_leaf_to(Context::parse(&ctx, "
|
src_rt.write().unwrap().insert_leaf(
|
||||||
<PosInt Radix BigEndian>
|
vec![
|
||||||
~ <Seq <Digit Radix> ~ ℤ_2^64 ~ machine.UInt64>
|
Context::parse(&ctx, "<PosInt Radix BigEndian>")
|
||||||
").apply_substitution(&|k|σ.get(k).cloned()).clone(),
|
.apply_substitution(&|k|σ.get(k).cloned()).clone(),
|
||||||
src_digits.reverse()
|
Context::parse(&ctx, "<Seq <Digit Radix>>")
|
||||||
|
.apply_substitution(&|k|σ.get(k).cloned()).clone(),
|
||||||
|
Context::parse(&ctx, "<Seq ℤ_2^64>"),
|
||||||
|
Context::parse(&ctx, "<Seq machine.UInt64>")
|
||||||
|
].into_iter(),
|
||||||
|
|
||||||
|
ReprLeaf::from_view( src_digits.reverse() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,29 +219,32 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
move |src_rt, σ|
|
move |src_rt, σ|
|
||||||
{
|
{
|
||||||
let src_digits = src_rt.descend(
|
let src_digits = ReprTree::descend(
|
||||||
|
&src_rt,
|
||||||
Context::parse(&ctx, "
|
Context::parse(&ctx, "
|
||||||
<PosInt Radix LittleEndian>
|
<PosInt Radix LittleEndian>
|
||||||
~ <Seq <Digit Radix>>
|
~ <Seq <Digit Radix>>
|
||||||
~ <List <Digit Radix>~ℤ_2^64~machine.UInt64 >
|
~ <List <Digit Radix>~ℤ_2^64~machine.UInt64 >
|
||||||
").apply_substitution(&|k|σ.get(k).cloned()).clone()
|
")
|
||||||
)
|
.apply_substitution(&|k|σ.get(k).cloned()).clone()
|
||||||
.expect("cant descend")
|
).expect("cant descend")
|
||||||
.view_list::<u64>();
|
.read().unwrap()
|
||||||
|
.get_port::< dyn ListView<u64> >().unwrap();
|
||||||
|
|
||||||
src_rt.attach_leaf_to(
|
src_rt.insert_leaf(
|
||||||
Context::parse(&ctx, "
|
Context::parse(&ctx, "
|
||||||
<PosInt Radix BigEndian>
|
<PosInt Radix BigEndian>
|
||||||
~ <Seq <Digit Radix>>
|
~ <Seq <Digit Radix>>
|
||||||
~ <List <Digit Radix>~ℤ_2^64~machine.UInt64 >
|
~ <List <Digit Radix>~ℤ_2^64~machine.UInt64 >
|
||||||
").apply_substitution(&|k|σ.get(k).cloned()).clone(),
|
"),
|
||||||
src_digits.reverse()
|
ReprLeaf::from_view( src_digits.reverse() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let mt = MorphismType {
|
let mt = MorphismType {
|
||||||
src_type: Context::parse(&ctx, "
|
src_type: Context::parse(&ctx, "
|
||||||
ℕ
|
ℕ
|
||||||
|
@ -268,15 +273,16 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
|
||||||
~ <List <Digit Radix>~Char >
|
~ <List <Digit Radix>~Char >
|
||||||
").apply_substitution(&|k|σ.get(k).cloned()).clone()
|
").apply_substitution(&|k|σ.get(k).cloned()).clone()
|
||||||
).expect("cant descend")
|
).expect("cant descend")
|
||||||
.view_list::<char>();
|
.read().unwrap()
|
||||||
|
.get_port::< dyn ListView<char> >().unwrap();
|
||||||
|
|
||||||
src_rt.attach_leaf_to(
|
src_rt.insert_leaf(
|
||||||
Context::parse(&ctx, "
|
Context::parse(&ctx, "
|
||||||
< PosInt Radix BigEndian >
|
< PosInt Radix BigEndian >
|
||||||
~ < Seq <Digit Radix> >
|
~ < Seq <Digit Radix> >
|
||||||
~ < List <Digit Radix>~Char >
|
~ < List <Digit Radix>~Char >
|
||||||
").apply_substitution(&|k| σ.get(k).cloned()).clone(),
|
").apply_substitution(&|k| σ.get(k).cloned()).clone(),
|
||||||
src_digits.reverse()
|
ReprLeaf::from_view( src_digits.reverse() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,23 +327,29 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
|
||||||
_ => 0
|
_ => 0
|
||||||
};
|
};
|
||||||
|
|
||||||
let src_digits_rt = src_rt.descend(Context::parse(&ctx, "
|
let src_digits_rt = ReprTree::descend(
|
||||||
|
src_rt,
|
||||||
|
Context::parse(&ctx, "
|
||||||
<PosInt SrcRadix LittleEndian>
|
<PosInt SrcRadix LittleEndian>
|
||||||
~ <Seq <Digit SrcRadix> ~ ℤ_2^64 ~ machine.UInt64 >
|
~ <Seq <Digit SrcRadix> ~ ℤ_2^64 ~ machine.UInt64 >"
|
||||||
").apply_substitution(&|k|σ.get(k).cloned()).clone()
|
).apply_substitution(&|k|σ.get(k).cloned()).clone()
|
||||||
).expect("cant descend repr tree");
|
).expect("cant descend repr tree");
|
||||||
|
|
||||||
let dst_digits_port =
|
let dst_digits_port =
|
||||||
src_digits_rt.view_seq::<u64>()
|
src_digits_rt.read().unwrap()
|
||||||
|
.view_seq::<u64>()
|
||||||
.to_positional_uint( src_radix )
|
.to_positional_uint( src_radix )
|
||||||
.transform_radix( dst_radix );
|
.transform_radix( dst_radix );
|
||||||
|
|
||||||
src_rt.attach_leaf_to(
|
src_rt.write().unwrap()
|
||||||
Context::parse(&ctx, "
|
.insert_leaf(
|
||||||
<PosInt DstRadix LittleEndian>
|
vec![
|
||||||
~ <Seq <Digit DstRadix> ~ ℤ_2^64 ~ machine.UInt64>
|
Context::parse(&ctx, "<PosInt DstRadix LittleEndian>").apply_substitution(&|k|σ.get(k).cloned()).clone(),
|
||||||
").apply_substitution(&|k|σ.get(k).cloned()).clone(),
|
Context::parse(&ctx, "<Seq <Digit DstRadix>>").apply_substitution(&|k|σ.get(k).cloned()).clone(),
|
||||||
dst_digits_port
|
Context::parse(&ctx, "<Seq ℤ_2^64>"),
|
||||||
|
Context::parse(&ctx, "<Seq machine.UInt64>"),
|
||||||
|
].into_iter(),
|
||||||
|
ReprLeaf::from_view(dst_digits_port)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use {
|
use {
|
||||||
r3vi::{
|
r3vi::{
|
||||||
view::{
|
view::{
|
||||||
ViewPort, port::UpdateTask,
|
ViewPort,
|
||||||
OuterViewPort, Observer,
|
OuterViewPort, Observer,
|
||||||
singleton::*,
|
singleton::*,
|
||||||
list::*
|
list::*
|
||||||
|
@ -32,34 +32,33 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
|
||||||
ctx.write().unwrap().morphisms.add_morphism(mt, {
|
ctx.write().unwrap().morphisms.add_morphism(mt, {
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
move |src_rt, σ| {
|
move |src_rt, σ| {
|
||||||
let list_port = src_rt.descend(Context::parse(&ctx, "<List Char>")).expect("descend").get_port::<dyn ListView<char>>().clone();
|
let list_port = src_rt.read().unwrap().get_port::<dyn ListView<char>>().clone();
|
||||||
if let Some(list_port) = list_port {
|
if let Some(list_port) = list_port {
|
||||||
|
|
||||||
// for each char, create EditTree
|
|
||||||
let edit_tree_list =
|
let edit_tree_list =
|
||||||
list_port
|
list_port
|
||||||
|
// for each char, create and EditTree
|
||||||
.map({
|
.map({
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
move |c| {
|
move |c| {
|
||||||
let item_rt = ReprTree::from_char(&ctx, *c);
|
let item_rt = ReprTree::from_char(&ctx, *c);
|
||||||
|
|
||||||
ctx.read().unwrap().setup_edittree(
|
ctx.read().unwrap().setup_edittree(
|
||||||
item_rt.clone(),
|
item_rt.clone(),
|
||||||
SingletonBuffer::new(0).get_port()
|
SingletonBuffer::new(0).get_port()
|
||||||
);
|
);
|
||||||
|
|
||||||
let et = item_rt
|
let et = item_rt
|
||||||
.descend(Context::parse(&ctx, "Char ~ EditTree")).expect("cant descend repr tree")
|
.descend(Context::parse(&ctx, "EditTree")).unwrap()
|
||||||
.get_port::< dyn SingletonView<Item = EditTree> >().expect("cant get view port (EditTree)")
|
.read().unwrap()
|
||||||
|
.get_port::< dyn SingletonView<Item = EditTree> >()
|
||||||
|
.expect("cant get view port (EditTree)")
|
||||||
.get_view().unwrap()
|
.get_view().unwrap()
|
||||||
.get();
|
.get();
|
||||||
Arc::new(RwLock::new(et))
|
Arc::new(RwLock::new(et))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
src_rt.attach_leaf_to(
|
src_rt.write().unwrap().insert_leaf(
|
||||||
Context::parse(&ctx, "<List Char>~<List EditTree>"),
|
Context::parse(&ctx, "<List EditTree>").get_lnf_vec().into_iter(),
|
||||||
edit_tree_list
|
ReprLeaf::from_view( edit_tree_list )
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
eprintln!("morphism missing view port");
|
eprintln!("morphism missing view port");
|
||||||
|
@ -71,29 +70,44 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
|
||||||
src_type: Context::parse(&ctx, "<List Item>~<List EditTree>~<Vec EditTree>"),
|
src_type: Context::parse(&ctx, "<List Item>~<List EditTree>~<Vec EditTree>"),
|
||||||
dst_type: Context::parse(&ctx, "<List Item>~EditTree")
|
dst_type: Context::parse(&ctx, "<List Item>~EditTree")
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.write().unwrap().morphisms.add_morphism(mt, {
|
ctx.write().unwrap().morphisms.add_morphism(mt, {
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
move |src_rt, σ| {
|
move |src_rt, σ| {
|
||||||
let item_id = laddertypes::TypeID::Var( ctx.read().unwrap().get_var_typeid("Item").unwrap() );
|
let item_id = laddertypes::TypeID::Var( ctx.read().unwrap().get_var_typeid("Item").unwrap() );
|
||||||
if let Some( item_type ) = σ.get( &item_id ) {
|
if let Some( item_type ) = σ.get( &item_id ) {
|
||||||
|
/*
|
||||||
|
let mut item_vec_buffer = VecBuffer::new();
|
||||||
|
|
||||||
|
eprintln!("try attach to data port");
|
||||||
|
if let Some( list_port ) =
|
||||||
|
src_rt
|
||||||
|
.descend(Context::parse(&ctx, "<List EditTree>")).expect("")
|
||||||
|
.read().unwrap()
|
||||||
|
.get_port::< dyn ListView< Arc<RwLock<EditTree>> > >()
|
||||||
|
{
|
||||||
|
eprintln!("get list<edittree> port");
|
||||||
|
item_vec_buffer.attach_to( list_port );
|
||||||
|
}*/
|
||||||
|
|
||||||
let mut item_vec_rt = src_rt
|
let mut item_vec_rt = src_rt
|
||||||
.descend(
|
.descend(Context::parse(&ctx, "<List EditTree>~<Vec EditTree>"))
|
||||||
Context::parse(&ctx, "<List Item~EditTree>~<Vec EditTree>")
|
|
||||||
.apply_substitution(&|id| σ.get(id).cloned()).clone()
|
|
||||||
)
|
|
||||||
.expect("cant descend src repr");
|
.expect("cant descend src repr");
|
||||||
|
|
||||||
let item_vec_buffer = item_vec_rt.vec_buffer::< Arc<RwLock<EditTree>> >();
|
let item_vec_buffer = item_vec_rt
|
||||||
|
.write().unwrap()
|
||||||
|
.vec_buffer::< Arc<RwLock<EditTree>> >().expect("cant get vec buffer");
|
||||||
|
|
||||||
|
// eprintln!("create ListEditor");
|
||||||
let mut list_editor = ListEditor::with_data(ctx.clone(), item_type.clone(), item_vec_buffer);
|
let mut list_editor = ListEditor::with_data(ctx.clone(), item_type.clone(), item_vec_buffer);
|
||||||
|
|
||||||
let edittree_list = list_editor.into_node(
|
let edittree_list = list_editor.into_node(
|
||||||
SingletonBuffer::<usize>::new(0).get_port()
|
SingletonBuffer::<usize>::new(0).get_port()
|
||||||
);
|
);
|
||||||
src_rt.insert_leaf(
|
|
||||||
Context::parse(&ctx, "<List Item> ~ EditTree")
|
// eprintln!("make edittree");
|
||||||
.apply_substitution(&|id| σ.get(id).cloned()).clone(),
|
src_rt.write().unwrap().insert_branch(
|
||||||
ReprLeaf::from_singleton_buffer(
|
ReprTree::from_singleton_buffer(
|
||||||
|
Context::parse(&ctx, "EditTree"),
|
||||||
SingletonBuffer::new(edittree_list)
|
SingletonBuffer::new(edittree_list)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -114,31 +128,64 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
|
||||||
move |src_rt, σ| {
|
move |src_rt, σ| {
|
||||||
let edittree =
|
let edittree =
|
||||||
src_rt
|
src_rt
|
||||||
.descend(Context::parse(&ctx, "<List Char>~EditTree")).unwrap()
|
.descend(Context::parse(&ctx, "EditTree")).unwrap()
|
||||||
.singleton_buffer::<EditTree>();
|
.singleton_buffer::<EditTree>();
|
||||||
|
|
||||||
let list_edit = edittree.get().get_edit::< ListEditor >().unwrap();
|
let list_edit = edittree.get().get_edit::< ListEditor >().unwrap();
|
||||||
let edittree_items = list_edit.read().unwrap().data.get_port().to_list();
|
let edittree_items = list_edit.read().unwrap().data.get_port().to_list();
|
||||||
|
src_rt.write().unwrap().insert_leaf(
|
||||||
src_rt.insert_leaf(
|
vec![].into_iter(),
|
||||||
Context::parse(&ctx, "<List Char>"),
|
|
||||||
ReprLeaf::from_view(
|
ReprLeaf::from_view(
|
||||||
edittree_items
|
edittree_items
|
||||||
.map(|edittree_char|
|
.map(
|
||||||
|
|edittree_char|
|
||||||
edittree_char
|
edittree_char
|
||||||
.read().unwrap()
|
.read().unwrap()
|
||||||
.get_edit::<CharEditor>().unwrap()
|
.get_edit::<CharEditor>().unwrap()
|
||||||
.read().unwrap()
|
.read().unwrap()
|
||||||
.get()
|
.get()
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
let mt = crate::repr_tree::MorphismType {
|
||||||
|
src_type: Context::parse(&ctx, "<List <Digit Radix>>~EditTree"),
|
||||||
|
dst_type: Context::parse(&ctx, "<List <Digit Radix>~Char>")
|
||||||
|
};
|
||||||
|
ctx.write().unwrap().morphisms.add_morphism(
|
||||||
|
mt,
|
||||||
|
{
|
||||||
|
let ctx = ctx.clone();
|
||||||
|
move |src_rt, σ| {
|
||||||
|
let edittree =
|
||||||
|
src_rt
|
||||||
|
.descend(Context::parse(&ctx, "EditTree")).unwrap()
|
||||||
|
.singleton_buffer::<EditTree>();
|
||||||
|
|
||||||
|
let list_edit = edittree.get().get_edit::< ListEditor >().unwrap();
|
||||||
|
let edittree_items = list_edit.read().unwrap().data.get_port().to_list();
|
||||||
|
src_rt.write().unwrap().insert_leaf(
|
||||||
|
vec![ Context::parse(&ctx, "<List Char>") ].into_iter(),
|
||||||
|
ReprLeaf::from_view(
|
||||||
|
edittree_items
|
||||||
|
.map(
|
||||||
|
|edittree_char|
|
||||||
|
edittree_char
|
||||||
|
.read().unwrap()
|
||||||
|
.get_edit::<crate::editors::digit::editor::DigitEditor>().unwrap()
|
||||||
|
.read().unwrap()
|
||||||
|
.get_char()
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/* todo : unify the following two morphims with generic item parameter ?
|
|
||||||
*/
|
|
||||||
let mt = crate::repr_tree::MorphismType {
|
let mt = crate::repr_tree::MorphismType {
|
||||||
src_type: Context::parse(&ctx, "<List Char>"),
|
src_type: Context::parse(&ctx, "<List Char>"),
|
||||||
dst_type: Context::parse(&ctx, "<List Char>~<Vec Char>")
|
dst_type: Context::parse(&ctx, "<List Char>~<Vec Char>")
|
||||||
|
@ -148,30 +195,17 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
|
||||||
{
|
{
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
move |src_rt, σ| {
|
move |src_rt, σ| {
|
||||||
src_rt
|
let buf = VecBuffer::<char>::new();
|
||||||
.attach_leaf_to(
|
let mut leaf = ReprLeaf::from_vec_buffer(buf);
|
||||||
Context::parse(&ctx, "<List Char>~<Vec Char>"),
|
leaf.attach_to(
|
||||||
src_rt
|
src_rt.read().unwrap()
|
||||||
.descend(Context::parse(&ctx, "<List Char>"))
|
.get_port::<dyn ListView<char>>()
|
||||||
.expect("descend")
|
.unwrap()
|
||||||
.view_list::<char>()
|
|
||||||
);
|
);
|
||||||
}
|
src_rt.write().unwrap().insert_leaf(
|
||||||
}
|
vec![ Context::parse(&ctx, "<Vec Char>") ].into_iter(),
|
||||||
|
leaf
|
||||||
);
|
);
|
||||||
|
|
||||||
let mt = crate::repr_tree::MorphismType {
|
|
||||||
src_type: Context::parse(&ctx, "<List Char>~<Vec Char>"),
|
|
||||||
dst_type: Context::parse(&ctx, "<List Char>")
|
|
||||||
};
|
|
||||||
ctx.write().unwrap().morphisms.add_morphism(
|
|
||||||
mt,
|
|
||||||
{
|
|
||||||
let ctx = ctx.clone();
|
|
||||||
move |src_rt, σ| {
|
|
||||||
let src_port = src_rt.descend(Context::parse(&ctx, "<List Char>~<Vec Char>")).expect("descend")
|
|
||||||
.get_port::<RwLock<Vec<char>>>().unwrap();
|
|
||||||
src_rt.attach_leaf_to( Context::parse(&ctx, "<List Char>"), src_port.to_list() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -185,14 +219,16 @@ pub fn init_ctx(ctx: Arc<RwLock<Context>>) {
|
||||||
{
|
{
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
move |src_rt, σ| {
|
move |src_rt, σ| {
|
||||||
let p =
|
let buf = VecBuffer::<Arc<RwLock<EditTree>>>::new();
|
||||||
src_rt
|
let mut leaf = ReprLeaf::from_vec_buffer(buf);
|
||||||
.descend(Context::parse(&ctx, "<List EditTree>")).expect("descend")
|
leaf.attach_to(
|
||||||
.get_port::<dyn ListView< Arc<RwLock<EditTree>> >>().unwrap();
|
src_rt.read().unwrap()
|
||||||
|
.get_port::<dyn ListView< Arc<RwLock<EditTree>> >>()
|
||||||
src_rt.attach_leaf_to(
|
.unwrap()
|
||||||
Context::parse(&ctx, "<List EditTree> ~ <Vec EditTree>"),
|
);
|
||||||
p
|
src_rt.write().unwrap().insert_leaf(
|
||||||
|
vec![ Context::parse(&ctx, "<Vec EditTree>") ].into_iter(),
|
||||||
|
leaf
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,14 +319,12 @@ impl ListEditor {
|
||||||
let mut b = item.ctrl.spillbuf.write().unwrap();
|
let mut b = item.ctrl.spillbuf.write().unwrap();
|
||||||
|
|
||||||
let rt = ReprTree::new_arc(self.typ.clone());
|
let rt = ReprTree::new_arc(self.typ.clone());
|
||||||
let mut et = self.ctx.read().unwrap()
|
let edittree = self.ctx.read().unwrap()
|
||||||
.setup_edittree(
|
.setup_edittree(
|
||||||
rt,
|
rt,
|
||||||
self.depth.map(|d| d+1)
|
self.depth.map(|d| d+1)
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(edittree) = et.as_mut(){
|
|
||||||
|
|
||||||
let mut tail_node = edittree.get_mut();
|
let mut tail_node = edittree.get_mut();
|
||||||
tail_node.goto(TreeCursor::home());
|
tail_node.goto(TreeCursor::home());
|
||||||
|
|
||||||
|
@ -356,8 +354,6 @@ impl ListEditor {
|
||||||
edittree.value.clone()
|
edittree.value.clone()
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
self.up();
|
self.up();
|
||||||
self.listlist_split();
|
self.listlist_split();
|
||||||
|
|
|
@ -179,7 +179,7 @@ impl Context {
|
||||||
&self,
|
&self,
|
||||||
rt: Arc<RwLock<ReprTree>>,
|
rt: Arc<RwLock<ReprTree>>,
|
||||||
depth: OuterViewPort<dyn SingletonView<Item = usize>>
|
depth: OuterViewPort<dyn SingletonView<Item = usize>>
|
||||||
) -> Option<SingletonBuffer<EditTree>> {
|
) -> SingletonBuffer<EditTree> {
|
||||||
let ladder = TypeTerm::Ladder(vec![
|
let ladder = TypeTerm::Ladder(vec![
|
||||||
rt.read().unwrap().get_type().clone(),
|
rt.read().unwrap().get_type().clone(),
|
||||||
self.type_term_from_str("EditTree").expect("")
|
self.type_term_from_str("EditTree").expect("")
|
||||||
|
@ -194,19 +194,14 @@ impl Context {
|
||||||
if let Some(new_edittree) =
|
if let Some(new_edittree) =
|
||||||
rt.descend(self.type_term_from_str("EditTree").unwrap())
|
rt.descend(self.type_term_from_str("EditTree").unwrap())
|
||||||
{
|
{
|
||||||
let typ = rt.read().unwrap().get_type().clone();
|
|
||||||
let buf = new_edittree.singleton_buffer::<EditTree>();
|
let buf = new_edittree.singleton_buffer::<EditTree>();
|
||||||
(*self.edittree_hook)(
|
(*self.edittree_hook)(
|
||||||
&mut *buf.get_mut(),
|
&mut *buf.get_mut(),
|
||||||
typ
|
rt.read().unwrap().get_type().clone()
|
||||||
);
|
);
|
||||||
Some(buf)
|
buf
|
||||||
} else {
|
} else {
|
||||||
eprintln!("cant find edit tree repr {} ~Ψ~ {}",
|
unreachable!();
|
||||||
self.type_term_to_str(rt.read().unwrap().get_halo_type()),
|
|
||||||
self.type_term_to_str(rt.read().unwrap().get_type())
|
|
||||||
);
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ use {
|
||||||
ViewPort, OuterViewPort,
|
ViewPort, OuterViewPort,
|
||||||
AnyViewPort, AnyInnerViewPort, AnyOuterViewPort,
|
AnyViewPort, AnyInnerViewPort, AnyOuterViewPort,
|
||||||
port::UpdateTask,
|
port::UpdateTask,
|
||||||
View, Observer,
|
View,
|
||||||
singleton::*,
|
singleton::*,
|
||||||
sequence::*,
|
sequence::*,
|
||||||
list::*
|
list::*
|
||||||
|
@ -40,7 +40,6 @@ pub struct ReprLeaf {
|
||||||
|
|
||||||
/// keepalive for the observer that updates the buffer from in_port
|
/// keepalive for the observer that updates the buffer from in_port
|
||||||
keepalive: Option<Arc<dyn Any + Send + Sync>>,
|
keepalive: Option<Arc<dyn Any + Send + Sync>>,
|
||||||
in_keepalive: Option<Arc<dyn Any + Send + Sync>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -73,73 +72,26 @@ impl ReprLeaf {
|
||||||
V::Msg: Clone
|
V::Msg: Clone
|
||||||
{
|
{
|
||||||
let mut in_port = ViewPort::<V>::new();
|
let mut in_port = ViewPort::<V>::new();
|
||||||
let in_keepalive = in_port.attach_to(src_port);
|
in_port.attach_to(src_port);
|
||||||
|
|
||||||
let mut out_port = ViewPort::<V>::new();
|
let mut buf_port = ViewPort::<V>::new();
|
||||||
let out_keepalive = out_port.attach_to(in_port.outer());
|
buf_port.attach_to(in_port.outer());
|
||||||
|
|
||||||
ReprLeaf {
|
ReprLeaf {
|
||||||
keepalive: Some(out_keepalive),
|
keepalive: None,
|
||||||
in_keepalive: Some(in_keepalive),
|
|
||||||
in_port: in_port.inner().into(),
|
in_port: in_port.inner().into(),
|
||||||
out_port: out_port.into(),
|
out_port: buf_port.into(),
|
||||||
data: None,
|
data: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn detach<V>(&mut self)
|
|
||||||
where V: View + ?Sized + 'static,
|
|
||||||
V::Msg: Clone
|
|
||||||
{
|
|
||||||
self.keepalive = None;
|
|
||||||
self.in_keepalive = None;
|
|
||||||
|
|
||||||
let ip = self.in_port.clone()
|
|
||||||
.downcast::<V>().ok()
|
|
||||||
.unwrap();
|
|
||||||
ip.0.detach();
|
|
||||||
|
|
||||||
if self.data.is_none() {
|
|
||||||
let mut op = self.out_port.clone()
|
|
||||||
.downcast::<V>().ok()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
op.detach();
|
|
||||||
self.keepalive = Some(op.attach_to(ip.0.outer()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn detach_vec<Item>(&mut self)
|
|
||||||
where Item: Clone + Send + Sync + 'static
|
|
||||||
{
|
|
||||||
self.keepalive = None;
|
|
||||||
self.in_keepalive = None;
|
|
||||||
|
|
||||||
let ip = self.in_port.clone()
|
|
||||||
.downcast::<dyn ListView<Item>>().ok()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
ip.0.detach();
|
|
||||||
|
|
||||||
if let Some(data) = self.data.as_mut() {
|
|
||||||
let mut op = self.out_port.clone()
|
|
||||||
.downcast::<RwLock<Vec<Item>>>().ok()
|
|
||||||
.unwrap();
|
|
||||||
op.detach();
|
|
||||||
|
|
||||||
let data = data.clone().downcast::< RwLock<Vec<Item>> >().ok().unwrap();
|
|
||||||
let buffer = VecBuffer::with_data_arc_port(data, op.inner());
|
|
||||||
self.keepalive = Some(buffer.attach_to(ip.0.outer()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn attach_to<V>(&mut self, src_port: OuterViewPort<V>)
|
pub fn attach_to<V>(&mut self, src_port: OuterViewPort<V>)
|
||||||
where V: View + ?Sized + 'static,
|
where V: View + ?Sized + 'static,
|
||||||
V::Msg: Clone
|
V::Msg: Clone
|
||||||
{
|
{
|
||||||
self.in_keepalive = Some(self.in_port.clone()
|
self.in_port.clone()
|
||||||
.downcast::<V>().ok().unwrap()
|
.downcast::<V>().ok().unwrap()
|
||||||
.0.attach_to( src_port ));
|
.0.attach_to( src_port );
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_singleton_buffer<T>( buffer: SingletonBuffer<T> ) -> Self
|
pub fn from_singleton_buffer<T>( buffer: SingletonBuffer<T> ) -> Self
|
||||||
|
@ -147,7 +99,6 @@ impl ReprLeaf {
|
||||||
{
|
{
|
||||||
let in_port = ViewPort::<dyn SingletonView<Item = T>>::new();
|
let in_port = ViewPort::<dyn SingletonView<Item = T>>::new();
|
||||||
ReprLeaf {
|
ReprLeaf {
|
||||||
in_keepalive: None,
|
|
||||||
keepalive: Some(buffer.attach_to(in_port.outer())),
|
keepalive: Some(buffer.attach_to(in_port.outer())),
|
||||||
in_port: in_port.inner().into(),
|
in_port: in_port.inner().into(),
|
||||||
out_port: buffer.get_port().0.into(),
|
out_port: buffer.get_port().0.into(),
|
||||||
|
@ -158,9 +109,9 @@ impl ReprLeaf {
|
||||||
pub fn from_vec_buffer<T>( buffer: VecBuffer<T> ) -> Self
|
pub fn from_vec_buffer<T>( buffer: VecBuffer<T> ) -> Self
|
||||||
where T: Clone + Send + Sync + 'static
|
where T: Clone + Send + Sync + 'static
|
||||||
{
|
{
|
||||||
|
eprintln!("ReprLeaf from vec buffer (LEN ={})", buffer.len());
|
||||||
let in_port = ViewPort::< dyn ListView<T> >::new();
|
let in_port = ViewPort::< dyn ListView<T> >::new();
|
||||||
ReprLeaf {
|
ReprLeaf {
|
||||||
in_keepalive: None,
|
|
||||||
keepalive: Some(buffer.attach_to(in_port.outer())),
|
keepalive: Some(buffer.attach_to(in_port.outer())),
|
||||||
in_port: in_port.inner().into(),
|
in_port: in_port.inner().into(),
|
||||||
out_port: buffer.get_port().0.into(),
|
out_port: buffer.get_port().0.into(),
|
||||||
|
@ -208,6 +159,7 @@ impl ReprLeaf {
|
||||||
|
|
||||||
let data_arc =
|
let data_arc =
|
||||||
if let Some(data) = self.data.as_ref() {
|
if let Some(data) = self.data.as_ref() {
|
||||||
|
eprintln!("downcast existing vec-data");
|
||||||
data.clone().downcast::<RwLock<Vec<T>>>().ok()
|
data.clone().downcast::<RwLock<Vec<T>>>().ok()
|
||||||
} else {
|
} else {
|
||||||
vec_port.update();
|
vec_port.update();
|
||||||
|
@ -223,8 +175,14 @@ impl ReprLeaf {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(data_arc) = data_arc {
|
if let Some(data_arc) = data_arc {
|
||||||
|
eprintln!("ReprLeaf: have Vec-like data-arc");
|
||||||
|
eprintln!("LEN = {}", data_arc.read().unwrap().len());
|
||||||
|
|
||||||
self.data = Some(data_arc.clone() as Arc<dyn Any + Send + Sync>);
|
self.data = Some(data_arc.clone() as Arc<dyn Any + Send + Sync>);
|
||||||
let buf = VecBuffer::with_data_arc_port(data_arc, vec_port.inner());
|
let buf = VecBuffer {
|
||||||
|
data: data_arc,
|
||||||
|
port: vec_port.inner()
|
||||||
|
};
|
||||||
self.keepalive = Some(buf.attach_to(
|
self.keepalive = Some(buf.attach_to(
|
||||||
self.in_port.0.clone()
|
self.in_port.0.clone()
|
||||||
.downcast::< dyn ListView<T> >()
|
.downcast::< dyn ListView<T> >()
|
||||||
|
@ -237,6 +195,7 @@ impl ReprLeaf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn get_port<V>(&self) -> Option<OuterViewPort<V>>
|
pub fn get_port<V>(&self) -> Option<OuterViewPort<V>>
|
||||||
where V: View + ?Sized + 'static,
|
where V: View + ?Sized + 'static,
|
||||||
V::Msg: Clone
|
V::Msg: Clone
|
||||||
|
@ -284,22 +243,6 @@ impl ReprTree {
|
||||||
&self.halo
|
&self.halo
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_leaf_types(&self) -> Vec< TypeTerm > {
|
|
||||||
let mut leaf_types = Vec::new();
|
|
||||||
if self.leaf.is_some() {
|
|
||||||
leaf_types.push( self.get_type().clone() );
|
|
||||||
}
|
|
||||||
for (branch_type, branch) in self.branches.iter() {
|
|
||||||
for t in branch.read().unwrap().get_leaf_types() {
|
|
||||||
leaf_types.push(TypeTerm::Ladder(vec![
|
|
||||||
self.get_type().clone(),
|
|
||||||
t
|
|
||||||
]).normalize())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
leaf_types
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn insert_branch(&mut self, repr: Arc<RwLock<ReprTree>>) {
|
pub fn insert_branch(&mut self, repr: Arc<RwLock<ReprTree>>) {
|
||||||
let branch_type = repr.read().unwrap().get_type().clone();
|
let branch_type = repr.read().unwrap().get_type().clone();
|
||||||
|
|
||||||
|
@ -309,7 +252,6 @@ impl ReprTree {
|
||||||
self.halo.clone(),
|
self.halo.clone(),
|
||||||
self.type_tag.clone()
|
self.type_tag.clone()
|
||||||
]).normalize() );
|
]).normalize() );
|
||||||
|
|
||||||
self.branches.insert(branch_type, repr.clone());
|
self.branches.insert(branch_type, repr.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,13 +298,6 @@ impl ReprTree {
|
||||||
V::Msg: Clone
|
V::Msg: Clone
|
||||||
{
|
{
|
||||||
if let Some(rung_type) = type_ladder.next() {
|
if let Some(rung_type) = type_ladder.next() {
|
||||||
if &rung_type == self.get_type() {
|
|
||||||
if let Some(leaf) = self.leaf.as_mut() {
|
|
||||||
leaf.attach_to(src_port);
|
|
||||||
} else {
|
|
||||||
self.leaf = Some(ReprLeaf::from_view(src_port));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if let Some(next_repr) = self.branches.get(&rung_type) {
|
if let Some(next_repr) = self.branches.get(&rung_type) {
|
||||||
next_repr.write().unwrap().attach_leaf_to(type_ladder, src_port);
|
next_repr.write().unwrap().attach_leaf_to(type_ladder, src_port);
|
||||||
} else {
|
} else {
|
||||||
|
@ -370,7 +305,6 @@ impl ReprTree {
|
||||||
next_repr.attach_leaf_to(type_ladder, src_port);
|
next_repr.attach_leaf_to(type_ladder, src_port);
|
||||||
self.insert_branch(Arc::new(RwLock::new(next_repr)));
|
self.insert_branch(Arc::new(RwLock::new(next_repr)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if let Some(leaf) = self.leaf.as_mut() {
|
if let Some(leaf) = self.leaf.as_mut() {
|
||||||
leaf.attach_to(src_port);
|
leaf.attach_to(src_port);
|
||||||
|
@ -380,38 +314,6 @@ impl ReprTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn attach_to<V>(
|
|
||||||
&mut self,
|
|
||||||
src_port: OuterViewPort<V>
|
|
||||||
)
|
|
||||||
where V: View + ?Sized + 'static,
|
|
||||||
V::Msg: Clone
|
|
||||||
{
|
|
||||||
if let Some(leaf) = self.leaf.as_mut() {
|
|
||||||
leaf.attach_to(src_port);
|
|
||||||
} else {
|
|
||||||
eprintln!("cant attach branch without leaf");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn detach(&mut self, ctx: &Arc<RwLock<Context>>) {
|
|
||||||
if let Some(leaf) = self.leaf.as_mut() {
|
|
||||||
if self.type_tag == Context::parse(&ctx, "Char") {
|
|
||||||
leaf.detach::<dyn SingletonView<Item = char>>();
|
|
||||||
}
|
|
||||||
if self.type_tag == Context::parse(&ctx, "<Vec Char>") {
|
|
||||||
leaf.detach_vec::<char>();
|
|
||||||
}
|
|
||||||
if self.type_tag == Context::parse(&ctx, "<List Char>") {
|
|
||||||
leaf.detach::<dyn ListView<char>>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (t,b) in self.branches.iter_mut() {
|
|
||||||
b.write().unwrap().detach(&ctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn insert_leaf(
|
pub fn insert_leaf(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut type_ladder: impl Iterator<Item = TypeTerm>,
|
mut type_ladder: impl Iterator<Item = TypeTerm>,
|
||||||
|
@ -450,15 +352,7 @@ impl ReprTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn descend(rt: &Arc<RwLock<Self>>, dst_type: impl Into<TypeTerm>) -> Option<Arc<RwLock<ReprTree>>> {
|
pub fn descend(rt: &Arc<RwLock<Self>>, dst_type: impl Into<TypeTerm>) -> Option<Arc<RwLock<ReprTree>>> {
|
||||||
let mut lnf = dst_type.into().get_lnf_vec();
|
ReprTree::descend_ladder(rt, dst_type.into().get_lnf_vec().into_iter())
|
||||||
if lnf.len() > 0 {
|
|
||||||
if lnf[0] == rt.get_type() {
|
|
||||||
lnf.remove(0);
|
|
||||||
}
|
|
||||||
ReprTree::descend_ladder(rt, lnf.into_iter())
|
|
||||||
} else {
|
|
||||||
Some(rt.clone())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ascend(rt: &Arc<RwLock<Self>>, type_term: impl Into<TypeTerm>) -> Arc<RwLock<ReprTree>> {
|
pub fn ascend(rt: &Arc<RwLock<Self>>, type_term: impl Into<TypeTerm>) -> Arc<RwLock<ReprTree>> {
|
||||||
|
@ -519,10 +413,6 @@ impl ReprTree {
|
||||||
self.get_port::<dyn SequenceView<Item = T>>().expect("no sequence-view available")
|
self.get_port::<dyn SequenceView<Item = T>>().expect("no sequence-view available")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view_list<T: Clone + Send + Sync + 'static>(&self) -> OuterViewPort<dyn ListView<T>> {
|
|
||||||
self.get_port::<dyn ListView<T>>().expect("no list-view available")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn view_char(&self) -> OuterViewPort<dyn SingletonView<Item = char>> {
|
pub fn view_char(&self) -> OuterViewPort<dyn SingletonView<Item = char>> {
|
||||||
self.get_port::<dyn SingletonView<Item = char>>().expect("no char-view available")
|
self.get_port::<dyn SingletonView<Item = char>>().expect("no char-view available")
|
||||||
}
|
}
|
||||||
|
@ -552,17 +442,11 @@ pub trait ReprTreeExt {
|
||||||
fn create_branch(&mut self, rung: impl Into<TypeTerm>);
|
fn create_branch(&mut self, rung: impl Into<TypeTerm>);
|
||||||
fn descend(&self, target_type: impl Into<TypeTerm>) -> Option<Arc<RwLock<ReprTree>>>;
|
fn descend(&self, target_type: impl Into<TypeTerm>) -> Option<Arc<RwLock<ReprTree>>>;
|
||||||
|
|
||||||
fn attach_leaf_to<V: View + ?Sized + 'static>(&self, t: impl Into<TypeTerm>, v: OuterViewPort<V>) where V::Msg: Clone;
|
|
||||||
fn get_port<V: View + ?Sized + 'static>(&self) -> Option<OuterViewPort<V>> where V::Msg: Clone;
|
|
||||||
|
|
||||||
fn view_char(&self) -> OuterViewPort<dyn SingletonView<Item = char>>;
|
fn view_char(&self) -> OuterViewPort<dyn SingletonView<Item = char>>;
|
||||||
fn view_u8(&self) -> OuterViewPort<dyn SingletonView<Item = u8>>;
|
fn view_u8(&self) -> OuterViewPort<dyn SingletonView<Item = u8>>;
|
||||||
fn view_u64(&self) -> OuterViewPort<dyn SingletonView<Item = u64>>;
|
fn view_u64(&self) -> OuterViewPort<dyn SingletonView<Item = u64>>;
|
||||||
fn view_usize(&self) -> OuterViewPort<dyn SingletonView<Item = usize>>;
|
fn view_usize(&self) -> OuterViewPort<dyn SingletonView<Item = usize>>;
|
||||||
|
|
||||||
fn view_seq<T: Send + Sync + 'static>(&self) -> OuterViewPort<dyn SequenceView<Item = T>>;
|
|
||||||
fn view_list<T: Clone + Send + Sync + 'static>(&self) -> OuterViewPort<dyn ListView<T>>;
|
|
||||||
|
|
||||||
fn singleton_buffer<T: Clone + Send + Sync + 'static>(&self) -> SingletonBuffer<T>;
|
fn singleton_buffer<T: Clone + Send + Sync + 'static>(&self) -> SingletonBuffer<T>;
|
||||||
fn vec_buffer<T: Clone + Send + Sync + 'static>(&self) -> VecBuffer<T>;
|
fn vec_buffer<T: Clone + Send + Sync + 'static>(&self) -> VecBuffer<T>;
|
||||||
}
|
}
|
||||||
|
@ -594,14 +478,6 @@ impl ReprTreeExt for Arc<RwLock<ReprTree>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_port<V: View + ?Sized + 'static>(&self) -> Option<OuterViewPort<V>> where V::Msg: Clone {
|
|
||||||
self.read().unwrap().get_port::<V>()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn attach_leaf_to<V: View + ?Sized + 'static>(&self, type_ladder: impl Into<TypeTerm>, v: OuterViewPort<V>) where V::Msg: Clone {
|
|
||||||
self.write().unwrap().attach_leaf_to::<V>(type_ladder.into().get_lnf_vec().into_iter(), v)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn descend(&self, target_type: impl Into<TypeTerm>) -> Option<Arc<RwLock<ReprTree>>> {
|
fn descend(&self, target_type: impl Into<TypeTerm>) -> Option<Arc<RwLock<ReprTree>>> {
|
||||||
ReprTree::descend( self, target_type )
|
ReprTree::descend( self, target_type )
|
||||||
}
|
}
|
||||||
|
@ -622,14 +498,6 @@ impl ReprTreeExt for Arc<RwLock<ReprTree>> {
|
||||||
self.read().unwrap().view_usize()
|
self.read().unwrap().view_usize()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view_seq<T: Send + Sync + 'static>(&self) -> OuterViewPort<dyn SequenceView<Item = T>> {
|
|
||||||
self.read().unwrap().view_seq::<T>()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn view_list<T: Clone + Send + Sync + 'static>(&self) -> OuterViewPort<dyn ListView<T>> {
|
|
||||||
self.read().unwrap().view_list::<T>()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn singleton_buffer<T: Clone + Send + Sync + 'static>(&self) -> SingletonBuffer<T> {
|
fn singleton_buffer<T: Clone + Send + Sync + 'static>(&self) -> SingletonBuffer<T> {
|
||||||
self.write().unwrap().singleton_buffer::<T>().expect("")
|
self.write().unwrap().singleton_buffer::<T>().expect("")
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,10 +52,7 @@ impl MorphismBase {
|
||||||
) {
|
) {
|
||||||
self.morphisms.push(
|
self.morphisms.push(
|
||||||
GenericReprTreeMorphism {
|
GenericReprTreeMorphism {
|
||||||
morph_type: MorphismType {
|
morph_type,
|
||||||
src_type: morph_type.src_type.normalize(),
|
|
||||||
dst_type: morph_type.dst_type.normalize()
|
|
||||||
},
|
|
||||||
setup_projection: Arc::new(setup_projection)
|
setup_projection: Arc::new(setup_projection)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -70,13 +67,12 @@ impl MorphismBase {
|
||||||
|
|
||||||
let unification_problem = laddertypes::UnificationProblem::new(
|
let unification_problem = laddertypes::UnificationProblem::new(
|
||||||
vec![
|
vec![
|
||||||
( src_type.clone().normalize(), m.morph_type.src_type.clone() ),
|
( src_type.clone(), m.morph_type.src_type.clone() ),
|
||||||
( dst_type.clone().normalize(), m.morph_type.dst_type.clone() )
|
( dst_type.clone(), m.morph_type.dst_type.clone() )
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
let unification_result = unification_problem.solve();
|
if let Ok(σ) = unification_problem.solve() {
|
||||||
if let Ok(σ) = unification_result {
|
|
||||||
return Some((m, σ));
|
return Some((m, σ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,70 +80,19 @@ impl MorphismBase {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn find_morphism_ladder(
|
|
||||||
&self,
|
|
||||||
src_type: &TypeTerm,
|
|
||||||
dst_type: &TypeTerm,
|
|
||||||
) -> Option<(
|
|
||||||
&GenericReprTreeMorphism,
|
|
||||||
TypeTerm,
|
|
||||||
HashMap<TypeID, TypeTerm>
|
|
||||||
)> {
|
|
||||||
let mut src_lnf = src_type.clone().get_lnf_vec();
|
|
||||||
let mut dst_lnf = dst_type.clone().get_lnf_vec();
|
|
||||||
let mut halo = vec![];
|
|
||||||
|
|
||||||
while src_lnf.len() > 0 && dst_lnf.len() > 0 {
|
|
||||||
if let Some((m, σ)) = self.find_morphism( &TypeTerm::Ladder(src_lnf.clone()), &TypeTerm::Ladder(dst_lnf.clone()) ) {
|
|
||||||
return Some((m, TypeTerm::Ladder(halo), σ));
|
|
||||||
} else {
|
|
||||||
if src_lnf[0] == dst_lnf[0] {
|
|
||||||
src_lnf.remove(0);
|
|
||||||
halo.push(dst_lnf.remove(0));
|
|
||||||
} else {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn apply_morphism(
|
pub fn apply_morphism(
|
||||||
&self,
|
&self,
|
||||||
repr_tree: Arc<RwLock<ReprTree>>,
|
mut repr_tree: Arc<RwLock<ReprTree>>,
|
||||||
src_type: &TypeTerm,
|
src_type: &TypeTerm,
|
||||||
dst_type: &TypeTerm
|
dst_type: &TypeTerm
|
||||||
) {
|
) {
|
||||||
if let Some((m, s, σ)) = self.find_morphism_ladder( &src_type, dst_type ) {
|
// let t = repr_tree.read().unwrap().get_type().clone();
|
||||||
//eprintln!("apply morphism on subtree {:?}", s);
|
if let Some((m, σ)) = self.find_morphism( &src_type, dst_type ) {
|
||||||
let mut rt = repr_tree.descend( s ).expect("descend");
|
|
||||||
(m.setup_projection)( &mut rt, &σ );
|
|
||||||
} else {
|
|
||||||
eprintln!("could not find morphism\n {:?}\n ====>\n {:?}", src_type, dst_type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
pub fn apply_seq_map_morphism<SrcItem, DstItem>(
|
|
||||||
&self,
|
|
||||||
mut repr_tree: Arc<RwLock<ReprTree>>,
|
|
||||||
src_item_type: &TypeTerm,
|
|
||||||
dst_item_type: &TypeTerm
|
|
||||||
) {
|
|
||||||
if let Some((item_morphism, σ)) = self.find_morphism( &src_item_type, dst_item_type ) {
|
|
||||||
|
|
||||||
let src_port = repr_tree.read().unwrap().get_port::<dyn SequenceView<Item = Arc<RwLock<ReprTree>> >>().unwrap();
|
|
||||||
src_port.map(
|
|
||||||
m.setup_projection
|
|
||||||
)
|
|
||||||
|
|
||||||
(m.setup_projection)( &mut repr_tree, &σ );
|
(m.setup_projection)( &mut repr_tree, &σ );
|
||||||
} else {
|
} else {
|
||||||
eprintln!("could not find item morphism");
|
eprintln!("could not find morphism");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
||||||
|
|
|
@ -7,7 +7,6 @@ use {
|
||||||
repr_tree::{Context, ReprTree},
|
repr_tree::{Context, ReprTree},
|
||||||
editors::list::*,
|
editors::list::*,
|
||||||
edit_tree::{TreeCursor, TreeNav, TreeNavResult, EditTree},
|
edit_tree::{TreeCursor, TreeNav, TreeNavResult, EditTree},
|
||||||
repr_tree::{ReprTreeExt, ReprLeaf}
|
|
||||||
},
|
},
|
||||||
crate::{
|
crate::{
|
||||||
DisplaySegment,
|
DisplaySegment,
|
||||||
|
@ -81,12 +80,10 @@ impl PTYListStyle {
|
||||||
editor.get_cursor_port(),
|
editor.get_cursor_port(),
|
||||||
editor.get_data_port()
|
editor.get_data_port()
|
||||||
);
|
);
|
||||||
|
let seg_seq = seg_seq.read().unwrap();
|
||||||
let seg_seq0 = seg_seq.read().unwrap();
|
|
||||||
let seg_seq = seg_seq0.get_view();
|
|
||||||
drop(seg_seq0);
|
|
||||||
|
|
||||||
seg_seq
|
seg_seq
|
||||||
|
.get_view()
|
||||||
.map(move |segment| segment.display_view())
|
.map(move |segment| segment.display_view())
|
||||||
.separate(make_label(&self.style.1))
|
.separate(make_label(&self.style.1))
|
||||||
.wrap(make_label(&self.style.0), make_label(&self.style.2))
|
.wrap(make_label(&self.style.0), make_label(&self.style.2))
|
||||||
|
@ -95,14 +92,15 @@ impl PTYListStyle {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn for_node(node: &mut EditTree, style: (&str, &str, &str)) {
|
pub fn for_node(node: &mut EditTree, style: (&str, &str, &str)) {
|
||||||
let editor = node.get_edit::<ListEditor>().unwrap();
|
|
||||||
let editor = editor.read().unwrap();
|
|
||||||
let pty_view = Self::new(style).pty_view(&editor);
|
|
||||||
node.disp.view
|
node.disp.view
|
||||||
.attach_leaf_to(
|
.write().unwrap()
|
||||||
|
.insert_branch(ReprTree::from_view(
|
||||||
Context::parse(&node.ctx, "TerminalView"),
|
Context::parse(&node.ctx, "TerminalView"),
|
||||||
pty_view
|
Self::new(style)
|
||||||
);
|
.pty_view(
|
||||||
|
&node.get_edit::<ListEditor>().unwrap().read().unwrap()
|
||||||
|
)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,8 +226,6 @@ impl PTYListController {
|
||||||
self.depth.map(|d| d+1)
|
self.depth.map(|d| d+1)
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(new_edittree) = new_edittree {
|
|
||||||
|
|
||||||
let mut ne = new_edittree.get();
|
let mut ne = new_edittree.get();
|
||||||
match ne.send_cmd_obj(cmd_obj.clone()) {
|
match ne.send_cmd_obj(cmd_obj.clone()) {
|
||||||
TreeNavResult::Continue => {
|
TreeNavResult::Continue => {
|
||||||
|
@ -241,12 +237,6 @@ impl PTYListController {
|
||||||
TreeNavResult::Exit
|
TreeNavResult::Exit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
panic!("cant get edit tree");
|
|
||||||
TreeNavResult::Continue
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
ListCursorMode::Select => {
|
ListCursorMode::Select => {
|
||||||
if let Some(item) = e.get_item_mut() {
|
if let Some(item) = e.get_item_mut() {
|
||||||
|
|
|
@ -17,6 +17,7 @@ use {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
pub fn edittree_make_char_view(
|
pub fn edittree_make_char_view(
|
||||||
node: EditTree
|
node: EditTree
|
||||||
) -> EditTree {
|
) -> EditTree {
|
||||||
|
|
Loading…
Reference in a new issue