huh.
Some checks failed
/ build (push) Has been cancelled

This commit is contained in:
🪞👃🪞 2025-08-07 22:46:50 +03:00
parent 43c71e874d
commit 8e0d53764b

View file

@ -63,30 +63,6 @@ pub struct App {
/// Base color.
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);* $(;)? })=>{
#[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();
clip_selected: Option<Arc<RwLock<MidiClip>>> = |self|match self.selection() {
Selection::TrackClip { track, scene } => self.scenes()[*scene].clips[*track].clone(),
_ => None
};
_ => None };
device_kind: usize = |self|if let Some(Dialog::Device(index)) = self.dialog {
index } else { 0 };
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 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() } }
/// 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 {
fn from_dsl (dsl: impl Dsl) -> Usually<Self> {
let mut profile = Self { ..Default::default() };
@ -309,6 +298,16 @@ impl 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 {
const PROFILES: &'static str = "profiles.edn";
const BINDINGS: &'static str = "bindings.edn";
@ -342,7 +341,7 @@ impl Config {
if let Some(id) = head.sym()? {
cfgs.bindings.write().unwrap().insert(
id.into(),
Binding::from_dsl(tail.tail()?)?
EventMap::from_dsl(&mut tail.tail()?)?
);
}
} else {