TextPoint 介面

定義

代表文字文件中的文字位置。Represents a location of text in a text document.

public interface class TextPoint
public interface class TextPoint
__interface TextPoint
[System.Runtime.InteropServices.Guid("7F59E94E-4939-40D2-9F7F-B7651C25905D")]
[System.Runtime.InteropServices.TypeLibType(4160)]
public interface TextPoint
[<System.Runtime.InteropServices.Guid("7F59E94E-4939-40D2-9F7F-B7651C25905D")>]
[<System.Runtime.InteropServices.TypeLibType(4160)>]
type TextPoint = interface
Public Interface TextPoint
衍生
屬性

範例

Sub TextPointExample()  
   ' Comments a region of code.  
   Dim selection As TextSelection  
   selection = dte.ActiveDocument.selection()  
   Dim Start As Editpoint  
   Start = selection.TopPoint.CreateEditPoint()  
   Dim endpt As TextPoint endpt = selection.BottomPoint  

   Dim undoObj As UndoContext = dte.UndoContext  
   undoobj.Open("Comment Region")  
   Do While (Start.LessThan(endpt))  
      Start.Insert("//")  
      Start.LineDown()  
      Start.StartOfLine()  
   Loop  
   undoobj.Close()  
End Sub  

備註

TextPoint物件可讓您尋找檔中的位置。The TextPoint object allows you to find locations in a document. 使用物件的屬性 TextPoint 時,您可以使用下列內容尋找文字:Using the properties of the TextPoint object, you can find text with:

  • 行號Line numbers

  • 行中的字元數Character numbers in a line

  • 檔開頭的絕對字元位置Absolute character locations from the beginning of the document

  • 顯示資料行Display columns

TextPoint 物件與物件類似 EditPoint ,不同之處在于它們會在程式碼編輯器中顯示的文字上運作,而不是在文字緩衝區中的資料。TextPoint objects are similar to EditPoint objects, except that they operate on text displayed in a code editor rather than data in the text buffer. 檔中的文字會受到全域編輯器狀態的影響,例如自動換行和虛擬空間,但不會影響文字緩衝區。Text in a document is affected by global editor states, such as word wrapping and virtual spaces, but the text buffer is not.

當您編輯檔時, TextPoint 物件不會相對於其周圍文字移動。As you edit a document, TextPoint objects do not move relative to their surrounding text. 也就是說,如果文字是在文字點之前插入,則其屬性的值 AbsoluteCharOffset 會遞增,以反映其在檔中的新位置。That is, if text is inserted before a text point, then the value of its AbsoluteCharOffset property is incremented to reflect its new location further down in the document. 如果有多個 TextPoint 物件位於相同的位置,而且有一個 EditPoint 物件用來插入新的文字,則新的字元會在所有物件的右邊, TextPoint 除了用來插入文字的物件之外。If multiple TextPoint objects are at the same location and an EditPoint object is used to insert new text, then the new characters are to the right of all of the TextPoint objects except the one used to insert the text.

TextDocument如果是唯讀的,任何嘗試修改物件的作業都會失敗 TextDocumentAny operation that attempts to modify a TextDocument object fails if the TextDocument is read-only.

屬性

AbsoluteCharOffset

取得從檔開頭到物件的以1起始的字元位移 TextPointGets the one-based character offset from the beginning of the document to the TextPoint object.

AtEndOfDocument

取得物件是否位於文件的結尾。Gets whether the object is at the end of the document.

AtEndOfLine

取得物件是否位於行的結尾。Gets whether or not object is at the end of a line.

AtStartOfDocument

取得物件是否位於文件的開頭。Gets whether or not the object is at the beginning of the document.

AtStartOfLine

取得物件是否位於行的開頭。Gets whether or not the object is at the beginning of a line.

CodeElement[vsCMElement]

傳回位置的程式碼元素 TextPointReturns the code element at the TextPoint location.

DisplayColumn

取得包含物件且目前顯示之資料行的編號 TextPointGets the number of the current displayed column containing the TextPoint object.

DTE

取得最上層的擴充性物件。Gets the top-level extensibility object.

Line

取得物件的行號。Gets the line number of the object.

LineCharOffset

取得物件的字元位移。Gets the character offset of the object.

LineLength

取得包含物件那一行的字元數,但不包含換行字元。Gets the number of characters in a line containing the object, excluding the new line character.

Parent

取得 TextPoint 物件的直屬父物件。Gets the immediate parent object of a TextPoint object.

方法

CreateEditPoint()

在進行呼叫之物件的所在位置建立並傳回 EditPoint 物件。Creates and returns an EditPoint object at the location of the calling object.

EqualTo(TextPoint)

傳回指定點物件屬性的值是否 AbsoluteCharOffset 等於呼叫物件的值 TextPointReturns whether the value of the given point object's AbsoluteCharOffset property is equal to that of the calling TextPoint object.

GreaterThan(TextPoint)

指出呼叫物件屬性的值是否 AbsoluteCharOffset 大於給定點物件的值。Indicates whether or not the value of the calling object's AbsoluteCharOffset property is greater than that of the given point object.

LessThan(TextPoint)

指出所呼叫物件的屬性值是否 AbsoluteCharOffset 小於指定之物件的值。Indicates whether or not the value of the called object's AbsoluteCharOffset property is less than that of the given object.

TryToShow(vsPaneShowHow, Object)

嘗試顯示文字點的位置。Attempts to display the text point's location.

適用於