|
|
|
@ -31,6 +31,10 @@
@@ -31,6 +31,10 @@
|
|
|
|
|
<Reference Include="System.Drawing" /> |
|
|
|
|
<Reference Include="System.Windows.Forms" /> |
|
|
|
|
<Reference Include="System.Xml" /> |
|
|
|
|
<Import Include="System" /> |
|
|
|
|
<Import Include="System.Text" /> |
|
|
|
|
<Import Include="System.Collections" /> |
|
|
|
|
<Import Include="System.Windows.Forms" /> |
|
|
|
|
</ProjectItems> |
|
|
|
|
|
|
|
|
|
<Files> |
|
|
|
@ -53,50 +57,46 @@
@@ -53,50 +57,46 @@
|
|
|
|
|
<File name="Src/Command.vb"> |
|
|
|
|
<![CDATA[${StandardHeader.VBNET} |
|
|
|
|
|
|
|
|
|
Imports System |
|
|
|
|
Imports System.Text |
|
|
|
|
Imports ICSharpCode.Core |
|
|
|
|
Imports ICSharpCode.SharpDevelop |
|
|
|
|
Imports ICSharpCode.SharpDevelop.Gui |
|
|
|
|
Imports ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor |
|
|
|
|
Imports ICSharpCode.TextEditor |
|
|
|
|
|
|
|
|
|
Namespace ${StandardNamespace} |
|
|
|
|
Public Class ToolCommand1 |
|
|
|
|
Inherits AbstractMenuCommand |
|
|
|
|
Public Overrides Sub Run() |
|
|
|
|
'' Here an example that shows how to access the current text document: |
|
|
|
|
|
|
|
|
|
Dim tecp As ITextEditorControlProvider = CType(WorkbenchSingleton.Workbench.ActiveContent, ITextEditorControlProvider) |
|
|
|
|
If tecp Is Nothing Then |
|
|
|
|
' active content is not a text editor control |
|
|
|
|
Return |
|
|
|
|
End If |
|
|
|
|
' Get the active text area from the control: |
|
|
|
|
Dim textArea As TextArea = tecp.TextEditorControl.ActiveTextAreaControl.TextArea |
|
|
|
|
If Not textArea.SelectionManager.HasSomethingSelected Then |
|
|
|
|
Return |
|
|
|
|
End If |
|
|
|
|
' get the selected text: |
|
|
|
|
Dim text As String = textArea.SelectionManager.SelectedText |
|
|
|
|
' reverse the text: |
|
|
|
|
Dim b As StringBuilder = new StringBuilder(text.Length) |
|
|
|
|
For i As Integer = text.Length - 1 To 0 |
|
|
|
|
b.Append(text(i)) |
|
|
|
|
Next |
|
|
|
|
Dim newText As String = b.ToString() |
|
|
|
|
' ensure caret is at start of selection |
|
|
|
|
textArea.Caret.Position = textArea.SelectionManager.SelectionCollection(0).StartPosition |
|
|
|
|
' deselect text |
|
|
|
|
textArea.SelectionManager.ClearSelection() |
|
|
|
|
' replace the selected text with the new text: |
|
|
|
|
' Replace() takes the arguments: start offset to replace, length of the text to remove, new text |
|
|
|
|
textArea.Document.Replace(textArea.Caret.Offset, text.Length, newText) |
|
|
|
|
' Redraw: |
|
|
|
|
textArea.Refresh() |
|
|
|
|
End Sub |
|
|
|
|
End Class |
|
|
|
|
End Namespace |
|
|
|
|
Public Class ToolCommand1 |
|
|
|
|
Inherits AbstractMenuCommand |
|
|
|
|
Public Overrides Sub Run() |
|
|
|
|
'' Here an example that shows how to access the current text document: |
|
|
|
|
|
|
|
|
|
Dim tecp As ITextEditorControlProvider = CType(WorkbenchSingleton.Workbench.ActiveContent, ITextEditorControlProvider) |
|
|
|
|
If tecp Is Nothing Then |
|
|
|
|
' active content is not a text editor control |
|
|
|
|
Return |
|
|
|
|
End If |
|
|
|
|
' Get the active text area from the control: |
|
|
|
|
Dim textArea As TextArea = tecp.TextEditorControl.ActiveTextAreaControl.TextArea |
|
|
|
|
If Not textArea.SelectionManager.HasSomethingSelected Then |
|
|
|
|
Return |
|
|
|
|
End If |
|
|
|
|
' get the selected text: |
|
|
|
|
Dim text As String = textArea.SelectionManager.SelectedText |
|
|
|
|
' reverse the text: |
|
|
|
|
Dim b As StringBuilder = new StringBuilder(text.Length) |
|
|
|
|
For i As Integer = text.Length - 1 To 0 |
|
|
|
|
b.Append(text(i)) |
|
|
|
|
Next |
|
|
|
|
Dim newText As String = b.ToString() |
|
|
|
|
' ensure caret is at start of selection |
|
|
|
|
textArea.Caret.Position = textArea.SelectionManager.SelectionCollection(0).StartPosition |
|
|
|
|
' deselect text |
|
|
|
|
textArea.SelectionManager.ClearSelection() |
|
|
|
|
' replace the selected text with the new text: |
|
|
|
|
' Replace() takes the arguments: start offset to replace, length of the text to remove, new text |
|
|
|
|
textArea.Document.Replace(textArea.Caret.Offset, text.Length, newText) |
|
|
|
|
' Redraw: |
|
|
|
|
textArea.Refresh() |
|
|
|
|
End Sub |
|
|
|
|
End Class |
|
|
|
|
]]></File> |
|
|
|
|
<File name="Configuration/AssemblyInfo.vb"> |
|
|
|
|
<![CDATA[${StandardHeader.VBNET} |
|
|
|
|