mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: <200 errors yay
This commit is contained in:
parent
14d619a10a
commit
694970bf0d
20 changed files with 384 additions and 305 deletions
|
|
@ -22,21 +22,20 @@ pub struct AddSampleModal {
|
|||
|
||||
exit!(AddSampleModal);
|
||||
|
||||
impl<'a> Render<TuiOutput<'a>, Rect> for AddSampleModal {
|
||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
||||
make_dim(to.buffer);
|
||||
impl Render<Tui> for AddSampleModal {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||
let area = to.area();
|
||||
to.make_dim();
|
||||
let area = center_box(
|
||||
to.area,
|
||||
64.max(to.area.width.saturating_sub(8)),
|
||||
20.max(to.area.width.saturating_sub(8)),
|
||||
area,
|
||||
64.max(area.width.saturating_sub(8)),
|
||||
20.max(area.width.saturating_sub(8)),
|
||||
);
|
||||
fill_fg(to.buffer, area, Color::Reset);
|
||||
fill_bg(to.buffer, area, Nord::bg_lo(true, true));
|
||||
fill_char(to.buffer, area, ' ');
|
||||
format!("{}", &self.dir.to_string_lossy())
|
||||
.blit(to.buffer, area.x+2, area.y+1, Some(Style::default().bold()))?;
|
||||
"Select sample:"
|
||||
.blit(to.buffer, area.x+2, area.y+2, Some(Style::default().bold()))?;
|
||||
to.fill_fg(area, Color::Reset);
|
||||
to.fill_bg(area, Nord::bg_lo(true, true));
|
||||
to.fill_char(area, ' ');
|
||||
to.blit(&format!("{}", &self.dir.to_string_lossy()), area.x+2, area.y+1, Some(Style::default().bold()))?;
|
||||
to.blit(&"Select sample:", area.x+2, area.y+2, Some(Style::default().bold()))?;
|
||||
for (i, (is_dir, name)) in self.subdirs.iter()
|
||||
.map(|path|(true, path))
|
||||
.chain(self.files.iter().map(|path|(false, path)))
|
||||
|
|
@ -49,7 +48,7 @@ impl<'a> Render<TuiOutput<'a>, Rect> for AddSampleModal {
|
|||
let t = if is_dir { "" } else { "" };
|
||||
let line = format!("{t} {}", name.to_string_lossy());
|
||||
let line = &line[..line.len().min(area.width as usize - 4)];
|
||||
line.blit(to.buffer, area.x + 2, area.y + 3 + i as u16, Some(if i == self.cursor {
|
||||
to.blit(&line, area.x + 2, area.y + 3 + i as u16, Some(if i == self.cursor {
|
||||
Style::default().green()
|
||||
} else {
|
||||
Style::default().white()
|
||||
|
|
@ -58,13 +57,14 @@ impl<'a> Render<TuiOutput<'a>, Rect> for AddSampleModal {
|
|||
Lozenge(Style::default()).draw(to)
|
||||
}
|
||||
}
|
||||
|
||||
handle!(AddSampleModal |self,e|{
|
||||
if handle_keymap(self, e, KEYMAP_ADD_SAMPLE)? {
|
||||
return Ok(true)
|
||||
impl Handle<Tui> for AddSampleModal {
|
||||
fn handle (&mut self, e: &Tui) -> Usually<bool> {
|
||||
if handle_keymap(self, e, KEYMAP_ADD_SAMPLE)? {
|
||||
return Ok(true)
|
||||
}
|
||||
Ok(true)
|
||||
}
|
||||
Ok(true)
|
||||
});
|
||||
}
|
||||
|
||||
impl AddSampleModal {
|
||||
pub fn new (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue