From f3ad5c78d77d1b3d728063164a861c1092e57735 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Mon, 27 Nov 2023 04:18:46 +0100 Subject: [PATCH] rename submodules to reprTree & editTree --- examples/tty-01-hello/src/main.rs | 56 +++++++------------ lib-nested-core/Cargo.toml | 2 +- .../src/{tree => editTree}/addr.rs | 0 .../src/{tree => editTree}/cursor.rs | 0 .../src/{tree => editTree}/diagnostics.rs | 2 +- lib-nested-core/src/{tree => editTree}/mod.rs | 0 lib-nested-core/src/{tree => editTree}/nav.rs | 2 +- .../src/{tree => editTree}/node.rs | 4 +- .../src/{tree => editTree}/treetype.rs | 2 +- lib-nested-core/src/editors/char/mod.rs | 4 +- lib-nested-core/src/editors/integer/ctx.rs | 4 +- lib-nested-core/src/editors/integer/editor.rs | 4 +- lib-nested-core/src/editors/list/cmd.rs | 4 +- lib-nested-core/src/editors/list/ctx.rs | 2 +- lib-nested-core/src/editors/list/editor.rs | 10 ++-- lib-nested-core/src/editors/list/nav.rs | 2 +- lib-nested-core/src/editors/list/segment.rs | 2 +- lib-nested-core/src/editors/mod.rs | 4 +- lib-nested-core/src/editors/sum/editor.rs | 4 +- lib-nested-core/src/editors/typeterm/cmd.rs | 4 +- lib-nested-core/src/editors/typeterm/ctx.rs | 2 +- lib-nested-core/src/editors/typeterm/mod.rs | 4 +- lib-nested-core/src/editors/typeterm/nav.rs | 2 +- lib-nested-core/src/lib.rs | 7 +-- .../src/{type_system => reprTree}/context.rs | 4 +- .../repr_tree.rs => reprTree/mod.rs} | 9 ++- lib-nested-core/src/type_system/mod.rs | 8 --- 27 files changed, 61 insertions(+), 87 deletions(-) rename lib-nested-core/src/{tree => editTree}/addr.rs (100%) rename lib-nested-core/src/{tree => editTree}/cursor.rs (100%) rename lib-nested-core/src/{tree => editTree}/diagnostics.rs (93%) rename lib-nested-core/src/{tree => editTree}/mod.rs (100%) rename lib-nested-core/src/{tree => editTree}/nav.rs (99%) rename lib-nested-core/src/{tree => editTree}/node.rs (98%) rename lib-nested-core/src/{tree => editTree}/treetype.rs (85%) rename lib-nested-core/src/{type_system => reprTree}/context.rs (99%) rename lib-nested-core/src/{type_system/repr_tree.rs => reprTree/mod.rs} (98%) delete mode 100644 lib-nested-core/src/type_system/mod.rs diff --git a/examples/tty-01-hello/src/main.rs b/examples/tty-01-hello/src/main.rs index 3dedd2b..45aae38 100644 --- a/examples/tty-01-hello/src/main.rs +++ b/examples/tty-01-hello/src/main.rs @@ -1,35 +1,24 @@ -extern crate r3vi; +extern crate cgmath; extern crate nested; extern crate nested_tty; +extern crate r3vi; extern crate termion; -extern crate cgmath; use { - r3vi::view::{ - ViewPort, - port::UpdateTask - }, - nested::{ - tree::{NestedNode}, - type_system::{Context, ReprTree} - }, - nested_tty::{ - Terminal, TerminalView, TerminalEvent, - TerminalStyle, - TerminalCompositor - }, cgmath::Vector2, + nested::reprTree::Context, + nested_tty::{Terminal, TerminalCompositor, TerminalEvent, TerminalStyle, TerminalView}, + r3vi::view::{port::UpdateTask, ViewPort}, + std::sync::{Arc, RwLock}, termion::event::{Event, Key}, - std::sync::{Arc, RwLock} }; - /* this task handles all terminal events (e.g. key press, resize) */ pub async fn event_loop( mut term: Terminal, term_port: ViewPort, - portmutex: Arc> + portmutex: Arc>, ) { loop { let ev = term.next_event().await; @@ -46,10 +35,7 @@ pub async fn event_loop( * all notifications which are influencing * the view in `term_port` */ -pub async fn update_loop( - term_port: ViewPort, - portmutex: Arc> -) { +pub async fn update_loop(term_port: ViewPort, portmutex: Arc>) { loop { { let _l = portmutex.write().unwrap(); @@ -64,7 +50,7 @@ async fn main() { /* initialize our terminal */ let term_port = ViewPort::new(); - + let mut term = Terminal::new(term_port.outer()); let term_writer = term.get_writer(); @@ -72,30 +58,28 @@ async fn main() { /* spawn event-handling & updating tasks */ - async_std::task::spawn( - update_loop(term_port.clone(), portmutex.clone())); + async_std::task::spawn(update_loop(term_port.clone(), portmutex.clone())); - async_std::task::spawn( - event_loop(term, term_port.clone(), portmutex.clone())); + async_std::task::spawn(event_loop(term, term_port.clone(), portmutex.clone())); /* populate the view in `term_port` */ let compositor = TerminalCompositor::new(term_port.inner()); - compositor.write().unwrap().push( - nested_tty::make_label("test") - .offset(Vector2::new(7,2))); + compositor + .write() + .unwrap() + .push(nested_tty::make_label("test").offset(Vector2::new(7, 2))); compositor.write().unwrap().push( nested_tty::make_label("Hello World") - .map_item(|p,a| - a.add_style_back( - TerminalStyle::fg_color(( (25*p.x%255) as u8, 200, 0 )) )) - .offset(Vector2::new(5, 3))); + .map_item(|p, a| { + a.add_style_back(TerminalStyle::fg_color(((25 * p.x % 255) as u8, 200, 0))) + }) + .offset(Vector2::new(5, 3)), + ); /* write the changes in the view of `term_port` to the terminal */ term_writer.show().await.expect("output error!"); } - - diff --git a/lib-nested-core/Cargo.toml b/lib-nested-core/Cargo.toml index f7b1235..0805fce 100644 --- a/lib-nested-core/Cargo.toml +++ b/lib-nested-core/Cargo.toml @@ -7,5 +7,5 @@ version = "0.1.0" [dependencies] r3vi = { path = "../../lib-r3vi" } laddertypes = { path = "../../lib-laddertypes" } -cgmath = { version = "0.18.0", features = ["serde"] } +cgmath = { version = "0.18.0", features = ["serde"] } diff --git a/lib-nested-core/src/tree/addr.rs b/lib-nested-core/src/editTree/addr.rs similarity index 100% rename from lib-nested-core/src/tree/addr.rs rename to lib-nested-core/src/editTree/addr.rs diff --git a/lib-nested-core/src/tree/cursor.rs b/lib-nested-core/src/editTree/cursor.rs similarity index 100% rename from lib-nested-core/src/tree/cursor.rs rename to lib-nested-core/src/editTree/cursor.rs diff --git a/lib-nested-core/src/tree/diagnostics.rs b/lib-nested-core/src/editTree/diagnostics.rs similarity index 93% rename from lib-nested-core/src/tree/diagnostics.rs rename to lib-nested-core/src/editTree/diagnostics.rs index 71fb079..0983f5b 100644 --- a/lib-nested-core/src/tree/diagnostics.rs +++ b/lib-nested-core/src/editTree/diagnostics.rs @@ -4,7 +4,7 @@ use { buffer::{vec::*, index_hashmap::*} }, crate::{ - type_system::ReprTree + reprTree::ReprTree }, std::sync::{Arc, RwLock}, cgmath::Point2 diff --git a/lib-nested-core/src/tree/mod.rs b/lib-nested-core/src/editTree/mod.rs similarity index 100% rename from lib-nested-core/src/tree/mod.rs rename to lib-nested-core/src/editTree/mod.rs diff --git a/lib-nested-core/src/tree/nav.rs b/lib-nested-core/src/editTree/nav.rs similarity index 99% rename from lib-nested-core/src/tree/nav.rs rename to lib-nested-core/src/editTree/nav.rs index 962834d..c2aca14 100644 --- a/lib-nested-core/src/tree/nav.rs +++ b/lib-nested-core/src/editTree/nav.rs @@ -15,7 +15,7 @@ use { }, crate::{ editors::list::ListCursorMode, - tree::TreeCursor + editTree::TreeCursor }, cgmath::Vector2, }; diff --git a/lib-nested-core/src/tree/node.rs b/lib-nested-core/src/editTree/node.rs similarity index 98% rename from lib-nested-core/src/tree/node.rs rename to lib-nested-core/src/editTree/node.rs index f0c9d16..ad66127 100644 --- a/lib-nested-core/src/tree/node.rs +++ b/lib-nested-core/src/editTree/node.rs @@ -7,8 +7,8 @@ use { }, laddertypes::{TypeTerm}, crate::{ - type_system::{ReprTree, Context}, - tree::{TreeNav, TreeCursor, TreeNavResult, TreeHeightOp, diagnostics::{Diagnostics, Message}}, + reprTree::{ReprTree, Context}, + editTree::{TreeNav, TreeCursor, TreeNavResult, TreeHeightOp, diagnostics::{Diagnostics, Message}}, editors::{list::{ListCursorMode}, ObjCommander} } }; diff --git a/lib-nested-core/src/tree/treetype.rs b/lib-nested-core/src/editTree/treetype.rs similarity index 85% rename from lib-nested-core/src/tree/treetype.rs rename to lib-nested-core/src/editTree/treetype.rs index 9f66849..4fed7a7 100644 --- a/lib-nested-core/src/tree/treetype.rs +++ b/lib-nested-core/src/editTree/treetype.rs @@ -2,7 +2,7 @@ use { laddertypes::{TypeTerm, TypeID}, crate::{ - tree::{TreeAddr} + editTree::{TreeAddr} } }; diff --git a/lib-nested-core/src/editors/char/mod.rs b/lib-nested-core/src/editors/char/mod.rs index a42dcf3..2fb66de 100644 --- a/lib-nested-core/src/editors/char/mod.rs +++ b/lib-nested-core/src/editors/char/mod.rs @@ -8,8 +8,8 @@ use { }, laddertypes::{TypeTerm}, crate::{ - type_system::{Context, ReprTree}, - tree::{NestedNode, TreeNavResult}, + reprTree::{Context, ReprTree}, + editTree::{NestedNode, TreeNavResult}, editors::ObjCommander, }, std::sync::Arc, diff --git a/lib-nested-core/src/editors/integer/ctx.rs b/lib-nested-core/src/editors/integer/ctx.rs index 95b138d..5f5859a 100644 --- a/lib-nested-core/src/editors/integer/ctx.rs +++ b/lib-nested-core/src/editors/integer/ctx.rs @@ -5,12 +5,12 @@ use { }, laddertypes::{TypeTerm}, crate::{ - type_system::{Context}, + reprTree::{Context}, + reprTree::{MorphismTypePattern}, editors::{ list::*, integer::* }, - type_system::{MorphismTypePattern}, }, std::sync::{Arc, RwLock} }; diff --git a/lib-nested-core/src/editors/integer/editor.rs b/lib-nested-core/src/editors/integer/editor.rs index 73bd353..c58b984 100644 --- a/lib-nested-core/src/editors/integer/editor.rs +++ b/lib-nested-core/src/editors/integer/editor.rs @@ -12,9 +12,9 @@ use { }, laddertypes::{TypeTerm}, crate::{ - type_system::{Context, ReprTree}, editors::{list::{ListCmd}, ObjCommander}, - tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor, diagnostics::{Message}}, + reprTree::{Context, ReprTree}, + editTree::{NestedNode, TreeNav, TreeNavResult, TreeCursor, diagnostics::{Message}}, }, std::sync::Arc, std::sync::RwLock, diff --git a/lib-nested-core/src/editors/list/cmd.rs b/lib-nested-core/src/editors/list/cmd.rs index ffcb9f1..59a28e7 100644 --- a/lib-nested-core/src/editors/list/cmd.rs +++ b/lib-nested-core/src/editors/list/cmd.rs @@ -4,8 +4,8 @@ use { }, crate::{ editors::{list::{ListEditor, ListCursor, ListCursorMode}, ObjCommander}, - type_system::{Context, ReprTree}, - tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor}, + reprTree::{Context, ReprTree}, + editTree::{NestedNode, TreeNav, TreeNavResult, TreeCursor}, }, std::sync::{Arc, RwLock} }; diff --git a/lib-nested-core/src/editors/list/ctx.rs b/lib-nested-core/src/editors/list/ctx.rs index 89376b7..67a73d1 100644 --- a/lib-nested-core/src/editors/list/ctx.rs +++ b/lib-nested-core/src/editors/list/ctx.rs @@ -2,7 +2,7 @@ use { r3vi::{view::{OuterViewPort, singleton::*}}, laddertypes::{TypeTerm}, crate::{ - type_system::{Context}, + reprTree::{Context}, editors::list::{ListEditor}//, PTYListController, PTYListStyle} }, std::sync::{Arc, RwLock} diff --git a/lib-nested-core/src/editors/list/editor.rs b/lib-nested-core/src/editors/list/editor.rs index 63b4644..cc6e7f1 100644 --- a/lib-nested-core/src/editors/list/editor.rs +++ b/lib-nested-core/src/editors/list/editor.rs @@ -5,9 +5,9 @@ use { }, laddertypes::{TypeTerm}, crate::{ - type_system::{Context, ReprTree}, + reprTree::{Context, ReprTree}, + editTree::{NestedNode, TreeNav, TreeCursor, diagnostics::Diagnostics}, editors::{list::{ListCursor, ListCursorMode, ListCmd}, ObjCommander}, - tree::{NestedNode, TreeNav, TreeCursor, diagnostics::Diagnostics}, }, std::sync::{Arc, RwLock} }; @@ -117,8 +117,7 @@ impl ListEditor { .set_diag(e .get_data_port() .enumerate() - .map( - |(idx, item_editor)| { + .map(|(idx, item_editor)| { let idx = *idx; item_editor .get_msg_port() @@ -129,8 +128,7 @@ impl ListEditor { msg } ) - } - ) + }) .flatten() ); diff --git a/lib-nested-core/src/editors/list/nav.rs b/lib-nested-core/src/editors/list/nav.rs index 31d0cc2..2976074 100644 --- a/lib-nested-core/src/editors/list/nav.rs +++ b/lib-nested-core/src/editors/list/nav.rs @@ -11,7 +11,7 @@ use { ListCursor, ListCursorMode, editor::ListEditor }, - tree::{TreeCursor, TreeNav, TreeNavResult, TreeHeightOp} + editTree::{TreeCursor, TreeNav, TreeNavResult, TreeHeightOp} }, cgmath::Vector2 }; diff --git a/lib-nested-core/src/editors/list/segment.rs b/lib-nested-core/src/editors/list/segment.rs index 5e8b611..8dcf003 100644 --- a/lib-nested-core/src/editors/list/segment.rs +++ b/lib-nested-core/src/editors/list/segment.rs @@ -9,7 +9,7 @@ use { }, crate::{ editors::list::{ListCursor, ListCursorMode}, - tree::{NestedNode} + editTree::{NestedNode} }, std::sync::Arc, std::sync::RwLock, diff --git a/lib-nested-core/src/editors/mod.rs b/lib-nested-core/src/editors/mod.rs index d48a5b3..849cb67 100644 --- a/lib-nested-core/src/editors/mod.rs +++ b/lib-nested-core/src/editors/mod.rs @@ -16,8 +16,8 @@ pub trait Commander { use std::sync::{Arc, RwLock}; use crate::{ - type_system::ReprTree, - tree::{nav::TreeNavResult} + reprTree::ReprTree, + editTree::nav::TreeNavResult }; pub trait ObjCommander { diff --git a/lib-nested-core/src/editors/sum/editor.rs b/lib-nested-core/src/editors/sum/editor.rs index 195c6b2..919dcb5 100644 --- a/lib-nested-core/src/editors/sum/editor.rs +++ b/lib-nested-core/src/editors/sum/editor.rs @@ -9,8 +9,8 @@ use { laddertypes::{TypeTerm}, crate::{ editors::{list::ListCursorMode, ObjCommander}, - type_system::{Context, ReprTree}, - tree::{TreeNav, TreeCursor, TreeNavResult, diagnostics::{Diagnostics, Message}, NestedNode}, + reprTree::{Context, ReprTree}, + editTree::{TreeNav, TreeCursor, TreeNavResult, diagnostics::{Diagnostics, Message}, NestedNode}, }, cgmath::{Vector2}, std::sync::{Arc, RwLock} diff --git a/lib-nested-core/src/editors/typeterm/cmd.rs b/lib-nested-core/src/editors/typeterm/cmd.rs index 29ec6cb..cf62d80 100644 --- a/lib-nested-core/src/editors/typeterm/cmd.rs +++ b/lib-nested-core/src/editors/typeterm/cmd.rs @@ -3,9 +3,9 @@ use { view::{singleton::*} }, crate::{ - type_system::{Context, ReprTree}, + reprTree::{Context, ReprTree}, + editTree::{NestedNode, TreeNav, TreeNavResult, TreeCursor}, editors::{list::{ListEditor, ListCmd, ListCursorMode}, ObjCommander}, - tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor}, }, std::{sync::{Arc, RwLock}}, diff --git a/lib-nested-core/src/editors/typeterm/ctx.rs b/lib-nested-core/src/editors/typeterm/ctx.rs index 58a65e4..cb9c1f9 100644 --- a/lib-nested-core/src/editors/typeterm/ctx.rs +++ b/lib-nested-core/src/editors/typeterm/ctx.rs @@ -4,7 +4,7 @@ use { }, laddertypes::{TypeTerm}, crate::{ - type_system::{Context, MorphismTypePattern}, + reprTree::{Context, MorphismTypePattern}, editors::{ list::{ListEditor, ListSegmentSequence}, typeterm::{State, TypeTermEditor} diff --git a/lib-nested-core/src/editors/typeterm/mod.rs b/lib-nested-core/src/editors/typeterm/mod.rs index a0c4c5c..2536c4e 100644 --- a/lib-nested-core/src/editors/typeterm/mod.rs +++ b/lib-nested-core/src/editors/typeterm/mod.rs @@ -11,9 +11,9 @@ use { }, laddertypes::{TypeID, TypeTerm}, crate::{ - type_system::{Context, ReprTree}, + reprTree::{Context, ReprTree}, + editTree::{NestedNode, TreeNav, TreeNavResult, TreeCursor}, editors::{list::{ListCursorMode, ListEditor, ListCmd}, ObjCommander}, - tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor}, }, std::{sync::{Arc, RwLock}} }; diff --git a/lib-nested-core/src/editors/typeterm/nav.rs b/lib-nested-core/src/editors/typeterm/nav.rs index 6fb7bf1..4439165 100644 --- a/lib-nested-core/src/editors/typeterm/nav.rs +++ b/lib-nested-core/src/editors/typeterm/nav.rs @@ -7,7 +7,7 @@ use { } }, crate::{ - tree::{TreeNav, TreeCursor, TreeNavResult, TreeHeightOp}, + editTree::{TreeNav, TreeCursor, TreeNavResult, TreeHeightOp}, editors::{typeterm::TypeTermEditor, list::ListCursorMode} }, cgmath::Vector2 diff --git a/lib-nested-core/src/lib.rs b/lib-nested-core/src/lib.rs index 285710c..c0ef04d 100644 --- a/lib-nested-core/src/lib.rs +++ b/lib-nested-core/src/lib.rs @@ -1,8 +1,5 @@ pub mod utils; pub mod editors; -pub mod tree; -pub mod type_system; +pub mod editTree; +pub mod reprTree; -pub fn magic_header() { - eprintln!("<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>"); -} diff --git a/lib-nested-core/src/type_system/context.rs b/lib-nested-core/src/reprTree/context.rs similarity index 99% rename from lib-nested-core/src/type_system/context.rs rename to lib-nested-core/src/reprTree/context.rs index bf4f8c4..06af8c3 100644 --- a/lib-nested-core/src/type_system/context.rs +++ b/lib-nested-core/src/reprTree/context.rs @@ -2,8 +2,8 @@ use { r3vi::{view::{OuterViewPort, singleton::*}, buffer::{singleton::*}}, laddertypes::{TypeDict, TypeTerm, TypeID}, crate::{ - type_system::{ReprTree}, - tree::NestedNode + reprTree::{ReprTree}, + editTree::NestedNode }, std::{ collections::HashMap, diff --git a/lib-nested-core/src/type_system/repr_tree.rs b/lib-nested-core/src/reprTree/mod.rs similarity index 98% rename from lib-nested-core/src/type_system/repr_tree.rs rename to lib-nested-core/src/reprTree/mod.rs index 7e226f9..758fea3 100644 --- a/lib-nested-core/src/type_system/repr_tree.rs +++ b/lib-nested-core/src/reprTree/mod.rs @@ -1,9 +1,12 @@ +pub mod context; + +pub use { + context::{Context, MorphismMode, MorphismType, MorphismTypePattern}, +}; + use { r3vi::view::{AnyOuterViewPort, OuterViewPort, View}, laddertypes::{TypeTerm}, - crate::{ - type_system::{Context} - }, std::{ collections::HashMap, sync::{Arc, RwLock}, diff --git a/lib-nested-core/src/type_system/mod.rs b/lib-nested-core/src/type_system/mod.rs deleted file mode 100644 index 6d52a5b..0000000 --- a/lib-nested-core/src/type_system/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub mod context; -pub mod repr_tree; - -pub use { - context::{Context, MorphismMode, MorphismType, MorphismTypePattern}, - repr_tree::ReprTree -}; -