Skip to content

Commit 639c332

Browse files
committed
Let people auto switch to clipboard history if there is only one search result and that is clipboard history
1 parent 3f63de8 commit 639c332

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

src/app/apps.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::{
1818
/// This struct represents a command that rustcast can perform, providing the rustcast
1919
/// the data needed to search for the app, to display the app in search results, and to actually
2020
/// "run" the app.
21-
#[derive(Debug, Clone)]
21+
#[derive(Debug, Clone, PartialEq)]
2222
pub struct App {
2323
pub open_command: Function,
2424
pub desc: String,
@@ -45,6 +45,13 @@ impl App {
4545
name: "Open RustCast Preferences".to_string(),
4646
name_lc: "settings".to_string(),
4747
},
48+
App {
49+
open_command: Function::Nothing,
50+
desc: RUSTCAST_DESC_NAME.to_string(),
51+
icons: None,
52+
name: "Clipboard History".to_string(),
53+
name_lc: "clipboard".to_string(),
54+
},
4855
]
4956
}
5057

src/app/tile/update.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task<Message> {
9292

9393
let max_elem = min(5, new_length);
9494

95+
if tile.results
96+
== vec![App {
97+
open_command: Function::Nothing,
98+
desc: RUSTCAST_DESC_NAME.to_string(),
99+
icons: None,
100+
name: "Clipboard History".to_string(),
101+
name_lc: "clipboard".to_string(),
102+
}]
103+
{
104+
tile.page = Page::ClipboardHistory
105+
}
106+
95107
if prev_size != new_length && tile.page == Page::Main {
96108
std::thread::sleep(Duration::from_millis(30));
97109

src/calculator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
//! This handle the logic for the calculator in rustcast
22
33
/// A struct that represents an expression
4-
#[derive(Debug, Clone, Copy)]
4+
#[derive(Debug, Clone, Copy, PartialEq)]
55
pub struct Expression {
66
pub first_num: f64,
77
pub operation: Operation,
88
pub second_num: f64,
99
}
1010

1111
/// An enum that represents the different operations that can be performed on an expression
12-
#[derive(Debug, Clone, Copy)]
12+
#[derive(Debug, Clone, Copy, PartialEq)]
1313
pub enum Operation {
1414
Addition,
1515
Subtraction,

src/commands.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use objc2_foundation::NSURL;
99
use crate::{calculator::Expression, clipboard::ClipBoardContentType, config::Config};
1010

1111
/// The different functions that rustcast can perform
12-
#[derive(Debug, Clone)]
12+
#[derive(Debug, Clone, PartialEq)]
1313
pub enum Function {
1414
OpenApp(String),
1515
RunShellCommand(String, String),
@@ -18,6 +18,7 @@ pub enum Function {
1818
GoogleSearch(String),
1919
Calculate(Expression),
2020
OpenPrefPane,
21+
Nothing,
2122
Quit,
2223
}
2324

@@ -91,6 +92,7 @@ impl Function {
9192
));
9293
});
9394
}
95+
Function::Nothing => {}
9496
Function::Quit => std::process::exit(0),
9597
}
9698
}

0 commit comments

Comments
 (0)