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:
Key | Action |
---|---|
q , Esc | Close the file dialog. |
j , Down | Move down in the file list. |
k , Up | Move up in the file list. |
Enter | Select the current item. |
u | Move one directory up. |
I | Toggle 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(());
}
_ => {}
}
}
)