@@ -65,6 +65,8 @@ use terminal_box::terminal_box;
65
65
use crate :: dnd:: DndDrop ;
66
66
mod terminal_box;
67
67
68
+ #[ cfg( feature = "password_manager" ) ]
69
+ mod password_manager;
68
70
mod terminal_theme;
69
71
70
72
mod dnd;
@@ -236,6 +238,8 @@ pub enum Action {
236
238
Profiles ,
237
239
SelectAll ,
238
240
Settings ,
241
+ #[ cfg( feature = "password_manager" ) ]
242
+ PasswordManager ,
239
243
ShowHeaderBar ( bool ) ,
240
244
TabActivate0 ,
241
245
TabActivate1 ,
@@ -278,6 +282,8 @@ impl Action {
278
282
Self :: PaneSplitHorizontal => Message :: PaneSplit ( pane_grid:: Axis :: Horizontal ) ,
279
283
Self :: PaneSplitVertical => Message :: PaneSplit ( pane_grid:: Axis :: Vertical ) ,
280
284
Self :: PaneToggleMaximized => Message :: PaneToggleMaximized ,
285
+ #[ cfg( feature = "password_manager" ) ]
286
+ Self :: PasswordManager => Message :: ToggleContextPage ( ContextPage :: PasswordManager ) ,
281
287
Self :: Paste => Message :: Paste ( entity_opt) ,
282
288
Self :: PastePrimary => Message :: PastePrimary ( entity_opt) ,
283
289
Self :: ProfileOpen ( profile_id) => Message :: ProfileOpen ( * profile_id) ,
@@ -362,6 +368,10 @@ pub enum Message {
362
368
PaneResized ( pane_grid:: ResizeEvent ) ,
363
369
PaneSplit ( pane_grid:: Axis ) ,
364
370
PaneToggleMaximized ,
371
+ #[ cfg( feature = "password_manager" ) ]
372
+ PasswordManager ( password_manager:: PasswordManagerMessage ) ,
373
+ #[ cfg( feature = "password_manager" ) ]
374
+ PasswordPaste ( secstr:: SecUtf8 , pane_grid:: Pane ) ,
365
375
Paste ( Option < segmented_button:: Entity > ) ,
366
376
PastePrimary ( Option < segmented_button:: Entity > ) ,
367
377
PasteValue ( Option < segmented_button:: Entity > , String ) ,
@@ -412,6 +422,8 @@ pub enum ContextPage {
412
422
ColorSchemes ( ColorSchemeKind ) ,
413
423
Profiles ,
414
424
Settings ,
425
+ #[ cfg( feature = "password_manager" ) ]
426
+ PasswordManager ,
415
427
}
416
428
417
429
/// The [`App`] stores application-specific state.
@@ -456,6 +468,8 @@ pub struct App {
456
468
profile_expanded : Option < ProfileId > ,
457
469
show_advanced_font_settings : bool ,
458
470
modifiers : Modifiers ,
471
+ #[ cfg( feature = "password_manager" ) ]
472
+ password_mgr : password_manager:: PasswordManager ,
459
473
}
460
474
461
475
impl App {
@@ -1569,6 +1583,8 @@ impl Application for App {
1569
1583
profile_expanded : None ,
1570
1584
show_advanced_font_settings : false ,
1571
1585
modifiers : Modifiers :: empty ( ) ,
1586
+ #[ cfg( feature = "password_manager" ) ]
1587
+ password_mgr : Default :: default ( ) ,
1572
1588
} ;
1573
1589
1574
1590
app. set_curr_font_weights_and_stretches ( ) ;
@@ -1582,6 +1598,10 @@ impl Application for App {
1582
1598
if self . core . window . show_context {
1583
1599
// Close context drawer if open
1584
1600
self . core . window . show_context = false ;
1601
+ #[ cfg( feature = "password_manager" ) ]
1602
+ if self . context_page == ContextPage :: PasswordManager {
1603
+ self . password_mgr . clear ( ) ;
1604
+ }
1585
1605
} else if self . find {
1586
1606
// Close find if open
1587
1607
self . find = false ;
@@ -1596,6 +1616,10 @@ impl Application for App {
1596
1616
if self . core . window . show_context {
1597
1617
Task :: none ( )
1598
1618
} else {
1619
+ #[ cfg( feature = "password_manager" ) ]
1620
+ if self . context_page == ContextPage :: PasswordManager {
1621
+ self . password_mgr . clear ( ) ;
1622
+ }
1599
1623
self . update_focus ( )
1600
1624
}
1601
1625
}
@@ -2147,6 +2171,23 @@ impl Application for App {
2147
2171
self . pane_model . panes . drop ( pane, target) ;
2148
2172
}
2149
2173
Message :: PaneDragged ( _) => { }
2174
+ #[ cfg( feature = "password_manager" ) ]
2175
+ Message :: PasswordManager ( msg) => {
2176
+ return self . password_mgr . update ( msg) ;
2177
+ }
2178
+ #[ cfg( feature = "password_manager" ) ]
2179
+ Message :: PasswordPaste ( password, pane) => {
2180
+ if let Some ( tab_model) = self . pane_model . panes . get ( pane) {
2181
+ let entity = tab_model. active ( ) ;
2182
+ if let Some ( terminal) = tab_model. data :: < Mutex < Terminal > > ( entity) {
2183
+ let terminal = terminal. lock ( ) . unwrap ( ) ;
2184
+ terminal. paste ( password. into_unsecure ( ) ) ;
2185
+ terminal. input_scroll ( b"\n " . as_slice ( ) ) ;
2186
+ self . core . window . show_context = false ;
2187
+ self . password_mgr . clear ( ) ;
2188
+ }
2189
+ }
2190
+ }
2150
2191
Message :: Paste ( entity_opt) => {
2151
2192
return clipboard:: read ( ) . map ( move |value_opt| match value_opt {
2152
2193
Some ( value) => action:: app ( Message :: PasteValue ( entity_opt, value) ) ,
@@ -2612,6 +2653,16 @@ impl Application for App {
2612
2653
ColorSchemeKind :: Light => light_entity,
2613
2654
} ) ;
2614
2655
}
2656
+
2657
+ #[ cfg( feature = "password_manager" ) ]
2658
+ if ContextPage :: PasswordManager == context_page {
2659
+ if self . core . window . show_context {
2660
+ self . password_mgr . pane = Some ( self . pane_model . focused ( ) ) ;
2661
+ return self . password_mgr . refresh_password_list ( ) ;
2662
+ } else {
2663
+ self . password_mgr . clear ( ) ;
2664
+ }
2665
+ }
2615
2666
}
2616
2667
Message :: UpdateDefaultProfile ( ( default, profile_id) ) => {
2617
2668
config_set ! ( default_profile, default . then_some( profile_id) ) ;
@@ -2685,6 +2736,12 @@ impl Application for App {
2685
2736
Message :: ToggleContextPage ( ContextPage :: Settings ) ,
2686
2737
)
2687
2738
. title ( fl ! ( "settings" ) ) ,
2739
+ #[ cfg( feature = "password_manager" ) ]
2740
+ ContextPage :: PasswordManager => context_drawer:: context_drawer (
2741
+ self . password_mgr . context_page ( self . core . system_theme ( ) ) ,
2742
+ Message :: ToggleContextPage ( ContextPage :: PasswordManager ) ,
2743
+ )
2744
+ . title ( fl ! ( "passwords-title" ) ) ,
2688
2745
} )
2689
2746
}
2690
2747
0 commit comments