@@ -69,13 +69,13 @@ public static Boolean ValidateFlagAction(ToolStripItem item, String action)
69
69
{
70
70
if ( ! document . IsUntitled ) return false ;
71
71
}
72
- else if ( action . Contains ( "HasBookmarks" ) )
72
+ if ( action . Contains ( "! HasBookmarks" ) )
73
73
{
74
- if ( ! document . HasBookmarks ) return false ;
74
+ if ( document . HasBookmarks ) return false ;
75
75
}
76
- else if ( action . Contains ( "! HasBookmarks" ) )
76
+ else if ( action . Contains ( "HasBookmarks" ) )
77
77
{
78
- if ( document . HasBookmarks ) return false ;
78
+ if ( ! document . HasBookmarks ) return false ;
79
79
}
80
80
if ( action . Contains ( "!IsAloneInPane" ) )
81
81
{
@@ -125,6 +125,19 @@ public static Boolean ValidateFlagAction(ToolStripItem item, String action)
125
125
{
126
126
if ( ! Globals . MainForm . MultiInstanceMode ) return false ;
127
127
}
128
+ if ( action . Contains ( "!IsFullScreen" ) )
129
+ {
130
+ if ( MainForm . Instance . IsFullScreen ) return false ;
131
+ }
132
+ else if ( action . Contains ( "IsFullScreen" ) )
133
+ {
134
+ if ( ! MainForm . Instance . IsFullScreen ) return false ;
135
+ }
136
+ if ( action . Contains ( "TracksBoolean" ) )
137
+ {
138
+ Boolean value = ( Boolean ) Globals . Settings . GetValue ( ( ( ItemData ) item . Tag ) . Tag ) ;
139
+ if ( ! value ) return false ;
140
+ }
128
141
if ( sci != null )
129
142
{
130
143
if ( action . Contains ( "!CanUndo" ) )
@@ -159,6 +172,31 @@ public static Boolean ValidateFlagAction(ToolStripItem item, String action)
159
172
{
160
173
if ( sci . SelText . Length == 0 ) return false ;
161
174
}
175
+ if ( action . Contains ( "!SaveBOM" ) )
176
+ {
177
+ if ( document . SciControl . SaveBOM ) return false ;
178
+ }
179
+ else if ( action . Contains ( "SaveBOM" ) )
180
+ {
181
+ if ( ! document . SciControl . SaveBOM ) return false ;
182
+ }
183
+ if ( action . Contains ( "!IsUnicode" ) )
184
+ {
185
+ if ( ScintillaManager . IsUnicode ( document . SciControl . Encoding . CodePage ) ) return false ;
186
+ }
187
+ else if ( action . Contains ( "IsUnicode" ) )
188
+ {
189
+ if ( ! ScintillaManager . IsUnicode ( document . SciControl . Encoding . CodePage ) ) return false ;
190
+ }
191
+ if ( action . Contains ( "SyntaxIs?" ) )
192
+ {
193
+ String [ ] chunks = action . Split ( '?' ) ;
194
+ if ( chunks . Length == 2 )
195
+ {
196
+ String language = document . SciControl . ConfigurationLanguage ;
197
+ if ( chunks [ chunks . Length - 1 ] != language . ToUpper ( ) ) return false ;
198
+ }
199
+ }
162
200
if ( action . Contains ( "IsActiveSyntax" ) )
163
201
{
164
202
String language = document . SciControl . ConfigurationLanguage ;
@@ -170,43 +208,17 @@ public static Boolean ValidateFlagAction(ToolStripItem item, String action)
170
208
if ( codepage == Encoding . Default . CodePage ) codepage = 0 ;
171
209
if ( ( ( ItemData ) item . Tag ) . Tag != codepage . ToString ( ) ) return false ;
172
210
}
173
- if ( action . Contains ( "SaveBOM" ) )
174
- {
175
- return document . SciControl . SaveBOM ;
176
- }
177
- if ( action . Contains ( "IsDefaultEncoding" ) )
178
- {
179
- Int32 codepage = document . SciControl . Encoding . CodePage ;
180
- return codepage == Encoding . Default . CodePage ;
181
- }
182
211
if ( action . Contains ( "IsActiveEOL" ) )
183
212
{
184
213
Int32 eolMode = document . SciControl . EOLMode ;
185
214
if ( ( ( ItemData ) item . Tag ) . Tag != eolMode . ToString ( ) ) return false ;
186
215
}
187
- if ( action . Contains ( "SyntaxIs? " ) )
216
+ if ( action . Contains ( "IsDefaultEncoding " ) )
188
217
{
189
- String [ ] chunks = action . Split ( '?' ) ;
190
- if ( chunks . Length == 2 )
191
- {
192
- String language = document . SciControl . ConfigurationLanguage ;
193
- if ( chunks [ chunks . Length - 1 ] != language . ToUpper ( ) ) return false ;
194
- }
218
+ Int32 codepage = document . SciControl . Encoding . CodePage ;
219
+ if ( codepage != Encoding . Default . CodePage ) return false ;
195
220
}
196
221
}
197
- if ( action . Contains ( "!IsFullScreen" ) )
198
- {
199
- if ( MainForm . Instance . IsFullScreen ) return false ;
200
- }
201
- else if ( action . Contains ( "IsFullScreen" ) )
202
- {
203
- if ( ! MainForm . Instance . IsFullScreen ) return false ;
204
- }
205
- if ( action . Contains ( "TracksBoolean" ) )
206
- {
207
- Boolean value = ( Boolean ) Globals . Settings . GetValue ( ( ( ItemData ) item . Tag ) . Tag ) ;
208
- if ( ! value ) return false ;
209
- }
210
222
return true ;
211
223
}
212
224
@@ -302,35 +314,53 @@ public static String GetActiveEncodingName()
302
314
ITabbedDocument document = Globals . CurrentDocument ;
303
315
if ( document != null && document . IsEditable )
304
316
{
305
- Boolean hasBOM = document . SciControl . SaveBOM ;
306
317
Int32 codepage = document . SciControl . Encoding . CodePage ;
307
- if ( codepage == Encoding . UTF8 . CodePage )
308
- {
309
- return GetLabelAsPlainText ( "Label.UTF8" , hasBOM ) ;
310
- }
311
- else if ( codepage == Encoding . UTF7 . CodePage )
312
- {
313
- return GetLabelAsPlainText ( "Label.UTF7" , hasBOM ) ;
314
- }
315
- else if ( codepage == Encoding . BigEndianUnicode . CodePage )
318
+ EncodingFileInfo info = FileHelper . GetEncodingFileInfo ( document . FileName ) ;
319
+ if ( codepage == info . CodePage )
316
320
{
317
- return GetLabelAsPlainText ( "Label.BigEndian" , hasBOM ) ;
321
+ if ( ScintillaManager . IsUnicode ( info . CodePage ) )
322
+ {
323
+ String name = "Unicode (" + info . Charset + ")" ;
324
+ return info . ContainsBOM ? name + " (BOM)" : name ;
325
+ }
326
+ else
327
+ {
328
+ String name = TextHelper . GetString ( "Label.8Bits" ) . Replace ( "&" , "" ) ;
329
+ return name + " (" + info . Charset + ")" ;
330
+ }
318
331
}
319
- else if ( codepage == Encoding . Unicode . CodePage )
332
+ else // Opened in different encoding...
320
333
{
321
- return GetLabelAsPlainText ( "Label.LittleEndian" , hasBOM ) ;
334
+ Boolean hasBOM = document . SciControl . SaveBOM ;
335
+ if ( codepage == Encoding . UTF8 . CodePage )
336
+ {
337
+ return GetLabelAsPlainText ( "Label.UTF8" , true , hasBOM ) ;
338
+ }
339
+ else if ( codepage == Encoding . UTF7 . CodePage )
340
+ {
341
+ return GetLabelAsPlainText ( "Label.UTF7" , true , hasBOM ) ;
342
+ }
343
+ else if ( codepage == Encoding . BigEndianUnicode . CodePage )
344
+ {
345
+ return GetLabelAsPlainText ( "Label.BigEndian" , true , hasBOM ) ;
346
+ }
347
+ else if ( codepage == Encoding . Unicode . CodePage )
348
+ {
349
+ return GetLabelAsPlainText ( "Label.LittleEndian" , true , hasBOM ) ;
350
+ }
351
+ else return GetLabelAsPlainText ( "Label.8Bits" , false , false ) ;
322
352
}
323
- else return GetLabelAsPlainText ( "Label.8Bits" , false ) ;
324
353
}
325
354
else return TextHelper . GetString ( "Info.Unknown" ) ;
326
355
}
327
356
328
357
/// <summary>
329
358
/// Gets a label as plain text by removing the accelerator key
330
359
/// </summary>
331
- public static String GetLabelAsPlainText ( String name , Boolean hasBOM )
360
+ public static String GetLabelAsPlainText ( String name , Boolean unicode , Boolean hasBOM )
332
361
{
333
362
String label = TextHelper . GetString ( name ) . Replace ( "&" , "" ) ;
363
+ if ( unicode ) label = "Unicode (" + label . ToLower ( ) + ")" ;
334
364
return hasBOM ? label + " (BOM)" : label ;
335
365
}
336
366
0 commit comments