Add Emacs style ctrl-g, ctrl-n, and ctrl-p (#77)

This commit is contained in:
Will Fancher 2021-05-09 14:43:55 -04:00 committed by GitHub
parent 4b9ff801a6
commit 623df9064e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -159,7 +159,9 @@ async fn key_handler(
app: &mut State,
) -> Option<String> {
match input {
Key::Esc | Key::Ctrl('c') | Key::Ctrl('d') => return Some(String::from("")),
Key::Esc | Key::Ctrl('c') | Key::Ctrl('d') | Key::Ctrl('g') => {
return Some(String::from(""))
}
Key::Char('\n') => {
let i = app.results_state.selected().unwrap_or(0);
@ -177,7 +179,7 @@ async fn key_handler(
app.input.pop();
query_results(app, search_mode, db).await.unwrap();
}
Key::Down => {
Key::Down | Key::Ctrl('n') => {
let i = match app.results_state.selected() {
Some(i) => {
if i == 0 {
@ -190,7 +192,7 @@ async fn key_handler(
};
app.results_state.select(Some(i));
}
Key::Up => {
Key::Up | Key::Ctrl('p') => {
let i = match app.results_state.selected() {
Some(i) => {
if i >= app.results.len() - 1 {