@@ -5,12 +5,11 @@ pub mod update;
55use crate :: app:: apps:: App ;
66use crate :: app:: { ArrowKey , Message , Move , Page } ;
77use crate :: clipboard:: ClipBoardContentType ;
8- use crate :: config:: Config ;
8+ use crate :: config:: { Config , Shelly } ;
99use crate :: debounce:: Debouncer ;
1010use crate :: platform:: default_app_paths;
11+ use crate :: platform:: macos:: launching:: Shortcut ;
1112
12- use global_hotkey:: hotkey:: HotKey ;
13- use global_hotkey:: { GlobalHotKeyEvent , HotKeyState } ;
1413
1514use iced:: futures:: SinkExt ;
1615use iced:: futures:: channel:: mpsc:: { Sender , channel} ;
@@ -191,9 +190,9 @@ pub struct Tile {
191190/// Stores the toggle [`HotKey`] and the Clipboard [`HotKey`]
192191#[ derive( Clone , Debug ) ]
193192pub struct Hotkeys {
194- pub toggle : HotKey ,
195- pub clipboard_hotkey : HotKey ,
196- pub shells : HashMap < u32 , String > ,
193+ pub toggle : Shortcut ,
194+ pub clipboard_hotkey : Shortcut ,
195+ pub shells : HashMap < Shortcut , Shelly > ,
197196}
198197
199198impl Tile {
@@ -230,7 +229,6 @@ impl Tile {
230229 _ => None ,
231230 } ) ;
232231 Subscription :: batch ( [
233- Subscription :: run ( handle_hotkeys) ,
234232 Subscription :: run ( handle_hot_reloading) ,
235233 keyboard,
236234 Subscription :: run ( handle_recipient) ,
@@ -242,37 +240,34 @@ impl Tile {
242240 if let keyboard:: Event :: KeyPressed { key, modifiers, .. } = event {
243241 match key {
244242 keyboard:: Key :: Named ( Named :: ArrowUp ) => {
245- return Some ( Message :: ChangeFocus ( ArrowKey :: Up , 1 ) ) ;
243+ Some ( Message :: ChangeFocus ( ArrowKey :: Up , 1 ) )
246244 }
247245 keyboard:: Key :: Named ( Named :: ArrowLeft ) => {
248- return Some ( Message :: ChangeFocus ( ArrowKey :: Left , 1 ) ) ;
246+ Some ( Message :: ChangeFocus ( ArrowKey :: Left , 1 ) )
249247 }
250248 keyboard:: Key :: Named ( Named :: ArrowRight ) => {
251- return Some ( Message :: ChangeFocus ( ArrowKey :: Right , 1 ) ) ;
249+ Some ( Message :: ChangeFocus ( ArrowKey :: Right , 1 ) )
252250 }
253251 keyboard:: Key :: Named ( Named :: ArrowDown ) => {
254- return Some ( Message :: ChangeFocus ( ArrowKey :: Down , 1 ) ) ;
252+ Some ( Message :: ChangeFocus ( ArrowKey :: Down , 1 ) )
255253 }
256254 keyboard:: Key :: Character ( chr) => {
257255 if modifiers. command ( ) && chr. to_string ( ) == "r" {
258- return Some ( Message :: ReloadConfig ) ;
256+ Some ( Message :: ReloadConfig )
259257 } else if chr. to_string ( ) == "p" && modifiers. control ( ) {
260- return Some ( Message :: ChangeFocus ( ArrowKey :: Up , 1 ) ) ;
258+ Some ( Message :: ChangeFocus ( ArrowKey :: Up , 1 ) )
261259 } else if chr. to_string ( ) == "n" && modifiers. control ( ) {
262- return Some ( Message :: ChangeFocus ( ArrowKey :: Down , 1 ) ) ;
260+ Some ( Message :: ChangeFocus ( ArrowKey :: Down , 1 ) )
263261 } else {
264- return Some ( Message :: FocusTextInput ( Move :: Forwards (
265- chr. to_string ( ) ,
266- ) ) ) ;
262+ Some ( Message :: FocusTextInput ( Move :: Forwards ( chr. to_string ( ) ) ) )
267263 }
268264 }
269- keyboard:: Key :: Named ( Named :: Enter ) => return Some ( Message :: OpenFocused ) ,
265+ keyboard:: Key :: Named ( Named :: Enter ) => Some ( Message :: OpenFocused ) ,
270266 keyboard:: Key :: Named ( Named :: Backspace ) => {
271- return Some ( Message :: FocusTextInput ( Move :: Back ) ) ;
267+ Some ( Message :: FocusTextInput ( Move :: Back ) )
272268 }
273- _ => { }
269+ _ => None ,
274270 }
275- None
276271 } else {
277272 None
278273 }
@@ -338,22 +333,6 @@ impl Tile {
338333 }
339334}
340335
341- /// This is the subscription function that handles hotkeys, e.g. for hiding / showing the window
342- fn handle_hotkeys ( ) -> impl futures:: Stream < Item = Message > {
343- stream:: channel ( 100 , async |mut output| {
344- let receiver = GlobalHotKeyEvent :: receiver ( ) ;
345- loop {
346- info ! ( "Hotkey received" ) ;
347- if let Ok ( event) = receiver. recv ( )
348- && event. state == HotKeyState :: Pressed
349- {
350- output. try_send ( Message :: KeyPressed ( event. id ) ) . unwrap ( ) ;
351- }
352- tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . await ;
353- }
354- } )
355- }
356-
357336/// This is the subscription function that handles the change in clipboard history
358337fn handle_clipboard_history ( ) -> impl futures:: Stream < Item = Message > {
359338 stream:: channel ( 100 , async |mut output| {
@@ -629,7 +608,6 @@ fn handle_recipient() -> impl futures::Stream<Item = Message> {
629608 let abcd = recipient
630609 . try_recv ( )
631610 . map ( async |msg| {
632- info ! ( "Sending a message" ) ;
633611 output. send ( msg) . await . unwrap ( ) ;
634612 } )
635613 . ok ( ) ;
0 commit comments