wip: borrow checker battles

This commit is contained in:
🪞👃🪞 2024-09-04 16:57:48 +03:00
parent 1d4db3c629
commit 7fbb40fad6
38 changed files with 778 additions and 708 deletions

View file

@ -23,20 +23,20 @@ pub struct AddSampleModal {
exit!(AddSampleModal);
impl<'a> Render<TuiOutput<'a>, Rect> for AddSampleModal {
fn render (&self, to: &mut TuiOutput<'a>) -> Usually<Rect> {
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
make_dim(to.buffer);
let area = center_box(
to.area,
64.max(to.area.width.saturating_sub(8)),
20.max(to.area.width.saturating_sub(8)),
);
fill_fg(buf, area, Color::Reset);
fill_bg(buf, area, Nord::bg_lo(true, true));
fill_char(buf, area, ' ');
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(buf, area.x+2, area.y+1, Some(Style::default().bold()))?;
.blit(to.buffer, area.x+2, area.y+1, Some(Style::default().bold()))?;
"Select sample:"
.blit(buf, area.x+2, area.y+2, Some(Style::default().bold()))?;
.blit(to.buffer, 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,13 +49,13 @@ 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(buf, area.x + 2, area.y + 3 + i as u16, Some(if i == self.cursor {
line.blit(to.buffer, area.x + 2, area.y + 3 + i as u16, Some(if i == self.cursor {
Style::default().green()
} else {
Style::default().white()
}))?;
}
Lozenge(Style::default()).draw(buf, area)
Lozenge(Style::default()).draw(to)
}
}