@@ -127,32 +127,12 @@ const StatusLine = Module("statusline", {
127
127
128
128
// set the visibility of the statusline
129
129
setVisibility : function ( request ) {
130
- if ( typeof this . setVisibility . MODE_AUTO == 'undefined' ) { // TODO proper initialization
131
- /*
132
- * There are three modes:
133
- *
134
- * AUTO: This shows or hides the statusline depending on the fullscreen state.
135
- * ON: Here the statusline is always visible, even in fullscreen.
136
- * OFF: The statusline is hidden, only the commandline is shown after typing a colon.
137
- */
138
- this . setVisibility . MODE_AUTO = 0 ;
139
- this . setVisibility . MODE_ON = 1 ;
140
- this . setVisibility . MODE_OFF = 2 ;
141
-
142
- /*
143
- * Several events can happen:
144
- *
145
- * FULLSCREEN: Whenever the fullscreen state changes.
146
- * TOGGLE: Cycles through all three modes. Currently there's no indicator, so it's not easy with three modes instead of two.
147
- * SHOW and HIDE: These are emitted when entering or leaving the commandline.
148
- */
149
- this . setVisibility . EVENT_TOGGLE = 3 ;
150
- this . setVisibility . EVENT_FULLSCREEN = 4 ;
151
- this . setVisibility . EVENT_SHOW = 5 ;
152
- this . setVisibility . EVENT_HIDE = 6 ;
130
+ if ( typeof this . setVisibility . UPDATE == 'undefined' ) { // TODO proper initialization
131
+ this . setVisibility . UPDATE = 0 ; // Apply current configuration
132
+ this . setVisibility . SHOW = 1 ; // Temporarily show statusline
133
+ this . setVisibility . HIDE = 2 ; // Temporarily hide statusline
153
134
154
135
this . setVisibility . contentSeparator = highlight . get ( 'ContentSeparator' ) . value ;
155
- this . setVisibility . mode = this . setVisibility . MODE_AUTO ;
156
136
this . setVisibility . isVisible = true ;
157
137
}
158
138
@@ -186,57 +166,34 @@ const StatusLine = Module("statusline", {
186
166
sv . isVisible = true ;
187
167
} ;
188
168
189
- switch ( request ) {
190
- case sv . MODE_AUTO :
191
- sv . mode = sv . MODE_AUTO ;
192
- statusline . setVisibility ( sv . EVENT_FULLSCREEN ) ;
193
- break ;
194
-
195
- case sv . MODE_ON :
196
- sv . mode = sv . MODE_ON ;
197
- showStatusline ( ) ;
198
- break ;
199
-
200
- case sv . MODE_OFF :
201
- sv . mode = sv . MODE_OFF ;
202
- hideStatusline ( ) ;
203
- break ;
204
-
205
- case sv . EVENT_FULLSCREEN :
206
- // Ignore fullscreen event if we are not in AUTO mode, visiblity was set manually.
207
- if ( sv . mode != sv . MODE_AUTO ) {
208
- break ;
209
- }
169
+ let mode = options [ "statuslinevisibility" ] ;
210
170
211
- if ( window . fullScreen ) {
212
- hideStatusline ( ) ;
213
- } else {
214
- showStatusline ( ) ;
215
- }
216
- break ;
217
-
218
- case sv . EVENT_TOGGLE :
219
- // Cycle through all available modes.
220
- switch ( sv . mode ) {
221
- case sv . MODE_AUTO :
222
- statusline . setVisibility ( sv . MODE_ON ) ;
171
+ switch ( request ) {
172
+ case sv . UPDATE :
173
+ switch ( mode ) {
174
+ case "auto" :
175
+ if ( window . fullScreen ) {
176
+ hideStatusline ( ) ;
177
+ } else {
178
+ showStatusline ( ) ;
179
+ }
223
180
break ;
224
- case sv . MODE_ON :
225
- statusline . setVisibility ( sv . MODE_OFF ) ;
181
+ case "visible" :
182
+ showStatusline ( ) ;
226
183
break ;
227
- case sv . MODE_OFF :
228
- statusline . setVisibility ( sv . MODE_AUTO ) ;
184
+ case "hidden" :
185
+ hideStatusline ( ) ;
229
186
break ;
230
187
}
231
188
break ;
232
189
233
- case sv . EVENT_SHOW :
190
+ case sv . SHOW :
234
191
showStatusline ( ) ;
235
192
break ;
236
193
237
- case sv . EVENT_HIDE :
238
- // Only hide when in AUTO +fullscreen or OFF .
239
- if ( ( sv . mode == sv . MODE_AUTO && window . fullScreen ) || sv . mode == sv . MODE_OFF ) {
194
+ case sv . HIDE :
195
+ // Only hide when in auto +fullscreen or hidden .
196
+ if ( ( mode == "auto" && window . fullScreen ) || mode == "hidden" ) {
240
197
hideStatusline ( ) ;
241
198
}
242
199
break ;
@@ -442,6 +399,23 @@ const StatusLine = Module("statusline", {
442
399
return [ [ name , fields [ name ] . description ] for ( name of Object . keys ( fields ) ) ] ;
443
400
} ,
444
401
} ) ;
402
+
403
+ options . add ( [ "statuslinevisibility" , "slv" ] ,
404
+ "Control the visibility of the statusline" ,
405
+ "string" , "auto" ,
406
+ {
407
+ setter : function setter ( value ) {
408
+ statusline . setVisibility ( statusline . setVisibility . UPDATE ) ;
409
+ return value ;
410
+ } ,
411
+ completer : function completer ( context ) {
412
+ return [
413
+ [ "auto" , "Hide statusline in fullscreen automatically" ] ,
414
+ [ "visible" , "Always show the statusline" ] ,
415
+ [ "hidden" , "Never show the statusline" ]
416
+ ] ;
417
+ } ,
418
+ } ) ;
445
419
}
446
420
} ) ;
447
421
0 commit comments