Skip to content

Commit 81a9bc7

Browse files
authored
Merge pull request #174 from unsecretised/better-shell-commands
Emoji and clipboard UI fixes
2 parents 3d8bf9c + 24b1db2 commit 81a9bc7

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

src/app/pages/clipboard.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use iced::widget::{
33
scrollable::{Direction, Scrollbar},
44
};
55

6-
use crate::{app::pages::prelude::*, clipboard::ClipBoardContentType};
6+
use crate::{
7+
app::{ToApp, pages::prelude::*},
8+
clipboard::ClipBoardContentType,
9+
};
710

811
pub fn clipboard_view(
912
clipboard_content: Vec<ClipBoardContentType>,
@@ -43,6 +46,7 @@ pub fn clipboard_view(
4346
horizontal: Scrollbar::new().scroller_width(0.).width(0.),
4447
},
4548
))
49+
.height(10000)
4650
.padding(10)
4751
.style(move |_| result_row_container_style(&theme_clone, false))
4852
.width((WINDOW_WIDTH / 3.) * 2.)

src/app/tile/update.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,28 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task<Message> {
415415
display_name: format!("Search for: {}", tile.query),
416416
search_name: String::new(),
417417
}];
418+
return single_item_resize_task(id);
418419
} else if tile.query_lc == "cbhist" {
419420
task = task.chain(Task::done(Message::SwitchToPage(Page::ClipboardHistory)));
420421
tile.page = Page::ClipboardHistory
421422
} else if tile.query_lc == "main" && tile.page != Page::Main {
422423
task = task.chain(Task::done(Message::SwitchToPage(Page::Main)));
423424
tile.page = Page::Main;
425+
} else if tile.query_lc.starts_with(">") && tile.page == Page::Main {
426+
tile.results = vec![App {
427+
ranking: 20,
428+
open_command: AppCommand::Function(Function::RunShellCommand(
429+
tile.query.strip_prefix(">").unwrap_or("").to_string(),
430+
)),
431+
display_name: format!(
432+
"Shell Command: {}",
433+
tile.query.strip_prefix(">").unwrap_or("")
434+
),
435+
icons: None,
436+
search_name: "".to_string(),
437+
desc: "Shell Command".to_string(),
438+
}];
439+
return single_item_resize_task(id);
424440
}
425441
tile.handle_search_query_changed();
426442

@@ -494,9 +510,9 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task<Message> {
494510
if !tile.query_lc.is_empty() && tile.page == Page::EmojiSearch {
495511
tile.results = tile
496512
.emoji_apps
497-
.search_prefix("")
513+
.search_prefix(&tile.query_lc)
498514
.map(|x| x.to_owned())
499-
.collect();
515+
.collect()
500516
}
501517

502518
tile.results.sort_by_key(|x| -x.ranking);

src/clipboard.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
//! This has all the logic regarding the cliboard history
22
use arboard::ImageData;
33

4-
use crate::{app::apps::App, commands::Function};
4+
use crate::{
5+
app::{ToApp, apps::App},
6+
commands::Function,
7+
};
58

69
/// The kinds of clipboard content that rustcast can handle and their contents
710
#[derive(Debug, Clone)]
@@ -10,10 +13,10 @@ pub enum ClipBoardContentType {
1013
Image(ImageData<'static>),
1114
}
1215

13-
impl ClipBoardContentType {
16+
impl ToApp for ClipBoardContentType {
1417
/// Returns the iced element for rendering the clipboard item, and the entire content since the
1518
/// display name is only the first line
16-
pub fn to_app(&self) -> App {
19+
fn to_app(&self) -> App {
1720
let mut display_name = match self {
1821
ClipBoardContentType::Image(_) => "<img>".to_string(),
1922
ClipBoardContentType::Text(a) => a.to_owned(),

0 commit comments

Comments
 (0)