mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-10-08 18:56:42 +02:00
toggle edit mode with editor
This commit is contained in:
parent
ea74aba7b7
commit
767f917302
5 changed files with 156 additions and 144 deletions
56
src/tek.rs
56
src/tek.rs
|
|
@ -390,62 +390,6 @@ impl ScenesView for App {
|
|||
}
|
||||
}
|
||||
|
||||
tui_keys!(self: App, input {
|
||||
#[cfg(feature = "prof2")] profiling::scope!("App::tui_keys!");
|
||||
Self::input_cmd(self, input)
|
||||
});
|
||||
|
||||
impl App {
|
||||
|
||||
fn input_cmd (state: &mut Self, input: &TuiEvent) -> Usually<()> {
|
||||
if let Some(bindings) = Self::input_cmds_find(state, input) {
|
||||
return Self::input_cmds_exec(state, bindings)
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn input_cmds_find (state: &mut Self, input: &TuiEvent) -> Option<Arc<[Binding<Arc<str>>]>> {
|
||||
for name in state.modes.read().iter().rev() {
|
||||
let mode = state.config.get_mode(name).as_ref().map(Arc::clone);
|
||||
if let Some(mode) = mode {
|
||||
let binds = state.config.binds.clone();
|
||||
for id in mode.keys.iter() {
|
||||
if let Some(event_map) = binds.find(id)
|
||||
&& let Some(bindings) = event_map.query(input) {
|
||||
return Some(bindings.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn input_cmds_exec (state: &mut Self, bindings: Arc<[Binding<Arc<str>>]>) -> Usually<()> {
|
||||
for binding in bindings.iter() {
|
||||
for src in binding.commands.iter() {
|
||||
if let Some(command) = Namespace::<AppCmd>::namespace(state, &src)? {
|
||||
Self::cmd_dispatch(state, command)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn cmd_dispatch (state: &mut Self, command: AppCmd) -> Usually<()> {
|
||||
match command.clone().dispatch(state) {
|
||||
Ok(undo) => {
|
||||
state.history.push((command, undo));
|
||||
Ok(())
|
||||
},
|
||||
Err(err) => {
|
||||
state.history.push((command, None));
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// A control axis.
|
||||
///
|
||||
/// ```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue