aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2023-08-02 20:43:00 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2023-08-02 20:43:00 +0200
commit2ae338a7e31aca86c2a2912508623e5c4a5ebc64 (patch)
tree6619291bb161aee6255f1fb0bfca2e9363893e5e /src
parent84ad0403b30f0ec1aecd7ea0c78c8baea7baa454 (diff)
print entry text on no matches or ctrl+enterHEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/main.rs25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs
index a5c4c8b..4210c9e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,7 @@
use gtk::gdk::keys::constants::{Escape as ESCAPE, Return as RETURN, Up as UP, Down as DOWN};
use gtk::{ApplicationWindow, SearchEntry, Box, ListStore, TreeView, ScrolledWindow, TreePath};
use gtk::prelude::*;
-use gtk::gdk;
+use gtk::gdk::{self, ModifierType};
use std::io;
use std::rc::Rc;
use gtk::glib;
@@ -130,16 +130,23 @@ fn build_ui(application: &gtk::Application) {
}
RETURN => {
let sel = treeview.cursor();
- let sel = sel.0.unwrap();
- let item : usize = sel.to_string().parse().unwrap();
- let mut i = 0;
+ if !event.state().contains(ModifierType::CONTROL_MASK) {
+ if let Some(sel) = sel.0 {
+ let item : usize = sel.to_string().parse().unwrap();
+ let mut i = 0;
- for option in filter_matches(&entry.text().to_string(), &options) {
- if i == item {
- println!("{}", option);
- break;
+ for option in filter_matches(&entry.text().to_string(), &options) {
+ if i == item {
+ println!("{}", option);
+ break;
+ }
+ i += 1;
+ }
+ } else {
+ println!("{}", entry.text());
}
- i += 1;
+ } else {
+ println!("{}", entry.text());
}
window.close();