From c3b8c68d1bb5b7d4351f66af125af1561dccf248 Mon Sep 17 00:00:00 2001 From: Alex Pasmantier <47638216+alexpasmantier@users.noreply.github.com> Date: Sat, 28 Dec 2024 16:36:30 +0100 Subject: [PATCH] feat(ux): print current query to stdout on Enter if no entry is selected (#151) Fixes #49 --- crates/television/app.rs | 9 ++++++++- crates/television/television.rs | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/television/app.rs b/crates/television/app.rs index a292719..612135f 100644 --- a/crates/television/app.rs +++ b/crates/television/app.rs @@ -45,6 +45,7 @@ pub struct App { #[derive(Debug)] pub enum ActionOutcome { Entry(Entry), + Input(String), Passthrough(Entry, String), None, } @@ -63,6 +64,10 @@ impl From for AppOutput { selected_entry: Some(entry), passthrough: None, }, + ActionOutcome::Input(input) => Self { + selected_entry: None, + passthrough: Some(input), + }, ActionOutcome::Passthrough(entry, key) => Self { selected_entry: Some(entry), passthrough: Some(key), @@ -261,7 +266,9 @@ impl App { { return Ok(ActionOutcome::Entry(entry)); } - return Ok(ActionOutcome::None); + return Ok(ActionOutcome::Input( + self.television.lock().await.current_pattern.clone(), + )); } Action::SelectPassthrough(passthrough) => { self.should_quit = true; diff --git a/crates/television/television.rs b/crates/television/television.rs index d2a0cf9..3be2b55 100644 --- a/crates/television/television.rs +++ b/crates/television/television.rs @@ -38,7 +38,7 @@ pub struct Television { pub(crate) channel: TelevisionChannel, pub(crate) remote_control: TelevisionChannel, pub mode: Mode, - current_pattern: String, + pub current_pattern: String, pub(crate) results_picker: Picker, pub(crate) rc_picker: Picker, results_area_height: u32, @@ -358,6 +358,11 @@ impl Television { self.change_channel(new_channel); } } + } else { + self.action_tx + .as_ref() + .unwrap() + .send(Action::SelectAndExit)?; } } Action::CopyEntryToClipboard => {