mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
remove edn_ prefix from a couple macros
This commit is contained in:
parent
798de37172
commit
34b35d08be
8 changed files with 25 additions and 25 deletions
|
|
@ -301,7 +301,7 @@ impl<'a, T: Context<'a, U>, U> Context<'a, U> for Option<T> {
|
|||
}
|
||||
}
|
||||
/// Implement `Context` for a context and type.
|
||||
#[macro_export] macro_rules! edn_provide {
|
||||
#[macro_export] macro_rules! provide {
|
||||
// Provide a value to the EDN template
|
||||
($type:ty:|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => {
|
||||
impl<'a> Context<'a, $type> for $State {
|
||||
|
|
@ -324,7 +324,7 @@ impl<'a, T: Context<'a, U>, U> Context<'a, U> for Option<T> {
|
|||
/// Implement `Context` for a context and numeric type.
|
||||
///
|
||||
/// This enables support for numeric literals.
|
||||
#[macro_export] macro_rules! edn_provide_num {
|
||||
#[macro_export] macro_rules! provide_num {
|
||||
// Provide a value that may also be a numeric literal in the EDN, to a generic implementation.
|
||||
($type:ty:|$self:ident:<$T:ident:$Trait:path>|{ $($pat:pat => $expr:expr),* $(,)? }) => {
|
||||
impl<'a, $T: $Trait> Context<'a, $type> for $T {
|
||||
|
|
@ -347,7 +347,7 @@ impl<'a, T: Context<'a, U>, U> Context<'a, U> for Option<T> {
|
|||
/// Implement `Context` for a context and content type.
|
||||
///
|
||||
/// This enables support for layout expressions.
|
||||
#[macro_export] macro_rules! edn_provide_content {
|
||||
#[macro_export] macro_rules! provide_content {
|
||||
(|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => {
|
||||
impl<'a, E: Output> Context<'a, Box<dyn Render<E> + 'a>> for $State {
|
||||
fn get (&'a $self, edn: &'a impl Atom<'a>) -> Option<Box<dyn Render<E> + 'a>> {
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ from!(|clip: Option<Arc<RwLock<MidiClip>>>|MidiEditor = {
|
|||
model.redraw();
|
||||
model
|
||||
});
|
||||
edn_provide!(bool: |self: MidiEditor| {
|
||||
provide!(bool: |self: MidiEditor| {
|
||||
":true" => true,
|
||||
":false" => false,
|
||||
":time-lock" => self.time_lock().get(),
|
||||
":time-lock-toggle" => !self.time_lock().get(),
|
||||
});
|
||||
edn_provide!(usize: |self: MidiEditor| {
|
||||
provide!(usize: |self: MidiEditor| {
|
||||
":note-length" => self.note_len(),
|
||||
|
||||
":note-pos" => self.note_pos(),
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ handle!(TuiIn: |self: MidiPool, input|{
|
|||
None
|
||||
})
|
||||
});
|
||||
edn_provide!(bool: |self: MidiPool| {});
|
||||
provide!(bool: |self: MidiPool| {});
|
||||
impl MidiPool {
|
||||
pub fn new_clip (&self) -> MidiClip {
|
||||
MidiClip::new("Clip", true, 4 * PPQ, None, Some(ItemPalette::random()))
|
||||
|
|
@ -242,19 +242,19 @@ impl MidiPool {
|
|||
(index, clip)
|
||||
}
|
||||
}
|
||||
edn_provide!(MidiClip: |self: MidiPool| {
|
||||
provide!(MidiClip: |self: MidiPool| {
|
||||
":new-clip" => self.new_clip(),
|
||||
":cloned-clip" => self.cloned_clip(),
|
||||
});
|
||||
edn_provide!(PathBuf: |self: MidiPool| {});
|
||||
edn_provide!(Arc<str>: |self: MidiPool| {});
|
||||
edn_provide!(usize: |self: MidiPool| {
|
||||
provide!(PathBuf: |self: MidiPool| {});
|
||||
provide!(Arc<str>: |self: MidiPool| {});
|
||||
provide!(usize: |self: MidiPool| {
|
||||
":current" => 0,
|
||||
":after" => 0,
|
||||
":previous" => 0,
|
||||
":next" => 0
|
||||
});
|
||||
edn_provide!(ItemColor: |self: MidiPool| {
|
||||
provide!(ItemColor: |self: MidiPool| {
|
||||
":random-color" => ItemColor::random()
|
||||
});
|
||||
#[derive(Clone, PartialEq, Debug)] pub enum PoolCommand {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::{sync::Arc, marker::PhantomData};
|
|||
/// This consists of:
|
||||
/// * render callback (implementation of [Content])
|
||||
/// * value providers (implementations of [Context])
|
||||
#[macro_export] macro_rules! edn_view {
|
||||
#[macro_export] macro_rules! view {
|
||||
($Output:ty: |$self:ident: $App:ty| $content:expr; {
|
||||
$( $type:ty { $($sym:literal => $value:expr),* } );*
|
||||
}) => {
|
||||
|
|
@ -22,7 +22,7 @@ use std::{sync::Arc, marker::PhantomData};
|
|||
}
|
||||
}
|
||||
/// Implements `Context` for content components and expressions
|
||||
#[macro_export] macro_rules! edn_provide_content {
|
||||
#[macro_export] macro_rules! provide_content {
|
||||
(|$self:ident:$State:ty|{ $($pat:pat => $expr:expr),* $(,)? }) => {
|
||||
impl<'a, E: Output> Context<'a, Box<dyn Render<E> + 'a>> for $State {
|
||||
fn get (&'a $self, edn: &'a impl Atom<'a>) -> Option<Box<dyn Render<E> + 'a>> {
|
||||
|
|
|
|||
|
|
@ -674,9 +674,9 @@ edn_command!(SamplerTuiCommand: |state: SamplerTui| {
|
|||
return None
|
||||
})
|
||||
});
|
||||
edn_provide!(usize: |self: SamplerTui| {});
|
||||
edn_provide!(PathBuf: |self: SamplerTui| {});
|
||||
edn_provide!(Arc<str>: |self: SamplerTui| {});
|
||||
provide!(usize: |self: SamplerTui| {});
|
||||
provide!(PathBuf: |self: SamplerTui| {});
|
||||
provide!(Arc<str>: |self: SamplerTui| {});
|
||||
edn_command!(FileBrowserCommand: |state: SamplerTui| {
|
||||
("begin" [] Self::Begin)
|
||||
("cancel" [] Self::Cancel)
|
||||
|
|
@ -713,10 +713,10 @@ edn_command!(SamplerCommand: |state: Sampler| {
|
|||
("note/off" [p: u7]
|
||||
Self::NoteOff(p.expect("no pitch")))
|
||||
});
|
||||
edn_provide!(u7: |self: Sampler| {});
|
||||
edn_provide!(Option<Arc<RwLock<Sample>>>: |self: Sampler| {});
|
||||
edn_provide!(usize: |self: Sampler| {});
|
||||
edn_provide!(f32: |self: Sampler| {});
|
||||
provide!(u7: |self: Sampler| {});
|
||||
provide!(Option<Arc<RwLock<Sample>>>: |self: Sampler| {});
|
||||
provide!(usize: |self: Sampler| {});
|
||||
provide!(f32: |self: Sampler| {});
|
||||
input_to_command!(FileBrowserCommand: |state:SamplerTui, input: Event|match input { _ => return None });
|
||||
command!(|self: FileBrowserCommand,state:SamplerTui|match self { _ => todo!() });
|
||||
//input_to_command!(SamplerTuiCommand: |state: SamplerTui, input: Event|match state.mode{
|
||||
|
|
|
|||
|
|
@ -161,14 +161,14 @@ has_editor!(|self: Tek|{
|
|||
};
|
||||
editor_h = 15;
|
||||
is_editing = self.editing.load(Relaxed); });
|
||||
edn_provide_num!(usize: |self: Tek| {
|
||||
provide_num!(usize: |self: Tek| {
|
||||
":scene" => self.selected.scene().unwrap_or(0),
|
||||
":scene-next" => (self.selected.scene().unwrap_or(0) + 1).min(self.scenes.len()),
|
||||
":scene-prev" => self.selected.scene().unwrap_or(0).saturating_sub(1),
|
||||
":track" => self.selected.track().unwrap_or(0),
|
||||
":track-next" => (self.selected.track().unwrap_or(0) + 1).min(self.tracks.len()),
|
||||
":track-prev" => self.selected.track().unwrap_or(0).saturating_sub(1) });
|
||||
edn_view!(TuiOut: |self: Tek| self.size.of(EdnView::from_source(self, self.edn.as_ref())); {
|
||||
view!(TuiOut: |self: Tek| self.size.of(EdnView::from_source(self, self.edn.as_ref())); {
|
||||
bool {};
|
||||
isize {};
|
||||
Color {};
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ pub enum ClockCommand {
|
|||
SetQuant(f64),
|
||||
SetSync(f64),
|
||||
}
|
||||
edn_provide_num!(u32: |self: Clock| {});
|
||||
edn_provide!(f64: |self: Clock| {});
|
||||
provide_num!(u32: |self: Clock| {});
|
||||
provide!(f64: |self: Clock| {});
|
||||
edn_command!(ClockCommand: |state: Clock| {
|
||||
("play" [] Self::Play(None))
|
||||
("play" [t: u32] Self::Play(t))
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ const EXAMPLES: &'static [&'static str] = &[
|
|||
include_str!("edn12.edn"),
|
||||
include_str!("edn13.edn"),
|
||||
];
|
||||
edn_view!(TuiOut: |self: Example|{
|
||||
view!(TuiOut: |self: Example|{
|
||||
let title = Tui::bg(Color::Rgb(60,10,10),
|
||||
Push::y(1, Align::n(format!("Example {}/{} in {:?}", self.0 + 1, EXAMPLES.len(), &self.1.wh()))));
|
||||
let code = Tui::bg(Color::Rgb(10,60,10),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue