fix warnings

This commit is contained in:
Michael Sippel 2022-12-18 01:39:01 +01:00
parent 35498a2fa7
commit 7a24111f08
Signed by: senvas
GPG key ID: F96CF119C34B64A6
23 changed files with 94 additions and 147 deletions

View file

@ -1,21 +1,17 @@
use { use {
crate::{ crate::{
core::{OuterViewPort, ViewPort, Context}, core::{OuterViewPort, Context},
list::{ListEditor},
sequence::{SequenceView, SequenceViewExt},
singleton::{SingletonBuffer, SingletonView}, singleton::{SingletonBuffer, SingletonView},
terminal::{ terminal::{
TerminalAtom, TerminalEditor, TerminalEditorResult, TerminalEvent, TerminalStyle, TerminalAtom,
TerminalView, TerminalEvent,
TerminalStyle
}, },
tree::{TreeCursor, TreeNav, TreeNavResult}, tree::NestedNode, Commander
diagnostics::Diagnostics,
Nested, tree::NestedNode, Commander
}, },
std::sync::Arc, std::sync::Arc,
std::sync::RwLock, std::sync::RwLock,
termion::event::{Event, Key}, termion::event::{Event, Key}
cgmath::Vector2
}; };
pub struct CharEditor { pub struct CharEditor {

View file

@ -296,7 +296,7 @@ impl Context {
} }
pub fn get_editor_ctor(&self, ty: &TypeTerm) -> Option<Arc<dyn Fn(Arc<RwLock<Self>>, TypeTerm, usize) -> Option<Arc<RwLock<dyn Nested + Send + Sync>>> + Send + Sync>> { pub fn get_editor_ctor(&self, ty: &TypeTerm) -> Option<Arc<dyn Fn(Arc<RwLock<Self>>, TypeTerm, usize) -> Option<Arc<RwLock<dyn Nested + Send + Sync>>> + Send + Sync>> {
if let TypeTerm::Type{ id, args } = ty.clone() { if let TypeTerm::Type{ id, args: _ } = ty.clone() {
if let Some(m) = self.editor_ctors.get(&id).cloned() { if let Some(m) = self.editor_ctors.get(&id).cloned() {
Some(m) Some(m)
} else { } else {

View file

@ -1,7 +1,7 @@
use { use {
crate::{ crate::{
core::{OuterViewPort, ViewPort}, core::{OuterViewPort},
sequence::{SequenceView, SequenceViewExt, decorator::{PTYSeqDecorate, SeqDecorStyle}}, sequence::{SequenceView},
vec::{VecBuffer}, vec::{VecBuffer},
index::{buffer::IndexBuffer}, index::{buffer::IndexBuffer},
terminal::{ terminal::{
@ -28,13 +28,13 @@ pub fn make_error(msg: OuterViewPort<dyn TerminalView>) -> Message {
mb.insert_iter(vec![ mb.insert_iter(vec![
(Point2::new(0, 0), (Point2::new(0, 0),
make_label("error: ") make_label("error: ")
.map_item(|p,a| a .map_item(|_p,a| a
.add_style_back(TerminalStyle::bold(true)) .add_style_back(TerminalStyle::bold(true))
.add_style_back(TerminalStyle::fg_color((200,0,0)))) .add_style_back(TerminalStyle::fg_color((200,0,0))))
), ),
(Point2::new(1, 0), (Point2::new(1, 0),
msg msg
.map_item(|p,a| a .map_item(|_p,a| a
.add_style_back(TerminalStyle::fg_color((180,180,180)))) .add_style_back(TerminalStyle::fg_color((180,180,180))))
) )
]); ]);
@ -50,13 +50,13 @@ pub fn make_warn(msg: OuterViewPort<dyn TerminalView>) -> Message {
mb.insert_iter(vec![ mb.insert_iter(vec![
(Point2::new(0, 0), (Point2::new(0, 0),
make_label("warning: ") make_label("warning: ")
.map_item(|p,a| a .map_item(|_p,a| a
.add_style_back(TerminalStyle::bold(true)) .add_style_back(TerminalStyle::bold(true))
.add_style_back(TerminalStyle::fg_color((200,200,0)))) .add_style_back(TerminalStyle::fg_color((200,200,0))))
), ),
(Point2::new(1, 0), (Point2::new(1, 0),
msg msg
.map_item(|p,a| a .map_item(|_p,a| a
.add_style_back(TerminalStyle::fg_color((180,180,180)))) .add_style_back(TerminalStyle::fg_color((180,180,180))))
) )
]); ]);
@ -72,13 +72,13 @@ pub fn make_todo(msg: OuterViewPort<dyn TerminalView>) -> Message {
mb.insert_iter(vec![ mb.insert_iter(vec![
(Point2::new(0, 0), (Point2::new(0, 0),
make_label("todo: ") make_label("todo: ")
.map_item(|p,a| a .map_item(|_p,a| a
.add_style_back(TerminalStyle::bold(true)) .add_style_back(TerminalStyle::bold(true))
.add_style_back(TerminalStyle::fg_color((180,180,250)))) .add_style_back(TerminalStyle::fg_color((180,180,250))))
), ),
(Point2::new(1, 0), (Point2::new(1, 0),
msg msg
.map_item(|p,a| a .map_item(|_p,a| a
.add_style_back(TerminalStyle::fg_color((180,180,180)))) .add_style_back(TerminalStyle::fg_color((180,180,180))))
) )
]); ]);

View file

@ -1,6 +1,6 @@
use { use {
crate::{ crate::{
core::{InnerViewPort, Observer, ObserverBroadcast, OuterViewPort, View, ViewPort, port::UpdateTask}, core::{InnerViewPort, Observer, ObserverBroadcast, OuterViewPort, View, ViewPort},
grid::{GridView, GridWindowIterator}, grid::{GridView, GridWindowIterator},
index::{IndexArea, IndexView}, index::{IndexArea, IndexView},
projection::ProjectionHelper, projection::ProjectionHelper,
@ -174,8 +174,8 @@ where
for chunk_idx in GridWindowIterator::from(top_range.clone()) { for chunk_idx in GridWindowIterator::from(top_range.clone()) {
if let Some(chunk) = self.chunks.get_mut(&chunk_idx) { if let Some(chunk) = self.chunks.get_mut(&chunk_idx) {
let old_offset = chunk.offset; let _old_offset = chunk.offset;
let old_limit = chunk.limit; let _old_limit = chunk.limit;
//chunk.limit = Point2::new( col_widths[chunk_idx.x as usize]-1, row_heights[chunk_idx.y as usize]-1 ); //chunk.limit = Point2::new( col_widths[chunk_idx.x as usize]-1, row_heights[chunk_idx.y as usize]-1 );
chunk.limit = *chunk.view.area().range().end(); chunk.limit = *chunk.view.area().range().end();

View file

@ -1,6 +1,6 @@
use { use {
crate::{ crate::{
core::{InnerViewPort, OuterViewPort, ViewPort, Observer, ObserverBroadcast, View}, core::{InnerViewPort, OuterViewPort, ViewPort, View},
index::{IndexArea, IndexView}, index::{IndexArea, IndexView},
}, },
std::sync::RwLock, std::sync::RwLock,

View file

@ -1,6 +1,6 @@
use { use {
crate::{ crate::{
core::{OuterViewPort, ViewPort}, core::{OuterViewPort},
list::{PTYListEditor}, list::{PTYListEditor},
sequence::{SequenceView, SequenceViewExt, decorator::{PTYSeqDecorate, SeqDecorStyle}}, sequence::{SequenceView, SequenceViewExt, decorator::{PTYSeqDecorate, SeqDecorStyle}},
singleton::{SingletonBuffer, SingletonView}, singleton::{SingletonBuffer, SingletonView},
@ -77,7 +77,7 @@ impl TerminalEditor for DigitEditor {
mb.insert_iter(vec![ mb.insert_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))))),
(Point2::new(3, 0), make_label("'")) (Point2::new(3, 0), make_label("'"))
]); ]);
self.msg.push(crate::diagnostics::make_error(mb.get_port().flatten())); self.msg.push(crate::diagnostics::make_error(mb.get_port().flatten()));

View file

@ -2,23 +2,19 @@ use {
crate::{ crate::{
core::{OuterViewPort, ViewPort}, core::{OuterViewPort, ViewPort},
list::{ list::{
ListCursor, ListCursorMode, ListCursor,
ListSegment, ListSegmentSequence, ListSegment, ListSegmentSequence,
segment::PTYSegment segment::PTYSegment
}, },
sequence::{SequenceView}, sequence::{SequenceView},
singleton::{SingletonBuffer, SingletonView}, singleton::{SingletonBuffer, SingletonView},
terminal::{ terminal::{
make_label, TerminalEditor, TerminalEditorResult, TerminalEvent, TerminalStyle,
TerminalView, TerminalView,
}, },
Nested, Nested,
tree::{TreeCursor, TreeNav, TreeNavResult}, vec::VecBuffer
vec::VecBuffer,
color::{bg_style_from_depth, fg_style_from_depth}
}, },
std::sync::{Arc, RwLock}, std::sync::{Arc, RwLock},
termion::event::{Event, Key},
}; };
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> //<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>

View file

@ -1,24 +1,12 @@
use { use {
crate::{ crate::{
core::{OuterViewPort, ViewPort},
list::{ list::{
ListCursor, ListCursorMode, ListCursor, ListCursorMode,
ListSegment, ListSegmentSequence,
ListEditor ListEditor
}, },
sequence::SequenceView,
singleton::{SingletonBuffer, SingletonView},
terminal::{
make_label, TerminalEditor, TerminalEditorResult, TerminalEvent, TerminalStyle,
TerminalView,
},
tree::{TreeCursor, TreeNav, TreeNavResult}, tree::{TreeCursor, TreeNav, TreeNavResult},
vec::VecBuffer,
color::{bg_style_from_depth, fg_style_from_depth},
Nested Nested
}, },
std::sync::{Arc, RwLock},
termion::event::{Event, Key},
cgmath::Vector2 cgmath::Vector2
}; };

View file

@ -1,21 +1,17 @@
use { use {
crate::{ crate::{
core::{OuterViewPort, ViewPort, TypeTerm}, core::{OuterViewPort},
list::{ list::{
ListCursor, ListCursorMode, ListCursor, ListCursorMode,
ListSegment, ListSegmentSequence,
ListEditor ListEditor
}, },
sequence::{SequenceView, decorator::{SeqDecorStyle, PTYSeqDecorate}}, sequence::{SequenceView, decorator::{SeqDecorStyle, PTYSeqDecorate}},
singleton::{SingletonBuffer, SingletonView},
terminal::{ terminal::{
make_label, TerminalEditor, TerminalEditorResult, TerminalEvent, TerminalStyle, TerminalEditor, TerminalEditorResult, TerminalEvent,
TerminalView, TerminalView,
}, },
tree::{TreeCursor, TreeNav, TreeNavResult}, tree::{TreeCursor, TreeNav, TreeNavResult},
diagnostics::{Diagnostics}, diagnostics::{Diagnostics},
vec::VecBuffer,
color::{bg_style_from_depth, fg_style_from_depth},
Nested Nested
}, },
std::sync::{Arc, RwLock}, std::sync::{Arc, RwLock},
@ -287,7 +283,6 @@ where ItemEditor: Nested + ?Sized + Send + Sync + 'static
{} {}
use crate::{ use crate::{
char_editor::CharEditor,
sequence::SequenceViewExt, sequence::SequenceViewExt,
StringGen StringGen
}; };

View file

@ -98,7 +98,7 @@ where ItemEditor: Nested + ?Sized + Send + Sync + 'static
fn get(&self, idx: &usize) -> Option<Self::Item> { fn get(&self, idx: &usize) -> Option<Self::Item> {
let c = self.cursor.get(); let c = self.cursor.get();
Some(if let Some(mut cur) = c.idx { Some(if let Some(cur) = c.idx {
match c.mode { match c.mode {
ListCursorMode::Select => { ListCursorMode::Select => {
ListSegment::Item { ListSegment::Item {
@ -158,7 +158,7 @@ where ItemEditor: Nested + ?Sized + Send + Sync + 'static
}), }),
data: proj_helper.new_sequence_arg(1, data_port, |s: &mut Self, idx| { data: proj_helper.new_sequence_arg(1, data_port, |s: &mut Self, idx| {
if let Some(mut cur_idx) = s.cur_cursor.idx { if let Some(cur_idx) = s.cur_cursor.idx {
match s.cur_cursor.mode { match s.cur_cursor.mode {
ListCursorMode::Insert => { ListCursorMode::Insert => {
if *idx < cur_idx as usize { if *idx < cur_idx as usize {

View file

@ -1,27 +1,22 @@
use { use {
crate::{ crate::{
core::{TypeTerm, TypeLadder, Context, OuterViewPort}, core::{TypeTerm, Context},
terminal::{TerminalView, TerminalEditor, TerminalEvent, TerminalEditorResult, make_label},
tree::{TreeNav},
integer::PosIntEditor, integer::PosIntEditor,
list::{ListEditor, PTYListEditor}, list::{PTYListEditor},
sequence::{decorator::{SeqDecorStyle}}, sequence::{decorator::{SeqDecorStyle}},
product::editor::ProductEditor,
sum::SumEditor, sum::SumEditor,
char_editor::CharEditor, char_editor::CharEditor,
diagnostics::Diagnostics,
Nested Nested
}, },
cgmath::{Vector2, Point2},
std::sync::{Arc, RwLock}, std::sync::{Arc, RwLock},
}; };
pub fn init_editor_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> { pub fn init_editor_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> {
let mut ctx = Arc::new(RwLock::new(Context::with_parent(Some(parent)))); let ctx = Arc::new(RwLock::new(Context::with_parent(Some(parent))));
ctx.write().unwrap().add_editor_ctor( ctx.write().unwrap().add_editor_ctor(
"Char", Arc::new( "Char", Arc::new(
|ctx: Arc<RwLock<Context>>, ty: TypeTerm, _depth: usize| { |ctx: Arc<RwLock<Context>>, _ty: TypeTerm, _depth: usize| {
Some( Some(
Arc::new(RwLock::new(CharEditor::new_node(&ctx))) Arc::new(RwLock::new(CharEditor::new_node(&ctx)))
as Arc<RwLock<dyn Nested + Send + Sync>>) as Arc<RwLock<dyn Nested + Send + Sync>>)
@ -34,7 +29,7 @@ pub fn init_editor_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> {
|ctx: Arc<RwLock<Context>>, ty: TypeTerm, depth: usize| { |ctx: Arc<RwLock<Context>>, ty: TypeTerm, depth: usize| {
match ty { match ty {
TypeTerm::Type { TypeTerm::Type {
id, args id: _, args
} => { } => {
if args.len() > 0 { if args.len() > 0 {
// todo: factor style out of type arGS // todo: factor style out of type arGS
@ -93,7 +88,7 @@ pub fn init_editor_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> {
ctx.write().unwrap().add_editor_ctor( ctx.write().unwrap().add_editor_ctor(
"Symbol", Arc::new( "Symbol", Arc::new(
|ctx: Arc<RwLock<Context>>, ty: TypeTerm, depth: usize| { |ctx: Arc<RwLock<Context>>, _ty: TypeTerm, depth: usize| {
Context::make_editor( Context::make_editor(
ctx.clone(), ctx.clone(),
ctx.read().unwrap().type_term_from_str("( List Char 0 )").unwrap(), ctx.read().unwrap().type_term_from_str("( List Char 0 )").unwrap(),
@ -105,7 +100,7 @@ pub fn init_editor_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> {
ctx.write().unwrap().add_editor_ctor( ctx.write().unwrap().add_editor_ctor(
"String", Arc::new( "String", Arc::new(
|ctx: Arc<RwLock<Context>>, ty: TypeTerm, depth: usize| { |ctx: Arc<RwLock<Context>>, _ty: TypeTerm, depth: usize| {
Context::make_editor( Context::make_editor(
ctx.clone(), ctx.clone(),
ctx.read().unwrap().type_term_from_str("( List Char 3 )").unwrap(), ctx.read().unwrap().type_term_from_str("( List Char 3 )").unwrap(),
@ -117,7 +112,7 @@ pub fn init_editor_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> {
ctx.write().unwrap().add_editor_ctor( ctx.write().unwrap().add_editor_ctor(
"TypeTerm", Arc::new( "TypeTerm", Arc::new(
|ctx: Arc<RwLock<Context>>, ty: TypeTerm, depth: usize| { |ctx: Arc<RwLock<Context>>, _ty: TypeTerm, depth: usize| {
let mut s = SumEditor::new( let mut s = SumEditor::new(
vec![ vec![
Context::make_editor(ctx.clone(), ctx.read().unwrap().type_term_from_str("( Symbol )").unwrap(), depth+1).unwrap(), Context::make_editor(ctx.clone(), ctx.read().unwrap().type_term_from_str("( Symbol )").unwrap(), depth+1).unwrap(),
@ -140,17 +135,17 @@ pub fn init_editor_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> {
} }
pub fn init_math_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> { pub fn init_math_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> {
let mut ctx = Arc::new(RwLock::new(Context::with_parent(Some(parent)))); let ctx = Arc::new(RwLock::new(Context::with_parent(Some(parent))));
ctx.write().unwrap().add_typename("MachineInt".into()); ctx.write().unwrap().add_typename("MachineInt".into());
ctx.write().unwrap().add_typename("Digit".into()); ctx.write().unwrap().add_typename("Digit".into());
ctx.write().unwrap().add_typename("BigEndian".into()); ctx.write().unwrap().add_typename("BigEndian".into());
ctx.write().unwrap().add_editor_ctor( ctx.write().unwrap().add_editor_ctor(
"PosInt", Arc::new( "PosInt", Arc::new(
|ctx: Arc<RwLock<Context>>, ty: TypeTerm, _depth: usize| { |_ctx: Arc<RwLock<Context>>, ty: TypeTerm, _depth: usize| {
match ty { match ty {
TypeTerm::Type { TypeTerm::Type {
id, args id: _, args
} => { } => {
if args.len() > 0 { if args.len() > 0 {
match args[0] { match args[0] {
@ -176,11 +171,11 @@ pub fn init_math_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> {
} }
pub fn init_os_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> { pub fn init_os_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> {
let mut ctx = Arc::new(RwLock::new(Context::with_parent(Some(parent)))); let ctx = Arc::new(RwLock::new(Context::with_parent(Some(parent))));
ctx.write().unwrap().add_editor_ctor( ctx.write().unwrap().add_editor_ctor(
"PathSegment", Arc::new( "PathSegment", Arc::new(
|ctx: Arc<RwLock<Context>>, ty: TypeTerm, depth: usize| { |ctx: Arc<RwLock<Context>>, _ty: TypeTerm, depth: usize| {
Context::make_editor( Context::make_editor(
ctx.clone(), ctx.clone(),
ctx.read().unwrap().type_term_from_str("( List Char 0 )").unwrap(), ctx.read().unwrap().type_term_from_str("( List Char 0 )").unwrap(),
@ -192,7 +187,7 @@ pub fn init_os_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> {
ctx.write().unwrap().add_editor_ctor( ctx.write().unwrap().add_editor_ctor(
"Path", Arc::new( "Path", Arc::new(
|ctx: Arc<RwLock<Context>>, ty: TypeTerm, depth: usize| { |ctx: Arc<RwLock<Context>>, _ty: TypeTerm, depth: usize| {
Context::make_editor( Context::make_editor(
ctx.clone(), ctx.clone(),
ctx.read().unwrap().type_term_from_str("( List PathSegment 6 )").unwrap(), ctx.read().unwrap().type_term_from_str("( List PathSegment 6 )").unwrap(),

View file

@ -1,24 +1,24 @@
use { use {
crate::{ crate::{
core::{ViewPort, OuterViewPort, TypeLadder, Context}, core::{OuterViewPort, TypeLadder, Context},
terminal::{ terminal::{
TerminalEditor, TerminalEditorResult, TerminalEditor, TerminalEditorResult,
TerminalEvent, TerminalView TerminalEvent, TerminalView
}, },
vec::{VecBuffer, MutableVecAccess}, vec::{VecBuffer},
index::{buffer::{IndexBuffer, MutableIndexAccess}, IndexView}, index::{buffer::{IndexBuffer, MutableIndexAccess}},
list::ListCursorMode, list::ListCursorMode,
product::{segment::ProductEditorSegment}, product::{segment::ProductEditorSegment},
sequence::{SequenceView}, sequence::{SequenceView},
tree::{TreeNav, TreeNavResult}, tree::{TreeNav, TreeNavResult},
diagnostics::{Diagnostics, Message}, diagnostics::{Diagnostics},
terminal::{TerminalStyle}, terminal::{TerminalStyle},
Nested Nested
}, },
cgmath::{Vector2, Point2}, cgmath::{Point2},
std::sync::{Arc, RwLock}, std::sync::{Arc, RwLock},
termion::event::{Event, Key}, termion::event::{Event, Key},
std::ops::{Deref, DerefMut} std::ops::{DerefMut}
}; };
pub struct ProductEditor { pub struct ProductEditor {
@ -155,7 +155,7 @@ impl ProductEditor {
self.msg_buf.update(idx as usize, Some(b.get_port().to_sequence().map( self.msg_buf.update(idx as usize, Some(b.get_port().to_sequence().map(
|msg| { |msg| {
let mut msg = msg.clone(); let mut msg = msg.clone();
msg.port = msg.port.map_item(|p,a| a.add_style_back(TerminalStyle::bg_color((40,40,40)))); msg.port = msg.port.map_item(|_p,a| a.add_style_back(TerminalStyle::bg_color((40,40,40))));
msg msg
} }
))); )));
@ -189,7 +189,7 @@ impl TerminalEditor 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();
if let Some(e) = editor.clone() { if let Some(e) = editor.clone() {
@ -227,7 +227,6 @@ impl TerminalEditor for ProductEditor {
} }
} else { } else {
unreachable!(); unreachable!();
TerminalEditorResult::Exit
} }
} else { } else {
TerminalEditorResult::Exit TerminalEditorResult::Exit

View file

@ -6,9 +6,8 @@ use {
product::{segment::ProductEditorSegment, ProductEditor}, product::{segment::ProductEditorSegment, ProductEditor},
Nested Nested
}, },
cgmath::{Point2, Vector2}, cgmath::{Vector2},
std::{sync::{Arc, RwLock}, ops::{Deref, DerefMut}}, std::{ops::{DerefMut}},
termion::event::{Event, Key},
}; };
impl TreeNav for ProductEditor { impl TreeNav for ProductEditor {
@ -56,7 +55,7 @@ impl TreeNav for ProductEditor {
let old_cursor = self.cursor; let old_cursor = self.cursor;
if let Some(mut segment) = self.get_cur_segment_mut() { if let Some(mut segment) = self.get_cur_segment_mut() {
if let Some(ProductEditorSegment::N{ t: _t, editor, ed_depth, cur_depth, cur_dist:_ }) = segment.deref_mut() { if let Some(ProductEditorSegment::N{ t: _t, editor, ed_depth: _, cur_depth: _, cur_dist:_ }) = segment.deref_mut() {
if let Some(e) = editor { if let Some(e) = editor {
let mut e = e.write().unwrap(); let mut e = e.write().unwrap();
e.goto(TreeCursor::none()); e.goto(TreeCursor::none());
@ -67,7 +66,7 @@ impl TreeNav for ProductEditor {
if c.tree_addr.len() > 0 { if c.tree_addr.len() > 0 {
self.cursor = Some(crate::modulo(c.tree_addr.remove(0), self.n_indices.len() as isize)); self.cursor = Some(crate::modulo(c.tree_addr.remove(0), self.n_indices.len() as isize));
if let Some(mut element) = self.get_cur_segment_mut() { if let Some(mut element) = self.get_cur_segment_mut() {
if let Some(ProductEditorSegment::N{ t, editor, ed_depth, cur_depth, cur_dist:_ }) = element.deref_mut() { if let Some(ProductEditorSegment::N{ t, editor, ed_depth, cur_depth: _, cur_dist:_ }) = element.deref_mut() {
if let Some(e) = editor { if let Some(e) = editor {
e.write().unwrap().goto(c.clone()); e.write().unwrap().goto(c.clone());
} else if c.tree_addr.len() > 0 { } else if c.tree_addr.len() > 0 {
@ -90,7 +89,7 @@ impl TreeNav for ProductEditor {
TreeNavResult::Continue TreeNavResult::Continue
} else { } else {
if let Some(mut ed) = self.get_cur_editor() { if let Some(ed) = self.get_cur_editor() {
ed.write().unwrap().goto(TreeCursor::none()); ed.write().unwrap().goto(TreeCursor::none());
} }
@ -124,7 +123,7 @@ impl TreeNav for ProductEditor {
if direction.y > 0 { if direction.y > 0 {
// dn // dn
if let Some(mut element) = self.get_cur_segment_mut() { if let Some(mut element) = self.get_cur_segment_mut() {
if let Some(ProductEditorSegment::N{ t, editor, ed_depth, cur_depth, cur_dist:_ }) = element.deref_mut() { if let Some(ProductEditorSegment::N{ t, editor, ed_depth, cur_depth: _, cur_dist:_ }) = element.deref_mut() {
if let Some(e) = editor { if let Some(e) = editor {
let mut e = e.write().unwrap(); let mut e = e.write().unwrap();
e.goby(direction); e.goby(direction);
@ -175,7 +174,7 @@ impl TreeNav for ProductEditor {
let old_cursor = self.cursor; let old_cursor = self.cursor;
let nav_result = let nav_result =
if let Some(mut element) = self.get_cur_segment_mut() { if let Some(mut element) = self.get_cur_segment_mut() {
if let Some(ProductEditorSegment::N{ t, editor, ed_depth, cur_depth, cur_dist:_ }) = element.deref_mut() { if let Some(ProductEditorSegment::N{ t: _, editor, ed_depth: _, cur_depth, cur_dist:_ }) = element.deref_mut() {
if let Some(e) = editor { if let Some(e) = editor {
let mut ce = e.write().unwrap(); let mut ce = e.write().unwrap();
//\\//\\//\\//\\ //\\//\\//\\//\\
@ -193,7 +192,6 @@ impl TreeNav for ProductEditor {
TreeNavResult::Continue TreeNavResult::Continue
} else { } else {
panic!("unplausible direction.y on exit"); panic!("unplausible direction.y on exit");
TreeNavResult::Continue
} }
} else if direction.y > 0 { } else if direction.y > 0 {
// dn // dn

View file

@ -2,15 +2,13 @@ use {
crate::{ crate::{
core::{OuterViewPort, TypeLadder, Context}, core::{OuterViewPort, TypeLadder, Context},
terminal::{ terminal::{
TerminalEditor, TerminalStyle, TerminalView, TerminalStyle, TerminalView,
make_label make_label
}, },
list::{ListCursorMode},
color::{bg_style_from_depth, fg_style_from_depth}, color::{bg_style_from_depth, fg_style_from_depth},
Nested Nested
}, },
std::{sync::{Arc, RwLock}, ops::{Deref, DerefMut}}, std::{sync::{Arc, RwLock}},
termion::event::{Event, Key},
}; };
#[derive(Clone)] #[derive(Clone)]
@ -32,12 +30,12 @@ impl ProductEditorSegment {
make_label(t.as_str()) make_label(t.as_str())
.map_item({ .map_item({
let depth = *depth; let depth = *depth;
move |i, x| move |_i, x|
x.add_style_back(fg_style_from_depth(depth)).add_style_back(TerminalStyle::italic(true)) x.add_style_back(fg_style_from_depth(depth)).add_style_back(TerminalStyle::italic(true))
} }
), ),
ProductEditorSegment::N { t: _, editor: Some(e), ed_depth, cur_depth, cur_dist } => ProductEditorSegment::N { t: _, editor: Some(e), ed_depth, cur_depth: _, cur_dist } =>
e.read().unwrap() e.read().unwrap()
.get_term_view() .get_term_view()
.map_item({ .map_item({
@ -45,7 +43,7 @@ impl ProductEditorSegment {
let d = *ed_depth; let d = *ed_depth;
let cur_dist = *cur_dist; let cur_dist = *cur_dist;
move |i, x| { move |_i, x| {
let c = e.read().unwrap().get_cursor(); let c = e.read().unwrap().get_cursor();
let cur_depth = c.tree_addr.len(); let cur_depth = c.tree_addr.len();
let select = let select =
@ -65,11 +63,11 @@ impl ProductEditorSegment {
ProductEditorSegment::N{ t, editor: None, ed_depth, cur_depth, cur_dist } => ProductEditorSegment::N{ t, editor: None, ed_depth, cur_depth, cur_dist } =>
make_label(&ctx.read().unwrap().type_term_to_str(&t[0])) make_label(&ctx.read().unwrap().type_term_to_str(&t[0]))
.map_item({ .map_item({
let cur_depth = *cur_depth; let _cur_depth = *cur_depth;
let ed_depth = *ed_depth; let _ed_depth = *ed_depth;
let cur_dist = *cur_dist; let cur_dist = *cur_dist;
move |i, x| move |_i, x|
x.add_style_back(TerminalStyle::fg_color((215,140,95))) x.add_style_back(TerminalStyle::fg_color((215,140,95)))
.add_style_back(bg_style_from_depth(if cur_dist == 0 { 0 } else { usize::MAX })) .add_style_back(bg_style_from_depth(if cur_dist == 0 { 0 } else { usize::MAX }))
.add_style_back(TerminalStyle::bold(cur_dist == 0)) .add_style_back(TerminalStyle::bold(cur_dist == 0))

View file

@ -195,7 +195,7 @@ impl PTYSeqDecorate for OuterViewPort<dyn SequenceView<Item = OuterViewPort<dyn
fn pty_decorate( fn pty_decorate(
&self, &self,
style: SeqDecorStyle, style: SeqDecorStyle,
depth: usize _depth: usize
) -> OuterViewPort<dyn TerminalView> { ) -> OuterViewPort<dyn TerminalView> {
match style { match style {
SeqDecorStyle::Plain => self SeqDecorStyle::Plain => self

View file

@ -1,6 +1,6 @@
use { use {
crate::{ crate::{
core::{InnerViewPort, OuterViewPort, Observer, ObserverBroadcast, View, ViewPort}, core::{InnerViewPort, OuterViewPort, View, ViewPort},
singleton::SingletonView, singleton::SingletonView,
}, },
std::sync::RwLock, std::sync::RwLock,

View file

@ -1,24 +1,18 @@
use { use {
crate::{ crate::{
core::{ViewPort, OuterViewPort, TypeLadder, Context}, core::{ViewPort, OuterViewPort},
terminal::{ terminal::{
TerminalEditor, TerminalEditorResult, TerminalEditor, TerminalEditorResult,
TerminalEvent, TerminalView TerminalEvent, TerminalView
}, },
vec::{VecBuffer, MutableVecAccess},
index::{buffer::{IndexBuffer, MutableIndexAccess}, IndexView},
list::ListCursorMode,
product::{segment::ProductEditorSegment},
sequence::{SequenceView}, sequence::{SequenceView},
tree::{TreeNav, TreeCursor, TreeNavResult}, tree::{TreeNav, TreeCursor, TreeNavResult},
diagnostics::{Diagnostics, Message}, diagnostics::{Diagnostics, Message},
terminal::{TerminalStyle},
Nested Nested
}, },
cgmath::{Vector2, Point2}, cgmath::{Vector2},
std::sync::{Arc, RwLock}, std::sync::{Arc, RwLock},
termion::event::{Event, Key}, termion::event::{Key}
std::ops::{Deref, DerefMut}
}; };
pub struct SumEditor { pub struct SumEditor {

View file

@ -1,6 +1,5 @@
use { use {
crate::list::ListCursorMode, crate::list::ListCursorMode
cgmath::Vector2
}; };
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> //<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>

View file

@ -36,7 +36,7 @@ pub trait TreeNav {
0 0
} }
fn goby(&mut self, direction: Vector2<isize>) -> TreeNavResult { fn goby(&mut self, _direction: Vector2<isize>) -> TreeNavResult {
TreeNavResult::Exit TreeNavResult::Exit
} }

View file

@ -3,12 +3,11 @@ use {
cgmath::Vector2, cgmath::Vector2,
crate::{ crate::{
core::{ViewPort, OuterViewPort, AnyOuterViewPort, context::ReprTree, Context}, core::{ViewPort, OuterViewPort, AnyOuterViewPort, context::ReprTree, Context},
singleton::{SingletonView, SingletonBuffer}, singleton::{SingletonBuffer},
sequence::SequenceView, sequence::SequenceView,
terminal::{TerminalView, TerminalEvent, TerminalEditor, TerminalEditorResult}, terminal::{TerminalView, TerminalEvent, TerminalEditor, TerminalEditorResult},
diagnostics::{Diagnostics, Message}, diagnostics::{Diagnostics, Message},
tree::{TreeNav, TreeCursor, TreeNavResult}, tree::{TreeNav, TreeCursor, TreeNavResult}, ObjCommander,
Commander, ObjCommander,
Nested Nested
}, },
}; };

View file

@ -1,6 +1,6 @@
use { use {
crate::{ crate::{
core::{ViewPort, OuterViewPort, TypeLadder, Context}, core::{OuterViewPort, Context},
terminal::{TerminalEvent, TerminalView, TerminalEditor, TerminalEditorResult}, terminal::{TerminalEvent, TerminalView, TerminalEditor, TerminalEditorResult},
sequence::{SequenceView, decorator::SeqDecorStyle}, sequence::{SequenceView, decorator::SeqDecorStyle},
list::{PTYListEditor}, list::{PTYListEditor},
@ -11,11 +11,10 @@ use {
integer::PosIntEditor, integer::PosIntEditor,
Nested Nested
}, },
cgmath::{Vector2, Point2}, cgmath::{Vector2},
termion::event::{Event, Key}, termion::event::{Key},
std::{ std::{
sync::{Arc, RwLock}, sync::{Arc, RwLock}
any::Any
} }
}; };
@ -114,7 +113,7 @@ impl TerminalEditor for TypeTermEditor {
}, },
_ => { _ => {
if *c == '(' { if *c == '(' {
let mut child = Arc::new(RwLock::new(TypeTermEditor { let _child = Arc::new(RwLock::new(TypeTermEditor {
ty: self.ty.clone(), ty: self.ty.clone(),
node: SumEditor::new( node: SumEditor::new(
vec![ vec![

View file

@ -1,6 +1,6 @@
use { use {
crate::{ crate::{
core::{InnerViewPort, OuterViewPort, Observer, ObserverBroadcast, View, ViewPort}, core::{InnerViewPort, OuterViewPort, View, ViewPort},
vec::VecDiff, vec::VecDiff,
}, },
std::sync::RwLock, std::sync::RwLock,

View file

@ -8,29 +8,20 @@ mod pty;
mod plot; mod plot;
use { use {
crate::{
// process::ProcessLauncher,
// command::Commander
},
cgmath::{Point2, Vector2}, cgmath::{Point2, Vector2},
nested::{ nested::{
core::{port::UpdateTask, Observer, OuterViewPort, AnyOuterViewPort, View, ViewPort, Context, TypeTerm, ReprTree}, core::{port::UpdateTask, Observer, AnyOuterViewPort, ViewPort, Context, ReprTree},
index::IndexArea, index::IndexArea,
list::{ListCursorMode, PTYListEditor}, list::{ListCursorMode, PTYListEditor},
sequence::{SequenceView, decorator::{SeqDecorStyle, Separate}}, sequence::{decorator::{SeqDecorStyle}},
terminal::{ terminal::{
make_label, Terminal, TerminalAtom, TerminalCompositor, TerminalEditor, make_label, Terminal, TerminalAtom, TerminalCompositor, TerminalEditor,
TerminalEditorResult, TerminalEvent, TerminalStyle, TerminalView, TerminalEditorResult, TerminalEvent, TerminalStyle,
}, },
tree::{TreeNav, TreeCursor, TreeNavResult}, tree::{TreeNav, TreeCursor, TreeNavResult},
vec::VecBuffer, vec::VecBuffer,
integer::{PosIntEditor},
char_editor::CharEditor,
product::ProductEditor,
sum::SumEditor,
diagnostics::{Diagnostics}, diagnostics::{Diagnostics},
index::{buffer::IndexBuffer}, index::{buffer::IndexBuffer}
Nested
}, },
std::sync::{Arc, RwLock}, std::sync::{Arc, RwLock},
termion::event::{Event, Key}, termion::event::{Event, Key},
@ -44,7 +35,7 @@ async fn main() {
let mut term = Terminal::new(term_port.outer()); let mut term = Terminal::new(term_port.outer());
let term_writer = term.get_writer(); let term_writer = term.get_writer();
let mut portmutex = Arc::new(RwLock::new(())); let portmutex = Arc::new(RwLock::new(()));
// Update Loop // // Update Loop //
let tp = term_port.clone(); let tp = term_port.clone();
@ -53,7 +44,7 @@ async fn main() {
async move { async move {
loop { loop {
{ {
let l = portmutex.write().unwrap(); let _l = portmutex.write().unwrap();
tp.update(); tp.update();
} }
async_std::task::sleep(std::time::Duration::from_millis(10)).await; async_std::task::sleep(std::time::Duration::from_millis(10)).await;
@ -67,12 +58,12 @@ async fn main() {
let ctx = nested::make_editor::init_math_ctx(ctx); let ctx = nested::make_editor::init_math_ctx(ctx);
let ctx = nested::make_editor::init_os_ctx(ctx); let ctx = nested::make_editor::init_os_ctx(ctx);
let mut vb = VecBuffer::<char>::new(); let vb = VecBuffer::<char>::new();
let mut rt_char = ReprTree::new_leaf( let rt_char = ReprTree::new_leaf(
ctx.read().unwrap().type_term_from_str("( List Char )").unwrap(), ctx.read().unwrap().type_term_from_str("( List Char )").unwrap(),
AnyOuterViewPort::from(vb.get_port()) AnyOuterViewPort::from(vb.get_port())
); );
let mut rt_digit = ReprTree::upcast(&rt_char, ctx.read().unwrap().type_term_from_str("( List ( Digit 10 ) )").unwrap()); let rt_digit = ReprTree::upcast(&rt_char, ctx.read().unwrap().type_term_from_str("( List ( Digit 10 ) )").unwrap());
rt_digit.write().unwrap().insert_branch( rt_digit.write().unwrap().insert_branch(
ReprTree::new_leaf( ReprTree::new_leaf(
ctx.read().unwrap().type_term_from_str("( List MachineInt )").unwrap(), ctx.read().unwrap().type_term_from_str("( List MachineInt )").unwrap(),
@ -194,7 +185,7 @@ async fn main() {
let mut b = VecBuffer::new(); let mut b = VecBuffer::new();
b.push( b.push(
make_label("@") make_label("@")
.map_item(|p,a| a .map_item(|_p,a| a
.add_style_back(TerminalStyle::bold(true)) .add_style_back(TerminalStyle::bold(true))
.add_style_back(TerminalStyle::fg_color((120,120,0)))) .add_style_back(TerminalStyle::fg_color((120,120,0))))
); );
@ -202,12 +193,12 @@ async fn main() {
for x in entry.addr.iter() { for x in entry.addr.iter() {
b.push( b.push(
make_label(&format!("{}", x)) make_label(&format!("{}", x))
.map_item(|p,a| a .map_item(|_p,a| a
.add_style_back(TerminalStyle::fg_color((0, 100, 20)))) .add_style_back(TerminalStyle::fg_color((0, 100, 20))))
); );
b.push( b.push(
make_label(".") make_label(".")
.map_item(|p,a| a .map_item(|_p,a| a
.add_style_back(TerminalStyle::bold(true)) .add_style_back(TerminalStyle::bold(true))
.add_style_back(TerminalStyle::fg_color((120,120,0)))) .add_style_back(TerminalStyle::fg_color((120,120,0))))
); );
@ -218,7 +209,7 @@ async fn main() {
.to_sequence() .to_sequence()
.to_grid_horizontal() .to_grid_horizontal()
.flatten() .flatten()
.map_item(move |p,a| { .map_item(move |_p,a| {
let select = false; let select = false;
if select { if select {
a.add_style_back(TerminalStyle::fg_color((60,60,60))) a.add_style_back(TerminalStyle::fg_color((60,60,60)))
@ -231,7 +222,7 @@ async fn main() {
]); ]);
let (w, h) = termion::terminal_size().unwrap(); let (_w, _h) = termion::terminal_size().unwrap();
/* /*
compositor compositor
.write() .write()
@ -251,7 +242,7 @@ async fn main() {
loop { loop {
let ev = term.next_event().await; let ev = term.next_event().await;
let l = portmutex.write().unwrap(); let _l = portmutex.write().unwrap();
if let TerminalEvent::Resize(new_size) = ev { if let TerminalEvent::Resize(new_size) = ev {
cur_size.set(new_size); cur_size.set(new_size);