Пример #1
0
 public static SourceCodeEditor add_CodeMarker(this SourceCodeEditor codeEditor, int offsetStart, int offsetEnd)
 {
     codeEditor.textEditor().invokeOnThread(
         () =>
     {
         var position1 = codeEditor.document().OffsetToPosition(offsetStart);
         var position2 = codeEditor.document().OffsetToPosition(offsetEnd);
         codeEditor.clearMarkers();
         codeEditor.selectTextWithColor(position1, position2)
         .refresh();
         codeEditor.document().MarkerStrategy.TextMarker.first().field("color", Color.Azure);
     });
     return(codeEditor);
 }
Пример #2
0
 public static SourceCodeEditor selectText(this SourceCodeEditor codeEditor, int offsetStart, int offsetEnd)
 {
     codeEditor.textEditor().invokeOnThread(
         () =>
     {
         try
         {
             var position1 = codeEditor.document().OffsetToPosition(offsetStart).location();
             var position2 = codeEditor.document().OffsetToPosition(offsetEnd).location();
             codeEditor.setSelectionText(position1, position2);
         }
         catch (Exception ex)
         {
             ex.log("in SourceCodeEditor selectText");
         }
     });
     return(codeEditor);
 }
Пример #3
0
 public static SourceCodeEditor markerColor(this SourceCodeEditor codeEditor, Color color)
 {
     codeEditor.textEditor().invokeOnThread(
         () =>
     {
         foreach (var marker in codeEditor.document().MarkerStrategy.TextMarker)
         {
             marker.field("color", color);
         }
     });
     return(codeEditor);
 }
Пример #4
0
 public static SourceCodeEditor     setSelectionText(this SourceCodeEditor codeEditor, Location startLocation, Location endLocation)
 {
     return(codeEditor.invokeOnThread(
                () => {
         var start = new TextLocation(startLocation.X - 1, startLocation.Y - 1);
         var end = new TextLocation(endLocation.X - 1, endLocation.Y - 1);
         var selection = new DefaultSelection(codeEditor.document(), start, end);
         codeEditor.textArea().SelectionManager.SetSelection(selection);
         codeEditor.caret_Line(start.Line);
         codeEditor.caret_Column(start.Column);
         return codeEditor;
     }));
 }
Пример #5
0
 public static SourceCodeEditor     selectTextWithColor(this SourceCodeEditor codeEditor, TextLocation startLocation, TextLocation endLocation)
 {
     if (startLocation > endLocation)
     {
         "in SourceCodeEditor.selectTextWithColor startLocation > endLocation".error();
         return(codeEditor);
     }
     if (startLocation.Column == -1 || startLocation.Line == -1 ||
         endLocation.Column == -1 || endLocation.Line == -1)
     {
         "in SourceCodeEditor.selectTextWithColor one of start or end location values was -1".error();
         return(codeEditor);
     }
     return(codeEditor.selectTextWithColor(new DefaultSelection(codeEditor.document(), startLocation, endLocation)));
 }
Пример #6
0
 public static SourceCodeEditor     selectTextWithColor(this SourceCodeEditor codeEditor, DefaultSelection selection, TextMarkerType textMarkerType, Color color)
 {
     if (selection.Length < 0)
     {
         "in SourceCodeEditor.selectTextWithColor selection.Length was <  0".error();
         return(codeEditor);
     }
     return(codeEditor.invokeOnThread(
                () => {
         var newMarker = new TextMarker(
             selection.Offset,
             selection.Length,
             textMarkerType, color);
         codeEditor.document().MarkerStrategy.AddMarker(newMarker);
         return codeEditor;
     }));
 }