@@ -13,10 +13,9 @@ use zellij_tile::prelude::actions::Action;
13
13
use zellij_tile:: prelude:: * ;
14
14
use zellij_tile_utils:: { palette_match, style} ;
15
15
16
- use first_line:: first_line;
16
+ use first_line:: { first_line, first_line_supermode } ;
17
17
use second_line:: {
18
- floating_panes_are_visible, fullscreen_panes_to_hide, keybinds,
19
- locked_floating_panes_are_visible, locked_fullscreen_panes_to_hide, system_clipboard_error,
18
+ floating_panes_are_visible, fullscreen_panes_to_hide, keybinds, system_clipboard_error,
20
19
text_copied_hint,
21
20
} ;
22
21
use tip:: utils:: get_cached_tip_name;
@@ -34,6 +33,10 @@ struct State {
34
33
mode_info : ModeInfo ,
35
34
text_copy_destination : Option < CopyDestination > ,
36
35
display_system_clipboard_failure : bool ,
36
+
37
+ supermode : bool ,
38
+ standby_mode : InputMode ,
39
+ current_mode : InputMode ,
37
40
}
38
41
39
42
register_plugin ! ( State ) ;
@@ -60,6 +63,7 @@ impl Display for LinePart {
60
63
#[ derive( Clone , Copy ) ]
61
64
pub struct ColoredElements {
62
65
pub selected : SegmentStyle ,
66
+ pub selected_standby_shortcut : SegmentStyle ,
63
67
pub unselected : SegmentStyle ,
64
68
pub unselected_alternate : SegmentStyle ,
65
69
pub disabled : SegmentStyle ,
@@ -109,6 +113,14 @@ fn color_elements(palette: Palette, different_color_alternates: bool) -> Colored
109
113
styled_text : style ! ( background, palette. green) . bold ( ) ,
110
114
suffix_separator : style ! ( palette. green, background) . bold ( ) ,
111
115
} ,
116
+ selected_standby_shortcut : SegmentStyle {
117
+ prefix_separator : style ! ( background, palette. green) ,
118
+ char_left_separator : style ! ( background, palette. green) . bold ( ) ,
119
+ char_shortcut : style ! ( palette. red, palette. green) . bold ( ) ,
120
+ char_right_separator : style ! ( background, palette. green) . bold ( ) ,
121
+ styled_text : style ! ( background, palette. green) . bold ( ) ,
122
+ suffix_separator : style ! ( palette. green, palette. fg) . bold ( ) ,
123
+ } ,
112
124
unselected : SegmentStyle {
113
125
prefix_separator : style ! ( background, palette. fg) ,
114
126
char_left_separator : style ! ( background, palette. fg) . bold ( ) ,
@@ -145,6 +157,14 @@ fn color_elements(palette: Palette, different_color_alternates: bool) -> Colored
145
157
styled_text : style ! ( background, palette. green) . bold ( ) ,
146
158
suffix_separator : style ! ( palette. green, background) . bold ( ) ,
147
159
} ,
160
+ selected_standby_shortcut : SegmentStyle {
161
+ prefix_separator : style ! ( background, palette. green) ,
162
+ char_left_separator : style ! ( background, palette. green) . bold ( ) ,
163
+ char_shortcut : style ! ( palette. red, palette. green) . bold ( ) ,
164
+ char_right_separator : style ! ( background, palette. green) . bold ( ) ,
165
+ styled_text : style ! ( background, palette. green) . bold ( ) ,
166
+ suffix_separator : style ! ( palette. green, palette. fg) . bold ( ) ,
167
+ } ,
148
168
unselected : SegmentStyle {
149
169
prefix_separator : style ! ( background, palette. fg) ,
150
170
char_left_separator : style ! ( background, palette. fg) . bold ( ) ,
@@ -187,12 +207,44 @@ impl ZellijPlugin for State {
187
207
EventType :: InputReceived ,
188
208
EventType :: SystemClipboardFailure ,
189
209
] ) ;
210
+ self . supermode = false ; // TODO: from config
211
+ self . standby_mode = InputMode :: Pane ;
212
+ if self . supermode {
213
+ switch_to_input_mode ( & InputMode :: Locked ) ; // supermode should start locked (TODO: only
214
+ // once per app load, let's not do this on
215
+ // each tab loading)
216
+ }
190
217
}
191
218
192
219
fn update ( & mut self , event : Event ) -> bool {
193
220
let mut should_render = false ;
194
221
match event {
195
222
Event :: ModeUpdate ( mode_info) => {
223
+ if self . supermode {
224
+ // supermode is a "sticky" mode that is not Normal or Locked
225
+ // using this configuration, we default to Locked mode in order to avoid key
226
+ // collisions with terminal applications
227
+ // whenever the user switches away from locked mode, we make sure to place them
228
+ // in the standby mode
229
+ // whenever the user switches to a mode that is not locked or normal, we set
230
+ // that mode as the standby mode
231
+ // whenever the user switches away from the standby mode, we palce them in
232
+ // normal mode
233
+ if mode_info. mode == InputMode :: Normal && self . current_mode == InputMode :: Locked
234
+ {
235
+ switch_to_input_mode ( & self . standby_mode ) ;
236
+ } else if mode_info. mode == InputMode :: Normal
237
+ && self . current_mode == self . standby_mode
238
+ {
239
+ switch_to_input_mode ( & InputMode :: Locked ) ;
240
+ } else if mode_info. mode != InputMode :: Locked
241
+ && mode_info. mode != InputMode :: Normal
242
+ {
243
+ self . standby_mode = mode_info. mode ;
244
+ }
245
+ self . current_mode = mode_info. mode ;
246
+ }
247
+
196
248
if self . mode_info != mode_info {
197
249
should_render = true ;
198
250
}
@@ -244,7 +296,17 @@ impl ZellijPlugin for State {
244
296
} ;
245
297
246
298
let active_tab = self . tabs . iter ( ) . find ( |t| t. active ) ;
247
- let first_line = first_line ( & self . mode_info , active_tab, cols, separator) ;
299
+ let first_line = if self . supermode {
300
+ first_line_supermode (
301
+ & self . standby_mode ,
302
+ & self . mode_info ,
303
+ active_tab,
304
+ cols,
305
+ separator,
306
+ )
307
+ } else {
308
+ first_line ( & self . mode_info , active_tab, cols, separator)
309
+ } ;
248
310
let second_line = self . second_line ( cols) ;
249
311
250
312
let background = match self . mode_info . style . colors . theme_hue {
@@ -296,21 +358,16 @@ impl State {
296
358
} else if let Some ( active_tab) = active_tab {
297
359
if active_tab. is_fullscreen_active {
298
360
match self . mode_info . mode {
299
- InputMode :: Normal => fullscreen_panes_to_hide (
300
- & self . mode_info . style . colors ,
301
- active_tab. panes_to_hide ,
302
- ) ,
303
- InputMode :: Locked => locked_fullscreen_panes_to_hide (
361
+ InputMode :: Normal | InputMode :: Locked => fullscreen_panes_to_hide (
304
362
& self . mode_info . style . colors ,
305
363
active_tab. panes_to_hide ,
306
364
) ,
307
365
_ => keybinds ( & self . mode_info , & self . tip_name , cols) ,
308
366
}
309
367
} else if active_tab. are_floating_panes_visible {
310
368
match self . mode_info . mode {
311
- InputMode :: Normal => floating_panes_are_visible ( & self . mode_info ) ,
312
- InputMode :: Locked => {
313
- locked_floating_panes_are_visible ( & self . mode_info . style . colors )
369
+ InputMode :: Normal | InputMode :: Locked => {
370
+ floating_panes_are_visible ( & self . mode_info )
314
371
} ,
315
372
_ => keybinds ( & self . mode_info , & self . tip_name , cols) ,
316
373
}
0 commit comments