add MessageCommand::Dismiss

This commit is contained in:
🪞👃🪞 2025-05-04 16:42:48 +03:00
parent 0a090765d3
commit ebd0f18c9c
5 changed files with 25 additions and 9 deletions

View file

@ -11,6 +11,7 @@
:arranger))))))
(keys
(layer-if :mode-message "./keys_message.edn")
(layer-if :mode-device-add "./keys_device_add.edn")
(layer-if :mode-pool-import "./keys_pool_file.edn")
(layer-if :mode-pool-export "./keys_pool_file.edn")

2
config/keys_message.edn Normal file
View file

@ -0,0 +1,2 @@
(@esc message dismiss)
(@enter message dismiss)

View file

@ -20,6 +20,7 @@ handle!(TuiIn: |self: Tek, input|Ok(if let Some(command) = self.config.keys.comm
expose!([self: Tek]
([bool]
(":mode-editor" self.is_editing())
(":mode-message" matches!(self.modal, Some(Modal::Message(..))))
(":mode-device-add" matches!(self.modal, Some(Modal::Device(..))))
(":mode-clip" !self.is_editing() && self.selected.is_clip())
(":mode-track" !self.is_editing() && self.selected.is_track())
@ -130,13 +131,14 @@ impose!([app: Tek]
("enqueue" [c: Arc<RwLock<MidiClip>>] Some(Self::Enqueue(c)))
("launch" [] Some(Self::Launch))
("select" [t: Selection] Some(t.map(Self::Select).expect("no selection")))
("clock" [,..a] ns!(ClockCommand, app.clock(), a, Self::Clock))
("scene" [,..a] ns!(SceneCommand, app, a, Self::Scene))
("track" [,..a] ns!(TrackCommand, app, a, Self::Track))
("input" [,..a] ns!(InputCommand, app, a, Self::Input))
("output" [,..a] ns!(OutputCommand, app, a, Self::Output))
("clip" [,..a] ns!(ClipCommand, app, a, Self::Clip))
("device" [,..a] ns!(DeviceCommand, app, a, Self::Device))
("clock" [,..a] ns!(ClockCommand, app.clock(), a, Self::Clock))
("scene" [,..a] ns!(SceneCommand, app, a, Self::Scene))
("track" [,..a] ns!(TrackCommand, app, a, Self::Track))
("input" [,..a] ns!(InputCommand, app, a, Self::Input))
("output" [,..a] ns!(OutputCommand, app, a, Self::Output))
("clip" [,..a] ns!(ClipCommand, app, a, Self::Clip))
("device" [,..a] ns!(DeviceCommand, app, a, Self::Device))
("message" [,..a] ns!(MessageCommand, app, a, Self::Message))
("pool" [,..a] app.pool.as_ref().map(|p|ns!(PoolCommand, p, a, Self::Pool)).flatten())
("editor" [,..a] app.editor().map(|e|ns!(MidiEditCommand, e, a, Self::Editor)).flatten())
("sampler" [,..a] app.sampler().map(|s|ns!(SamplerCommand, s, a, Self::Sampler)).flatten())
@ -166,6 +168,9 @@ impose!([app: Tek]
("pick" [index: usize] Some(Self::Pick(index.unwrap())))
("add" [index: usize] Some(Self::Add(index.unwrap()))))
(MessageCommand:
("dismiss" [] Some(Self::Dismiss)))
(SceneCommand:
("add" [] Some(Self::Add))
("delete" [a: Option<usize>] Some(Self::Del(a.flatten().unwrap())))
@ -198,6 +203,7 @@ defcom!([self, app: Tek]
(Clip [cmd: ClipCommand] cmd.delegate(app, Self::Clip)?)
(Clock [cmd: ClockCommand] cmd.delegate(app, Self::Clock)?)
(Device [cmd: DeviceCommand] cmd.delegate(app, Self::Device)?)
(Message [cmd: MessageCommand] cmd.delegate(app, Self::Message)?)
(Editor [cmd: MidiEditCommand] delegate_to_editor(app, cmd)?)
(Pool [cmd: PoolCommand] delegate_to_pool(app, cmd)?)
(ToggleHelp [] cmd!(app.toggle_modal(Some(Modal::Help))))
@ -222,6 +228,9 @@ defcom!([self, app: Tek]
(Pick [i: usize] cmd!(app.device_pick(i)))
(Add [i: usize] cmd!(app.device_add(i))))
(MessageCommand
(Dismiss [] cmd!(app.message_dismiss())))
(TrackCommand
(TogglePlay [] Some(Self::TogglePlay))
(ToggleSolo [] Some(Self::ToggleSolo))

View file

@ -429,6 +429,10 @@ impl Tek {
]
}
pub(crate) fn message_dismiss (&mut self) {
self.modal = None;
}
}
has_size!(<TuiOut>|self: Tek|&self.size);
@ -471,7 +475,7 @@ pub enum Message {
}
content!(TuiOut: |self: Message| match self {
Self::FailedToAddDevice => "Failed to add device"
Self::FailedToAddDevice => "Failed to add device."
});
/// Represents the current user selection in the arranger

View file

@ -122,7 +122,7 @@ impl Tek {
}
fn view_modal_message <'a> (&'a self, message: &'a Message) -> impl Content<TuiOut> + use<'a> {
Bsp::s(message, "[ OK ]")
Bsp::s(message, Bsp::s("", "[ OK ]"))
}
/// Spacing between tracks.