aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 08c1ded..9fe62b3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -34,7 +34,7 @@ fn main() -> ExitCode {
let grid = Grid::new();
window.set_child(Some(&grid));
- let input = Entry::new();
+ let input = Entry::builder().width_request(300).build();
grid.attach(&input, 0, 0, 1, 1);
let output = Entry::builder().editable(false).build();
@@ -59,6 +59,7 @@ fn main() -> ExitCode {
window.add_controller(key_controller);
glib::spawn_future_local(async move {
+ let mut prev_input = String::from("");
loop {
if ping_recv.recv().await.is_err() {
break;
@@ -66,17 +67,21 @@ fn main() -> ExitCode {
let Some(input) = get_mail(mailbox.as_ref()) else {
continue;
};
+ if input == prev_input {
+ continue;
+ }
+ prev_input = input.clone();
let (output_send, output_recv) = async_channel::bounded(1);
let thread_handle = gtk4::gio::spawn_blocking(move || {
if let Some(result) = parser::parse(&input) {
- output_send.send_blocking(result).unwrap();
+ output_send.send_blocking(format!("{result}")).unwrap();
}
});
let _ = thread_handle.await;
let Ok(result) = output_recv.try_recv() else {
continue;
};
- output.set_text(&format!("{result}"));
+ output.set_text(&result);
}
});