@@ -24,6 +24,8 @@ class StatusBarPanel {
2424 this . eolHandler = opts . eolHandler ;
2525 this . chrEncHandler = opts . chrEncHandler ;
2626 this . chrEncGetter = opts . chrEncGetter ;
27+ this . getEncodingState = opts . getEncodingState ;
28+ this . getEOLState = opts . getEOLState ;
2729 this . htmlOutput = opts . htmlOutput ;
2830
2931 this . eolVal = null ;
@@ -115,7 +117,7 @@ class StatusBarPanel {
115117
116118 if ( isNaN ( chrEncVal ) ) return ;
117119
118- this . chrEncHandler ( chrEncVal ) ;
120+ this . chrEncHandler ( chrEncVal , true ) ;
119121 this . updateCharEnc ( chrEncVal ) ;
120122 hideElement ( e . target . closest ( ".cm-status-bar-select-content" ) ) ;
121123 }
@@ -212,12 +214,31 @@ class StatusBarPanel {
212214 * @param {EditorState } state
213215 */
214216 updateEOL ( state ) {
215- if ( state . lineBreak === this . eolVal ) return ;
217+ if ( this . getEOLState ( ) < 2 && state . lineBreak === this . eolVal ) return ;
216218
217219 const val = this . dom . querySelector ( ".eol-value" ) ;
218220 const button = val . closest ( ".cm-status-bar-select-btn" ) ;
219- const eolCode = eolSeqToCode [ state . lineBreak ] ;
220- const eolName = eolCodeToName [ eolCode ] ;
221+ let eolCode = eolSeqToCode [ state . lineBreak ] ;
222+ let eolName = eolCodeToName [ eolCode ] ;
223+
224+ switch ( this . getEOLState ( ) ) {
225+ case 1 : // Detected
226+ val . classList . add ( "font-italic" ) ;
227+ eolCode += " (detected)" ;
228+ eolName += " (detected)" ;
229+ // Pulse
230+ val . classList . add ( "pulse" ) ;
231+ setTimeout ( ( ) => {
232+ val . classList . remove ( "pulse" ) ;
233+ } , 2000 ) ;
234+ break ;
235+ case 0 : // Unset
236+ case 2 : // Manually set
237+ default :
238+ val . classList . remove ( "font-italic" ) ;
239+ break ;
240+ }
241+
221242 val . textContent = eolCode ;
222243 button . setAttribute ( "title" , `End of line sequence:<br>${ eolName } ` ) ;
223244 button . setAttribute ( "data-original-title" , `End of line sequence:<br>${ eolName } ` ) ;
@@ -230,12 +251,30 @@ class StatusBarPanel {
230251 */
231252 updateCharEnc ( ) {
232253 const chrEncVal = this . chrEncGetter ( ) ;
233- if ( chrEncVal === this . chrEncVal ) return ;
254+ if ( this . getEncodingState ( ) < 2 && chrEncVal === this . chrEncVal ) return ;
234255
235- const name = CHR_ENC_SIMPLE_REVERSE_LOOKUP [ chrEncVal ] ? CHR_ENC_SIMPLE_REVERSE_LOOKUP [ chrEncVal ] : "Raw Bytes" ;
256+ let name = CHR_ENC_SIMPLE_REVERSE_LOOKUP [ chrEncVal ] ? CHR_ENC_SIMPLE_REVERSE_LOOKUP [ chrEncVal ] : "Raw Bytes" ;
236257
237258 const val = this . dom . querySelector ( ".chr-enc-value" ) ;
238259 const button = val . closest ( ".cm-status-bar-select-btn" ) ;
260+
261+ switch ( this . getEncodingState ( ) ) {
262+ case 1 : // Detected
263+ val . classList . add ( "font-italic" ) ;
264+ name += " (detected)" ;
265+ // Pulse
266+ val . classList . add ( "pulse" ) ;
267+ setTimeout ( ( ) => {
268+ val . classList . remove ( "pulse" ) ;
269+ } , 2000 ) ;
270+ break ;
271+ case 0 : // Unset
272+ case 2 : // Manually set
273+ default :
274+ val . classList . remove ( "font-italic" ) ;
275+ break ;
276+ }
277+
239278 val . textContent = name ;
240279 button . setAttribute ( "title" , `${ this . label } character encoding:<br>${ name } ` ) ;
241280 button . setAttribute ( "data-original-title" , `${ this . label } character encoding:<br>${ name } ` ) ;
0 commit comments