summaryrefslogtreecommitdiffstats
path: root/src/app/launcher.rs
diff options
context:
space:
mode:
authororhun <orhun@archlinux.org>2021-07-08 02:05:37 +0300
committerorhun <orhun@archlinux.org>2021-07-08 02:05:37 +0300
commit888a5d836d036e199bde044c08adc04a38d9464d (patch)
tree302fa7cf0c67921d5363a4b55b0e00d9eb95834e /src/app/launcher.rs
parentcb1df0b004e04f7aa71ac5398355877f18e46ae4 (diff)
feat: Add `--select` option (#24)
Diffstat (limited to 'src/app/launcher.rs')
-rw-r--r--src/app/launcher.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/app/launcher.rs b/src/app/launcher.rs
index 7212ff9..e3b897d 100644
--- a/src/app/launcher.rs
+++ b/src/app/launcher.rs
@@ -22,6 +22,7 @@ use std::path::Path;
use std::process::Command as OsCommand;
use std::str;
use std::str::FromStr;
+use std::time::Instant;
use tui::style::Color;
/// Max duration of prompt messages.
@@ -71,10 +72,20 @@ impl<'a> App<'a> {
.expect("failed to get public keys")
.to_vec(),
);
+ let state = State::from(args);
Ok(Self {
- state: State::from(args),
mode: Mode::Normal,
- prompt: Prompt::default(),
+ prompt: if state.select.is_some() {
+ Prompt {
+ output_type: OutputType::Action,
+ text: String::from("-- select --"),
+ clock: Some(Instant::now()),
+ ..Prompt::default()
+ }
+ } else {
+ Prompt::default()
+ },
+ state,
tab: Tab::Keys(KeyType::Public),
options: StatefulList::with_items(Vec::new()),
splash_screen: SplashScreen::new("splash.jpg", 12)?,
@@ -825,7 +836,11 @@ impl<'a> App<'a> {
};
match content {
Ok(content) => {
- if let Some(clipboard) = self.clipboard.as_mut() {
+ if self.state.select.is_some() {
+ self.state.exit_message = Some(content);
+ self.run_command(Command::Quit)?;
+ } else if let Some(clipboard) = self.clipboard.as_mut()
+ {
clipboard
.set_contents(content)
.expect("failed to set clipboard contents");
@@ -843,7 +858,7 @@ impl<'a> App<'a> {
Err(e) => {
self.prompt.set_output((
OutputType::Failure,
- format!("copy error: {}", e),
+ format!("selection error: {}", e),
));
}
}