cargo fix

This commit is contained in:
Michael Sippel 2023-08-21 16:31:44 +02:00
parent 249e811c77
commit 077d91c47e
Signed by: senvas
GPG key ID: F96CF119C34B64A6
13 changed files with 56 additions and 78 deletions

View file

@ -8,7 +8,7 @@ use {
}, },
crate::{ crate::{
type_system::{Context, ReprTree, TypeTerm}, type_system::{Context, ReprTree, TypeTerm},
terminal::{TerminalAtom, TerminalStyle}, terminal::{TerminalAtom},
tree::{NestedNode, TreeNavResult}, tree::{NestedNode, TreeNavResult},
commander::{ObjCommander} commander::{ObjCommander}
}, },
@ -39,6 +39,7 @@ impl ObjCommander for CharEditor {
let value = cmd_view.get(); let value = cmd_view.get();
if self.ctx.read().unwrap().meta_chars.contains(&value) { if self.ctx.read().unwrap().meta_chars.contains(&value) {
eprintln!("char: meta char EXID");
TreeNavResult::Exit TreeNavResult::Exit
} else { } else {
self.data.set(value); self.data.set(value);

View file

@ -1,18 +1,13 @@
use { use {
crate::{ crate::{
type_system::{Context, TypeTerm, ReprTree}, type_system::{Context, TypeTerm},
editors::{ editors::{
char::*,
list::*, list::*,
integer::*, integer::*
product::*
}, },
tree::{NestedNode},
diagnostics::{Diagnostics},
type_system::{MorphismTypePattern}, type_system::{MorphismTypePattern},
}, },
std::sync::{Arc, RwLock}, std::sync::{Arc, RwLock}
cgmath::Point2
}; };
pub fn init_ctx(ctx: &mut Context) { pub fn init_ctx(ctx: &mut Context) {
@ -55,8 +50,8 @@ pub fn init_ctx(ctx: &mut Context) {
ctx.add_morphism(pattern, ctx.add_morphism(pattern,
Arc::new( Arc::new(
|mut node, dst_type| { |mut node, dst_type| {
let depth = node.depth.get(); let _depth = node.depth.get();
let editor = node.editor.get().unwrap().downcast::<RwLock<ListEditor>>().unwrap(); let _editor = node.editor.get().unwrap().downcast::<RwLock<ListEditor>>().unwrap();
// todo: check src_type parameter to be ( Digit radix ) // todo: check src_type parameter to be ( Digit radix )

View file

@ -12,9 +12,9 @@ use {
}, },
crate::{ crate::{
type_system::{Context, TypeTerm, ReprTree}, type_system::{Context, TypeTerm, ReprTree},
editors::list::{ListEditor, ListCmd, PTYListController, PTYListStyle}, editors::list::{ListCmd, PTYListController, PTYListStyle},
terminal::{ terminal::{
TerminalAtom, TerminalEvent, TerminalStyle, make_label TerminalAtom, TerminalStyle, make_label
}, },
diagnostics::{Message}, diagnostics::{Message},
tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor}, tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor},
@ -23,7 +23,6 @@ use {
std::sync::Arc, std::sync::Arc,
std::sync::RwLock, std::sync::RwLock,
std::iter::FromIterator, std::iter::FromIterator,
termion::event::{Event, Key},
cgmath::{Point2} cgmath::{Point2}
}; };
@ -56,7 +55,7 @@ impl ObjCommander for DigitEditor {
add a message to the diagnostics view add a message to the diagnostics view
*/ */
let mut message = IndexBuffer::from_iter(vec![ let message = IndexBuffer::from_iter(vec![
(Point2::new(1, 0), make_label("invalid digit '")), (Point2::new(1, 0), make_label("invalid digit '")),
(Point2::new(2, 0), make_label(&format!("{}", c)) (Point2::new(2, 0), make_label(&format!("{}", c))
.map_item(|_p,a| a.add_style_back(TerminalStyle::fg_color((140,140,250))))), .map_item(|_p,a| a.add_style_back(TerminalStyle::fg_color((140,140,250))))),

View file

@ -1,7 +1,6 @@
use { use {
r3vi::{ r3vi::{
view::{singleton::*}, view::{singleton::*}
buffer::{singleton::*}
}, },
crate::{ crate::{
editors::list::{ListEditor, ListCursor, ListCursorMode}, editors::list::{ListEditor, ListCursor, ListCursorMode},

View file

@ -1,13 +1,10 @@
use { use {
r3vi::{ r3vi::{
view::{port::UpdateTask, OuterViewPort, singleton::*, sequence::*}, view::{sequence::*}
buffer::{singleton::*, vec::*}
}, },
crate::{ crate::{
type_system::{Context, TypeTerm, ReprTree}, type_system::{Context, TypeTerm},
editors::list::{ListEditor, ListCursor, ListCursorMode, ListCmd, PTYListController, PTYListStyle}, editors::list::{ListEditor, PTYListController, PTYListStyle}
tree::{NestedNode, TreeNav, TreeCursor},
diagnostics::Diagnostics
}, },
std::sync::{Arc, RwLock} std::sync::{Arc, RwLock}
}; };

View file

@ -5,7 +5,7 @@ use {
}, },
crate::{ crate::{
type_system::{Context, TypeTerm, ReprTree}, type_system::{Context, TypeTerm, ReprTree},
editors::list::{ListCursor, ListCursorMode, ListCmd, PTYListController, PTYListStyle}, editors::list::{ListCursor, ListCursorMode},
tree::{NestedNode, TreeNav, TreeCursor}, tree::{NestedNode, TreeNav, TreeCursor},
diagnostics::Diagnostics diagnostics::Diagnostics
}, },
@ -319,7 +319,7 @@ impl ListEditor {
if let Some(item) = self.get_item() { if let Some(item) = self.get_item() {
// let item = item.read().unwrap(); // let item = item.read().unwrap();
let depth = item.depth; let _depth = item.depth;
if let Some(head_editor) = item.editor.get() { if let Some(head_editor) = item.editor.get() {
eprintln!("listlistsplit:editor = {:?}", Arc::into_raw(head_editor.clone())); eprintln!("listlistsplit:editor = {:?}", Arc::into_raw(head_editor.clone()));
@ -400,7 +400,7 @@ impl ListEditor {
let next_editor = next_editor.read().unwrap(); let next_editor = next_editor.read().unwrap();
if let Some(next_editor) = next_editor.editor.get() { if let Some(next_editor) = next_editor.editor.get() {
if let Ok(next_editor) = next_editor.downcast::<RwLock<ListEditor>>() { if let Ok(next_editor) = next_editor.downcast::<RwLock<ListEditor>>() {
let mut next_editor = next_editor.write().unwrap(); let next_editor = next_editor.write().unwrap();
let cur_editor = item.editor.get().unwrap(); let cur_editor = item.editor.get().unwrap();
let cur_editor = cur_editor.downcast::<RwLock<ListEditor>>().unwrap(); let cur_editor = cur_editor.downcast::<RwLock<ListEditor>>().unwrap();
let mut cur_editor = cur_editor.write().unwrap(); let mut cur_editor = cur_editor.write().unwrap();

View file

@ -4,16 +4,14 @@ use {
projection::decorate_sequence::*, projection::decorate_sequence::*,
}, },
crate::{ crate::{
type_system::{Context, TypeTerm, ReprTree}, type_system::{Context, ReprTree},
editors::list::*, editors::list::*,
terminal::{TerminalEvent, TerminalView, make_label}, terminal::{TerminalEvent, TerminalView, make_label},
tree::{TreeCursor, TreeNav, TreeNavResult}, tree::{TreeCursor, TreeNav, TreeNavResult},
diagnostics::{Diagnostics},
tree::NestedNode, tree::NestedNode,
PtySegment PtySegment
}, },
std::sync::{Arc, RwLock}, std::sync::{Arc, RwLock},
std::any::{Any},
termion::event::{Event, Key} termion::event::{Event, Key}
}; };
@ -103,7 +101,7 @@ impl PTYListController {
close_char: Option<char> close_char: Option<char>
) { ) {
{ {
let mut ctx = node.ctx.as_ref(); let ctx = node.ctx.as_ref();
let mut ctx = ctx.write().unwrap(); let mut ctx = ctx.write().unwrap();
if let Some(c) = split_char.as_ref() { if let Some(c) = split_char.as_ref() {
@ -137,7 +135,7 @@ impl PTYListController {
self.depth = depth; self.depth = depth;
} }
pub fn handle_term_event(&mut self, event: &TerminalEvent, cmd_obj: Arc<RwLock<ReprTree>>) -> TreeNavResult { pub fn handle_term_event(&mut self, event: &TerminalEvent, _cmd_obj: Arc<RwLock<ReprTree>>) -> TreeNavResult {
let mut e = self.editor.write().unwrap(); let mut e = self.editor.write().unwrap();
match event { match event {
TerminalEvent::Input(Event::Key(Key::Insert)) => { TerminalEvent::Input(Event::Key(Key::Insert)) => {
@ -193,7 +191,7 @@ impl PTYListController {
} }
}, },
ListCursorMode::Select => { ListCursorMode::Select => {
if let Some(mut item) = e.get_item_mut() { if let Some(item) = e.get_item_mut() {
eprintln!("PTYList(select): forward any cmd to current child item"); eprintln!("PTYList(select): forward any cmd to current child item");
let res = item.write().unwrap().send_cmd_obj(cmd_obj.clone()); let res = item.write().unwrap().send_cmd_obj(cmd_obj.clone());
let child_close_char = item.read().unwrap().close_char.get(); let child_close_char = item.read().unwrap().close_char.get();

View file

@ -211,7 +211,7 @@ impl ObjCommander for ProductEditor {
let mut update_segment = false; let mut update_segment = false;
let result = if let Some(mut segment) = self.get_cur_segment_mut().as_deref_mut() { let _result = if let Some(mut segment) = self.get_cur_segment_mut().as_deref_mut() {
if let Some(ProductEditorSegment::N{ t, editor, ed_depth, cur_depth, cur_dist: _ }) = segment.deref_mut() { if let Some(ProductEditorSegment::N{ t, editor, ed_depth, cur_depth, cur_dist: _ }) = segment.deref_mut() {
*cur_depth = self.get_cursor().tree_addr.len(); *cur_depth = self.get_cursor().tree_addr.len();

View file

@ -1,21 +1,14 @@
use { use {
r3vi::{ r3vi::{
buffer::singleton::*, view::{singleton::*, sequence::*}
view::{singleton::*, sequence::*, OuterViewPort},
projection::flatten_grid::*,
projection::flatten_singleton::*
}, },
crate::{ crate::{
type_system::{Context, TypeID, TypeTerm, ReprTree, MorphismTypePattern}, type_system::{Context, TypeTerm, MorphismTypePattern},
terminal::{TerminalEvent, TerminalStyle}, terminal::{TerminalStyle},
editors::{sum::*, list::{ListCursorMode, ListEditor, PTYListStyle, PTYListController}, typeterm::{State, TypeTermEditor}}, editors::{list::{PTYListStyle, PTYListController}, typeterm::{State, TypeTermEditor}}
tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor},
commander::ObjCommander,
PtySegment
}, },
termion::event::{Key}, std::{sync::{Arc, RwLock}},
std::{sync::{Arc, RwLock}, any::Any}, cgmath::{Point2}
cgmath::{Vector2, Point2}
}; };
pub fn init_ctx(ctx: &mut Context) { pub fn init_ctx(ctx: &mut Context) {
@ -31,8 +24,8 @@ pub fn init_ctx(ctx: &mut Context) {
ctx.add_morphism( ctx.add_morphism(
MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type").unwrap() }, MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type").unwrap() },
Arc::new(move |mut node, _dst_type:_| { Arc::new(move |node, _dst_type:_| {
let mut new_node = TypeTermEditor::with_node( node.ctx.clone(), node.depth.get(), node.clone(), State::Any ); let new_node = TypeTermEditor::with_node( node.ctx.clone(), node.depth.get(), node.clone(), State::Any );
Some(new_node) Some(new_node)
})); }));
@ -77,14 +70,14 @@ pub fn init_ctx(ctx: &mut Context) {
// display variables blue color // display variables blue color
if let Some(v) = node.view { if let Some(v) = node.view {
node.view = Some( node.view = Some(
v.map_item(|i,p| p.add_style_front(TerminalStyle::fg_color((5, 120, 240))))); v.map_item(|_i,p| p.add_style_front(TerminalStyle::fg_color((5, 120, 240)))));
} }
Some(node) Some(node)
})); }));
ctx.add_morphism( ctx.add_morphism(
MorphismTypePattern { src_tyid: ctx.get_typeid("PosInt"), dst_tyid: ctx.get_typeid("Type::Lit::Num").unwrap() }, MorphismTypePattern { src_tyid: ctx.get_typeid("PosInt"), dst_tyid: ctx.get_typeid("Type::Lit::Num").unwrap() },
Arc::new(|mut node, _dst_type:_| { Arc::new(|node, _dst_type:_| {
Some(node) Some(node)
})); }));
@ -115,3 +108,4 @@ pub fn init_ctx(ctx: &mut Context) {
Some(TypeTermEditor::new_node(ctx, depth)) Some(TypeTermEditor::new_node(ctx, depth))
})); }));
} }

View file

@ -5,21 +5,16 @@ pub use ctx::init_ctx;
use { use {
r3vi::{ r3vi::{
buffer::singleton::*, buffer::singleton::*,
view::{singleton::*, sequence::*, OuterViewPort}, view::{singleton::*, sequence::*, OuterViewPort}
projection::flatten_grid::*,
projection::flatten_singleton::*
}, },
crate::{ crate::{
type_system::{Context, TypeID, TypeTerm, ReprTree, MorphismTypePattern}, type_system::{Context, TypeID, TypeTerm, ReprTree},
terminal::{TerminalEvent, TerminalStyle}, editors::{list::{ListCursorMode}},
editors::{sum::*, list::{ListCursorMode, ListEditor, PTYListStyle, PTYListController}},
tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor}, tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor},
commander::ObjCommander, commander::ObjCommander
PtySegment
}, },
termion::event::{Key},
std::{sync::{Arc, RwLock}, any::Any}, std::{sync::{Arc, RwLock}, any::Any},
cgmath::{Vector2, Point2} cgmath::{Vector2}
}; };
#[derive(PartialEq, Eq, Clone, Copy)] #[derive(PartialEq, Eq, Clone, Copy)]
@ -55,7 +50,7 @@ impl TypeTermEditor {
match term { match term {
TypeTerm::TypeID( tyid ) => { TypeTerm::TypeID( tyid ) => {
let mut editor = node.get_edit::<TypeTermEditor>().expect("typ term edit"); let editor = node.get_edit::<TypeTermEditor>().expect("typ term edit");
editor.write().unwrap().set_state(match tyid { editor.write().unwrap().set_state(match tyid {
TypeID::Fun(_) => State::FunSymbol, TypeID::Fun(_) => State::FunSymbol,
TypeID::Var(_) => State::VarSymbol TypeID::Var(_) => State::VarSymbol
@ -71,11 +66,11 @@ impl TypeTermEditor {
}, },
TypeTerm::App( args ) => { TypeTerm::App( args ) => {
let mut editor = node.get_edit::<TypeTermEditor>().expect("typ term edit"); let editor = node.get_edit::<TypeTermEditor>().expect("typ term edit");
editor.write().unwrap().set_state( State::App ); editor.write().unwrap().set_state( State::App );
for x in args.iter() { for x in args.iter() {
let mut arg_node = TypeTermEditor::from_type_term( ctx.clone(), depth+1, x ); let arg_node = TypeTermEditor::from_type_term( ctx.clone(), depth+1, x );
eprintln!("add node arg!"); eprintln!("add node arg!");
node.send_cmd_obj( node.send_cmd_obj(
@ -88,11 +83,11 @@ impl TypeTermEditor {
} }
TypeTerm::Ladder( args ) => { TypeTerm::Ladder( args ) => {
let mut editor = node.get_edit::<TypeTermEditor>().expect("typ term edit"); let editor = node.get_edit::<TypeTermEditor>().expect("typ term edit");
editor.write().unwrap().set_state( State::Ladder ); editor.write().unwrap().set_state( State::Ladder );
for x in args.iter() { for x in args.iter() {
let mut arg_node = TypeTermEditor::from_type_term( ctx.clone(), depth+1, x ); let arg_node = TypeTermEditor::from_type_term( ctx.clone(), depth+1, x );
eprintln!("add node arg!"); eprintln!("add node arg!");
node.send_cmd_obj( node.send_cmd_obj(
@ -105,10 +100,10 @@ impl TypeTermEditor {
} }
TypeTerm::Num( n ) => { TypeTerm::Num( n ) => {
let mut editor = node.get_edit::<TypeTermEditor>().expect("typ term edit"); let editor = node.get_edit::<TypeTermEditor>().expect("typ term edit");
let mut int_edit = crate::editors::integer::PosIntEditor::from_u64(node.ctx.clone(), 10, *n as u64); let int_edit = crate::editors::integer::PosIntEditor::from_u64(node.ctx.clone(), 10, *n as u64);
let mut node = int_edit.into_node(); let node = int_edit.into_node();
editor.write().unwrap().editor.set(node.editor.get()); editor.write().unwrap().editor.set(node.editor.get());
editor.write().unwrap().cur_node.set(node); editor.write().unwrap().cur_node.set(node);
@ -116,7 +111,7 @@ impl TypeTermEditor {
} }
TypeTerm::Char( c ) => { TypeTerm::Char( c ) => {
let mut editor = node.get_edit::<TypeTermEditor>().expect("typ term edit"); let editor = node.get_edit::<TypeTermEditor>().expect("typ term edit");
editor.write().unwrap().set_state( State::Char ); editor.write().unwrap().set_state( State::Char );
editor.write().unwrap().send_cmd_obj(ReprTree::from_char(&ctx, *c)); editor.write().unwrap().send_cmd_obj(ReprTree::from_char(&ctx, *c));
@ -158,7 +153,7 @@ impl TypeTermEditor {
node node
} }
State::Num => { State::Num => {
let mut int_edit = crate::editors::integer::PosIntEditor::new(self.ctx.clone(), 10); let int_edit = crate::editors::integer::PosIntEditor::new(self.ctx.clone(), 10);
let mut node = int_edit.into_node(); let mut node = int_edit.into_node();
node = node.morph( (&self.ctx, "( Type::Lit::Num )").into() ); node = node.morph( (&self.ctx, "( Type::Lit::Num )").into() );
@ -198,13 +193,13 @@ impl TypeTermEditor {
} }
fn with_node(ctx: Arc<RwLock<Context>>, depth: usize, node: NestedNode, state: State) -> NestedNode { fn with_node(ctx: Arc<RwLock<Context>>, depth: usize, node: NestedNode, state: State) -> NestedNode {
let buffer = SingletonBuffer::<Option<TypeTerm>>::new( None ); let _buffer = SingletonBuffer::<Option<TypeTerm>>::new( None );
let data = Arc::new(RwLock::new(ReprTree::new( let data = Arc::new(RwLock::new(ReprTree::new(
(&ctx, "( Type )") (&ctx, "( Type )")
))); )));
let mut editor = TypeTermEditor { let editor = TypeTermEditor {
ctx: ctx.clone(), ctx: ctx.clone(),
state, state,
data: data.clone(), data: data.clone(),

View file

@ -69,7 +69,7 @@ impl MorphismTypePattern {
} }
impl From<MorphismType> for MorphismTypePattern { impl From<MorphismType> for MorphismTypePattern {
fn from(mut value: MorphismType) -> MorphismTypePattern { fn from(value: MorphismType) -> MorphismTypePattern {
fn strip( x: &TypeTerm ) -> TypeID { fn strip( x: &TypeTerm ) -> TypeID {
match x { match x {
TypeTerm::TypeID(id) => id.clone(), TypeTerm::TypeID(id) => id.clone(),
@ -280,7 +280,7 @@ impl Context {
/* create new context per node ?? too heavy.. whats the reason? TODO */ /* create new context per node ?? too heavy.. whats the reason? TODO */
let new_ctx = Arc::new(RwLock::new(Context::with_parent(Some(ctx.clone())))); let new_ctx = Arc::new(RwLock::new(Context::with_parent(Some(ctx.clone()))));
let new_depth = depth; let _new_depth = depth;
mk_node( mk_node(
NestedNode::new(new_ctx, ReprTree::new_arc(type_term.clone()), 0), NestedNode::new(new_ctx, ReprTree::new_arc(type_term.clone()), 0),
@ -289,7 +289,7 @@ impl Context {
} }
pub fn morph_node(mut node: NestedNode, dst_type: TypeTerm) -> NestedNode { pub fn morph_node(mut node: NestedNode, dst_type: TypeTerm) -> NestedNode {
let mut src_type = node.data.read().unwrap().get_type().clone(); let src_type = node.data.read().unwrap().get_type().clone();
let pattern = MorphismType { src_type: Some(src_type), dst_type: dst_type.clone() }; let pattern = MorphismType { src_type: Some(src_type), dst_type: dst_type.clone() };
/* it is not univesally true to always use ascend. /* it is not univesally true to always use ascend.

View file

@ -22,7 +22,7 @@ impl std::fmt::Debug for ReprTree {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "type: {:?}", self.type_tag)?; write!(f, "type: {:?}", self.type_tag)?;
for (k,x) in self.branches.iter() { for (_k,x) in self.branches.iter() {
write!(f, "child: {:?}", x)?; write!(f, "child: {:?}", x)?;
} }

View file

@ -202,8 +202,8 @@ impl TypeTerm {
// returns provided syntax-type, // returns provided syntax-type,
pub fn is_semantic_subtype_of(&self, expected_type: &TypeTerm) -> Option< TypeTerm > { pub fn is_semantic_subtype_of(&self, expected_type: &TypeTerm) -> Option< TypeTerm > {
let mut provided_lnf = self.clone(); let provided_lnf = self.clone();
let mut expected_lnf = expected_type.clone(); let expected_lnf = expected_type.clone();
match match
(provided_lnf.normalize(), (provided_lnf.normalize(),