mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
parent
43c71e874d
commit
8e0d53764b
1 changed files with 26 additions and 27 deletions
|
|
@ -63,30 +63,6 @@ pub struct App {
|
||||||
/// Base color.
|
/// Base color.
|
||||||
pub color: ItemTheme,
|
pub color: ItemTheme,
|
||||||
}
|
}
|
||||||
/// Configuration
|
|
||||||
#[derive(Default, Debug)]
|
|
||||||
pub struct Config {
|
|
||||||
/// XDG basedirs
|
|
||||||
pub dirs: BaseDirectories,
|
|
||||||
/// Available view profiles
|
|
||||||
pub profiles: Arc<RwLock<BTreeMap<Arc<str>, Profile>>>,
|
|
||||||
/// Available input bindings
|
|
||||||
pub bindings: Arc<RwLock<BTreeMap<Arc<str>, Binding<AppCommand>>>>,
|
|
||||||
}
|
|
||||||
/// Profile
|
|
||||||
#[derive(Default, Debug)]
|
|
||||||
pub struct Profile {
|
|
||||||
/// Path of configuration entrypoint
|
|
||||||
pub path: PathBuf,
|
|
||||||
/// Name of configuration
|
|
||||||
pub name: Option<Arc<str>>,
|
|
||||||
/// Description of configuration
|
|
||||||
pub info: Option<Arc<str>>,
|
|
||||||
/// View definition
|
|
||||||
pub view: Arc<str>,
|
|
||||||
// Input keymap
|
|
||||||
pub keys: EventMap<TuiEvent, AppCommand>,
|
|
||||||
}
|
|
||||||
macro_rules!dsl_expose(($Struct:ident { $($fn:ident: $ret:ty = |$self:ident|$body:expr);* $(;)? })=>{
|
macro_rules!dsl_expose(($Struct:ident { $($fn:ident: $ret:ty = |$self:ident|$body:expr);* $(;)? })=>{
|
||||||
#[tengri_proc::expose] impl $Struct { $(fn $fn (&$self) -> $ret { $body })* }
|
#[tengri_proc::expose] impl $Struct { $(fn $fn (&$self) -> $ret { $body })* }
|
||||||
});
|
});
|
||||||
|
|
@ -134,8 +110,7 @@ dsl_expose!(App {
|
||||||
select_track_prev: Selection = |self|self.selection().select_track_prev();
|
select_track_prev: Selection = |self|self.selection().select_track_prev();
|
||||||
clip_selected: Option<Arc<RwLock<MidiClip>>> = |self|match self.selection() {
|
clip_selected: Option<Arc<RwLock<MidiClip>>> = |self|match self.selection() {
|
||||||
Selection::TrackClip { track, scene } => self.scenes()[*scene].clips[*track].clone(),
|
Selection::TrackClip { track, scene } => self.scenes()[*scene].clips[*track].clone(),
|
||||||
_ => None
|
_ => None };
|
||||||
};
|
|
||||||
device_kind: usize = |self|if let Some(Dialog::Device(index)) = self.dialog {
|
device_kind: usize = |self|if let Some(Dialog::Device(index)) = self.dialog {
|
||||||
index } else { 0 };
|
index } else { 0 };
|
||||||
device_kind_next: usize = |self|if let Some(Dialog::Device(index)) = self.dialog {
|
device_kind_next: usize = |self|if let Some(Dialog::Device(index)) = self.dialog {
|
||||||
|
|
@ -294,6 +269,20 @@ maybe_has!(Scene: |self: App| { MaybeHas::<Scene>::get(&self.project) };
|
||||||
impl HasClipsSize for App { fn clips_size (&self) -> &Measure<TuiOut> { &self.project.inner_size } }
|
impl HasClipsSize for App { fn clips_size (&self) -> &Measure<TuiOut> { &self.project.inner_size } }
|
||||||
impl HasTrackScroll for App { fn track_scroll (&self) -> usize { self.project.track_scroll() } }
|
impl HasTrackScroll for App { fn track_scroll (&self) -> usize { self.project.track_scroll() } }
|
||||||
impl HasSceneScroll for App { fn scene_scroll (&self) -> usize { self.project.scene_scroll() } }
|
impl HasSceneScroll for App { fn scene_scroll (&self) -> usize { self.project.scene_scroll() } }
|
||||||
|
/// Profile
|
||||||
|
#[derive(Default, Debug)]
|
||||||
|
pub struct Profile {
|
||||||
|
/// Path of configuration entrypoint
|
||||||
|
pub path: PathBuf,
|
||||||
|
/// Name of configuration
|
||||||
|
pub name: Option<Arc<str>>,
|
||||||
|
/// Description of configuration
|
||||||
|
pub info: Option<Arc<str>>,
|
||||||
|
/// View definition
|
||||||
|
pub view: Arc<str>,
|
||||||
|
// Input keymap
|
||||||
|
pub keys: EventMap<TuiEvent, AppCommand>,
|
||||||
|
}
|
||||||
impl Profile {
|
impl Profile {
|
||||||
fn from_dsl (dsl: impl Dsl) -> Usually<Self> {
|
fn from_dsl (dsl: impl Dsl) -> Usually<Self> {
|
||||||
let mut profile = Self { ..Default::default() };
|
let mut profile = Self { ..Default::default() };
|
||||||
|
|
@ -309,6 +298,16 @@ impl Profile {
|
||||||
Ok(profile)
|
Ok(profile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// Configuration
|
||||||
|
#[derive(Default, Debug)]
|
||||||
|
pub struct Config {
|
||||||
|
/// XDG basedirs
|
||||||
|
pub dirs: BaseDirectories,
|
||||||
|
/// Available view profiles
|
||||||
|
pub profiles: Arc<RwLock<BTreeMap<Arc<str>, Profile>>>,
|
||||||
|
/// Available input bindings
|
||||||
|
pub bindings: Arc<RwLock<BTreeMap<Arc<str>, EventMap<TuiEvent, AppCommand>>>>,
|
||||||
|
}
|
||||||
impl Config {
|
impl Config {
|
||||||
const PROFILES: &'static str = "profiles.edn";
|
const PROFILES: &'static str = "profiles.edn";
|
||||||
const BINDINGS: &'static str = "bindings.edn";
|
const BINDINGS: &'static str = "bindings.edn";
|
||||||
|
|
@ -342,7 +341,7 @@ impl Config {
|
||||||
if let Some(id) = head.sym()? {
|
if let Some(id) = head.sym()? {
|
||||||
cfgs.bindings.write().unwrap().insert(
|
cfgs.bindings.write().unwrap().insert(
|
||||||
id.into(),
|
id.into(),
|
||||||
Binding::from_dsl(tail.tail()?)?
|
EventMap::from_dsl(&mut tail.tail()?)?
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue