Update of /cvsroot/cpptool/rfta/src/rftavc7addin/exploration
In directory sc8-pr-cvs1:/tmp/cvs-serv22820/exploration
Added Files:
Exploration.vb MacroTest.cpp
Log Message:
* squeleton for a VC7 plug-in. The toolbar and a menu are added to VC7 interface. Though icones are not displayed. A dialog box is displayed when the command is activated.
--- NEW FILE: Exploration.vb ---
Imports EnvDTE
Imports System.Diagnostics
Public Module Module1
' Test: how to get the current selection
' Retrieving the TextSelection, its property AnchorPoint and ActivePoint are VirtualPoint.
' The offset in number of character from the beginning of the document is in the
' AbsoluteCharOffset property of a VirtualPoint object. It is 1 based (begin of doc = offset 1)
Sub TestEditPoint()
Dim doc As Document = DTE.ActiveDocument
Dim sel As TextSelection = doc.Selection
Dim startPoint As VirtualPoint = sel.AnchorPoint
Dim endPoint As VirtualPoint = sel.ActivePoint
MsgBox("Start: " & startPoint.AbsoluteCharOffset & ", End: " & endPoint.AbsoluteCharOffset)
End Sub
Sub TestReplaceText()
Dim doc As TextDocument = DTE.ActiveDocument.Object
Dim point As EditPoint = doc.CreateEditPoint()
point.MoveToAbsoluteOffset(5)
point.Delete(4)
point.MoveToAbsoluteOffset(12 + 4 - 5)
point.Delete(4)
'point.MoveToAbsoluteOffset(5)
'point.Insert("5678")
'point.MoveToAbsoluteOffset(12 + 4)
'point.Insert("4567")
End Sub
' The UndoContext given by DTE can be used to group command so that a
' single undo undo them all.
' The name passed to the Open method is the name displayed in the undo
' Combobox.
' The UndoContext should only be Open/Close if not yet Open (meaning
' we are already within a command group)
Sub TestUndoCommandGroup()
Dim undo As UndoContext = DTE.UndoContext
Dim wasOpen As Boolean = undo.IsOpen
If wasOpen = False Then
undo.Open("Test undo command group", False)
End If
TestReplaceText()
If wasOpen = False Then
undo.Close()
End If
End Sub
Sub TestUndoSubCommandGroup()
Dim undo As UndoContext = DTE.UndoContext
undo.Open("Test undo command group", False)
TestReplaceText()
TestUndoCommandGroup()
undo.Close()
End Sub
End Module
--- NEW FILE: MacroTest.cpp ---
0123456789
abcdefghij
9876543210
jihgfedcba
ABCDEFGHIJ
JIHGFEDCBA
|