@@ -22,11 +22,13 @@ use iced::{
2222} ;
2323use iced:: { event, window} ;
2424
25+ use log:: info;
2526use objc2:: rc:: Retained ;
2627use objc2_app_kit:: NSRunningApplication ;
2728use rayon:: iter:: { IntoParallelRefIterator , ParallelIterator } ;
2829use tray_icon:: TrayIcon ;
2930
31+ use std:: fmt:: Debug ;
3032use std:: fs;
3133use std:: ops:: Bound ;
3234use std:: time:: Duration ;
@@ -70,18 +72,23 @@ impl AppIndex {
7072/// This is the base window, and its a "Tile"
7173/// Its fields are:
7274/// - Theme ([`iced::Theme`])
75+ /// - Focus "ID" (which element in the choices is currently selected)
7376/// - Query (String)
7477/// - Query Lowercase (String, but lowercase)
7578/// - Previous Query Lowercase (String)
7679/// - Results (Vec<[`App`]>) the results of the search
77- /// - Options (Vec<[`App`]>) the options to search through
80+ /// - Options ([`AppIndex`]) the options to search through (is a BTreeMap wrapper)
81+ /// - Emoji Apps ([`AppIndex`]) emojis that are considered as "apps"
7882/// - Visible (bool) whether the window is visible or not
7983/// - Focused (bool) whether the window is focused or not
8084/// - Frontmost ([`Option<Retained<NSRunningApplication>>`]) the frontmost application before the window was opened
8185/// - Config ([`Config`]) the app's config
82- /// - Open Hotkey ID (`u32`) the id of the hotkey that opens the window
86+ /// - Hotkeys, storing the hotkey used for directly opening to the clipboard history page, and
87+ /// opening the app
88+ /// - Sender (The [`ExtSender`] that sends messages, used by the tray icon currently)
8389/// - Clipboard Content (`Vec<`[`ClipBoardContentType`]`>`) all of the cliboard contents
8490/// - Page ([`Page`]) the current page of the window (main or clipboard history)
91+ /// - RustCast's height: to figure out which height to resize to
8592#[ derive( Clone ) ]
8693pub struct Tile {
8794 pub theme : iced:: Theme ,
@@ -95,7 +102,6 @@ pub struct Tile {
95102 focused : bool ,
96103 frontmost : Option < Retained < NSRunningApplication > > ,
97104 pub config : Config ,
98- /// The opening hotkey
99105 hotkeys : Hotkeys ,
100106 clipboard_content : Vec < ClipBoardContentType > ,
101107 tray_icon : Option < TrayIcon > ,
@@ -104,7 +110,7 @@ pub struct Tile {
104110 pub height : f32 ,
105111}
106112
107- #[ derive( Clone ) ]
113+ #[ derive( Clone , Debug ) ]
108114pub struct Hotkeys {
109115 pub toggle : HotKey ,
110116 pub clipboard_hotkey : HotKey ,
@@ -285,6 +291,7 @@ fn handle_hot_reloading() -> impl futures::Stream<Item = Message> {
285291 } )
286292}
287293
294+ /// Helper fn for counting directories (since macos `.app`'s are directories) inside a directory
288295fn count_dirs_in_dir ( dir : impl AsRef < Path > ) -> usize {
289296 // Read the directory; if it fails, treat as empty
290297 let entries = match fs:: read_dir ( dir) {
@@ -298,11 +305,12 @@ fn count_dirs_in_dir(dir: impl AsRef<Path>) -> usize {
298305 . count ( )
299306}
300307
301- /// This is the subscription function that handles hotkeys for hiding / showing the window
308+ /// This is the subscription function that handles hotkeys, e.g. for hiding / showing the window
302309fn handle_hotkeys ( ) -> impl futures:: Stream < Item = Message > {
303310 stream:: channel ( 100 , async |mut output| {
304311 let receiver = GlobalHotKeyEvent :: receiver ( ) ;
305312 loop {
313+ info ! ( "Hotkey received" ) ;
306314 if let Ok ( event) = receiver. recv ( )
307315 && event. state == HotKeyState :: Pressed
308316 {
@@ -331,6 +339,7 @@ fn handle_clipboard_history() -> impl futures::Stream<Item = Message> {
331339 if byte_rep != prev_byte_rep
332340 && let Some ( content) = & byte_rep
333341 {
342+ info ! ( "Adding item to cbhist" ) ;
334343 output
335344 . send ( Message :: ClipboardHistory ( content. to_owned ( ) ) )
336345 . await
@@ -342,6 +351,7 @@ fn handle_clipboard_history() -> impl futures::Stream<Item = Message> {
342351 } )
343352}
344353
354+ /// Handles the rx / receiver for sending and receiving messages
345355fn handle_recipient ( ) -> impl futures:: Stream < Item = Message > {
346356 stream:: channel ( 100 , async |mut output| {
347357 let ( sender, mut recipient) = channel ( 100 ) ;
@@ -353,6 +363,7 @@ fn handle_recipient() -> impl futures::Stream<Item = Message> {
353363 let abcd = recipient
354364 . try_recv ( )
355365 . map ( async |msg| {
366+ info ! ( "Sending a message" ) ;
356367 output. send ( msg) . await . unwrap ( ) ;
357368 } )
358369 . ok ( ) ;
0 commit comments