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},
singleton::{SingletonBuffer, SingletonView},
terminal::{TerminalAtom, TerminalEvent, TerminalStyle},
tree::NestedNode, Commander
tree::NestedNode,
commander::Commander
},
std::sync::Arc,
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

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

View file

@ -4,10 +4,8 @@
pub mod core;
pub mod type_system;
pub mod projection;
pub mod bimap;
pub mod modulo;
pub use modulo::modulo;
pub mod commander;
pub mod utils;
// semantics
pub mod singleton;
@ -26,49 +24,16 @@ pub mod tree;
pub mod diagnostics;
// high-level types
pub mod char_editor;
pub mod char;
pub mod integer;
pub mod make_editor;
pub mod type_term_editor;
// display
pub mod color;
pub mod terminal;
pub fn magic_header() {
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 {
fn get_string(&self) -> String;
}

View file

@ -67,7 +67,7 @@ impl ListEditor {
pub fn get_item(&self) -> Option<NestedNode> {
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() {
Some(self.data.get(idx))
} else {
@ -79,7 +79,7 @@ impl ListEditor {
}
pub fn get_item_mut(&mut self) -> Option<MutableVecAccess<NestedNode>> {
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() {
Some(self.data.get_mut(idx))
} else {
@ -108,4 +108,3 @@ impl ListEditor {
self.data.clear();
}
}

View file

@ -98,7 +98,7 @@ impl TreeNav for ListEditor {
TreeNavResult::Continue
}
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 {
mode: new_cur.leaf_mode,
@ -118,7 +118,7 @@ impl TreeNav for ListEditor {
}
_ => {
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 {
mode: ListCursorMode::Select,

View file

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

View file

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

View file

@ -63,7 +63,7 @@ impl TreeNav for ProductEditor {
}
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(ProductEditorSegment::N{ t, editor, ed_depth, cur_depth: _, cur_dist:_ }) = element.deref_mut() {
if let Some(e) = editor {

View file

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

View file

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

View file

@ -9,7 +9,7 @@ use {
terminal::{TerminalView, TerminalEvent, TerminalEditor, TerminalEditorResult},
diagnostics::{Diagnostics, Message},
tree::{TreeNav, TreeCursor, TreeNavResult},
ObjCommander,
commander::ObjCommander,
Nested
}
};

View file

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

View file

@ -1,10 +1,14 @@
pub mod type_term;
pub mod repr_tree;
pub mod context;
pub mod make_editor;
pub mod type_term_editor;
pub use {
repr_tree::{ReprTree},
type_term::{TypeDict, TypeID, TypeTerm, TypeLadder},
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},
diagnostics::{Diagnostics, Message},
sum::SumEditor,
char_editor::CharEditor,
char::CharEditor,
integer::PosIntEditor,
tree::NestedNode,
Commander, PtySegment
commander::Commander,
PtySegment
},
cgmath::{Vector2},
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;
mod pty;
mod incubator;
// TODO rewrite process & command with incubator rules
//mod process;
@ -22,7 +23,7 @@ use {
vec::VecBuffer,
diagnostics::{Diagnostics},
index::{buffer::IndexBuffer},
Commander
commander::Commander
},
std::sync::{Arc, RwLock},
termion::event::{Event, Key},
@ -55,10 +56,10 @@ async fn main() {
// Type Context //
let ctx = Arc::new(RwLock::new(Context::new()));
let ctx = nested::make_editor::init_mem_ctx(ctx);
let ctx = nested::make_editor::init_editor_ctx(ctx);
let ctx = nested::make_editor::init_math_ctx(ctx);
let ctx = nested::make_editor::init_os_ctx(ctx);
let ctx = nested::type_system::init_mem_ctx(ctx);
let ctx = nested::type_system::init_editor_ctx(ctx);
let ctx = nested::type_system::init_math_ctx(ctx);
let ctx = nested::type_system::init_os_ctx(ctx);
let vb = VecBuffer::<char>::new();
let rt_char = ReprTree::new_leaf(
@ -237,7 +238,6 @@ async fn main() {
tree_addr: vec![0],
});
loop {
let ev = term.next_event().await;
let _l = portmutex.write().unwrap();
@ -248,7 +248,6 @@ async fn main() {
continue;
}
/*
if let Some(process_editor) = process_list_editor.get_item() {
let mut pe = process_editor.write().unwrap();