44using System . IO ;
55using System . Linq ;
66using System . Text ;
7+ using System . Text . RegularExpressions ;
78using System . Threading ;
89using System . Threading . Tasks ;
910using System . Timers ;
1617using ICSharpCode . AvalonEdit . Document ;
1718using ICSharpCode . AvalonEdit . Editing ;
1819using ICSharpCode . AvalonEdit . Folding ;
20+ using ICSharpCode . AvalonEdit . Highlighting ;
1921using ICSharpCode . AvalonEdit . Rendering ;
2022using ICSharpCode . AvalonEdit . Utils ;
2123using MahApps . Metro . Controls . Dialogs ;
@@ -170,6 +172,36 @@ public EditorElement(string filePath)
170172 CompileBox . IsChecked = filePath . EndsWith ( ".sp" ) ;
171173 }
172174
175+ public string FullFilePath
176+ {
177+ get => _FullFilePath ;
178+ set
179+ {
180+ var fInfo = new FileInfo ( value ) ;
181+ _FullFilePath = fInfo . FullName ;
182+ Parent . Title = fInfo . Name ;
183+ if ( fileWatcher != null ) fileWatcher . Path = fInfo . DirectoryName ;
184+ }
185+ }
186+
187+ public bool NeedsSave
188+ {
189+ get => _NeedsSave ;
190+ set
191+ {
192+ if ( ! ( value ^ _NeedsSave ) ) //when not changed
193+ return ;
194+ _NeedsSave = value ;
195+ if ( Parent != null )
196+ {
197+ if ( _NeedsSave )
198+ Parent . Title = "*" + Parent . Title ;
199+ else
200+ Parent . Title = Parent . Title . Trim ( '*' ) ;
201+ }
202+ }
203+ }
204+
173205 private async void TextArea_MouseDown ( object sender , MouseButtonEventArgs e )
174206 {
175207 if ( ! Keyboard . IsKeyDown ( Key . LeftCtrl ) ) return ;
@@ -254,9 +286,9 @@ private string GetWordAtMousePosition(MouseEventArgs e)
254286 if ( offset >= editor . TextArea . Document . TextLength )
255287 offset -- ;
256288
257- int offsetStart = TextUtilities . GetNextCaretPosition ( editor . TextArea . Document , offset ,
289+ var offsetStart = TextUtilities . GetNextCaretPosition ( editor . TextArea . Document , offset ,
258290 LogicalDirection . Backward , CaretPositioningMode . WordBorder ) ;
259- int offsetEnd = TextUtilities . GetNextCaretPosition ( editor . TextArea . Document , offset ,
291+ var offsetEnd = TextUtilities . GetNextCaretPosition ( editor . TextArea . Document , offset ,
260292 LogicalDirection . Forward , CaretPositioningMode . WordBorder ) ;
261293
262294 if ( offsetEnd == - 1 || offsetStart == - 1 )
@@ -270,36 +302,6 @@ private string GetWordAtMousePosition(MouseEventArgs e)
270302 return editor . TextArea . Document . GetText ( offsetStart , offsetEnd - offsetStart ) ;
271303 }
272304
273- public string FullFilePath
274- {
275- get => _FullFilePath ;
276- set
277- {
278- var fInfo = new FileInfo ( value ) ;
279- _FullFilePath = fInfo . FullName ;
280- Parent . Title = fInfo . Name ;
281- if ( fileWatcher != null ) fileWatcher . Path = fInfo . DirectoryName ;
282- }
283- }
284-
285- public bool NeedsSave
286- {
287- get => _NeedsSave ;
288- set
289- {
290- if ( ! ( value ^ _NeedsSave ) ) //when not changed
291- return ;
292- _NeedsSave = value ;
293- if ( Parent != null )
294- {
295- if ( _NeedsSave )
296- Parent . Title = "*" + Parent . Title ;
297- else
298- Parent . Title = Parent . Title . Trim ( '*' ) ;
299- }
300- }
301- }
302-
303305 private void AutoSaveTimer_Elapsed ( object sender , ElapsedEventArgs e )
304306 {
305307 if ( NeedsSave )
@@ -657,7 +659,6 @@ private void Caret_PositionChanged(object sender, EventArgs e)
657659 , fInfo . Name ) . Condense ( ) ;
658660
659661 if ( fInfo . Extension . Trim ( '.' ) . ToLowerInvariant ( ) == "sp" )
660- {
661662 if ( el . IsLoaded )
662663 {
663664 caret = el . editor . CaretOffset ;
@@ -666,7 +667,6 @@ private void Caret_PositionChanged(object sender, EventArgs e)
666667 . Condense ( ) ;
667668 currentFunctions = definitions [ i ] . Functions ;
668669 }
669- }
670670 }
671671
672672 var smDef = Program . Configs [ Program . SelectedConfig ] . GetSMDef ( )
@@ -675,6 +675,7 @@ private void Caret_PositionChanged(object sender, EventArgs e)
675675 var acNodes = smDef . ProduceACNodes ( ) ;
676676 var isNodes = smDef . ProduceISNodes ( ) ;
677677
678+ ce . editor . SyntaxHighlighting = new AeonEditorHighlighting ( smDef ) ;
678679 foreach ( var el in ee )
679680 {
680681 if ( el == ce )
@@ -683,6 +684,7 @@ private void Caret_PositionChanged(object sender, EventArgs e)
683684 if ( ce . ISAC_Open ) continue ;
684685 }
685686
687+
686688 el . InterruptLoadAutoCompletes ( smDef . FunctionStrings , smFunctions , acNodes ,
687689 isNodes , smDef . Methodmaps . ToArray ( ) , smDef . Variables . ToArray ( ) ) ;
688690 }
0 commit comments