mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
implement bold modifier
This commit is contained in:
parent
794460b2e4
commit
581b0f5f3b
2 changed files with 23 additions and 1 deletions
|
|
@ -258,6 +258,13 @@ impl TuiOutput {
|
|||
) {
|
||||
buffer_update(&mut self.buffer, area, callback);
|
||||
}
|
||||
pub fn fill_bold (&mut self, area: [u16;4], on: bool) {
|
||||
if on {
|
||||
self.buffer_update(area, &|cell,_,_|cell.modifier.insert(Modifier::BOLD))
|
||||
} else {
|
||||
self.buffer_update(area, &|cell,_,_|cell.modifier.remove(Modifier::BOLD))
|
||||
}
|
||||
}
|
||||
pub fn fill_bg (&mut self, area: [u16;4], color: Color) {
|
||||
self.buffer_update(area, &|cell,_,_|{cell.set_bg(color);})
|
||||
}
|
||||
|
|
@ -428,12 +435,25 @@ pub trait TuiStyle: Widget<Engine = Tui> + Sized {
|
|||
fn bg (self, color: Color) -> impl Widget<Engine = Tui> {
|
||||
Layers::new(move |add|{ add(&Background(color))?; add(&self) })
|
||||
}
|
||||
fn bold (self, on: bool) -> impl Widget<Engine = Tui> {
|
||||
Layers::new(move |add|{ add(&Bold(on))?; add(&self) })
|
||||
}
|
||||
fn border (self, style: impl BorderStyle) -> impl Widget<Engine = Tui> {
|
||||
Bordered(style, self)
|
||||
}
|
||||
}
|
||||
impl<W: Widget<Engine = Tui>> TuiStyle for W {}
|
||||
|
||||
pub struct Bold(pub bool);
|
||||
impl Widget for Bold {
|
||||
type Engine = Tui;
|
||||
fn layout (&self, _: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
Ok(Some([0,0]))
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
Ok(to.fill_bold(to.area(), self.0))
|
||||
}
|
||||
}
|
||||
pub struct Foreground(pub Color);
|
||||
impl Widget for Foreground {
|
||||
type Engine = Tui;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@ impl Content for ArrangerStatusBar {
|
|||
Self::PhrasePool => "Phrases",
|
||||
Self::PhraseEditor => "Sequencer",
|
||||
};
|
||||
TuiStyle::bg(format!(" {label} "), Color::Rgb(150, 160, 90)).fg(Color::Rgb(0, 0, 0))
|
||||
TuiStyle::bg(format!(" {label} "), Color::Rgb(150, 160, 90))
|
||||
.fg(Color::Rgb(0, 0, 0))
|
||||
.bold(true)
|
||||
}
|
||||
}
|
||||
impl Content for Arrangement<Tui> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue