Macro bind_keys

Source
macro_rules! bind_keys {
    ($file_dialog:expr, $e:expr) => { ... };
}
Expand description

Macro to automatically overwrite the default key bindings of the app, when the file dialog is open.

This macro only works inside of a function that returns a std::io::Result or a result that has an error type that implements From<std::io::Error>.

Default bindings:

KeyAction
q, EscClose the file dialog.
j, DownMove down in the file list.
k, UpMove up in the file list.
EnterSelect the current item.
uMove one directory up.
IToggle showing hidden files.

§Example

bind_keys!(
    // Expression to use to access the file dialog.
    app.file_dialog,
    // Event handler of the app, when the file dialog is closed.
    if let Event::Key(key) = event::read()? {
        match key.code {
            KeyCode::Char('q') => {
                return Ok(());
            }
            _ => {}
        }
    }
)