axis config: bring failure under test

This commit is contained in:
i do not exist 2026-10-04 23:10:23 +03:00
parent 5aaa0f3e4e
commit a355e482c7
16 changed files with 1328 additions and 1149 deletions

View file

@ -1207,3 +1207,396 @@
//Ok(app)
//})?)?
//}
//impl<'a> Iterator for EntriesIterator<'a, Tui> {
//type Item = impl Draw<Tui>;
//fn next (&mut self) -> Option<Self::Item> {
//let dirs = self.browser.dirs.len();
//let files = self.browser.files.len();
//let index = self.index;
//if self.index < dirs {
//self.index += 1;
//Some(bold(true, self.browser.dirs[index].1.as_str()))
//} else if self.index < dirs + files {
//self.index += 1;
//Some(bold(false, self.browser.files[index - dirs].1.as_str()))
//} else {
//None
//}
//}
//}
//impl<'a> PoolView<'a> {
//fn tui (&self) -> impl Draw<'_, Tui> {
//let Self(pool) = self;
////let color = self.1.clip().map(|c|c.try_read().unwrap().color).unwrap_or_else(||g(32).into());
////let on_bg = |x|x;//below(Repeat(" "), bg(color.darkest.term, x));
////let border = |x|x;//Outer(Style::default().fg(color.dark.term).bg(color.darkest.term)).enclose(x);
////let height = pool.clips.try_read().unwrap().len() as u16;
//iter(
//||pool.clips.clone().into_iter(),
//move|clip: Arc<RwLock<MidiClip>>, i: usize|{
//let MidiClip { ref name, color, length, .. } = *clip.try_read().unwrap();
//let item_height = 1;
//let _item_offset = i as u16 * item_height;
//let selected = i == pool.clip_index();
//let b = if selected { color.light.term } else { color.base.term };
//let f = color.lightest.term;
//let name = if false { format!(" {i:>3}") } else { format!(" {i:>3} {name}") };
//let length = if false { String::default() } else { format!("{length} ") };
//bg(b, below!(
//fg(f, bold(selected, name)).origin_w().full_w(),
//fg(f, bold(selected, length)).origin_e().full_w(),
//when(selected, bold(true, fg(g(255), "▶"))).origin_w().full_w(),
//when(selected, bold(true, fg(g(255), "◀"))).origin_e().full_w(),
//)).exact_h(1)
//}).origin_n().full_h().exact_w(20)
//}
//}
//impl ClipLength {
//fn tui (&self) -> impl Draw<'_, Tui> {
//use ClipLengthFocus::*;
//let bars = format!("{}", self.bars());
//let beats = format!("{}", self.beats());
//let ticks = format!("{:>02}", self.ticks());
//match self.focus {
//None => east!(" ", bars, ".", beats, ".", ticks),
//Some(Bar) => east!("[", bars, "]", beats, ".", ticks),
//Some(Beat) => east!(" ", bars, "[", beats, "]", ticks),
//Some(Tick) => east!(" ", bars, ".", beats, "[", ticks),
//}
//}
//}
//pub fn tui (
//app: Arc<RwLock<App>>,
//jack: Jack,
//sync_lead: &bool,
//sync_follow: &bool,
//) -> Usually<()> {
//// Run the [Tui] and [Jack] threads with the [App] state.
//Tui::run_main(&jack.run(move|jack|{
//// Between jack init and app's first cycle:
////jack.sync_lead(*sync_lead, |mut state|{
////let clock = app.try_write().unwrap().clock();
////clock.playhead.update_from_sample(state.position.frame() as f64);
////state.position.bbt = Some(clock.bbt());
////state.position
////})?;
////jack.sync_follow(*sync_follow)?;
//// FIXME: They don't work properly.
//Ok(app)
//})?)?
//}
//impl<T: HasPool
//+ Namespace<bool>
//+ Namespace<usize>
//+ Namespace<Arc<str>>
//+ Namespace<PathBuf>
//+ Namespace<MidiClip>
//+ Namespace<ItemColor>
//+ Namespace<BrowseCmd>
//> PoolControl for T {}
//#[tek_proc::commands(PolCmd = "pool")] pub trait PoolControl: HasPool
//+ Namespace<bool>
//+ Namespace<usize>
//+ Namespace<Arc<str>>
//+ Namespace<PathBuf>
//+ Namespace<MidiClip>
//+ Namespace<ItemColor>
//+ Namespace<BrowseCmd>
//{
///// Toggle visibility of pool
//#[command(Show = "show")] fn show (&mut self, visible: bool) -> Perhaps<PoolCmd> {
//self.pool_mut().visible = visible;
//Ok(Some(PoolCmd::Show { visible: !visible }))
//}
///// Set selected clip
//#[command(Select = "select")] fn select (&mut self, index: usize) -> Perhaps<PoolCmd> {
//self.pool_mut().set_clip_index(index);
//Ok(None)
//}
///// Delete a clip from the pool
//#[command(Delete = "delete")] fn delete (&mut self, index: usize) -> Perhaps<PoolCmd> {
//let clip = self.pool_mut().remove(index).read().clone();
//Ok(Some(PoolCmd::Add { index, clip }))
//}
///// Switch places of two clips in pool
//#[command(Swap = "swap")] fn swap (&mut self, index: usize, other: usize) -> Perhaps<PoolCmd> {
//self.pool_mut().swap(index, other);
//Ok(Some(PoolCmd::Swap { index, other }))
//}
///// Add clip to pool
//#[command(Add = "add")] fn clip_add (&mut self, index: usize, clip: MidiClip) -> Perhaps<PoolCmd> {
//let mut index = index;
//let clip = Arc::new(RwLock::new(clip.clone()));
//let mut clips = self.pool_mut().clips_mut();
//if index >= clips.len() {
//index = clips.len();
//clips.push(clip)
//} else {
//clips.insert(index, clip);
//}
//Ok(Some(PoolCmd::Delete { index }))
//}
///// Set name of clip
//#[command(SetName = "set-name")] fn clip_set_name (&mut self, index: usize, name: Arc<str>) -> Perhaps<PoolCmd> {
//Ok(self.pool_mut().clips.read().get(index).map(|clip|{
//let old_name = clip.read().name.clone();
//clip.write().name = name.clone();
//PoolCmd::SetName { index, name: old_name }
//}))
//}
///// Set length of clip
//#[command(SetLength = "set-length")] fn clip_set_length (&mut self, index: usize, length: usize) -> Perhaps<PoolCmd> {
//Ok(self.pool_mut().clips.read().get(index).map(|clip|{
//let old_len = clip.read().length;
//clip.write().length = length;
//PoolCmd::SetLength { index, length: old_len }
//}))
//}
///// Set color of clip
//#[command(SetColor = "set-color")] fn clip_set_color (&mut self, index: usize, color: ItemColor) -> Perhaps<PoolCmd> {
//let mut color = ItemTheme::from(color);
//std::mem::swap(&mut color, &mut self.pool().clips.read()[index].write().color);
//Ok(Some(PoolCmd::SetColor { index, color: color.base }))
//}
///// Enter crop mode
//#[command(CropBegin = "crop/begin")] fn crop_begin (&mut self) -> Perhaps<PoolCmd> {
//let index = self.pool().clip_index();
//let length = self.pool().clips.read()[index].read().length;
//*self.pool_mut().mode_mut() = Some(PoolMode::Length(index, length, ClipLengthFocus::Bar));
//Ok(None)
//}
///// Exit crop mode, discard
//#[command(CropCancel = "crop/cancel")] fn crop_cancel (&mut self) -> Perhaps<PoolCmd> {
//if let Some(PoolMode::Length(..)) = self.pool_mut().mode_mut().clone() {
//*self.pool_mut().mode_mut() = None;
//}
//Ok(None)
//}
//#[command(CropSet = "crop/set")] fn crop_set (&mut self, _length: usize) -> Perhaps<PoolCmd> {
//if let Some(PoolMode::Length(clip, ref mut length, ref mut _focus))
//= self.pool_mut().mode_mut().clone()
//{
//let old_length;
//{
//let clip = self.pool().clips.read()[clip].clone();//.write();
//old_length = Some(clip.read().length);
//clip.write().length = *length;
//}
//*self.pool_mut().mode_mut() = None;
//return Ok(old_length.map(|l|PoolCmd::CropSet { _length: l }))
//}
//Ok(None)
//}
//#[command(CropNext = "crop/next")] fn crop_next (&mut self) -> Perhaps<PoolCmd> {
//if let Some(PoolMode::Length(
//_clip, ref mut _length, ref mut focus
//)) = self.pool_mut().mode_mut().clone() {
//focus.next()
//};
//Ok(None)
//}
//#[command(CropPrev = "crop/prev")] fn crop_prev (&mut self) -> Perhaps<PoolCmd> {
//if let Some(PoolMode::Length(
//_clip, ref mut _length, ref mut focus
//)) = self.pool_mut().mode_mut().clone() {
//focus.prev()
//};
//Ok(None)
//}
//#[command(CropInc = "crop/inc")] fn crop_inc (&mut self) -> Perhaps<PoolCmd> {
//if let Some(PoolMode::Length(
//_clip, ref mut length, ref mut focus
//)) = self.pool_mut().mode_mut().clone() {
//match focus {
//ClipLengthFocus::Bar => { *length += 4 * PPQ },
//ClipLengthFocus::Beat => { *length += PPQ },
//ClipLengthFocus::Tick => { *length += 1 },
//}
//}
//Ok(None)
//}
//#[command(CropDec = "crop/dec")] fn crop_dec (&mut self) -> Perhaps<PoolCmd> {
//if let Some(PoolMode::Length(
//_clip, ref mut length, ref mut focus
//)) = self.pool_mut().mode_mut().clone() {
//match focus {
//ClipLengthFocus::Bar => { *length = length.saturating_sub(4 * PPQ) },
//ClipLengthFocus::Beat => { *length = length.saturating_sub(PPQ) },
//ClipLengthFocus::Tick => { *length = length.saturating_sub(1) },
//}
//}
//Ok(None)
//}
///// Enter rename mode
//#[command(RenameBegin = "rename/begin")] fn rename_begin (&mut self) -> Perhaps<PoolCmd> {
//let index = self.pool().clip_index();
//let name = self.pool().clips.read()[index].read().name.clone();
//*self.pool_mut().mode_mut() = Some(PoolMode::Rename(index, name));
//Ok(None)
//}
///// Exit rename mode, discard
//#[command(RenameCancel = "rename/cancel")] fn rename_cancel (&mut self) -> Perhaps<PoolCmd> {
//if let Some(PoolMode::Rename(clip, ref mut old_name)) = self.pool_mut().mode_mut().clone() {
//self.pool().clips.read()[clip].write().name = old_name.clone().into();
//}
//Ok(None)
//}
///// Exit rename mode, update name
//#[command(RenameConfirm = "rename/confirm")] fn rename_confirm (&mut self) -> Perhaps<PoolCmd> {
//Ok(if let Some(PoolMode::Rename(_clip, ref mut old_name)) = self.pool_mut().mode_mut().clone() {
//let old_name = old_name.clone();
//*self.pool_mut().mode_mut() = None;
//Some(PoolCmd::RenameSet { value: old_name })
//} else {
//None
//})
//}
//#[command(RenameSet = "rename/set")] fn rename_set (&mut self, value: Arc<str>) -> Perhaps<PoolCmd> {
//if let Some(PoolMode::Rename(clip, ref mut _old_name)) = self.pool_mut().mode_mut().clone() {
//self.pool().clips.read()[clip].write().name = value.clone();
//}
//Ok(None)
//}
/////// Import from file
////#[command(Browse = "browse")]
////fn browse (&mut self, command: BrowseCmd) -> Perhaps<PoolCmd> {
////Ok(if let Some(browse) = self.pool_mut().browse.as_mut() {
////command.act(browse)?.map(|command|PoolCmd::Browse{command})
////} else {
////None
////})
////}
///// Import clip to pool from file
//#[command(Import = "import")]
//fn clip_import (&mut self, index: usize, path: PathBuf) -> Perhaps<PoolCmd>
//where Self: Sized
//{
//let bytes = std::fs::read(&path)?;
//let smf = Smf::parse(bytes.as_slice())?;
//let mut t = 0u32;
//let mut events = vec![];
//for track in smf.tracks.iter() {
//for event in track.iter() {
//t += event.delta.as_int();
//if let TrackEventKind::Midi { channel, message } = event.kind {
//events.push((t, channel.as_int(), message));
//}
//}
//}
//let mut clip = MidiClip::new("imported", true, t as usize + 1, None, None);
//for event in events.iter() {
//clip.notes[event.0 as usize].push(event.2);
//}
//Ok(PoolCmd::Add { index, clip }.dispatch(self)?)
//}
/////// Export to file
////#[command(Export = "export")]
////fn export (&mut self, command: BrowseCmd) -> Perhaps<PoolCmd> {
////Ok(if let Some(browse) = self.pool_mut().browse.as_mut() {
////command.act(browse)?.map(|command|PoolCmd::Export{command})
////} else {
////None
////})
////}
//}
//pub(crate) struct EntriesIterator<'a, S: Screen> {
//pub browser: &'a Browse,
//pub offset: usize,
//pub length: usize,
//pub index: usize,
//_screen: std::marker::PhantomData<S>
//}
// Commands supported by [Browse]
//#[derive(Debug, Clone, PartialEq)]
//pub enum BrowseCommand {
//Begin,
//Cancel,
//Confirm,
//Select(usize),
//Chdir(PathBuf),
//Filter(Arc<str>),
//}
//impl AsRef<Arc<[MenuItem]>> for MenuItems {
//fn as_ref (&self) -> &Arc<[MenuItem]> {
//&self.0
//}
//}
//impl_from!(Pool<MidiClip>: |clip:&Arc<RwLock<MidiClip>>|{
//let model = Self::default();
//model.clips.try_write().unwrap().push(clip.clone());
//model.clip.store(1, Relaxed);
//model
//});
//impl Pool {
//pub fn clip_index (&self) -> usize {
//self.clip.load(Relaxed)
//}
//pub fn set_clip_index (&self, value: usize) {
//self.clip.store(value, Relaxed);
//}
//pub fn mode (&self) -> &Option<PoolMode> {
//&self.mode
//}
//pub fn mode_mut (&mut self) -> &mut Option<PoolMode> {
//&mut self.mode
//}
//pub fn begin_import (&mut self) -> Usually<()> {
//*self.mode_mut() = Some(PoolMode::Import(
//self.clip_index(),
//Browse::new(None)?
//));
//Ok(())
//}
//pub fn begin_export (&mut self) -> Usually<()> {
//*self.mode_mut() = Some(PoolMode::Export(
//self.clip_index(),
//Browse::new(None)?
//));
//Ok(())
//}
//pub fn new_clip (&self) -> MidiClip {
//MidiClip::new("Clip", true, 4 * PPQ, None, Some(ItemTheme::random()))
//}
//pub fn cloned_clip (&self) -> MidiClip {
//let index = self.clip_index();
//let mut clip = self.clips.read()[index].read().duplicate();
//clip.color = ItemTheme::random_near(clip.color, 0.25);
//clip
//}
//pub fn add_new_clip (&self) -> (usize, Arc<RwLock<MidiClip>>) {
//let clip = Arc::new(RwLock::new(self.new_clip()));
//let index = {
//let mut clips = self.clips.try_write().unwrap();
//clips.push(clip.clone());
//clips.len().saturating_sub(1)
//};
//self.clip.store(index, Relaxed);
//(index, clip)
//}
//pub fn delete_clip (&mut self, clip: &MidiClip) -> bool {
//let index = self.clips.try_read().unwrap().iter().position(|x|*x.try_read().unwrap()==*clip);
//if let Some(index) = index {
//self.clips.try_write().unwrap().remove(index);
//return true
//}
//false
//}
//fn _clip_new (&self) -> MidiClip { self.new_clip() }
//fn _clip_cloned (&self) -> MidiClip { self.cloned_clip() }
//fn _clip_index_current (&self) -> usize { 0 }
//fn _clip_index_after (&self) -> usize { 0 }
//fn _clip_index_previous (&self) -> usize { 0 }
//fn _clip_index_next (&self) -> usize { 0 }
//fn _color_random (&self) -> ItemColor { ItemColor::random() }
//}