From 8f8bd96daed8a2e99a0f3b69057ed2658b647a27 Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Fri, 19 Apr 2024 06:22:56 -0400 Subject: [PATCH] Cleaned up old files Removed plugins and components modules. These may be added back in, but with a different implementation. --- Cargo.toml | 5 --- docs/index.md | 75 ++++++++++++++++++++++++++++++++++++- examples/paragraph.rs | 14 ------- src/components/mod.rs | 2 - src/components/paragraph.rs | 36 ------------------ src/lib.rs | 2 - src/plugins/keybind.rs | 2 - src/plugins/mod.rs | 13 ------- 8 files changed, 74 insertions(+), 75 deletions(-) delete mode 100644 examples/paragraph.rs delete mode 100644 src/components/mod.rs delete mode 100644 src/components/paragraph.rs delete mode 100644 src/plugins/keybind.rs delete mode 100644 src/plugins/mod.rs diff --git a/Cargo.toml b/Cargo.toml index 2a045f9..921239b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,12 +34,7 @@ path = "examples/navigation.rs" name = "stack" path = "examples/stack.rs" -[[example]] -name = "paragraph" -path = "examples/paragraph.rs" - [dependencies] anyhow = "1.0.71" crossterm = "0.27" ctrlc = "3.3.1" -textwrap = "0.16.0" diff --git a/docs/index.md b/docs/index.md index 1a893be..6e76cf2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,2 +1,75 @@ -# Document Title +--- +title: Arkham +subtitle: An Ergonomic TUI Framework +--- + + +```Rust +fn welcome(ctx &mut ViewContext) { + ctx.insert((0,0), "Welcome"); +} +``` + +# Robust TUI foundation + +Arkham attempts to give a firm foundation for building TUI Apps. +It does not provide a set of widgets or components that can be used. +Instead, it tries to make the process of building terminal interfaces +easy enough that they aren't necessary. + +- Keyboard handling +- Terminal modification +- Full screen terminal UIs with _alternate screen_ handling +- Full run loop and rendering engine +- Easy text formatting and styling +- Ergonomic component architecture +- Dependency injection + +# Components are simple functions + +```Rust +fn my_component(ctx &mut ViewContext) { + ctx.insert((0,0), "Welcome"); +} +``` + + +# Easily handle text styling + +```Rust +fn my_component(ctx &mut ViewContext) { + ctx.insert( + (0,0), + "Welcome" + .to_runes() + .bg(Color::Blue) + .fg(Color::White), + ); +} +``` + + +# Painless dependency injection + +```Rust +fn my_component(ctx &mut ViewContext, user: Res) { + ctx.insert( + (0,0), + format!("Hello, {}", user.name), + ); +} +``` + +# Easy keyboard handling + +```Rust +fn my_component(ctx &mut ViewContext, kb: Res) { + if kb.char() == Some('x') { + ctx.insert( + (0,0), + "X marks the spot" + ); + } +} +``` diff --git a/examples/paragraph.rs b/examples/paragraph.rs deleted file mode 100644 index 87afae9..0000000 --- a/examples/paragraph.rs +++ /dev/null @@ -1,14 +0,0 @@ -use arkham::prelude::*; - -fn main() { - let _ = App::new(root).run(); -} - -fn root(ctx: &mut ViewContext) { - let mut stack = ctx.vertical_stack(ctx.size()); - let p = arkham::components::Paragraph::new("Rust is a multi-paradigm, general-purpose programming language that emphasizes performance, type safety, and concurrency. It enforces memory safety—ensuring that all references point to valid memory—without requiring the use of a garbage collector or reference counting present in other memory-safe languages."); - stack.component(Size::new(100_usize, p.height(100)), p); - let p = arkham::components::Paragraph::new("Rust is a multi-paradigm, general-purpose programming language that emphasizes performance, type safety, and concurrency. It enforces memory safety—ensuring that all references point to valid memory—without requiring the use of a garbage collector or reference counting present in other memory-safe languages."); - stack.component(Size::new(100_usize, p.height(100)), p); - ctx.component(ctx.size(), stack); -} diff --git a/src/components/mod.rs b/src/components/mod.rs deleted file mode 100644 index 1f526a4..0000000 --- a/src/components/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod paragraph; -pub use paragraph::Paragraph; diff --git a/src/components/paragraph.rs b/src/components/paragraph.rs deleted file mode 100644 index b93abd0..0000000 --- a/src/components/paragraph.rs +++ /dev/null @@ -1,36 +0,0 @@ -use crate::prelude::{Callable, ToRuneExt}; -use crossterm::style::Color; -use std::ops::Deref; -#[allow(dead_code)] -#[derive(Debug)] -pub struct Paragraph { - content: String, - fg: Option, - bg: Option, -} - -impl Paragraph { - pub fn new(content: &str) -> Self { - Self { - content: content.to_string(), - fg: None, - bg: None, - } - } - pub fn height(&self, width: usize) -> usize { - textwrap::wrap(&self.content, width).len() - } -} - -impl Callable<()> for Paragraph { - fn call(&self, view: &mut crate::prelude::ViewContext, _args: ()) { - let lines = textwrap::wrap(&self.content, view.width()); - let mut stack = view.vertical_stack(view.size()); - for line in lines.iter() { - let _ = line.deref().to_runes(); - - stack.insert(line); - } - view.component(view.size(), stack); - } -} diff --git a/src/lib.rs b/src/lib.rs index 569a531..b0d7f22 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,8 @@ mod app; -pub mod components; mod container; mod context; mod geometry; mod input; -mod plugins; mod runes; mod stack; pub mod symbols; diff --git a/src/plugins/keybind.rs b/src/plugins/keybind.rs deleted file mode 100644 index 182f9ec..0000000 --- a/src/plugins/keybind.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[allow(dead_code)] -pub struct KeybindPlugin; diff --git a/src/plugins/mod.rs b/src/plugins/mod.rs deleted file mode 100644 index 88fd47a..0000000 --- a/src/plugins/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -use crate::prelude::ViewContext; - -pub mod keybind; - -pub trait Pluigin { - fn build(ctx: ViewContext); - - #[allow(unused_variables)] - fn before_render(ctx: ViewContext) {} - - #[allow(unused_variables)] - fn after_render(ctx: ViewContext) {} -}