mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-10-08 10:46:43 +02:00
This commit is contained in:
parent
b6f7d2d361
commit
e42f400514
4 changed files with 83 additions and 57 deletions
|
|
@ -512,7 +512,7 @@ pub fn tek_vec_arc_str <'a> (_: &App, _: impl Language) -> Perhaps<Vec<Arc<str>>
|
|||
#[command(Enter = "enter")] pub fn enter_mode (&mut self, mode: Arc<str>) -> Perhaps<AppCmd> {
|
||||
let mut modes = self.stack().write();
|
||||
Ok(if modes.last().map(|mode|mode.name.as_ref()) != Some(mode.as_ref()) {
|
||||
let data = Default::default();
|
||||
let data = self.modes().read().get(&mode).map(|mode|&mode.data).cloned();
|
||||
modes.push(Frame::new(mode, data));
|
||||
Some(AppCmd::Leave)
|
||||
} else {
|
||||
|
|
@ -531,25 +531,27 @@ pub fn tek_vec_arc_str <'a> (_: &App, _: impl Language) -> Perhaps<Vec<Arc<str>>
|
|||
}
|
||||
/// Increment the given data axis.
|
||||
#[command(Inc = "inc")] pub fn inc (&mut self, axis: Arc<str>) -> Perhaps<AppCmd> {
|
||||
if let Some(mode) = self.stack().write().last_mut() {
|
||||
if mode.data.contains_key(&axis) {
|
||||
*mode.data.get_mut(&axis).unwrap() += 1;
|
||||
} else {
|
||||
return err!("invalid axis {axis} for mode {}", &mode.name)
|
||||
Ok(self.stack().write().last_mut().map(|frame|{
|
||||
if let Some(mode) = self.modes().read().get(&frame.name)
|
||||
&& let Some(param) = mode.axis.get(&axis)
|
||||
&& mode.data.contains_key(param)
|
||||
{
|
||||
*frame.data.get_mut(param).unwrap() += 1;
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
None
|
||||
}).flatten())
|
||||
}
|
||||
/// Decrement the given data axis.
|
||||
#[command(Dec = "dec")] pub fn dec (&mut self, axis: Arc<str>) -> Perhaps<AppCmd> {
|
||||
if let Some(mode) = self.stack().write().last_mut() {
|
||||
if mode.data.contains_key(&axis) {
|
||||
*mode.data.get_mut(&axis).unwrap() -= 1;
|
||||
} else {
|
||||
return err!("invalid axis {axis} for mode {}", &mode.name)
|
||||
Ok(self.stack().write().last_mut().map(|frame|{
|
||||
if let Some(mode) = self.modes().read().get(&frame.name)
|
||||
&& let Some(param) = mode.axis.get(&axis)
|
||||
&& mode.data.contains_key(param)
|
||||
{
|
||||
*frame.data.get_mut(param).unwrap() -= 1;
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
None
|
||||
}).flatten())
|
||||
}
|
||||
/// Cancel current selection.
|
||||
#[command(Cancel = "cancel")] pub fn cmd_cancel (&mut self) -> Perhaps<AppCmd> {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,12 @@ impl Frame {
|
|||
|
||||
impl<T: AsRef<str>> From<T> for Frame {
|
||||
fn from (name: T) -> Self {
|
||||
Self::new(name, Default::default())
|
||||
Self::new(name, None)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Mode> for Frame {
|
||||
fn from (mode: Mode) -> Self {
|
||||
Self::new(mode.name.get(0).cloned().unwrap_or_default(), Some(mode.data.clone()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
55
src/tek.edn
55
src/tek.edn
|
|
@ -11,26 +11,35 @@
|
|||
(axis IFine @lt @gt )
|
||||
(axis WFine @openbrace @closebrace )
|
||||
|
||||
(mode Menu (name Main Menu) (info Welcome to Tek!)
|
||||
(axis Y Index) (data Index 1)
|
||||
(mode Menu
|
||||
(name Main Menu)
|
||||
(info Welcome to Tek!)
|
||||
(axis Y Index)
|
||||
(data Index 1)
|
||||
(bind Confirm)
|
||||
(view (bar/s 2 Transport (bar/n 2 StatusBar (align/c (bar/s 2 (align/x Logo) Menu))))))
|
||||
|
||||
(mode Help
|
||||
(axis Y Index) (data Index 0)
|
||||
(axis P Page) (data Page 0)
|
||||
(axis Y Index)
|
||||
(data Index 0)
|
||||
(axis P Page)
|
||||
(data Page 0)
|
||||
(view (bg (g 32) (fg (g 64) (full/xy (align/c (bg (g 48) (fg (g 224)
|
||||
(bar/s 2 (text Help yourself! ) (align/c Config))))))))))
|
||||
|
||||
(mode Options
|
||||
(axis Y Index) (data Index 0)
|
||||
(axis P Page) (data Page 0)
|
||||
(axis Y Index)
|
||||
(data Index 0)
|
||||
(axis P Page)
|
||||
(data Page 0)
|
||||
(view (bg (g 32) (fg (g 64) (full/xy
|
||||
(bg (g 48) (fg (g 224) (align/c (expand/wh 2 2 (text Options ))))))))))
|
||||
|
||||
(mode History
|
||||
(axis Y Index) (data Index 0)
|
||||
(axis P Page) (data Page 0)
|
||||
(axis Y Index)
|
||||
(data Index 0)
|
||||
(axis P Page)
|
||||
(data Page 0)
|
||||
(view (bg (g 32) (fg (g 64) (full/xy (bg (g 48) (fg (g 224)
|
||||
(align/c (bar/s 1 (text Project history ) HistoryList)))))))))
|
||||
|
||||
|
|
@ -41,20 +50,26 @@
|
|||
(bsp/e (push/x 1 (text Yes)) (align/ne (pull/x 2 (text No))))))))))))))
|
||||
|
||||
(mode Save
|
||||
(axis X Input) (data Input 0)
|
||||
(axis Y Index) (data Index 0)
|
||||
(axis X Input)
|
||||
(data Input 0)
|
||||
(axis Y Index)
|
||||
(data Index 0)
|
||||
(view (bg (g 32) (fg (g 64) (full/xy (bg (g 48) (fg (g 224)
|
||||
(align/c (bar/s 1 (expand/wh 2 2 (text Save to: )) (text <file browser here>))))))))))
|
||||
|
||||
(mode Load
|
||||
(axis X Input) (data Input 0)
|
||||
(axis Y Index) (data Index 0)
|
||||
(axis X Input)
|
||||
(data Input 0)
|
||||
(axis Y Index)
|
||||
(data Index 0)
|
||||
(view (bg (g 32) (fg (g 64) (full/xy (bg (g 48) (fg (g 224)
|
||||
(align/c (bar/s 1 (expand/wh 2 2 (text Load from: )) (text <file browser here>))))))))))
|
||||
|
||||
(mode Rename
|
||||
(axis X Input) (data Input 0)
|
||||
(axis Y Index) (data Index 0)
|
||||
(axis X Input)
|
||||
(data Input 0)
|
||||
(axis Y Index)
|
||||
(data Index 0)
|
||||
(view (bg (g 32) (fg (g 64) (full/xy (bg (g 48) (fg (g 224)
|
||||
(align/c (expand/wh 2 2 (text Rename item ))))))))))
|
||||
|
||||
|
|
@ -63,8 +78,10 @@
|
|||
(view Transport))
|
||||
|
||||
(mode Arranger (name Arranger) (info Launch grid.)
|
||||
(axis X Track) (data Track 1)
|
||||
(axis Y Scene) (data Scene 1)
|
||||
(axis X Track)
|
||||
(data Track 1)
|
||||
(axis Y Scene)
|
||||
(data Scene 1)
|
||||
(bind Global Clock Tracks Scenes Clip Launch Color History)
|
||||
(view (bar/n 2 StatusBar (bar/s 8 (bar/e 16 (align/nw Transport)
|
||||
(bar/w 20 (bar/s 2 (bar/w 4 TracksOutputsAdd TracksOutputsCount)
|
||||
|
|
@ -77,8 +94,10 @@
|
|||
(bar/w 20 (text) (bar/e 16 ScenesNames ScenesClips))))))
|
||||
|
||||
(mode Edit (info MIDI editor.)
|
||||
(axis X Time) (data Time 0)
|
||||
(axis Y Pitch) (data Pitch 36))
|
||||
(axis X Time)
|
||||
(data Time 0)
|
||||
(axis Y Pitch)
|
||||
(data Pitch 36))
|
||||
|
||||
(mode Sequencer (info MIDI sequencer.)
|
||||
(bind Global Clock I IFine Y Page EditorView EditorAdd EditorDel)
|
||||
|
|
|
|||
45
src/tek.rs
45
src/tek.rs
|
|
@ -723,35 +723,34 @@ pub use self::proj::*; mod proj {
|
|||
Config => watch.config_print(),
|
||||
Resume => todo!("resume session"),
|
||||
List => todo!("list sessions"),
|
||||
New(sesh) => Exit::run(|exit|Tui::run_main(
|
||||
exit.clone(),
|
||||
{
|
||||
#[allow(unused_mut)]
|
||||
let mut app = App::new(Some(exit), sesh.init()?, watch, Some(vec![
|
||||
"Menu".into()
|
||||
]));
|
||||
app.dialog = Dialog::welcome();
|
||||
#[cfg(feature = "prof2")] {
|
||||
if trace {
|
||||
app.guard = Some({
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
//let tracy = tracing_tracy::TracyLayer::default();
|
||||
let (flame, _guard) = tracing_flame::FlameLayer::with_file("./tracing.folded").unwrap();
|
||||
//let registry = tracing_subscriber::registry().with(flame).init();
|
||||
//tracing::subscriber::set_global_default(registry)?;
|
||||
tracing::subscriber::set_global_default(tracing_subscriber::registry().with(flame))?;
|
||||
_guard
|
||||
})
|
||||
}
|
||||
}
|
||||
Arc::new(RwLock::new(app))
|
||||
})).map(|_|())?,
|
||||
New(sesh) => Exit::run(|exit|Tui::run_main(exit.clone(), {
|
||||
#[allow(unused_mut)]
|
||||
let mut app = App::new(Some(exit), sesh.init()?, watch, None);
|
||||
app.dialog = Dialog::welcome();
|
||||
app.enter_mode("Menu".into())?;
|
||||
#[cfg(feature = "prof2")] app.trace(trace);
|
||||
Arc::new(RwLock::new(app))
|
||||
})).map(|_|())?,
|
||||
_ => todo!()
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl App {
|
||||
#[cfg(feature = "prof2")] fn trace (&mut self, trace: bool) {
|
||||
self.guard = trace.then(||Some({
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
//let tracy = tracing_tracy::TracyLayer::default();
|
||||
let (flame, _guard) = tracing_flame::FlameLayer::with_file("./tracing.folded").unwrap();
|
||||
//let registry = tracing_subscriber::registry().with(flame).init();
|
||||
//tracing::subscriber::set_global_default(registry)?;
|
||||
tracing::subscriber::set_global_default(tracing_subscriber::registry().with(flame))?;
|
||||
_guard
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_status (project: &Project) {
|
||||
println!("Name: {:?}", &project.name);
|
||||
println!("JACK: {:?}", &project.jack);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue