Cleaned up old files
Removed plugins and components modules. These may be added back in, but with a different implementation.
This commit is contained in:
parent
c3a14d6c33
commit
8f8bd96dae
|
@ -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"
|
||||
|
|
|
@ -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<MyUser>) {
|
||||
ctx.insert(
|
||||
(0,0),
|
||||
format!("Hello, {}", user.name),
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
# Easy keyboard handling
|
||||
|
||||
```Rust
|
||||
fn my_component(ctx &mut ViewContext, kb: Res<Keyboard>) {
|
||||
if kb.char() == Some('x') {
|
||||
ctx.insert(
|
||||
(0,0),
|
||||
"X marks the spot"
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
mod paragraph;
|
||||
pub use paragraph::Paragraph;
|
|
@ -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<Color>,
|
||||
bg: Option<Color>,
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
#[allow(dead_code)]
|
||||
pub struct KeybindPlugin;
|
|
@ -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) {}
|
||||
}
|
Loading…
Reference in New Issue