mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
compiles... and crashes. added snazzy cli header
This commit is contained in:
parent
a4f0487324
commit
70fd1efc1e
5 changed files with 32 additions and 12 deletions
|
|
@ -1,7 +1,16 @@
|
|||
use crate::*;
|
||||
use clap::{self, Parser, Subcommand};
|
||||
const HEADER: &'static str = r#"
|
||||
|
||||
░▒▓████████▓▒░▒▓███████▓▒░▒▓█▓▒░░▒▓█▓▒░░
|
||||
░░░░▒▓█▓▒░░░░░▒▓█▓▒░░░░░░░▒▓█▓▒░▒▓█▓▒░░░
|
||||
░░░░▒▓█▓▒░░░░░▒▓█████▓▒░░░▒▓██████▓▒░░░░
|
||||
░░░░▒▓█▓▒░░░░░▒▓█▓▒░░░░░░░▒▓█▓▒░▒▓█▓▒░░░
|
||||
░░░░▒▓█▓▒░░░░░▒▓█▓▒░░░░░░░▒▓█▓▒░░▒▓█▓▒░░
|
||||
░░░░▒▓█▓▒░░░░░▒▓███████▓▒░▒▓█▓▒░░▒▓█▓▒░░"#;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(version, about, long_about = None)]
|
||||
#[command(version, about = Some(HEADER), long_about = Some(HEADER))]
|
||||
pub struct TekCli {
|
||||
/// Which app to initialize
|
||||
#[command(subcommand)] mode: TekMode,
|
||||
|
|
|
|||
|
|
@ -56,11 +56,11 @@ pub(crate) struct ArrangerView<'a> {
|
|||
|
||||
scene_last: usize,
|
||||
scene_count: usize,
|
||||
scene_scroll: Fill<Fixed<ScrollbarV>>,
|
||||
scene_scroll: Fill<Fixed<u16, ScrollbarV>>,
|
||||
scene_selected: Option<usize>,
|
||||
scenes_height: u16,
|
||||
|
||||
track_scroll: Fill<Fixed<ScrollbarH>>,
|
||||
track_scroll: Fill<Fixed<u16, ScrollbarH>>,
|
||||
track_count: usize,
|
||||
track_selected: Option<usize>,
|
||||
tracks_height: u16,
|
||||
|
|
@ -70,9 +70,11 @@ impl<'a> Content<TuiOut> for ArrangerView<'a> {
|
|||
fn content (&self) -> impl Render<TuiOut> {
|
||||
Bsp::s(self.inputs(),
|
||||
Bsp::s(self.tracks(),
|
||||
Bsp::n(self.outputs(), Tui::bg(Reset, Bsp::s(self.track_scroll,
|
||||
Bsp::e(self.scene_scroll,
|
||||
Fixed::y(self.scenes_height,self.scenes())))))))
|
||||
Bsp::n(self.outputs(), Tui::bg(Reset, Bsp::s(
|
||||
&self.track_scroll,
|
||||
Bsp::e(
|
||||
&self.scene_scroll,
|
||||
Fixed::y(self.scenes_height, self.scenes())))))))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -177,7 +177,5 @@ pub(crate) fn per_track <'a, T: Content<TuiOut> + 'a, U: TracksSizes<'a>> (
|
|||
let _ = heading("", "", 0, "", true);
|
||||
let _ = heading("", "", 0, "", false);
|
||||
let _ = wrap(Reset, Reset, "");
|
||||
let _ = row(0, 0, 0, "", "", "");
|
||||
let _ = row_top(0, 0, 0, "", "", "");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,19 @@ use crate::*;
|
|||
|
||||
/// Clear a pre-allocated buffer, then write into it.
|
||||
#[macro_export] macro_rules! rewrite {
|
||||
($buf:ident, $($rest:tt)*) => { |$buf,_,_|{$buf.clear();write!($buf, $($rest)*)} } }
|
||||
($buf:ident, $($rest:tt)*) => {
|
||||
|$buf,_,_|{
|
||||
$buf.clear();
|
||||
write!($buf, $($rest)*)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)] pub(crate) struct ViewMemo<T, U> {
|
||||
pub(crate) value: T,
|
||||
pub(crate) view: Arc<RwLock<U>>
|
||||
}
|
||||
|
||||
impl<T: PartialEq, U> ViewMemo<T, U> {
|
||||
fn new (value: T, view: U) -> Self {
|
||||
Self { value, view: Arc::new(view.into()) }
|
||||
|
|
@ -21,6 +28,7 @@ impl<T: PartialEq, U> ViewMemo<T, U> {
|
|||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)] pub(crate) struct ViewCache {
|
||||
pub(crate) sr: ViewMemo<Option<(bool, f64)>, String>,
|
||||
pub(crate) buf: ViewMemo<Option<f64>, String>,
|
||||
|
|
@ -33,6 +41,7 @@ impl<T: PartialEq, U> ViewMemo<T, U> {
|
|||
pub(crate) stop: Arc<str>,
|
||||
pub(crate) edit: Arc<str>,
|
||||
}
|
||||
|
||||
impl Default for ViewCache {
|
||||
fn default () -> Self {
|
||||
Self {
|
||||
|
|
|
|||
|
|
@ -74,9 +74,11 @@ impl<'a> ArrangerView<'a> {
|
|||
}
|
||||
|
||||
fn track_counter (&'a self) -> Arc<RwLock<String>> {
|
||||
let track_counter_data = (self.track_selected.unwrap_or(0), self.tracks().len());
|
||||
let track_counter = rewrite!(buf, "{}/{}", track_counter_data.0, track_counter_data.1);
|
||||
self.app.fmtd.write().unwrap().trks.update(Some(track_counter_data), track_counter);
|
||||
let track_counter_data = (self.track_selected.unwrap_or(0), self.track_count);
|
||||
self.app.fmtd.write().unwrap().trks.update(
|
||||
Some(track_counter_data),
|
||||
rewrite!(buf, "{}/{}", track_counter_data.0, track_counter_data.1)
|
||||
);
|
||||
self.app.fmtd.read().unwrap().trks.view.clone()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue