mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
0.5.0: Tui::modify, Bold -> Modify
This commit is contained in:
parent
a42e17a9d4
commit
b43cd0f64f
4 changed files with 38 additions and 35 deletions
40
Cargo.lock
generated
40
Cargo.lock
generated
|
|
@ -188,9 +188,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "darling"
|
name = "darling"
|
||||||
version = "0.20.10"
|
version = "0.20.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989"
|
checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling_core",
|
"darling_core",
|
||||||
"darling_macro",
|
"darling_macro",
|
||||||
|
|
@ -198,9 +198,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "darling_core"
|
name = "darling_core"
|
||||||
version = "0.20.10"
|
version = "0.20.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5"
|
checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fnv",
|
"fnv",
|
||||||
"ident_case",
|
"ident_case",
|
||||||
|
|
@ -212,9 +212,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "darling_macro"
|
name = "darling_macro"
|
||||||
version = "0.20.10"
|
version = "0.20.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
|
checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling_core",
|
"darling_core",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
@ -441,9 +441,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.26"
|
version = "0.4.27"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
|
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lru"
|
name = "lru"
|
||||||
|
|
@ -462,9 +462,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.8.5"
|
version = "0.8.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5"
|
checksum = "ff70ce3e48ae43fa075863cef62e8b43b71a4f2382229920e0df362592919430"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"adler2",
|
"adler2",
|
||||||
]
|
]
|
||||||
|
|
@ -501,9 +501,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.21.1"
|
version = "1.21.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc"
|
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "palette"
|
name = "palette"
|
||||||
|
|
@ -791,9 +791,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "1.0.3"
|
version = "1.0.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96"
|
checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"errno",
|
"errno",
|
||||||
|
|
@ -928,13 +928,13 @@ dependencies = [
|
||||||
"fastrand",
|
"fastrand",
|
||||||
"getrandom 0.3.2",
|
"getrandom 0.3.2",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix 1.0.3",
|
"rustix 1.0.5",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri"
|
name = "tengri"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tengri_dsl",
|
"tengri_dsl",
|
||||||
"tengri_input",
|
"tengri_input",
|
||||||
|
|
@ -944,7 +944,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_dsl"
|
name = "tengri_dsl"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools 0.14.0",
|
"itertools 0.14.0",
|
||||||
"konst",
|
"konst",
|
||||||
|
|
@ -955,7 +955,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_input"
|
name = "tengri_input"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tengri_dsl",
|
"tengri_dsl",
|
||||||
"tengri_tui",
|
"tengri_tui",
|
||||||
|
|
@ -963,7 +963,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_output"
|
name = "tengri_output"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proptest",
|
"proptest",
|
||||||
"proptest-derive",
|
"proptest-derive",
|
||||||
|
|
@ -974,7 +974,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_tui"
|
name = "tengri_tui"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomic_float",
|
"atomic_float",
|
||||||
"better-panic",
|
"better-panic",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
|
||||||
|
|
@ -152,8 +152,11 @@ pub trait TuiStyle {
|
||||||
fn fg_bg <R: Content<TuiOut>> (fg: Color, bg: Color, w: R) -> Background<Foreground<R>> {
|
fn fg_bg <R: Content<TuiOut>> (fg: Color, bg: Color, w: R) -> Background<Foreground<R>> {
|
||||||
Background(bg, Foreground(fg, w))
|
Background(bg, Foreground(fg, w))
|
||||||
}
|
}
|
||||||
fn bold <R: Content<TuiOut>> (enable: bool, w: R) -> Bold<R> {
|
fn modify <R: Content<TuiOut>> (enable: bool, modifier: Modifier, w: R) -> Modify<R> {
|
||||||
Bold(enable, w)
|
Modify(enable, modifier, w)
|
||||||
|
}
|
||||||
|
fn bold <R: Content<TuiOut>> (enable: bool, w: R) -> Modify<R> {
|
||||||
|
Self::modify(enable, Modifier::BOLD, w)
|
||||||
}
|
}
|
||||||
fn border <R: Content<TuiOut>, S: BorderStyle> (enable: bool, style: S, w: R) -> Bordered<S, R> {
|
fn border <R: Content<TuiOut>, S: BorderStyle> (enable: bool, style: S, w: R) -> Bordered<S, R> {
|
||||||
Bordered(enable, style, w)
|
Bordered(enable, style, w)
|
||||||
|
|
@ -162,16 +165,7 @@ pub trait TuiStyle {
|
||||||
|
|
||||||
impl TuiStyle for Tui {}
|
impl TuiStyle for Tui {}
|
||||||
|
|
||||||
pub struct Bold<R: Content<TuiOut>>(pub bool, R);
|
pub struct Foreground<R: Content<TuiOut>>(pub Color, pub R);
|
||||||
impl<R: Content<TuiOut>> Content<TuiOut> for Bold<R> {
|
|
||||||
fn content (&self) -> impl Render<TuiOut> { &self.1 }
|
|
||||||
fn render (&self, to: &mut TuiOut) {
|
|
||||||
to.fill_bold(to.area(), self.0);
|
|
||||||
self.1.render(to)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Foreground<R: Content<TuiOut>>(pub Color, R);
|
|
||||||
impl<R: Content<TuiOut>> Content<TuiOut> for Foreground<R> {
|
impl<R: Content<TuiOut>> Content<TuiOut> for Foreground<R> {
|
||||||
fn content (&self) -> impl Render<TuiOut> { &self.1 }
|
fn content (&self) -> impl Render<TuiOut> { &self.1 }
|
||||||
fn render (&self, to: &mut TuiOut) {
|
fn render (&self, to: &mut TuiOut) {
|
||||||
|
|
@ -180,7 +174,7 @@ impl<R: Content<TuiOut>> Content<TuiOut> for Foreground<R> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Background<R: Content<TuiOut>>(pub Color, R);
|
pub struct Background<R: Content<TuiOut>>(pub Color, pub R);
|
||||||
impl<R: Content<TuiOut>> Content<TuiOut> for Background<R> {
|
impl<R: Content<TuiOut>> Content<TuiOut> for Background<R> {
|
||||||
fn content (&self) -> impl Render<TuiOut> { &self.1 }
|
fn content (&self) -> impl Render<TuiOut> { &self.1 }
|
||||||
fn render (&self, to: &mut TuiOut) {
|
fn render (&self, to: &mut TuiOut) {
|
||||||
|
|
@ -189,6 +183,15 @@ impl<R: Content<TuiOut>> Content<TuiOut> for Background<R> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct Modify<R: Content<TuiOut>>(pub bool, pub Modifier, pub R);
|
||||||
|
impl<R: Content<TuiOut>> Content<TuiOut> for Modify<R> {
|
||||||
|
fn content (&self) -> impl Render<TuiOut> { &self.2 }
|
||||||
|
fn render (&self, to: &mut TuiOut) {
|
||||||
|
to.fill_mod(to.area(), self.0, self.1);
|
||||||
|
self.2.render(to)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Styled<R: Content<TuiOut>>(pub Option<Style>, pub R);
|
pub struct Styled<R: Content<TuiOut>>(pub Option<Style>, pub R);
|
||||||
impl<R: Content<TuiOut>> Content<TuiOut> for Styled<R> {
|
impl<R: Content<TuiOut>> Content<TuiOut> for Styled<R> {
|
||||||
fn content (&self) -> impl Render<TuiOut> { &self.1 }
|
fn content (&self) -> impl Render<TuiOut> { &self.1 }
|
||||||
|
|
|
||||||
|
|
@ -111,8 +111,8 @@ impl TuiOut {
|
||||||
}
|
}
|
||||||
pub fn tint_all (&mut self, fg: Color, bg: Color, modifier: Modifier) {
|
pub fn tint_all (&mut self, fg: Color, bg: Color, modifier: Modifier) {
|
||||||
for cell in self.buffer.content.iter_mut() {
|
for cell in self.buffer.content.iter_mut() {
|
||||||
cell.bg = bg;
|
|
||||||
cell.fg = fg;
|
cell.fg = fg;
|
||||||
|
cell.bg = bg;
|
||||||
cell.modifier = modifier;
|
cell.modifier = modifier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue