further file renaming

This commit is contained in:
Michael Sippel 2023-01-02 18:49:32 +01:00
parent 280796ab17
commit 0edbd748a5
Signed by: senvas
GPG key ID: F96CF119C34B64A6
28 changed files with 96 additions and 88 deletions

View file

@ -4,7 +4,8 @@ use {
type_system::{Context}, type_system::{Context},
singleton::{SingletonBuffer, SingletonView}, singleton::{SingletonBuffer, SingletonView},
terminal::{TerminalAtom, TerminalEvent, TerminalStyle}, terminal::{TerminalAtom, TerminalEvent, TerminalStyle},
tree::NestedNode, Commander tree::NestedNode,
commander::Commander
}, },
std::sync::Arc, std::sync::Arc,
std::sync::RwLock, std::sync::RwLock,

31
nested/src/commander.rs Normal file
View file

@ -0,0 +1,31 @@
pub trait Commander {
type Cmd;
fn send_cmd(&mut self, cmd: &Self::Cmd);
}
use std::sync::{Arc, RwLock};
use crate::{
type_system::ReprTree,
singleton::SingletonView
};
pub trait ObjCommander {
fn send_cmd_obj(&mut self, cmd_obj: Arc<RwLock<ReprTree>>);
}
//impl<Cmd: 'static, T: Commander<Cmd>> ObjCommander for T {
impl<C: Commander> ObjCommander for C
where C::Cmd: 'static
{
fn send_cmd_obj(&mut self, cmd_obj: Arc<RwLock<ReprTree>>) {
self.send_cmd(
&cmd_obj.read().unwrap()
.get_port::<dyn SingletonView<Item = C::Cmd>>().unwrap()
.get_view().unwrap()
.get()
);
}
}

View file

@ -43,7 +43,7 @@ impl<V: View + ?Sized, T: Observer<V>> ObserverExt<V> for T {
} }
} }
/*\ /*\
<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> <<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
Broadcast Broadcast
<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> <<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>

View file

@ -15,7 +15,7 @@ use {
diagnostics::{Diagnostics, Message}, diagnostics::{Diagnostics, Message},
tree::NestedNode, tree::NestedNode,
Nested, Nested,
Commander commander::Commander
}, },
std::sync::Arc, std::sync::Arc,
std::sync::RwLock, std::sync::RwLock,

View file

@ -4,10 +4,8 @@
pub mod core; pub mod core;
pub mod type_system; pub mod type_system;
pub mod projection; pub mod projection;
pub mod bimap; pub mod commander;
pub mod modulo; pub mod utils;
pub use modulo::modulo;
// semantics // semantics
pub mod singleton; pub mod singleton;
@ -26,49 +24,16 @@ pub mod tree;
pub mod diagnostics; pub mod diagnostics;
// high-level types // high-level types
pub mod char_editor; pub mod char;
pub mod integer; pub mod integer;
pub mod make_editor;
pub mod type_term_editor;
// display // display
pub mod color;
pub mod terminal; pub mod terminal;
pub fn magic_header() { pub fn magic_header() {
eprintln!("<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>"); eprintln!("<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>");
} }
pub trait Commander {
type Cmd;
fn send_cmd(&mut self, cmd: &Self::Cmd);
}
use std::sync::{Arc, RwLock};
use crate::{
type_system::ReprTree,
singleton::SingletonView
};
pub trait ObjCommander {
fn send_cmd_obj(&mut self, cmd_obj: Arc<RwLock<ReprTree>>);
}
//impl<Cmd: 'static, T: Commander<Cmd>> ObjCommander for T {
impl<C: Commander> ObjCommander for C
where C::Cmd: 'static
{
fn send_cmd_obj(&mut self, cmd_obj: Arc<RwLock<ReprTree>>) {
self.send_cmd(
&cmd_obj.read().unwrap()
.get_port::<dyn SingletonView<Item = C::Cmd>>().unwrap()
.get_view().unwrap()
.get()
);
}
}
pub trait StringGen { pub trait StringGen {
fn get_string(&self) -> String; fn get_string(&self) -> String;
} }

View file

@ -67,7 +67,7 @@ impl ListEditor {
pub fn get_item(&self) -> Option<NestedNode> { pub fn get_item(&self) -> Option<NestedNode> {
if let Some(idx) = self.cursor.get().idx { if let Some(idx) = self.cursor.get().idx {
let idx = crate::modulo(idx as isize, self.data.len() as isize) as usize; let idx = crate::utils::modulo(idx as isize, self.data.len() as isize) as usize;
if idx < self.data.len() { if idx < self.data.len() {
Some(self.data.get(idx)) Some(self.data.get(idx))
} else { } else {
@ -79,7 +79,7 @@ impl ListEditor {
} }
pub fn get_item_mut(&mut self) -> Option<MutableVecAccess<NestedNode>> { pub fn get_item_mut(&mut self) -> Option<MutableVecAccess<NestedNode>> {
if let Some(idx) = self.cursor.get().idx { if let Some(idx) = self.cursor.get().idx {
let idx = crate::modulo(idx as isize, self.data.len() as isize) as usize; let idx = crate::utils::modulo(idx as isize, self.data.len() as isize) as usize;
if idx < self.data.len() { if idx < self.data.len() {
Some(self.data.get_mut(idx)) Some(self.data.get_mut(idx))
} else { } else {
@ -108,4 +108,3 @@ impl ListEditor {
self.data.clear(); self.data.clear();
} }
} }

View file

@ -98,7 +98,7 @@ impl TreeNav for ListEditor {
TreeNavResult::Continue TreeNavResult::Continue
} }
1 => { 1 => {
let idx = crate::modulo(new_cur.tree_addr[0], if new_cur.leaf_mode == ListCursorMode::Insert { 1 } else { 0 } + self.data.len() as isize); let idx = crate::utils::modulo(new_cur.tree_addr[0], if new_cur.leaf_mode == ListCursorMode::Insert { 1 } else { 0 } + self.data.len() as isize);
self.cursor.set(ListCursor { self.cursor.set(ListCursor {
mode: new_cur.leaf_mode, mode: new_cur.leaf_mode,
@ -118,7 +118,7 @@ impl TreeNav for ListEditor {
} }
_ => { _ => {
if self.data.len() > 0 { if self.data.len() > 0 {
let idx = crate::modulo(new_cur.tree_addr[0], self.data.len() as isize); let idx = crate::utils::modulo(new_cur.tree_addr[0], self.data.len() as isize);
self.cursor.set(ListCursor { self.cursor.set(ListCursor {
mode: ListCursorMode::Select, mode: ListCursorMode::Select,

View file

@ -14,7 +14,7 @@ use {
tree::{TreeCursor, TreeNav, TreeNavResult}, tree::{TreeCursor, TreeNav, TreeNavResult},
diagnostics::{Diagnostics}, diagnostics::{Diagnostics},
tree::NestedNode, Nested, tree::NestedNode, Nested,
Commander commander::Commander
}, },
std::sync::{Arc, RwLock}, std::sync::{Arc, RwLock},
termion::event::{Event, Key}, termion::event::{Event, Key},

View file

@ -7,15 +7,14 @@ use {
singleton::SingletonView, singleton::SingletonView,
terminal::{TerminalView, TerminalStyle, make_label}, terminal::{TerminalView, TerminalStyle, make_label},
tree::{NestedNode, TreeNav}, tree::{NestedNode, TreeNav},
color::{bg_style_from_depth, fg_style_from_depth}, utils::color::{bg_style_from_depth, fg_style_from_depth},
PtySegment PtySegment
}, },
std::sync::Arc, std::sync::Arc,
std::sync::RwLock, std::sync::RwLock,
}; };
pub enum ListSegment pub enum ListSegment {
{
InsertCursor, InsertCursor,
Item { Item {
editor: NestedNode, editor: NestedNode,
@ -24,8 +23,7 @@ pub enum ListSegment
} }
} }
impl PtySegment for ListSegment impl PtySegment for ListSegment {
{
fn pty_view(&self) -> OuterViewPort<dyn TerminalView> { fn pty_view(&self) -> OuterViewPort<dyn TerminalView> {
match self { match self {
ListSegment::InsertCursor => { ListSegment::InsertCursor => {
@ -58,8 +56,7 @@ impl PtySegment for ListSegment
} }
} }
pub struct ListSegmentSequence pub struct ListSegmentSequence {
{
data: Arc<dyn SequenceView<Item = NestedNode>>, data: Arc<dyn SequenceView<Item = NestedNode>>,
cursor: Arc<dyn SingletonView<Item = ListCursor>>, cursor: Arc<dyn SingletonView<Item = ListCursor>>,
@ -71,13 +68,11 @@ pub struct ListSegmentSequence
proj_helper: ProjectionHelper<usize, Self>, proj_helper: ProjectionHelper<usize, Self>,
} }
impl View for ListSegmentSequence impl View for ListSegmentSequence {
{
type Msg = usize; type Msg = usize;
} }
impl SequenceView for ListSegmentSequence impl SequenceView for ListSegmentSequence {
{
type Item = ListSegment; type Item = ListSegment;
fn len(&self) -> Option<usize> { fn len(&self) -> Option<usize> {
@ -128,8 +123,7 @@ impl SequenceView for ListSegmentSequence
} }
} }
impl ListSegmentSequence impl ListSegmentSequence {
{
pub fn new( pub fn new(
cursor_port: OuterViewPort<dyn SingletonView<Item = ListCursor>>, cursor_port: OuterViewPort<dyn SingletonView<Item = ListCursor>>,
data_port: OuterViewPort<dyn SequenceView<Item = NestedNode>>, data_port: OuterViewPort<dyn SequenceView<Item = NestedNode>>,

View file

@ -1,10 +0,0 @@
pub struct PathSegmentEditor {
parent: Path,
}
pub struct PathEditor {
}

View file

@ -86,7 +86,7 @@ impl ProductEditor {
} }
pub fn get_editor_segment(&self, mut idx: isize) -> ProductEditorSegment { pub fn get_editor_segment(&self, mut idx: isize) -> ProductEditorSegment {
idx = crate::modulo(idx, self.n_indices.len() as isize); idx = crate::utils::modulo(idx, self.n_indices.len() as isize);
if let Some(pos) = self.n_indices.get(idx as usize) { if let Some(pos) = self.n_indices.get(idx as usize) {
self.segments.get(pos).unwrap() self.segments.get(pos).unwrap()
} else { } else {
@ -95,7 +95,7 @@ impl ProductEditor {
} }
pub fn get_editor_segment_mut(&mut self, mut idx: isize) -> MutableIndexAccess<Point2<i16>, ProductEditorSegment> { pub fn get_editor_segment_mut(&mut self, mut idx: isize) -> MutableIndexAccess<Point2<i16>, ProductEditorSegment> {
idx = crate::modulo(idx, self.n_indices.len() as isize); idx = crate::utils::modulo(idx, self.n_indices.len() as isize);
if let Some(pos) = self.n_indices.get(idx as usize) { if let Some(pos) = self.n_indices.get(idx as usize) {
self.segments.get_mut(pos) self.segments.get_mut(pos)
} else { } else {

View file

@ -63,7 +63,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::utils::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 {

View file

@ -6,7 +6,7 @@ use {
TerminalStyle, TerminalView, TerminalStyle, TerminalView,
make_label make_label
}, },
color::{bg_style_from_depth, fg_style_from_depth}, utils::color::{bg_style_from_depth, fg_style_from_depth},
tree::{NestedNode, TreeNav} tree::{NestedNode, TreeNav}
}, },
std::{sync::{Arc, RwLock}}, std::{sync::{Arc, RwLock}},

View file

@ -9,7 +9,7 @@ use {
tree::{TreeNav, TreeCursor, TreeNavResult}, tree::{TreeNav, TreeCursor, TreeNavResult},
diagnostics::{Diagnostics, Message}, diagnostics::{Diagnostics, Message},
tree::NestedNode, tree::NestedNode,
Commander, commander::Commander,
PtySegment PtySegment
}, },
cgmath::{Vector2}, cgmath::{Vector2},

View file

@ -9,7 +9,7 @@ use {
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

@ -5,8 +5,8 @@ use {
list::{PTYListEditor}, list::{PTYListEditor},
sequence::{decorator::{SeqDecorStyle}}, sequence::{decorator::{SeqDecorStyle}},
sum::SumEditor, sum::SumEditor,
char_editor::CharEditor, char::CharEditor,
type_term_editor::TypeTermEditor, type_system::TypeTermEditor,
Nested Nested
}, },
std::sync::{Arc, RwLock}, std::sync::{Arc, RwLock},

View file

@ -1,10 +1,14 @@
pub mod type_term; pub mod type_term;
pub mod repr_tree; pub mod repr_tree;
pub mod context; pub mod context;
pub mod make_editor;
pub mod type_term_editor;
pub use { pub use {
repr_tree::{ReprTree}, repr_tree::{ReprTree},
type_term::{TypeDict, TypeID, TypeTerm, TypeLadder}, type_term::{TypeDict, TypeID, TypeTerm, TypeLadder},
context::{Context, MorphismMode, MorphismType}, context::{Context, MorphismMode, MorphismType},
type_term_editor::TypeTermEditor,
make_editor::*
}; };

View file

@ -1,4 +1,4 @@
use {crate::bimap::Bimap, std::collections::HashMap}; use {crate::utils::Bimap, std::collections::HashMap};
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> //<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>

View file

@ -8,10 +8,11 @@ use {
tree::{TreeNav, TreeCursor, TreeNavResult}, tree::{TreeNav, TreeCursor, TreeNavResult},
diagnostics::{Diagnostics, Message}, diagnostics::{Diagnostics, Message},
sum::SumEditor, sum::SumEditor,
char_editor::CharEditor, char::CharEditor,
integer::PosIntEditor, integer::PosIntEditor,
tree::NestedNode, tree::NestedNode,
Commander, PtySegment commander::Commander,
PtySegment
}, },
cgmath::{Vector2}, cgmath::{Vector2},
termion::event::{Key}, termion::event::{Key},

6
nested/src/utils/mod.rs Normal file
View file

@ -0,0 +1,6 @@
pub mod bimap;
pub mod modulo;
pub mod color;
pub use modulo::modulo;
pub use bimap::Bimap;

18
shell/src/incubator.rs Normal file
View file

@ -0,0 +1,18 @@
use {
nested::commander::Commander,
nested::terminal::TerminalEvent
};
struct Incubator {
}
impl Commander for Incubator {
type Cmd = TerminalEvent;
fn send_cmd(&mut self, cmd: &TerminalEvent) {
}
}

View file

@ -1,6 +1,7 @@
extern crate portable_pty; extern crate portable_pty;
mod pty; mod pty;
mod incubator;
// TODO rewrite process & command with incubator rules // TODO rewrite process & command with incubator rules
//mod process; //mod process;
@ -22,7 +23,7 @@ use {
vec::VecBuffer, vec::VecBuffer,
diagnostics::{Diagnostics}, diagnostics::{Diagnostics},
index::{buffer::IndexBuffer}, index::{buffer::IndexBuffer},
Commander commander::Commander
}, },
std::sync::{Arc, RwLock}, std::sync::{Arc, RwLock},
termion::event::{Event, Key}, termion::event::{Event, Key},
@ -55,10 +56,10 @@ async fn main() {
// Type Context // // Type Context //
let ctx = Arc::new(RwLock::new(Context::new())); let ctx = Arc::new(RwLock::new(Context::new()));
let ctx = nested::make_editor::init_mem_ctx(ctx); let ctx = nested::type_system::init_mem_ctx(ctx);
let ctx = nested::make_editor::init_editor_ctx(ctx); let ctx = nested::type_system::init_editor_ctx(ctx);
let ctx = nested::make_editor::init_math_ctx(ctx); let ctx = nested::type_system::init_math_ctx(ctx);
let ctx = nested::make_editor::init_os_ctx(ctx); let ctx = nested::type_system::init_os_ctx(ctx);
let vb = VecBuffer::<char>::new(); let vb = VecBuffer::<char>::new();
let rt_char = ReprTree::new_leaf( let rt_char = ReprTree::new_leaf(
@ -237,7 +238,6 @@ async fn main() {
tree_addr: vec![0], tree_addr: vec![0],
}); });
loop { loop {
let ev = term.next_event().await; let ev = term.next_event().await;
let _l = portmutex.write().unwrap(); let _l = portmutex.write().unwrap();
@ -248,7 +248,6 @@ async fn main() {
continue; continue;
} }
/* /*
if let Some(process_editor) = process_list_editor.get_item() { if let Some(process_editor) = process_list_editor.get_item() {
let mut pe = process_editor.write().unwrap(); let mut pe = process_editor.write().unwrap();