remove Tui suffixes

This commit is contained in:
🪞👃🪞 2025-01-06 21:10:36 +01:00
parent 8d519c53dc
commit 795d91abd8
14 changed files with 47 additions and 47 deletions

View file

@ -1,5 +1,5 @@
include!("./lib.rs");
use tek::ArrangerTui;
use tek::Arranger;
pub fn main () -> Usually<()> { ArrangerCli::parse().run() }
/// Launches an interactive MIDI arranger.
@ -32,7 +32,7 @@ impl ArrangerCli {
let name = self.name.as_deref().unwrap_or("tek_arranger");
let engine = Tui::new()?;
let state = JackConnection::new(name)?.activate_with(|jack|{
let mut app = ArrangerTui::try_from(jack)?;
let mut app = Arranger::try_from(jack)?;
let jack = jack.read().unwrap();
app.color = ItemPalette::random();
add_tracks(&jack, &mut app, self)?;
@ -43,7 +43,7 @@ impl ArrangerCli {
}
}
fn add_tracks (jack: &JackConnection, app: &mut ArrangerTui, cli: &ArrangerCli) -> Usually<()> {
fn add_tracks (jack: &JackConnection, app: &mut Arranger, cli: &ArrangerCli) -> Usually<()> {
let n = cli.tracks;
let track_color_1 = ItemColor::random();
let track_color_2 = ItemColor::random();
@ -109,7 +109,7 @@ fn add_tracks (jack: &JackConnection, app: &mut ArrangerTui, cli: &ArrangerCli)
Ok(())
}
fn add_scenes (app: &mut ArrangerTui, n: usize) -> Usually<()> {
fn add_scenes (app: &mut Arranger, n: usize) -> Usually<()> {
let scene_color_1 = ItemColor::random();
let scene_color_2 = ItemColor::random();
for i in 0..n {

View file

@ -27,7 +27,7 @@ impl SequencerCli {
let name = self.name.as_deref().unwrap_or("tek_sequencer");
let engine = Tui::new()?;
let state = JackConnection::new(name)?.activate_with(|jack|{
let mut app = SequencerTui::try_from(jack)?;
let mut app = Sequencer::try_from(jack)?;
let jack = jack.read().unwrap();
let midi_in = jack.register_port("i", MidiIn::default())?;
let midi_out = jack.register_port("o", MidiOut::default())?;

View file

@ -14,7 +14,7 @@ mod arranger_v_io; pub(crate) use self::arranger_v_io::*;
mod arranger_v_sep; pub(crate) use self::arranger_v_sep::*;
/// Root view for standalone `tek_arranger`
pub struct ArrangerTui {
pub struct Arranger {
jack: Arc<RwLock<JackConnection>>,
pub clock: Clock,
pub pool: PoolModel,
@ -30,7 +30,7 @@ pub struct ArrangerTui {
pub editor: MidiEditor,
pub perf: PerfModel,
}
impl ArrangerTui {
impl Arranger {
pub fn selected (&self) -> ArrangerSelection {
self.selected
}
@ -73,7 +73,7 @@ impl ArrangerTui {
}
}
}
from_jack!(|jack| ArrangerTui {
from_jack!(|jack| Arranger {
let clock = Clock::from(jack);
let phrase = Arc::new(RwLock::new(MidiClip::new(
"Clip", true, 4 * clock.timebase.ppq.get() as usize,
@ -96,7 +96,7 @@ from_jack!(|jack| ArrangerTui {
jack: jack.clone(),
}
});
impl ArrangerTui {
impl Arranger {
fn render_mode (state: &Self) -> impl Content<TuiOut> + use<'_> {
match state.mode {
ArrangerMode::H => todo!("horizontal arranger"),
@ -104,7 +104,7 @@ impl ArrangerTui {
}
}
}
render!(TuiOut: (self: ArrangerTui) => {
render!(TuiOut: (self: Arranger) => {
let pool_size = if self.pool.visible { self.splits[1] } else { 0 };
let with_pool = |x|Bsp::w(Fixed::x(pool_size, PoolView(self.pool.visible, &self.pool)), x);
let status = ArrangerStatus::from(self);
@ -125,7 +125,7 @@ render!(TuiOut: (self: ArrangerTui) => {
Fill::xy(&self.editor),
)))))
});
audio!(|self: ArrangerTui, client, scope|{
audio!(|self: Arranger, client, scope|{
// Start profiling cycle
let t0 = self.perf.get_t0();
// Update transport clock
@ -161,7 +161,7 @@ audio!(|self: ArrangerTui, client, scope|{
self.perf.update(t0, scope);
return Control::Continue
});
has_clock!(|self: ArrangerTui|&self.clock);
has_phrases!(|self: ArrangerTui|self.pool.phrases);
has_editor!(|self: ArrangerTui|self.editor);
handle!(TuiIn: |self: ArrangerTui, input|ArrangerCommand::execute_with_state(self, input.event()));
has_clock!(|self: Arranger|&self.clock);
has_phrases!(|self: Arranger|self.pool.phrases);
has_editor!(|self: Arranger|self.editor);
handle!(TuiIn: |self: Arranger, input|ArrangerCommand::execute_with_state(self, input.event()));

View file

@ -49,10 +49,10 @@ pub enum ArrangerClipCommand {
SetColor(usize, usize, ItemPalette),
}
//handle!(TuiIn: |self: ArrangerTui, input|ArrangerCommand::execute_with_state(self, input.event()));
//input_to_command!(ArrangerCommand: |state: ArrangerTui, input: Event|{KEYS_ARRANGER.handle(state, input)?});
//handle!(TuiIn: |self: Arranger, input|ArrangerCommand::execute_with_state(self, input.event()));
//input_to_command!(ArrangerCommand: |state: Arranger, input: Event|{KEYS_ARRANGER.handle(state, input)?});
keymap!(KEYS_ARRANGER = |state: ArrangerTui, input: Event| ArrangerCommand {
keymap!(KEYS_ARRANGER = |state: Arranger, input: Event| ArrangerCommand {
key(Char('u')) => Cmd::History(-1),
key(Char('U')) => Cmd::History(1),
// TODO: k: toggle on-screen keyboard
@ -160,7 +160,7 @@ keymap!(KEYS_ARRANGER = |state: ArrangerTui, input: Event| ArrangerCommand {
None
})?);
command!(|self: ArrangerCommand, state: ArrangerTui|match self {
command!(|self: ArrangerCommand, state: Arranger|match self {
Self::Clock(cmd) => cmd.delegate(state, Self::Clock)?,
Self::Clip(cmd) => cmd.delegate(state, Self::Clip)?,
Self::Scene(cmd) => cmd.delegate(state, Self::Scene)?,
@ -202,7 +202,7 @@ command!(|self: ArrangerCommand, state: ArrangerTui|match self {
},
Self::Clear => { todo!() },
});
command!(|self: ArrangerTrackCommand, state: ArrangerTui|match self {
command!(|self: ArrangerTrackCommand, state: Arranger|match self {
Self::SetColor(index, color) => {
let old = state.tracks[index].color;
state.tracks[index].color = color;
@ -214,7 +214,7 @@ command!(|self: ArrangerTrackCommand, state: ArrangerTui|match self {
},
_ => None
});
command!(|self: ArrangerSceneCommand, state: ArrangerTui|match self {
command!(|self: ArrangerSceneCommand, state: Arranger|match self {
Self::Delete(index) => {
state.scene_del(index);
None
@ -232,7 +232,7 @@ command!(|self: ArrangerSceneCommand, state: ArrangerTui|match self {
},
_ => None
});
command!(|self: ArrangerClipCommand, state: ArrangerTui|match self {
command!(|self: ArrangerClipCommand, state: Arranger|match self {
Self::Get(track, scene) => { todo!() },
Self::Put(track, scene, phrase) => {
let old = state.scenes[scene].clips[track].clone();

View file

@ -1,5 +1,5 @@
use crate::*;
impl ArrangerTui {
impl Arranger {
pub fn scene_add (&mut self, name: Option<&str>, color: Option<ItemPalette>)
-> Usually<&mut ArrangerScene>
{

View file

@ -1,5 +1,5 @@
use crate::*;
impl ArrangerTui {
impl Arranger {
pub fn track_next_name (&self) -> String {
format!("T{}", self.tracks.len() + 1)
}

View file

@ -2,8 +2,8 @@ use crate::*;
// egyptian snakes den
pub(crate) const HEADER_H: u16 = 5;
pub(crate) const SCENES_W_OFFSET: u16 = 3;
impl ArrangerTui {
pub fn render_mode_v (state: &ArrangerTui, factor: usize) -> impl Content<TuiOut> + use<'_> {
impl Arranger {
pub fn render_mode_v (state: &Arranger, factor: usize) -> impl Content<TuiOut> + use<'_> {
lay!(
ArrangerVColSep::from(state),
ArrangerVRowSep::from((state, factor)),

View file

@ -8,7 +8,7 @@ pub struct ArrangerVClips<'a> {
rows: Vec<(usize, usize)>,
}
impl<'a> ArrangerVClips<'a> {
pub fn new (state: &'a ArrangerTui, zoom: usize) -> Self {
pub fn new (state: &'a Arranger, zoom: usize) -> Self {
Self {
size: &state.size,
tracks: &state.tracks,

View file

@ -10,7 +10,7 @@ pub struct ArrangerVCursor {
scenes_w: u16,
}
from!(|args:(&ArrangerTui, usize)|ArrangerVCursor = Self {
from!(|args:(&Arranger, usize)|ArrangerVCursor = Self {
cols: ArrangerTrack::widths(&args.0.tracks),
rows: ArrangerScene::ppqs(&args.0.scenes, args.1),
selected: args.0.selected(),

View file

@ -8,7 +8,7 @@ pub struct ArrangerVHead<'a> {
tracks: &'a [ArrangerTrack],
}
from!(<'a>|state: &'a ArrangerTui|ArrangerVHead<'a> = Self { // A
from!(<'a>|state: &'a Arranger|ArrangerVHead<'a> = Self { // A
tracks: &state.tracks,
timebase: state.clock().timebase(),
current: &state.clock().playhead,

View file

@ -6,7 +6,7 @@ pub struct ArrangerVIns<'a> {
tracks: &'a Vec<ArrangerTrack>,
}
from!(<'a>|args: &'a ArrangerTui|ArrangerVIns<'a> = Self {
from!(<'a>|args: &'a Arranger|ArrangerVIns<'a> = Self {
size: &args.size,
tracks: &args.tracks,
});
@ -18,7 +18,7 @@ pub struct ArrangerVOuts<'a> {
tracks: &'a Vec<ArrangerTrack>,
}
from!(<'a>|args: &'a ArrangerTui|ArrangerVOuts<'a> = Self {
from!(<'a>|args: &'a Arranger|ArrangerVOuts<'a> = Self {
size: &args.size,
tracks: &args.tracks,
});

View file

@ -6,7 +6,7 @@ pub struct ArrangerVColSep {
cols: Vec<(usize, usize)>,
scenes_w: u16
}
from!(|state:&ArrangerTui|ArrangerVColSep = Self {
from!(|state:&Arranger|ArrangerVColSep = Self {
fg: TuiTheme::separator_fg(false),
cols: ArrangerTrack::widths(&state.tracks),
scenes_w: SCENES_W_OFFSET + ArrangerScene::longest_name(&state.scenes) as u16,
@ -25,7 +25,7 @@ pub struct ArrangerVRowSep {
fg: Color,
rows: Vec<(usize, usize)>,
}
from!(|args:(&ArrangerTui, usize)|ArrangerVRowSep = Self {
from!(|args:(&Arranger, usize)|ArrangerVRowSep = Self {
fg: TuiTheme::separator_fg(false),
rows: ArrangerScene::ppqs(&args.0.scenes, args.1),
});

View file

@ -5,7 +5,7 @@ use SequencerCommand as Cmd;
use MidiEditCommand::*;
use PhrasePoolCommand::*;
/// Root view for standalone `tek_sequencer`.
pub struct SequencerTui {
pub struct Sequencer {
_jack: Arc<RwLock<JackConnection>>,
pub pool: PoolModel,
@ -23,7 +23,7 @@ pub struct SequencerTui {
pub midi_buf: Vec<Vec<Vec<u8>>>,
pub perf: PerfModel,
}
from_jack!(|jack|SequencerTui {
from_jack!(|jack|Sequencer {
let clock = Clock::from(jack);
let phrase = Arc::new(RwLock::new(MidiClip::new(
"Clip", true, 4 * clock.timebase.ppq.get() as usize,
@ -47,11 +47,11 @@ from_jack!(|jack|SequencerTui {
clock,
}
});
render!(TuiOut: (self: SequencerTui) => self.size.of(
render!(TuiOut: (self: Sequencer) => self.size.of(
Bsp::s(self.toolbar_view(),
Bsp::n(self.status_view(),
Bsp::w(self.pool_view(), Fill::xy(&self.editor))))));
impl SequencerTui {
impl Sequencer {
fn toolbar_view (&self) -> impl Content<TuiOut> + use<'_> {
self.transport.then(||TransportView::new(true, &self.clock))
}
@ -68,7 +68,7 @@ impl SequencerTui {
Fixed::x(pool_w, Align::e(Fill::y(PoolView(self.compact, &self.pool))))
}
}
audio!(|self:SequencerTui, client, scope|{
audio!(|self:Sequencer, client, scope|{
// Start profiling cycle
let t0 = self.perf.get_t0();
// Update transport clock
@ -85,11 +85,11 @@ audio!(|self:SequencerTui, client, scope|{
self.perf.update(t0, scope);
Control::Continue
});
has_size!(<TuiOut>|self:SequencerTui|&self.size);
has_clock!(|self:SequencerTui|&self.clock);
has_phrases!(|self:SequencerTui|self.pool.phrases);
has_editor!(|self:SequencerTui|self.editor);
handle!(TuiIn: |self:SequencerTui,input|SequencerCommand::execute_with_state(self, input.event()));
has_size!(<TuiOut>|self:Sequencer|&self.size);
has_clock!(|self:Sequencer|&self.clock);
has_phrases!(|self:Sequencer|self.pool.phrases);
has_editor!(|self:Sequencer|self.editor);
handle!(TuiIn: |self:Sequencer,input|SequencerCommand::execute_with_state(self, input.event()));
#[derive(Clone, Debug)] pub enum SequencerCommand {
Compact(bool),
History(isize),
@ -98,7 +98,7 @@ handle!(TuiIn: |self:SequencerTui,input|SequencerCommand::execute_with_state(sel
Editor(MidiEditCommand),
Enqueue(Option<Arc<RwLock<MidiClip>>>),
}
keymap!(KEYS_SEQUENCER = |state: SequencerTui, input: Event| SequencerCommand {
keymap!(KEYS_SEQUENCER = |state: Sequencer, input: Event| SequencerCommand {
// TODO: k: toggle on-screen keyboard
ctrl(key(Char('k'))) => { todo!("keyboard") },
// Transport: Play/pause
@ -134,7 +134,7 @@ keymap!(KEYS_SEQUENCER = |state: SequencerTui, input: Event| SequencerCommand {
} else {
return None
});
command!(|self: SequencerCommand, state: SequencerTui|match self {
command!(|self: SequencerCommand, state: Sequencer|match self {
Self::Enqueue(phrase) => {
state.player.enqueue_next(phrase.as_ref());
None

View file

@ -8,7 +8,7 @@ pub struct SequencerStatus {
pub(crate) size: String,
pub(crate) playing: bool,
}
from!(|state:&SequencerTui|SequencerStatus = {
from!(|state:&Sequencer|SequencerStatus = {
let samples = state.clock.chunk.load(Relaxed);
let rate = state.clock.timebase.sr.get();
let buffer = samples as f64 / rate;
@ -57,7 +57,7 @@ pub struct ArrangerStatus {
pub(crate) size: String,
pub(crate) playing: bool,
}
from!(|state:&ArrangerTui|ArrangerStatus = {
from!(|state:&Arranger|ArrangerStatus = {
let samples = state.clock.chunk.load(Relaxed);
let rate = state.clock.timebase.sr.get();
let buffer = samples as f64 / rate;