@@ -6,7 +6,9 @@ use cosmic::{
66 app:: { Core , Task , context_drawer, cosmic:: Cosmic } ,
77 cosmic_config, cosmic_theme, executor,
88 iced:: {
9- self , Alignment , Event , Length , Size , Subscription , event,
9+ self , Alignment , Event , Length , Size , Subscription ,
10+ core:: SmolStr ,
11+ event,
1012 futures:: { self , SinkExt } ,
1113 keyboard:: { Event as KeyEvent , Key , Modifiers } ,
1214 stream, window,
@@ -35,7 +37,7 @@ use std::{
3537
3638use crate :: {
3739 app:: { Action , ContextPage , Message as AppMessage , PreviewItem , PreviewKind } ,
38- config:: { Config , DialogConfig , Favorite , TIME_CONFIG_ID , ThumbCfg , TimeConfig } ,
40+ config:: { Config , DialogConfig , Favorite , TIME_CONFIG_ID , ThumbCfg , TimeConfig , TypeToSearch } ,
3941 fl, home_dir,
4042 key_bind:: key_binds,
4143 localize:: LANGUAGE_SORTER ,
@@ -413,7 +415,7 @@ enum Message {
413415 DialogUpdate ( DialogPage ) ,
414416 Filename ( String ) ,
415417 Filter ( usize ) ,
416- Key ( Modifiers , Key ) ,
418+ Key ( Modifiers , Key , Option < SmolStr > ) ,
417419 ModifiersChanged ( Modifiers ) ,
418420 MounterItems ( MounterKey , MounterItems ) ,
419421 NewFolder ,
@@ -1339,12 +1341,14 @@ impl Application for App {
13391341 }
13401342 return self . rescan_tab ( ) ;
13411343 }
1342- Message :: Key ( modifiers, key) => {
1344+ Message :: Key ( modifiers, key, text ) => {
13431345 for ( key_bind, action) in self . key_binds . iter ( ) {
13441346 if key_bind. matches ( modifiers, & key) {
13451347 return self . update ( Message :: from ( action. message ( ) ) ) ;
13461348 }
13471349 }
1350+
1351+ // Check key binds from accept label
13481352 if let Some ( key_bind) = & self . accept_label . key_bind_opt {
13491353 if key_bind. matches ( modifiers, & key) {
13501354 return self . update ( if self . flags . kind . save ( ) {
@@ -1354,6 +1358,36 @@ impl Application for App {
13541358 } ) ;
13551359 }
13561360 }
1361+
1362+ // Uncaptured keys with only shift modifiers go to the search or location box
1363+ if !modifiers. logo ( )
1364+ && !modifiers. control ( )
1365+ && !modifiers. alt ( )
1366+ && matches ! ( key, Key :: Character ( _) )
1367+ {
1368+ if let Some ( text) = text {
1369+ match self . flags . config . type_to_search {
1370+ TypeToSearch :: Recursive => {
1371+ let mut term = self . search_get ( ) . unwrap_or_default ( ) . to_string ( ) ;
1372+ term. push_str ( & text) ;
1373+ return self . search_set ( Some ( term) ) ;
1374+ }
1375+ TypeToSearch :: EnterPath => {
1376+ let location = self . tab . edit_location . as_ref ( ) . map_or_else (
1377+ || self . tab . location . clone ( ) ,
1378+ |x| x. location . clone ( ) ,
1379+ ) ;
1380+ // Try to add text to end of location
1381+ if let Some ( path) = location. path_opt ( ) {
1382+ let mut path_string = path. to_string_lossy ( ) . to_string ( ) ;
1383+ path_string. push_str ( & text) ;
1384+ self . tab . edit_location =
1385+ Some ( location. with_path ( PathBuf :: from ( path_string) ) . into ( ) ) ;
1386+ }
1387+ }
1388+ }
1389+ }
1390+ }
13571391 }
13581392 Message :: ModifiersChanged ( modifiers) => {
13591393 self . modifiers = modifiers;
@@ -1904,8 +1938,13 @@ impl Application for App {
19041938 struct TimeSubscription ;
19051939 let mut subscriptions = vec ! [
19061940 event:: listen_with( |event, status, _window_id| match event {
1907- Event :: Keyboard ( KeyEvent :: KeyPressed { key, modifiers, .. } ) => match status {
1908- event:: Status :: Ignored => Some ( Message :: Key ( modifiers, key) ) ,
1941+ Event :: Keyboard ( KeyEvent :: KeyPressed {
1942+ key,
1943+ modifiers,
1944+ text,
1945+ ..
1946+ } ) => match status {
1947+ event:: Status :: Ignored => Some ( Message :: Key ( modifiers, key, text) ) ,
19091948 event:: Status :: Captured => None ,
19101949 } ,
19111950 Event :: Keyboard ( KeyEvent :: ModifiersChanged ( modifiers) ) => {
0 commit comments