diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-08-02 20:43:00 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-08-02 20:43:00 +0200 |
| commit | 2ae338a7e31aca86c2a2912508623e5c4a5ebc64 (patch) | |
| tree | 6619291bb161aee6255f1fb0bfca2e9363893e5e | |
| parent | 84ad0403b30f0ec1aecd7ea0c78c8baea7baa454 (diff) | |
| -rw-r--r-- | src/main.rs | 25 |
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: >k::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(); |