mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-02-22 02:59:02 +01:00
parent
006cddcc16
commit
06f8ed3ae3
13 changed files with 133 additions and 125 deletions
51
Cargo.lock
generated
51
Cargo.lock
generated
|
|
@ -1166,35 +1166,20 @@ dependencies = [
|
|||
name = "tengri"
|
||||
version = "0.14.0"
|
||||
dependencies = [
|
||||
"atomic_float",
|
||||
"better-panic",
|
||||
"bumpalo",
|
||||
"crossterm 0.29.0",
|
||||
"dizzle",
|
||||
"tengri",
|
||||
"tengri_input",
|
||||
"tengri_output",
|
||||
"tengri_proc",
|
||||
"tengri_tui",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tengri_input"
|
||||
version = "0.14.0"
|
||||
dependencies = [
|
||||
"dizzle",
|
||||
"tengri_tui",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tengri_output"
|
||||
version = "0.14.0"
|
||||
dependencies = [
|
||||
"atomic_float",
|
||||
"bumpalo",
|
||||
"dizzle",
|
||||
"palette",
|
||||
"proptest",
|
||||
"proptest-derive",
|
||||
"quanta",
|
||||
"rand 0.8.5",
|
||||
"ratatui",
|
||||
"tengri",
|
||||
"tengri_tui",
|
||||
"tengri_proc",
|
||||
"unicode-width 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1208,26 +1193,6 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tengri_tui"
|
||||
version = "0.14.0"
|
||||
dependencies = [
|
||||
"atomic_float",
|
||||
"better-panic",
|
||||
"bumpalo",
|
||||
"crossterm 0.29.0",
|
||||
"dizzle",
|
||||
"palette",
|
||||
"quanta",
|
||||
"rand 0.8.5",
|
||||
"ratatui",
|
||||
"tengri",
|
||||
"tengri_input",
|
||||
"tengri_output",
|
||||
"tengri_proc",
|
||||
"unicode-width 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.18"
|
||||
|
|
|
|||
74
Cargo.toml
74
Cargo.toml
|
|
@ -1,3 +1,43 @@
|
|||
[package]
|
||||
name = "tengri"
|
||||
edition = "2024"
|
||||
version = "0.15.0"
|
||||
description = "UI metaframework."
|
||||
|
||||
[features]
|
||||
default = [ "input", "output", "tui" ]
|
||||
bumpalo = [ "dep:bumpalo" ]
|
||||
input = [ ]
|
||||
output = [ ]
|
||||
tui = [ ]
|
||||
dsl = [ ]
|
||||
|
||||
[dependencies]
|
||||
anyhow = { version = "1.0" }
|
||||
atomic_float = { version = "1" }
|
||||
better-panic = { version = "0.3.0" }
|
||||
bumpalo = { version = "3.19.0", optional = true }
|
||||
crossterm = { version = "0.29.0" }
|
||||
heck = { version = "0.5" }
|
||||
palette = { version = "0.7.6", features = [ "random" ] }
|
||||
proc-macro2 = { version = "1", features = ["span-locations"] }
|
||||
quanta = { version = "0.12.3" }
|
||||
quote = { version = "1" }
|
||||
rand = { version = "0.8.5" }
|
||||
ratatui = { version = "0.29.0", features = [ "unstable-widget-ref", "underline-color" ] }
|
||||
syn = { version = "2", features = ["full", "extra-traits"] }
|
||||
unicode-width = { version = "0.2" }
|
||||
dizzle = { path = "../dizzle" }
|
||||
|
||||
[dev-dependencies]
|
||||
proptest = { version = "^1" }
|
||||
proptest-derive = { version = "^0.5.1" }
|
||||
tengri = { path = ".", features = [ "dsl" ] }
|
||||
tengri_proc = { path = "./proc" }
|
||||
|
||||
[lib]
|
||||
path = "src/tengri.rs"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
|
||||
|
|
@ -5,35 +45,5 @@ lto = true
|
|||
inherits = "test"
|
||||
lto = false
|
||||
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
"./tengri",
|
||||
"./proc",
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.14.0"
|
||||
edition = "2024"
|
||||
|
||||
[workspace.dependencies]
|
||||
dizzle = { path = "../dizzle" }
|
||||
tengri = { path = "./tengri" }
|
||||
tengri_proc = { path = "./proc" }
|
||||
|
||||
anyhow = { version = "1.0" }
|
||||
atomic_float = { version = "1" }
|
||||
better-panic = { version = "0.3.0" }
|
||||
bumpalo = { version = "3.19.0" }
|
||||
crossterm = { version = "0.29.0" }
|
||||
heck = { version = "0.5" }
|
||||
palette = { version = "0.7.6", features = [ "random" ] }
|
||||
proc-macro2 = { version = "1", features = ["span-locations"] }
|
||||
proptest = { version = "^1" }
|
||||
proptest-derive = { version = "^0.5.1" }
|
||||
quanta = { version = "0.12.3" }
|
||||
quote = { version = "1" }
|
||||
rand = { version = "0.8.5" }
|
||||
ratatui = { version = "0.29.0", features = [ "unstable-widget-ref", "underline-color" ] }
|
||||
syn = { version = "2", features = ["full", "extra-traits"] }
|
||||
unicode-width = { version = "0.2" }
|
||||
[target.'cfg(target_os = "linux")']
|
||||
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
tengri/README.md
|
||||
56
README.md
Normal file
56
README.md
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
***tengri*** is a metaframework for building interactive applications with rust. (aren't we all?)
|
||||
|
||||
tengri is developed as part of [***tek***](https://codeberg.org/unspeaker/tek),
|
||||
a music program for terminals.
|
||||
|
||||
tengri contains:
|
||||
* [***dizzle***](./dsl), a framework for defining domain-specific languages
|
||||
* [***output***](./output), an abstract UI layout framework
|
||||
* [***input***](./input), an abstract UI event framework
|
||||
* [***tui***](./tui), an implementation of tengri over [***ratatui***](https://ratatui.rs/).
|
||||
|
||||
as well as:
|
||||
* [***core***](./core), the shared definitions ("utils") module
|
||||
* [***proc***](./proc), the space for procedural macros
|
||||
* [***tengri***](./tengri), the top-level reexport crate
|
||||
|
||||
tengri is published under [**AGPL3**](./LICENSE).
|
||||
|
||||
## Input
|
||||
|
||||
***tengri_input*** is where tengri's input handling is defined.
|
||||
|
||||
the following items are provided:
|
||||
* `Input` trait, for defining for input sources
|
||||
* `Handle` trait and `handle!` macro, for defining input handlers
|
||||
* `Command` trait and the `command!` macro, for defining commands that inputs may result in
|
||||
|
||||
## Output
|
||||
|
||||
***tengri_output*** is an abstract interface layout framework.
|
||||
|
||||
it expresses the following notions:
|
||||
|
||||
* [**space:**](./src/space.rs) `Direction`, `Coordinate`, `Area`, `Size`, `Measure`
|
||||
|
||||
* [**output:**](./src/output.rs) `Out`, `Draw`, `Content`
|
||||
* the layout operators are generic over `Draw` and/or `Content`
|
||||
* the traits `Draw` and `Content` are generic over `Out`
|
||||
* implement `Out` to bring a layout to a new backend:
|
||||
[see `TuiOut` in `tengri_tui`](../tui/src/tui_engine/tui_output.rs)
|
||||
|
||||
* [**layout:**](./src/layout.rs)
|
||||
* conditionals: `When`, `Either`
|
||||
* iteration: `Map`
|
||||
* concatenation: `Bsp`
|
||||
* positioning: `Align`, `Push`, `Pull`
|
||||
* sizing: `Fill`, `Fixed`, `Expand`, `Shrink`, `Min`, `Max`
|
||||
* implement custom components (that may be backend-dependent):
|
||||
[see `tui_content` in `tengri_tui`](../tui/src/tui_content)
|
||||
|
||||
## TUI
|
||||
|
||||
***tengri_tui*** implements [tengri_output](../output) and [tengri_input](../input)
|
||||
on top of [ratatui](https://ratatui.rs/) and [crossterm](https://github.com/crossterm-rs/crossterm).
|
||||
|
||||
tengri is published under [**AGPL3**](../LICENSE).
|
||||
|
|
@ -453,6 +453,22 @@ pub fn tui_input <T: Handle<TuiIn> + Send + Sync + 'static> (
|
|||
})
|
||||
}
|
||||
|
||||
/// Should be impl something or other...
|
||||
///
|
||||
/// ```
|
||||
/// struct State;
|
||||
/// impl<'b> Namespace<'b, bool> for State {}
|
||||
/// impl<'b> Namespace<'b, u16> for State {}
|
||||
/// impl<'b> Namespace<'b, Color> for State {}
|
||||
/// impl Understand<TuiOut, ()> for State {}
|
||||
/// let state = State;
|
||||
/// let out = TuiOut::default();
|
||||
/// tengri::evaluate_output_expression_tui(&state, &mut out, "")?;
|
||||
/// tengri::evaluate_output_expression_tui(&state, &mut out, "text Hello world!")?;
|
||||
/// tengri::evaluate_output_expression_tui(&state, &mut out, "fg (g 0) (text Hello world!)")?;
|
||||
/// tengri::evaluate_output_expression_tui(&state, &mut out, "bg (g 2) (text Hello world!)")?;
|
||||
/// tengri::evaluate_output_expression_tui(&state, &mut out, "(bg (g 3) (fg (g 4) (text Hello world!)))")?;
|
||||
/// ```
|
||||
#[cfg(feature = "dsl")] pub fn evaluate_output_expression_tui <'a, S> (
|
||||
state: &S, output: &mut TuiOut, expr: impl Expression + 'a
|
||||
) -> Usually<bool> where
|
||||
|
|
@ -472,22 +488,22 @@ pub fn tui_input <T: Handle<TuiIn> + Send + Sync + 'static> (
|
|||
let _arg2 = tail1.head();
|
||||
match frags.next() {
|
||||
|
||||
Some("text") => if let Some(src) = args?.src()? { output.place(&src) },
|
||||
Some("text") => {
|
||||
if let Some(src) = args?.src()? { output.place(&src) }
|
||||
},
|
||||
|
||||
Some("fg") => {
|
||||
let arg0 = arg0?.expect("fg: expected arg 0 (color)");
|
||||
output.place(&Tui::fg(
|
||||
Namespace::<Color>::namespace(state, arg0)?.unwrap_or_else(||panic!("fg: {arg0:?}: not a color")),
|
||||
Thunk::new(move|output: &mut TuiOut|state.understand(output, &arg1).unwrap()),
|
||||
))
|
||||
let arg0 = arg0?.expect("fg: expected arg 0 (color)");
|
||||
let color = Namespace::namespace(state, arg0)?.unwrap_or_else(||panic!("fg: {arg0:?}: not a color"));
|
||||
let thunk = Thunk::new(move|output: &mut TuiOut|state.understand(output, &arg1).unwrap());
|
||||
output.place(&Tui::fg(color, thunk))
|
||||
},
|
||||
|
||||
Some("bg") => {
|
||||
let arg0 = arg0?.expect("bg: expected arg 0 (color)");
|
||||
output.place(&Tui::bg(
|
||||
Namespace::<Color>::namespace(state, arg0)?.unwrap_or_else(||panic!("bg: {arg0:?}: not a color")),
|
||||
Thunk::new(move|output: &mut TuiOut|state.understand(output, &arg1).unwrap()),
|
||||
))
|
||||
let arg0 = arg0?.expect("bg: expected arg 0 (color)");
|
||||
let color = Namespace::namespace(state, arg0)?.unwrap_or_else(||panic!("bg: {arg0:?}: not a color"));
|
||||
let thunk = Thunk::new(move|output: &mut TuiOut|state.understand(output, &arg1).unwrap());
|
||||
output.place(&Tui::bg(color, thunk))
|
||||
},
|
||||
|
||||
_ => return Ok(false)
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
[package]
|
||||
name = "tengri"
|
||||
edition = "2024"
|
||||
description = "UI metaframework."
|
||||
version = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = [ "input", "output", "tui" ]
|
||||
bumpalo = [ "dep:bumpalo" ]
|
||||
input = [ ]
|
||||
output = [ ]
|
||||
tui = [ ]
|
||||
dsl = [ ]
|
||||
|
||||
[dependencies]
|
||||
atomic_float = { workspace = true }
|
||||
better-panic = { workspace = true }
|
||||
bumpalo = { workspace = true, optional = true }
|
||||
crossterm = { workspace = true }
|
||||
dizzle = { workspace = true }
|
||||
palette = { workspace = true }
|
||||
quanta = { workspace = true }
|
||||
rand = { workspace = true }
|
||||
ratatui = { workspace = true }
|
||||
unicode-width = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
tengri_proc = { workspace = true }
|
||||
tengri = { workspace = true, features = [ "dsl" ] }
|
||||
crossterm = { workspace = true }
|
||||
proptest = { workspace = true }
|
||||
proptest-derive = { workspace = true }
|
||||
|
||||
[lib]
|
||||
path = "tengri.rs"
|
||||
|
||||
[target.'cfg(target_os = "linux")']
|
||||
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue