add type-to-select option for keyboard navigation
This commit is contained in:
parent
d9b6404f1b
commit
5e92d081c6
5 changed files with 71 additions and 0 deletions
|
|
@ -568,6 +568,8 @@ struct App {
|
|||
FxHashSet<PathBuf>,
|
||||
)>,
|
||||
auto_scroll_speed: Option<i16>,
|
||||
type_select_prefix: String,
|
||||
type_select_last_key: Option<Instant>,
|
||||
}
|
||||
|
||||
impl App {
|
||||
|
|
@ -1038,6 +1040,8 @@ impl Application for App {
|
|||
key_binds,
|
||||
watcher_opt: None,
|
||||
auto_scroll_speed: None,
|
||||
type_select_prefix: String::new(),
|
||||
type_select_last_key: None,
|
||||
};
|
||||
|
||||
let commands = Task::batch([
|
||||
|
|
@ -1448,6 +1452,20 @@ impl Application for App {
|
|||
Some(location.with_path(PathBuf::from(path_string)).into());
|
||||
}
|
||||
}
|
||||
TypeToSearch::SelectByPrefix => {
|
||||
// Reset buffer if timeout elapsed
|
||||
if let Some(last_key) = self.type_select_last_key {
|
||||
if last_key.elapsed() >= tab::TYPE_SELECT_TIMEOUT {
|
||||
self.type_select_prefix.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Accumulate character and select
|
||||
self.type_select_prefix.push_str(&text.to_lowercase());
|
||||
self.type_select_last_key = Some(Instant::now());
|
||||
|
||||
self.tab.select_by_prefix(&self.type_select_prefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue