mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: <200 errors yay
This commit is contained in:
parent
14d619a10a
commit
694970bf0d
20 changed files with 384 additions and 305 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use crate::*;
|
||||
impl<'a> Arranger<TuiOutput<'a>, Rect> {
|
||||
impl<'a> Arranger<Tui> {
|
||||
pub fn rename_selected (&mut self) {
|
||||
self.modal = Some(Box::new(ArrangerRenameModal::new(
|
||||
self.selected,
|
||||
|
|
@ -31,16 +31,17 @@ impl ArrangerRenameModal {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl<'a> Render<TuiOutput<'a>, Rect> for ArrangerRenameModal {
|
||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
||||
let y = to.area.y + to.area.height / 2;
|
||||
impl Render<Tui> for ArrangerRenameModal {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||
let area = to.area();
|
||||
let y = area.y + area.height / 2;
|
||||
let bg_area = Rect {
|
||||
x: 1,
|
||||
y: y - 1,
|
||||
width: to.area.width - 2,
|
||||
width: area.width - 2,
|
||||
height: 3
|
||||
};
|
||||
fill_bg(to.buffer, bg_area, Nord::BG0);
|
||||
to.fill_bg(bg_area, Nord::BG0);
|
||||
Lozenge(Style::default().bold().white().dim()).draw(to.buffer, bg_area)?;
|
||||
let label = match self.target {
|
||||
ArrangerFocus::Mix => "Rename project:",
|
||||
|
|
@ -49,50 +50,52 @@ impl<'a> Render<TuiOutput<'a>, Rect> for ArrangerRenameModal {
|
|||
ArrangerFocus::Clip(_, _) => "Rename clip:",
|
||||
};
|
||||
let style = Some(Style::default().not_bold().white().not_dim());
|
||||
label.blit(to.buffer, to.area.x + 3, y, style)?;
|
||||
to.blit(&label, area.x + 3, y, style)?;
|
||||
let style = Some(Style::default().bold().white().not_dim());
|
||||
self.value.blit(to.buffer, to.area.x + 3 + label.len() as u16 + 1, y, style)?;
|
||||
to.blit(&self.value, area.x + 3 + label.len() as u16 + 1, y, style)?;
|
||||
let style = Some(Style::default().bold().white().not_dim().reversed());
|
||||
"▂".blit(to.buffer, to.area.x + 3 + label.len() as u16 + 1 + self.cursor as u16, y, style)?;
|
||||
Ok(Some(to.area))
|
||||
to.blit(&"▂", area.x + 3 + label.len() as u16 + 1 + self.cursor as u16, y, style)?;
|
||||
Ok(Some(area))
|
||||
}
|
||||
}
|
||||
handle!(ArrangerRenameModal |self, e| {
|
||||
match e {
|
||||
AppEvent::Input(Event::Key(k)) => {
|
||||
match k.code {
|
||||
KeyCode::Esc => {
|
||||
self.exit();
|
||||
},
|
||||
KeyCode::Enter => {
|
||||
*self.result.write().unwrap() = self.value.clone();
|
||||
self.exit();
|
||||
},
|
||||
KeyCode::Left => {
|
||||
self.cursor = self.cursor.saturating_sub(1);
|
||||
},
|
||||
KeyCode::Right => {
|
||||
self.cursor = self.value.len().min(self.cursor + 1)
|
||||
},
|
||||
KeyCode::Backspace => {
|
||||
let last = self.value.len().saturating_sub(1);
|
||||
self.value = format!("{}{}",
|
||||
&self.value[0..self.cursor.min(last)],
|
||||
&self.value[self.cursor.min(last)..last]
|
||||
);
|
||||
self.cursor = self.cursor.saturating_sub(1)
|
||||
impl Handle<Tui> for TransportQuantize {
|
||||
fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
|
||||
match e {
|
||||
AppEvent::Input(Event::Key(k)) => {
|
||||
match k.code {
|
||||
KeyCode::Esc => {
|
||||
self.exit();
|
||||
},
|
||||
KeyCode::Enter => {
|
||||
*self.result.write().unwrap() = self.value.clone();
|
||||
self.exit();
|
||||
},
|
||||
KeyCode::Left => {
|
||||
self.cursor = self.cursor.saturating_sub(1);
|
||||
},
|
||||
KeyCode::Right => {
|
||||
self.cursor = self.value.len().min(self.cursor + 1)
|
||||
},
|
||||
KeyCode::Backspace => {
|
||||
let last = self.value.len().saturating_sub(1);
|
||||
self.value = format!("{}{}",
|
||||
&self.value[0..self.cursor.min(last)],
|
||||
&self.value[self.cursor.min(last)..last]
|
||||
);
|
||||
self.cursor = self.cursor.saturating_sub(1)
|
||||
}
|
||||
KeyCode::Char(c) => {
|
||||
self.value.insert(self.cursor, c);
|
||||
self.cursor = self.value.len().min(self.cursor + 1)
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
KeyCode::Char(c) => {
|
||||
self.value.insert(self.cursor, c);
|
||||
self.cursor = self.value.len().min(self.cursor + 1)
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
Ok(true)
|
||||
},
|
||||
_ => Ok(false),
|
||||
Ok(true)
|
||||
},
|
||||
_ => Ok(false),
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
impl Exit for ArrangerRenameModal {
|
||||
fn exited (&self) -> bool {
|
||||
self.done
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue