mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
shorten TuiIn, TuiOut
This commit is contained in:
parent
ca16a91015
commit
21741ebc52
20 changed files with 77 additions and 75 deletions
|
|
@ -160,7 +160,7 @@ input_to_command!(ArrangerCommand: <Tui>|state: ArrangerTui, input|match input.e
|
|||
None
|
||||
})?
|
||||
});
|
||||
fn to_arrangement_command (state: &ArrangerTui, input: &TuiInput) -> Option<ArrangerCommand> {
|
||||
fn to_arrangement_command (state: &ArrangerTui, input: &TuiIn) -> Option<ArrangerCommand> {
|
||||
use ArrangerCommand as Cmd;
|
||||
use ArrangerSelection as Selected;
|
||||
use ArrangerSceneCommand as Scene;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ from!(|args:(&ArrangerTui, usize)|ArrangerVCursor = Self {
|
|||
}),
|
||||
});
|
||||
impl Content<Tui> for ArrangerVCursor {
|
||||
fn render (&self, to: &mut TuiOutput) {
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
let area = to.area();
|
||||
let focused = true;
|
||||
let selected = self.selected;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ pub trait BorderStyle: Send + Sync + Copy {
|
|||
fn sw (&self) -> &str { Self::SW }
|
||||
fn se (&self) -> &str { Self::SE }
|
||||
#[inline] fn draw <'a> (
|
||||
&self, to: &mut TuiOutput
|
||||
&self, to: &mut TuiOut
|
||||
) -> Usually<()> {
|
||||
self.draw_horizontal(to, None)?;
|
||||
self.draw_vertical(to, None)?;
|
||||
|
|
@ -61,7 +61,7 @@ pub trait BorderStyle: Send + Sync + Copy {
|
|||
Ok(())
|
||||
}
|
||||
#[inline] fn draw_horizontal (
|
||||
&self, to: &mut TuiOutput, style: Option<Style>
|
||||
&self, to: &mut TuiOut, style: Option<Style>
|
||||
) -> Usually<[u16;4]> {
|
||||
let area = to.area();
|
||||
let style = style.or_else(||self.style_horizontal());
|
||||
|
|
@ -73,7 +73,7 @@ pub trait BorderStyle: Send + Sync + Copy {
|
|||
Ok(area)
|
||||
}
|
||||
#[inline] fn draw_vertical (
|
||||
&self, to: &mut TuiOutput, style: Option<Style>
|
||||
&self, to: &mut TuiOut, style: Option<Style>
|
||||
) -> Usually<[u16;4]> {
|
||||
let area = to.area();
|
||||
let style = style.or_else(||self.style_vertical());
|
||||
|
|
@ -91,7 +91,7 @@ pub trait BorderStyle: Send + Sync + Copy {
|
|||
Ok(area)
|
||||
}
|
||||
#[inline] fn draw_corners (
|
||||
&self, to: &mut TuiOutput, style: Option<Style>
|
||||
&self, to: &mut TuiOut, style: Option<Style>
|
||||
) -> Usually<[u16;4]> {
|
||||
let area = to.area();
|
||||
let style = style.or_else(||self.style_corners());
|
||||
|
|
@ -129,7 +129,7 @@ macro_rules! border {
|
|||
#[derive(Copy, Clone)]
|
||||
pub struct $T(pub Style);
|
||||
impl Content<Tui> for $T {
|
||||
fn render (&self, to: &mut TuiOutput) { self.draw(to); }
|
||||
fn render (&self, to: &mut TuiOut) { self.draw(to); }
|
||||
}
|
||||
)+}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ pub trait FocusWrap<T> {
|
|||
fn wrap <W: Content<Tui>> (self, focus: T, content: &'_ W) -> impl Content<Tui> + '_;
|
||||
}
|
||||
|
||||
pub fn to_focus_command <T: Send + Sync> (input: &TuiInput) -> Option<FocusCommand<T>> {
|
||||
pub fn to_focus_command <T: Send + Sync> (input: &TuiIn) -> Option<FocusCommand<T>> {
|
||||
Some(match input.event() {
|
||||
key_pat!(Tab) => FocusCommand::Next,
|
||||
key_pat!(Shift-Tab) => FocusCommand::Prev,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub(crate) use ::tek_layout::{
|
|||
Input, Handle, handle,
|
||||
kexp, key_pat, key_event_pat, key_event_expr,
|
||||
tui::{
|
||||
Tui, TuiInput, TuiOutput,
|
||||
Tui, TuiIn, TuiOut,
|
||||
crossterm::{
|
||||
self,
|
||||
event::{
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ pub struct TrackView<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Content<Tui> for TrackView<'a> {
|
||||
fn render (&self, to: &mut TuiOutput) {
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
todo!();
|
||||
//let mut area = to.area();
|
||||
//if let Some(chain) = self.chain {
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ impl Plugin {
|
|||
}
|
||||
}
|
||||
impl Content<Tui> for Plugin {
|
||||
fn render (&self, to: &mut TuiOutput) {
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
let area = to.area();
|
||||
let [x, y, _, height] = area;
|
||||
let mut width = 20u16;
|
||||
|
|
@ -187,7 +187,7 @@ impl Content<Tui> for Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
fn draw_header (state: &Plugin, to: &mut TuiOutput, x: u16, y: u16, w: u16) {
|
||||
fn draw_header (state: &Plugin, to: &mut TuiOut, x: u16, y: u16, w: u16) {
|
||||
let style = Style::default().gray();
|
||||
let label1 = format!(" {}", state.name);
|
||||
to.blit(&label1, x + 1, y, Some(style.white().bold()));
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ input_to_command!(PoolCommand:<Tui>|state: PoolModel,input|match state.phrases_m
|
|||
_ => to_phrases_command(state, input)?
|
||||
});
|
||||
|
||||
fn to_phrases_command (state: &PoolModel, input: &TuiInput) -> Option<PoolCommand> {
|
||||
fn to_phrases_command (state: &PoolModel, input: &TuiIn) -> Option<PoolCommand> {
|
||||
use KeyCode::{Up, Down, Delete, Char};
|
||||
use PoolCommand as Cmd;
|
||||
let index = state.phrase_index();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ impl Command<PoolModel> for PhraseRenameCommand {
|
|||
}
|
||||
|
||||
impl InputToCommand<Tui, PoolModel> for PhraseRenameCommand {
|
||||
fn input_to_command (state: &PoolModel, from: &TuiInput) -> Option<Self> {
|
||||
fn input_to_command (state: &PoolModel, from: &TuiIn) -> Option<Self> {
|
||||
use KeyCode::{Char, Backspace, Enter, Esc};
|
||||
if let Some(PoolMode::Rename(_, ref old_name)) = state.phrases_mode() {
|
||||
Some(match from.event() {
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ fn scan (dir: &PathBuf) -> Usually<(Vec<OsString>, Vec<OsString>)> {
|
|||
}
|
||||
|
||||
fn draw_sample (
|
||||
to: &mut TuiOutput, x: u16, y: u16, note: Option<&u7>, sample: &Sample, focus: bool
|
||||
to: &mut TuiOut, x: u16, y: u16, note: Option<&u7>, sample: &Sample, focus: bool
|
||||
) -> Usually<usize> {
|
||||
let style = if focus { Style::default().green() } else { Style::default() };
|
||||
if focus {
|
||||
|
|
@ -171,7 +171,7 @@ fn draw_sample (
|
|||
}
|
||||
|
||||
impl Content<Tui> for AddSampleModal {
|
||||
fn render (&self, to: &mut TuiOutput) {
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
todo!()
|
||||
//let area = to.area();
|
||||
//to.make_dim();
|
||||
|
|
@ -208,7 +208,7 @@ impl Content<Tui> for AddSampleModal {
|
|||
}
|
||||
|
||||
//impl Handle<Tui> for AddSampleModal {
|
||||
//fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
||||
//fn handle (&mut self, from: &TuiIn) -> Perhaps<bool> {
|
||||
//if from.handle_keymap(self, KEYMAP_ADD_SAMPLE)? {
|
||||
//return Ok(Some(true))
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ impl<W: Content<Tui>> Content<Tui> for Bold<W> {
|
|||
fn content (&self) -> impl Content<Tui> {
|
||||
Some(&self.1)
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) {
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
to.fill_bold(to.area(), self.0);
|
||||
self.1.render(to)
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ impl<W: Content<Tui>> Content<Tui> for Foreground<W> {
|
|||
fn content (&self) -> impl Content<Tui> {
|
||||
Some(&self.1)
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) {
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
to.fill_fg(to.area(), self.0);
|
||||
self.1.render(to)
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ impl<W: Content<Tui>> Content<Tui> for Background<W> {
|
|||
fn content (&self) -> impl Content<Tui> {
|
||||
Some(&self.1)
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) {
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
to.fill_bg(to.area(), self.0);
|
||||
self.1.render(to)
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ impl Content<Tui> for Styled<&str> {
|
|||
fn content (&self) -> impl Content<Tui> {
|
||||
Some(&self.1)
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) {
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
// FIXME
|
||||
let [x, y, ..] = to.area();
|
||||
//let [w, h] = self.min_size(to.area().wh())?.unwrap();
|
||||
|
|
|
|||
|
|
@ -180,12 +180,12 @@ command!(|self:TransportCommand,state:TransportTui|match self {
|
|||
//Ok(None)
|
||||
//});
|
||||
impl InputToCommand<Tui, TransportTui> for TransportCommand {
|
||||
fn input_to_command (state: &TransportTui, input: &TuiInput) -> Option<Self> {
|
||||
fn input_to_command (state: &TransportTui, input: &TuiIn) -> Option<Self> {
|
||||
to_transport_command(state, input)
|
||||
.or_else(||to_focus_command(input).map(TransportCommand::Focus))
|
||||
}
|
||||
}
|
||||
pub fn to_transport_command <T, U> (state: &T, input: &TuiInput) -> Option<TransportCommand>
|
||||
pub fn to_transport_command <T, U> (state: &T, input: &TuiIn) -> Option<TransportCommand>
|
||||
where
|
||||
T: TransportControl<U>,
|
||||
U: Into<Option<TransportFocus>>,
|
||||
|
|
@ -228,7 +228,7 @@ where
|
|||
}
|
||||
})
|
||||
}
|
||||
fn to_bpm_command (input: &TuiInput, bpm: f64) -> Option<TransportCommand> {
|
||||
fn to_bpm_command (input: &TuiIn, bpm: f64) -> Option<TransportCommand> {
|
||||
Some(match input.event() {
|
||||
key_pat!(Char(',')) => Clock(SetBpm(bpm - 1.0)),
|
||||
key_pat!(Char('.')) => Clock(SetBpm(bpm + 1.0)),
|
||||
|
|
@ -237,7 +237,7 @@ fn to_bpm_command (input: &TuiInput, bpm: f64) -> Option<TransportCommand> {
|
|||
_ => return None,
|
||||
})
|
||||
}
|
||||
fn to_quant_command (input: &TuiInput, quant: &Quantize) -> Option<TransportCommand> {
|
||||
fn to_quant_command (input: &TuiIn, quant: &Quantize) -> Option<TransportCommand> {
|
||||
Some(match input.event() {
|
||||
key_pat!(Char(',')) => Clock(SetQuant(quant.prev())),
|
||||
key_pat!(Char('.')) => Clock(SetQuant(quant.next())),
|
||||
|
|
@ -246,7 +246,7 @@ fn to_quant_command (input: &TuiInput, quant: &Quantize) -> Option<TransportComm
|
|||
_ => return None,
|
||||
})
|
||||
}
|
||||
fn to_sync_command (input: &TuiInput, sync: &LaunchSync) -> Option<TransportCommand> {
|
||||
fn to_sync_command (input: &TuiIn, sync: &LaunchSync) -> Option<TransportCommand> {
|
||||
Some(match input.event() {
|
||||
key_pat!(Char(',')) => Clock(SetSync(sync.prev())),
|
||||
key_pat!(Char('.')) => Clock(SetSync(sync.next())),
|
||||
|
|
@ -255,7 +255,7 @@ fn to_sync_command (input: &TuiInput, sync: &LaunchSync) -> Option<TransportComm
|
|||
_ => return None,
|
||||
})
|
||||
}
|
||||
fn to_seek_command (input: &TuiInput) -> Option<TransportCommand> {
|
||||
fn to_seek_command (input: &TuiIn) -> Option<TransportCommand> {
|
||||
Some(match input.event() {
|
||||
key_pat!(Char(',')) => todo!("transport seek bar"),
|
||||
key_pat!(Char('.')) => todo!("transport seek bar"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue