@@ -127,32 +127,12 @@ const StatusLine = Module("statusline", {
127127
128128 // set the visibility of the statusline
129129 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
153134
154135 this . setVisibility . contentSeparator = highlight . get ( 'ContentSeparator' ) . value ;
155- this . setVisibility . mode = this . setVisibility . MODE_AUTO ;
156136 this . setVisibility . isVisible = true ;
157137 }
158138
@@ -186,57 +166,34 @@ const StatusLine = Module("statusline", {
186166 sv . isVisible = true ;
187167 } ;
188168
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" ] ;
210170
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+ }
223180 break ;
224- case sv . MODE_ON :
225- statusline . setVisibility ( sv . MODE_OFF ) ;
181+ case "visible" :
182+ showStatusline ( ) ;
226183 break ;
227- case sv . MODE_OFF :
228- statusline . setVisibility ( sv . MODE_AUTO ) ;
184+ case "hidden" :
185+ hideStatusline ( ) ;
229186 break ;
230187 }
231188 break ;
232189
233- case sv . EVENT_SHOW :
190+ case sv . SHOW :
234191 showStatusline ( ) ;
235192 break ;
236193
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" ) {
240197 hideStatusline ( ) ;
241198 }
242199 break ;
@@ -442,6 +399,23 @@ const StatusLine = Module("statusline", {
442399 return [ [ name , fields [ name ] . description ] for ( name of Object . keys ( fields ) ) ] ;
443400 } ,
444401 } ) ;
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+ } ) ;
445419 }
446420} ) ;
447421
0 commit comments