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

View file

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

View file

@ -12,9 +12,9 @@ use {
},
crate::{
type_system::{Context, TypeTerm, ReprTree},
editors::list::{ListEditor, ListCmd, PTYListController, PTYListStyle},
editors::list::{ListCmd, PTYListController, PTYListStyle},
terminal::{
TerminalAtom, TerminalEvent, TerminalStyle, make_label
TerminalAtom, TerminalStyle, make_label
},
diagnostics::{Message},
tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor},
@ -23,7 +23,6 @@ use {
std::sync::Arc,
std::sync::RwLock,
std::iter::FromIterator,
termion::event::{Event, Key},
cgmath::{Point2}
};
@ -56,7 +55,7 @@ impl ObjCommander for DigitEditor {
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(2, 0), make_label(&format!("{}", c))
.map_item(|_p,a| a.add_style_back(TerminalStyle::fg_color((140,140,250))))),

View file

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

View file

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

View file

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

View file

@ -4,16 +4,14 @@ use {
projection::decorate_sequence::*,
},
crate::{
type_system::{Context, TypeTerm, ReprTree},
type_system::{Context, ReprTree},
editors::list::*,
terminal::{TerminalEvent, TerminalView, make_label},
tree::{TreeCursor, TreeNav, TreeNavResult},
diagnostics::{Diagnostics},
tree::NestedNode,
PtySegment
},
std::sync::{Arc, RwLock},
std::any::{Any},
termion::event::{Event, Key}
};
@ -103,7 +101,7 @@ impl PTYListController {
close_char: Option<char>
) {
{
let mut ctx = node.ctx.as_ref();
let ctx = node.ctx.as_ref();
let mut ctx = ctx.write().unwrap();
if let Some(c) = split_char.as_ref() {
@ -137,7 +135,7 @@ impl PTYListController {
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();
match event {
TerminalEvent::Input(Event::Key(Key::Insert)) => {
@ -193,7 +191,7 @@ impl PTYListController {
}
},
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");
let res = item.write().unwrap().send_cmd_obj(cmd_obj.clone());
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 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() {
*cur_depth = self.get_cursor().tree_addr.len();

View file

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

View file

@ -5,21 +5,16 @@ pub use ctx::init_ctx;
use {
r3vi::{
buffer::singleton::*,
view::{singleton::*, sequence::*, OuterViewPort},
projection::flatten_grid::*,
projection::flatten_singleton::*
view::{singleton::*, sequence::*, OuterViewPort}
},
crate::{
type_system::{Context, TypeID, TypeTerm, ReprTree, MorphismTypePattern},
terminal::{TerminalEvent, TerminalStyle},
editors::{sum::*, list::{ListCursorMode, ListEditor, PTYListStyle, PTYListController}},
type_system::{Context, TypeID, TypeTerm, ReprTree},
editors::{list::{ListCursorMode}},
tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor},
commander::ObjCommander,
PtySegment
commander::ObjCommander
},
termion::event::{Key},
std::{sync::{Arc, RwLock}, any::Any},
cgmath::{Vector2, Point2}
cgmath::{Vector2}
};
#[derive(PartialEq, Eq, Clone, Copy)]
@ -55,7 +50,7 @@ impl TypeTermEditor {
match term {
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 {
TypeID::Fun(_) => State::FunSymbol,
TypeID::Var(_) => State::VarSymbol
@ -71,11 +66,11 @@ impl TypeTermEditor {
},
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 );
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!");
node.send_cmd_obj(
@ -88,11 +83,11 @@ impl TypeTermEditor {
}
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 );
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!");
node.send_cmd_obj(
@ -105,10 +100,10 @@ impl TypeTermEditor {
}
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 mut node = int_edit.into_node();
let int_edit = crate::editors::integer::PosIntEditor::from_u64(node.ctx.clone(), 10, *n as u64);
let node = int_edit.into_node();
editor.write().unwrap().editor.set(node.editor.get());
editor.write().unwrap().cur_node.set(node);
@ -116,7 +111,7 @@ impl TypeTermEditor {
}
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().send_cmd_obj(ReprTree::from_char(&ctx, *c));
@ -158,7 +153,7 @@ impl TypeTermEditor {
node
}
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();
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 {
let buffer = SingletonBuffer::<Option<TypeTerm>>::new( None );
let _buffer = SingletonBuffer::<Option<TypeTerm>>::new( None );
let data = Arc::new(RwLock::new(ReprTree::new(
(&ctx, "( Type )")
)));
let mut editor = TypeTermEditor {
let editor = TypeTermEditor {
ctx: ctx.clone(),
state,
data: data.clone(),

View file

@ -69,7 +69,7 @@ impl MorphismTypePattern {
}
impl From<MorphismType> for MorphismTypePattern {
fn from(mut value: MorphismType) -> MorphismTypePattern {
fn from(value: MorphismType) -> MorphismTypePattern {
fn strip( x: &TypeTerm ) -> TypeID {
match x {
TypeTerm::TypeID(id) => id.clone(),
@ -280,7 +280,7 @@ impl Context {
/* 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_depth = depth;
let _new_depth = depth;
mk_node(
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 {
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() };
/* 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 {
write!(f, "type: {:?}", self.type_tag)?;
for (k,x) in self.branches.iter() {
for (_k,x) in self.branches.iter() {
write!(f, "child: {:?}", x)?;
}

View file

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