diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..87ab448 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,14 @@ +name: Tests + +on: + workflow_dispatch: + push: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Build + run: cargo test diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 02df51e..a8d775e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,4 +1,4 @@ -name: Publish Documentation +name: User Guide on: workflow_dispatch: @@ -10,11 +10,9 @@ jobs: build: runs-on: ubuntu-latest steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v4 - - - name: Build + - name: Build run: | curl --proto '=https' --tlsv1.2 -LsSf https://github.com/5Sigma/codex/releases/latest/download/Codex-installer.sh | sh codex -r docs build diff --git a/Cargo.toml b/Cargo.toml index 921239b..2ee7ccc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,14 @@ edition = "2021" description = "TUI made simple" authors = ["Joe Bellus"] license = "MIT" +exclude = [ + "docs/*" +] +homepage = "https://5sigma.github.io/arkham" +repository = "https://github.com/5Sigma/arkham" +readme = "readme.md" +keywords = ["terminal", "tui", "cli", "console"] +categories = ["command-line-interface", "command-line-utilities"] [[example]] name = "simple" diff --git a/docs/index.md b/docs/index.md index 6e76cf2..5c96d88 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,12 +3,7 @@ title: Arkham subtitle: An Ergonomic TUI Framework --- - -```Rust -fn welcome(ctx &mut ViewContext) { - ctx.insert((0,0), "Welcome"); -} -``` +![welcome](/welcome.png) # Robust TUI foundation diff --git a/docs/static/welcome.png b/docs/static/welcome.png new file mode 100644 index 0000000..b4263e6 Binary files /dev/null and b/docs/static/welcome.png differ diff --git a/examples/theme.rs b/examples/theme.rs index b7284e9..d257c31 100644 --- a/examples/theme.rs +++ b/examples/theme.rs @@ -9,8 +9,8 @@ fn main() { fn root(ctx: &mut ViewContext, theme: Res) { let size = ctx.size(); - ctx.paint(size, theme.bg_primary); - ctx.paint(Rect::new((5, 5), size - 10), theme.bg_secondary); + ctx.fill_all(theme.bg_primary); + ctx.fill(Rect::new((5, 5), size - 10), theme.bg_secondary); ctx.insert((10, 10), "Hello World"); ctx.insert( ((size.width / 2) - 7, 0), diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..5a0480c --- /dev/null +++ b/readme.md @@ -0,0 +1,91 @@ +
+

Arkham

+

+ An ergonomic TUI Framework +

+

+ + +[![crates.io](https://img.shields.io/crates/v/arkham?label=latest)](https://crates.io/crates/arkham) +[![Documentation](https://docs.rs/arkham/badge.svg?version=0.2.1)](https://docs.rs/arkham/0.2.1) +![Crates.io Downloads (latest version)](https://img.shields.io/crates/dv/arkham) +
+[![guide](https://github.com/5sigma/arkham/actions/workflows/docs.yml/badge.svg)](https://github.com/5sigma/arkham/actions/workflows/docs.yml) +[![CI](https://github.com/5sigma/arkham/actions/workflows/ci.yml/badge.svg)](https://github.com/5sigma/arkham/actions/workflows/ci.yml) + +[Read The Guide](https://5sigma.github.io/arkham) + + +

+

+ +![Welcome](docs/static/welcome.png) + +# 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/src/app.rs b/src/app.rs index 9f208a1..712f1e7 100644 --- a/src/app.rs +++ b/src/app.rs @@ -100,7 +100,7 @@ where /// state. /// /// Example: - /// ``` + /// ```no_run /// use arkham::prelude::*; /// struct MyResource { /// value: i32 @@ -126,7 +126,7 @@ where /// is meant to store application state. /// /// Example: - /// ``` + /// ```no_run /// use arkham::prelude::*; /// struct MyState { /// value: i32 diff --git a/src/view.rs b/src/view.rs index 2969966..3cee364 100644 --- a/src/view.rs +++ b/src/view.rs @@ -70,16 +70,6 @@ impl View { (self.width(), self.height()).into() } - /// Paint is a conveinence method for filling a region ith a given color. - /// This is done by using the passed color as the background color and - /// filling the region with ' ' characters. - pub fn paint(&mut self, rect: R, color: Color) - where - R: Into, - { - self.fill(rect, Rune::new().content(' ').bg(color)); - } - /// Fill a region of the view with a single rune, repeating it in every /// position. pub fn fill(&mut self, rect: R, rune: U)