new key binding macro

This commit is contained in:
🪞👃🪞 2025-01-02 21:03:20 +01:00
parent 5bc19a45d2
commit 6c266fcfca
16 changed files with 254 additions and 251 deletions

View file

@ -103,7 +103,7 @@ command!(|self:PoolCommand, state: PoolModel|{
}
});
input_to_command!(PoolCommand:<Tui>|state: PoolModel,input|match state.phrases_mode() {
input_to_command!(PoolCommand: |state: PoolModel, input: Event|match state.phrases_mode() {
Some(PoolMode::Rename(..)) => Self::Rename(PhraseRenameCommand::input_to_command(state, input)?),
Some(PoolMode::Length(..)) => Self::Length(PhraseLengthCommand::input_to_command(state, input)?),
Some(PoolMode::Import(..)) => Self::Import(FileBrowserCommand::input_to_command(state, input)?),
@ -111,12 +111,12 @@ input_to_command!(PoolCommand:<Tui>|state: PoolModel,input|match state.phrases_m
_ => to_phrases_command(state, input)?
});
fn to_phrases_command (state: &PoolModel, input: &TuiIn) -> Option<PoolCommand> {
fn to_phrases_command (state: &PoolModel, input: &Event) -> Option<PoolCommand> {
use KeyCode::{Up, Down, Delete, Char};
use PoolCommand as Cmd;
let index = state.phrase_index();
let count = state.phrases().len();
Some(match input.event() {
Some(match input {
key_pat!(Char('n')) => Cmd::Rename(PhraseRenameCommand::Begin),
key_pat!(Char('t')) => Cmd::Length(PhraseLengthCommand::Begin),
key_pat!(Char('m')) => Cmd::Import(FileBrowserCommand::Begin),