aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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();