84 lines
4.1 KiB
Diff
84 lines
4.1 KiB
Diff
diff --git a/anyrun/src/main.rs b/anyrun/src/main.rs
|
|
index fb9f62e..ac006c1 100644
|
|
--- a/anyrun/src/main.rs
|
|
+++ b/anyrun/src/main.rs
|
|
@@ -12,7 +12,11 @@ use std::{
|
|
use abi_stable::std_types::{ROption, RVec};
|
|
use anyrun_interface::{HandleResult, Match, PluginInfo, PluginRef, PollResult};
|
|
use clap::{Parser, ValueEnum};
|
|
-use gtk::{gdk, gdk_pixbuf, gio, glib, prelude::*};
|
|
+use gtk::{
|
|
+ gdk::{self, ModifierType},
|
|
+ gdk_pixbuf, gio, glib,
|
|
+ prelude::*,
|
|
+};
|
|
use nix::unistd;
|
|
use serde::Deserialize;
|
|
use wl_clipboard_rs::copy;
|
|
@@ -477,14 +481,18 @@ fn activate(app: >k::Application, runtime_data: Rc<RefCell<RuntimeData>>) {
|
|
|
|
window.connect_key_press_event(move |window, event| {
|
|
use gdk::keys::constants;
|
|
- match event.keyval() {
|
|
+ match (event.state(), event.keyval()) {
|
|
// Close window on escape
|
|
- constants::Escape => {
|
|
+ (_, constants::Escape) => {
|
|
window.close();
|
|
Inhibit(true)
|
|
}
|
|
// Handle selections
|
|
- constants::Down | constants::Tab | constants::Up => {
|
|
+ (_, constants::Down)
|
|
+ | (_, constants::Tab)
|
|
+ | (_, constants::Up)
|
|
+ | (ModifierType::CONTROL_MASK, constants::p)
|
|
+ | (ModifierType::CONTROL_MASK, constants::n) => {
|
|
// Combine all of the matches into a `Vec` to allow for easier handling of the selection
|
|
let combined_matches = runtime_data_clone
|
|
.borrow()
|
|
@@ -511,10 +519,12 @@ fn activate(app: >k::Application, runtime_data: Rc<RefCell<RuntimeData>>) {
|
|
// If nothing is selected select either the top or bottom match based on the input
|
|
if !combined_matches.is_empty() {
|
|
match event.keyval() {
|
|
- constants::Down | constants::Tab => combined_matches[0]
|
|
- .1
|
|
- .select_row(Some(&combined_matches[0].0)),
|
|
- constants::Up => {
|
|
+ constants::Down | constants::Tab | constants::n => {
|
|
+ combined_matches[0]
|
|
+ .1
|
|
+ .select_row(Some(&combined_matches[0].0))
|
|
+ }
|
|
+ constants::Up | constants::p => {
|
|
combined_matches[combined_matches.len() - 1].1.select_row(
|
|
Some(&combined_matches[combined_matches.len() - 1].0),
|
|
)
|
|
@@ -537,7 +547,7 @@ fn activate(app: >k::Application, runtime_data: Rc<RefCell<RuntimeData>>) {
|
|
|
|
// Move the selection based on the input, loops from top to bottom and vice versa
|
|
match event.keyval() {
|
|
- constants::Down | constants::Tab => {
|
|
+ constants::Down | constants::Tab | constants::n => {
|
|
if index < combined_matches.len() - 1 {
|
|
combined_matches[index + 1]
|
|
.1
|
|
@@ -548,7 +558,7 @@ fn activate(app: >k::Application, runtime_data: Rc<RefCell<RuntimeData>>) {
|
|
.select_row(Some(&combined_matches[0].0));
|
|
}
|
|
}
|
|
- constants::Up => {
|
|
+ constants::Up | constants::p => {
|
|
if index > 0 {
|
|
combined_matches[index - 1]
|
|
.1
|
|
@@ -565,7 +575,7 @@ fn activate(app: >k::Application, runtime_data: Rc<RefCell<RuntimeData>>) {
|
|
Inhibit(true)
|
|
}
|
|
// Handle when the selected match is "activated"
|
|
- constants::Return => {
|
|
+ (_, constants::Return) => {
|
|
let mut _runtime_data_clone = runtime_data_clone.borrow_mut();
|
|
|
|
let (selected_match, plugin_view) = match _runtime_data_clone
|