rename: tek, Tek -> app, App
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
🪞👃🪞 2025-05-09 17:28:09 +03:00
parent cc88743054
commit 87cd6099ad
11 changed files with 139 additions and 139 deletions

View file

@ -7,7 +7,7 @@ macro_rules! ns { ($C:ty, $s:expr, $a:expr, $W:expr) => { <$C>::try_from_expr($s
macro_rules! cmd { ($cmd:expr) => {{ $cmd; None }}; }
macro_rules! cmd_todo { ($msg:literal) => {{ println!($msg); None }}; }
handle!(TuiIn: |self: Tek, input|Ok(if let Some(command) = self.config.keys.command(self, input) {
handle!(TuiIn: |self: App, input|Ok(if let Some(command) = self.config.keys.command(self, input) {
let undo = command.execute(self)?;
if let Some(undo) = undo {
self.history.push(undo);
@ -17,7 +17,7 @@ handle!(TuiIn: |self: Tek, input|Ok(if let Some(command) = self.config.keys.comm
None
}));
#[tengri_proc::expose] impl Tek {
#[tengri_proc::expose] impl App {
fn focus_editor (&self) -> bool {
self.is_editing()
}
@ -253,30 +253,30 @@ handle!(TuiIn: |self: Tek, input|Ok(if let Some(command) = self.config.keys.comm
}
}
#[tengri_proc::command(Tek)] impl TekCommand {
fn toggle_help (tek: &mut Tek, value: bool) -> Perhaps<Self> {
tek.toggle_dialog(Some(Dialog::Help));
#[tengri_proc::command(App)] impl AppCommand {
fn toggle_help (app: &mut App, value: bool) -> Perhaps<Self> {
app.toggle_dialog(Some(Dialog::Help));
Ok(None)
}
fn toggle_menu (tek: &mut Tek, value: bool) -> Perhaps<Self> {
tek.toggle_dialog(Some(Dialog::Menu));
fn toggle_menu (app: &mut App, value: bool) -> Perhaps<Self> {
app.toggle_dialog(Some(Dialog::Menu));
Ok(None)
}
fn toggle_edit (tek: &mut Tek, value: bool) -> Perhaps<Self> {
tek.toggle_editor(Some(value));
fn toggle_edit (app: &mut App, value: bool) -> Perhaps<Self> {
app.toggle_editor(Some(value));
Ok(None)
}
fn editor (tek: &mut Tek, command: MidiEditCommand) -> Perhaps<Self> {
Ok(tek.editor.as_mut().map(|editor|command.execute(editor))
fn editor (app: &mut App, command: MidiEditCommand) -> Perhaps<Self> {
Ok(app.editor.as_mut().map(|editor|command.execute(editor))
.transpose()?
.flatten()
.map(|undo|Self::Editor { command: undo }))
}
fn pool (tek: &mut Tek, command: PoolCommand) -> Perhaps<Self> {
Ok(if let Some(pool) = tek.pool.as_mut() {
let undo = command.clone().delegate(pool, |command|TekCommand::Pool{command})?;
fn pool (app: &mut App, command: PoolCommand) -> Perhaps<Self> {
Ok(if let Some(pool) = app.pool.as_mut() {
let undo = command.clone().delegate(pool, |command|AppCommand::Pool{command})?;
// update linked editor after pool action
tek.editor.as_mut().map(|editor|match command {
app.editor.as_mut().map(|editor|match command {
// autoselect: automatically load selected clip in editor
PoolCommand::Select { .. } |
// autocolor: update color in all places simultaneously
@ -289,54 +289,54 @@ handle!(TuiIn: |self: Tek, input|Ok(if let Some(command) = self.config.keys.comm
None
})
}
fn sampler (tek: &mut Tek, command: SamplerCommand) -> Perhaps<Self> {
Ok(tek.sampler_mut()
fn sampler (app: &mut App, command: SamplerCommand) -> Perhaps<Self> {
Ok(app.sampler_mut()
.map(|s|command.delegate(s, |command|Self::Sampler{command}))
.transpose()?
.flatten())
}
fn scene (tek: &mut Tek, command: SceneCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Scene{command})?)
fn scene (app: &mut App, command: SceneCommand) -> Perhaps<Self> {
Ok(command.delegate(app, |command|Self::Scene{command})?)
}
fn track (tek: &mut Tek, command: TrackCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Track{command})?)
fn track (app: &mut App, command: TrackCommand) -> Perhaps<Self> {
Ok(command.delegate(app, |command|Self::Track{command})?)
}
fn input (tek: &mut Tek, command: InputCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Input{command})?)
fn input (app: &mut App, command: InputCommand) -> Perhaps<Self> {
Ok(command.delegate(app, |command|Self::Input{command})?)
}
fn output (tek: &mut Tek, command: OutputCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Output{command})?)
fn output (app: &mut App, command: OutputCommand) -> Perhaps<Self> {
Ok(command.delegate(app, |command|Self::Output{command})?)
}
fn clip (tek: &mut Tek, command: ClipCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Clip{command})?)
fn clip (app: &mut App, command: ClipCommand) -> Perhaps<Self> {
Ok(command.delegate(app, |command|Self::Clip{command})?)
}
fn clock (tek: &mut Tek, command: ClockCommand) -> Perhaps<Self> {
Ok(command.execute(&mut tek.clock)?.map(|command|Self::Clock{command}))
fn clock (app: &mut App, command: ClockCommand) -> Perhaps<Self> {
Ok(command.execute(&mut app.clock)?.map(|command|Self::Clock{command}))
}
fn device (tek: &mut Tek, command: DeviceCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Device{command})?)
fn device (app: &mut App, command: DeviceCommand) -> Perhaps<Self> {
Ok(command.delegate(app, |command|Self::Device{command})?)
}
fn message (tek: &mut Tek, command: MessageCommand) -> Perhaps<Self> {
Ok(command.delegate(tek, |command|Self::Message{command})?)
fn message (app: &mut App, command: MessageCommand) -> Perhaps<Self> {
Ok(command.delegate(app, |command|Self::Message{command})?)
}
fn color (tek: &mut Tek, theme: ItemTheme) -> Perhaps<Self> {
Ok(tek.set_color(Some(theme)).map(|theme|Self::Color{theme}))
fn color (app: &mut App, theme: ItemTheme) -> Perhaps<Self> {
Ok(app.set_color(Some(theme)).map(|theme|Self::Color{theme}))
}
fn enqueue (tek: &mut Tek, clip: Option<Arc<RwLock<MidiClip>>>) -> Perhaps<Self> {
fn enqueue (app: &mut App, clip: Option<Arc<RwLock<MidiClip>>>) -> Perhaps<Self> {
todo!()
}
fn history (tek: &mut Tek, delta: isize) -> Perhaps<Self> {
fn history (app: &mut App, delta: isize) -> Perhaps<Self> {
todo!()
}
fn zoom (tek: &mut Tek, zoom: usize) -> Perhaps<Self> {
fn zoom (app: &mut App, zoom: usize) -> Perhaps<Self> {
todo!()
}
fn launch (tek: &mut Tek) -> Perhaps<Self> {
tek.launch();
fn launch (app: &mut App) -> Perhaps<Self> {
app.launch();
Ok(None)
}
fn select (tek: &mut Tek, selection: Selection) -> Perhaps<Self> {
tek.select(selection);
fn select (app: &mut App, selection: Selection) -> Perhaps<Self> {
app.select(selection);
Ok(None)
//("select" [t: usize, s: usize] Some(match (t.expect("no track"), s.expect("no scene")) {
//(0, 0) => Self::Select(Selection::Mix),
@ -344,149 +344,149 @@ handle!(TuiIn: |self: Tek, input|Ok(if let Some(command) = self.config.keys.comm
//(0, s) => Self::Select(Selection::Scene(s)),
//(t, s) => Self::Select(Selection::TrackClip { track: t, scene: s }) })))
}
fn stop_all (tek: &mut Tek) -> Perhaps<Self> {
tek.stop_all();
fn stop_all (app: &mut App) -> Perhaps<Self> {
app.stop_all();
Ok(None)
}
}
#[tengri_proc::command(Tek)] impl InputCommand {
fn add (tek: &mut Tek) -> Perhaps<Self> {
tek.midi_in_add()?;
#[tengri_proc::command(App)] impl InputCommand {
fn add (app: &mut App) -> Perhaps<Self> {
app.midi_in_add()?;
Ok(None)
}
}
#[tengri_proc::command(Tek)] impl OutputCommand {
fn add (tek: &mut Tek) -> Perhaps<Self> {
tek.midi_out_add()?;
#[tengri_proc::command(App)] impl OutputCommand {
fn add (app: &mut App) -> Perhaps<Self> {
app.midi_out_add()?;
Ok(None)
}
}
#[tengri_proc::command(Tek)] impl DeviceCommand {
fn picker (tek: &mut Tek) -> Perhaps<Self> {
tek.device_picker_show();
#[tengri_proc::command(App)] impl DeviceCommand {
fn picker (app: &mut App) -> Perhaps<Self> {
app.device_picker_show();
Ok(None)
}
fn pick (tek: &mut Tek, i: usize) -> Perhaps<Self> {
tek.device_pick(i);
fn pick (app: &mut App, i: usize) -> Perhaps<Self> {
app.device_pick(i);
Ok(None)
}
fn add (tek: &mut Tek, i: usize) -> Perhaps<Self> {
tek.device_add(i);
fn add (app: &mut App, i: usize) -> Perhaps<Self> {
app.device_add(i);
Ok(None)
}
}
#[tengri_proc::command(Tek)] impl MessageCommand {
fn dismiss (tek: &mut Tek) -> Perhaps<Self> {
tek.message_dismiss();
#[tengri_proc::command(App)] impl MessageCommand {
fn dismiss (app: &mut App) -> Perhaps<Self> {
app.message_dismiss();
Ok(None)
}
}
#[tengri_proc::command(Tek)] impl TrackCommand {
fn toggle_play (tek: &mut Tek) -> Perhaps<Self> {
#[tengri_proc::command(App)] impl TrackCommand {
fn toggle_play (app: &mut App) -> Perhaps<Self> {
todo!()
}
fn toggle_solo (tek: &mut Tek) -> Perhaps<Self> {
fn toggle_solo (app: &mut App) -> Perhaps<Self> {
todo!()
}
fn toggle_rec (tek: &mut Tek) -> Perhaps<Self> {
tek.track_toggle_record();
fn toggle_rec (app: &mut App) -> Perhaps<Self> {
app.track_toggle_record();
Ok(Some(Self::ToggleRec))
}
fn toggle_mon (tek: &mut Tek) -> Perhaps<Self> {
tek.track_toggle_monitor();
fn toggle_mon (app: &mut App) -> Perhaps<Self> {
app.track_toggle_monitor();
Ok(Some(Self::ToggleMon))
}
fn set_size (tek: &mut Tek, size: usize) -> Perhaps<Self> {
fn set_size (app: &mut App, size: usize) -> Perhaps<Self> {
todo!()
}
fn set_zoom (tek: &mut Tek, zoom: usize) -> Perhaps<Self> {
fn set_zoom (app: &mut App, zoom: usize) -> Perhaps<Self> {
todo!()
}
fn swap (tek: &mut Tek, index: usize, other: usize) -> Perhaps<Self> {
fn swap (app: &mut App, index: usize, other: usize) -> Perhaps<Self> {
todo!();
Ok(Some(Self::Swap { index, other }))
}
fn del (tek: &mut Tek, index: usize) -> Perhaps<Self> {
tek.track_del(index);
fn del (app: &mut App, index: usize) -> Perhaps<Self> {
app.track_del(index);
Ok(None)
}
fn stop (tek: &mut Tek, index: usize) -> Perhaps<Self> {
tek.tracks[index].player.enqueue_next(None);
fn stop (app: &mut App, index: usize) -> Perhaps<Self> {
app.tracks[index].player.enqueue_next(None);
Ok(None)
}
fn add (tek: &mut Tek) -> Perhaps<Self> {
Ok(Some(Self::Del { index: tek.track_add_focus()? }))
fn add (app: &mut App) -> Perhaps<Self> {
Ok(Some(Self::Del { index: app.track_add_focus()? }))
}
fn set_color (tek: &mut Tek, index: usize, color: ItemTheme) -> Perhaps<Self> {
Ok(Some(Self::SetColor { index, color: tek.track_set_color(index, color) }))
fn set_color (app: &mut App, index: usize, color: ItemTheme) -> Perhaps<Self> {
Ok(Some(Self::SetColor { index, color: app.track_set_color(index, color) }))
}
}
#[tengri_proc::command(Tek)] impl SceneCommand {
fn add (tek: &mut Tek) -> Perhaps<Self> {
#[tengri_proc::command(App)] impl SceneCommand {
fn add (app: &mut App) -> Perhaps<Self> {
todo!()
}
fn del (tek: &mut Tek, index: usize) -> Perhaps<Self> {
tek.scene_del(index);
fn del (app: &mut App, index: usize) -> Perhaps<Self> {
app.scene_del(index);
Ok(None)
}
fn enqueue (tek: &mut Tek, index: usize) -> Perhaps<Self> {
tek.scene_enqueue(index);
fn enqueue (app: &mut App, index: usize) -> Perhaps<Self> {
app.scene_enqueue(index);
Ok(None)
}
fn set_color (tek: &mut Tek, index: usize, color: ItemTheme) -> Perhaps<Self> {
Ok(Some(Self::SetColor { index, color: tek.scene_set_color(index, color) }))
fn set_color (app: &mut App, index: usize, color: ItemTheme) -> Perhaps<Self> {
Ok(Some(Self::SetColor { index, color: app.scene_set_color(index, color) }))
}
fn set_size (tek: &mut Tek, index: usize, size: usize) -> Perhaps<Self> {
fn set_size (app: &mut App, index: usize, size: usize) -> Perhaps<Self> {
todo!()
}
fn set_zoom (tek: &mut Tek, index: usize, zoom: usize) -> Perhaps<Self> {
fn set_zoom (app: &mut App, index: usize, zoom: usize) -> Perhaps<Self> {
todo!()
}
fn swap (tek: &mut Tek, index: usize, other: usize) -> Perhaps<Self> {
fn swap (app: &mut App, index: usize, other: usize) -> Perhaps<Self> {
todo!();
Ok(Some(Self::Swap { index, other }))
}
}
#[tengri_proc::command(Tek)] impl ClipCommand {
fn get (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> {
#[tengri_proc::command(App)] impl ClipCommand {
fn get (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//(Get [a: usize, b: usize] cmd_todo!("\n\rtodo: clip: get: {a} {b}"))
//("get" [a: usize, b: usize] Some(Self::Get(a.unwrap(), b.unwrap())))
todo!()
}
fn edit (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> {
fn edit (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//(Edit [clip: MaybeClip] cmd_todo!("\n\rtodo: clip: edit: {clip:?}"))
//("edit" [a: MaybeClip] Some(Self::Edit(a.unwrap())))
todo!()
}
fn set_loop (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> {
fn set_loop (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//(SetLoop [t: usize, s: usize, l: bool] cmd_todo!("\n\rtodo: {self:?}"))
//("loop" [a: usize, b: usize, c: bool] Some(Self::SetLoop(a.unwrap(), b.unwrap(), c.unwrap())))
todo!()
}
fn put (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> {
fn put (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//(Put [t: usize, s: usize, c: MaybeClip]
//Some(Self::Put(t, s, app.clip_put(t, s, c))))
//("put" [a: usize, b: usize, c: MaybeClip] Some(Self::Put(a.unwrap(), b.unwrap(), c.unwrap())))
todo!()
}
fn del (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> {
fn del (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//("delete" [a: usize, b: usize] Some(Self::Put(a.unwrap(), b.unwrap(), None))))
todo!()
}
fn enqueue (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> {
fn enqueue (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//(Enqueue [t: usize, s: usize]
//cmd!(app.tracks[t].player.enqueue_next(app.scenes[s].clips[t].as_ref())))
//("enqueue" [a: usize, b: usize] Some(Self::Enqueue(a.unwrap(), b.unwrap())))
todo!()
}
fn set_color (tek: &mut Tek, a: usize, b: usize) -> Perhaps<Self> {
fn set_color (app: &mut App, a: usize, b: usize) -> Perhaps<Self> {
//(SetColor [t: usize, s: usize, c: ItemTheme]
//app.clip_set_color(t, s, c).map(|o|Self::SetColor(t, s, o)))));
//("color" [a: usize, b: usize] Some(Self::SetColor(a.unwrap(), b.unwrap(), ItemTheme::random())))