mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
wip5 (66e): kk
This commit is contained in:
parent
5507b71973
commit
7d78811f68
4 changed files with 117 additions and 118 deletions
|
|
@ -112,6 +112,9 @@ impl Render<Tui> for Styled<&str> {
|
|||
}
|
||||
|
||||
pub trait BorderStyle: Send + Sync + Copy {
|
||||
fn wrap <W: Render<Tui>> (self, w: W) -> Bordered<Self, W> {
|
||||
Bordered(self, w)
|
||||
}
|
||||
const NW: &'static str = "";
|
||||
const N: &'static str = "";
|
||||
const NE: &'static str = "";
|
||||
|
|
|
|||
|
|
@ -52,8 +52,7 @@ impl<'a, T: HasEditor> From<&'a T> for PhraseView<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Content<Tui> for PhraseView<'a> {
|
||||
fn content (&self) -> impl Render<Tui> {
|
||||
render!(|self: PhraseView<'a>|{
|
||||
let Self {
|
||||
focused, entered, size,
|
||||
phrase, view_mode, buffer,
|
||||
|
|
@ -140,8 +139,7 @@ impl<'a> Content<Tui> for PhraseView<'a> {
|
|||
Tui::push_y(1, Widget::new(|to|Ok(Some(to)), cursor))
|
||||
)),
|
||||
))))
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum PhraseViewMode {
|
||||
|
|
|
|||
|
|
@ -63,14 +63,13 @@ render!(|self: PhraseListView<'a>|{
|
|||
}
|
||||
});
|
||||
let border_color = if *focused {Color::Rgb(100, 110, 40)} else {Color::Rgb(70, 80, 50)};
|
||||
let border = Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(border_color));
|
||||
let content = content.fill_xy().bg(Color::Rgb(28, 35, 25)).border(border);
|
||||
let content = Tui::bg(Color::Rgb(28, 35, 25), Tui::fill_xy(content));
|
||||
let title_color = if *focused {Color::Rgb(150, 160, 90)} else {Color::Rgb(120, 130, 100)};
|
||||
let upper_left = format!("[{}] {title}", if *entered {"■"} else {" "});
|
||||
let upper_right = format!("({})", phrases.len());
|
||||
lay!(
|
||||
content,
|
||||
Tui::fg(title_color, upper_left.to_string()).push_x(1).align_nw().fill_xy(),
|
||||
Tui::fg(title_color, upper_right.to_string()).pull_x(1).align_ne().fill_xy(),
|
||||
Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(border_color)).wrap(content),
|
||||
Tui::fill_xy(Tui::at_nw(Tui::push_x(1, Tui::fg(title_color, upper_left.to_string())))),
|
||||
Tui::fill_xy(Tui::at_ne(Tui::pull_x(1, Tui::fg(title_color, upper_right.to_string())))),
|
||||
)
|
||||
});
|
||||
|
|
|
|||
|
|
@ -35,28 +35,27 @@ impl<'a> PhraseSelector<'a> {
|
|||
}
|
||||
|
||||
// TODO: Display phrases always in order of appearance
|
||||
impl<'a> Content<Tui> for PhraseSelector<'a> {
|
||||
fn content (&self) -> impl Render<Tui> {
|
||||
render!(|self:PhraseSelector<'a>|{
|
||||
let Self { title, phrase, focused, entered } = self;
|
||||
let content = Layers::new(move|add|{
|
||||
if let Some((instant, Some(phrase))) = phrase {
|
||||
let Phrase { ref name, color, length, .. } = *phrase.read().unwrap();
|
||||
let length = PhraseLength::new(length, None);
|
||||
let length = length.align_e().fill_x();
|
||||
let row1 = lay!(format!(" ").align_w().fill_x(), length).fill_x();
|
||||
let length = Tui::fill_x(Tui::at_e(length));
|
||||
let row1 = Tui::fill_x(lay!(Tui::fill_x(Tui::at_w(format!(" "))), length));
|
||||
let row2 = format!(" {name}");
|
||||
let row2 = TuiStyle::bold(row2, true);
|
||||
let row2 = Tui::bold(true, row2);
|
||||
add(&Tui::bg(color.base.rgb, Tui::fill_x(Tui::to_south(row1, row2))))?;
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
let border_color = if *focused {Color::Rgb(100, 110, 40)} else {Color::Rgb(70, 80, 50)};
|
||||
let border = Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(border_color));
|
||||
let content = content.fill_xy().bg(Color::Rgb(28, 35, 25)).border(border);
|
||||
//let content = Tui::bg(Color::Rgb(28, 35, 25), Tui::fill_xy(content)).border(border);
|
||||
let content = Tui::bg(Color::Rgb(28, 35, 25), Tui::fill_xy(content));
|
||||
let title_color = if *focused {Color::Rgb(150, 160, 90)} else {Color::Rgb(120, 130, 100)};
|
||||
lay!(
|
||||
content,
|
||||
TuiStyle::fg(*title, title_color).push_x(1).align_nw().fill_xy(),
|
||||
Tui::over(
|
||||
border.wrap(content),
|
||||
Tui::fill_xy(Tui::at_nw(Tui::push_x(1, Tui::fg(title_color, *title)))),
|
||||
)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue