IVsTextView Interface

Manages the text view of an editor window and contains methods to manage the text view. The view is essentially the editor window shown in the user interface (UI).

Namespace:  Microsoft.VisualStudio.TextManager.Interop
Assembly:  Microsoft.VisualStudio.TextManager.Interop (in Microsoft.VisualStudio.TextManager.Interop.dll)

public interface IVsTextView

The IVsTextView type exposes the following members.

  NameDescription
Public methodAddCommandFilterAdds a command filter to the existing chain of command filters.
Public methodCenterColumnsPlaces the specified column of text in the center of the view.
Public methodCenterLinesPlaces the specified lines of text in the center of the view.
Public methodClearSelectionClears the current selection.
Public methodCloseViewCloses and unregisters a view with the view manager.
Public methodEnsureSpanVisibleEnsures that text is in view, both vertically and horizontally.
Public methodGetBufferReturns the current contents of the text buffer.
Public methodGetCaretPosReturns the line and column index of the cursor position.
Public methodGetLineAndColumnConverts a text stream position to a line and column index.
Public methodGetLineHeightReturns the pixel height of a line.
Public methodGetNearestPositionConverts a line and column index to a text stream position.
Public methodGetPointOfLineColumnReturns the coordinates for the upper left corner of a particular line and column.
Public methodGetScrollInfoReturns the core text editor's scroll bar settings for the specified scroll bar.
Public methodGetSelectedTextReturns a copy of the selected text.
Public methodGetSelectionReturns the text span corresponding to the current selection, if there is one.
Public methodGetSelectionDataObjectReturns a copy of the selected text in IDataObject interface format.
Public methodGetSelectionModeReturns the current selection mode.
Public methodGetSelectionSpanReturns the text span associated with a selection.
Public methodGetTextStreamReturns a specified stream of text in a string.
Public methodGetWindowHandleReturns the window handle for this view.
Public methodGetWordExtentReturns the current word extent.
Public methodHighlightMatchingBraceHighlights the matching brace in a language construct.
Public methodInitializeCreates the view and allows clients to specify one or more TextViewInitFlags options.
Public methodPositionCaretForEditingPuts the caret in a position suitable for editing a function.
Public methodRemoveCommandFilterRemoves a command filter from the chain of command filters.
Public methodReplaceTextOnLineReplaces line text.
Public methodRestrictViewRangeReduces the view’s range of visible/editable lines to a subset of the buffer’s lines.
Public methodSendExplicitFocusSends explicit focus to the window.
Public methodSetBufferAssociates a text buffer with the view.
Public methodSetCaretPosSets the coordinates of the end point of a selection.
Public methodSetScrollPositionSets the core text editor's scroll bar settings for the specified scroll bar.
Public methodSetSelectionSelects specified text.
Public methodSetSelectionModeSets the selection mode.
Public methodSetTopLineSets the top line in the view to the baseline.
Public methodUpdateCompletionStatusUsed for word completion control.
Public methodUpdateTipWindowUpdates the tip window.
Public methodUpdateViewFrameCaptionForces the view to update its frame window caption, such as "[Read only]".
Top

The IVsTextView interface is not the MDI child, but an individual window of text. If a splitter is involved, there can be multiple views in an MDI child. The term, caret, refers to the text insertion point, while the term, cursor, refers to the mouse pointer.

Caution noteCaution

This interface is not thread-safe. You should not call anything on this interface from anything but the main UI thread.

If you need to perform any operations on the view from a different thread, you may either:

Some methods on IVsTextViewuse ViewCol coordinates (for example, GetTextStream and GetCaretPos), while others use CharIndex coordinates (for example, GetWordExtent). ViewCol coordinates may include virtual space while CharIndex coordinates are only an offset into a buffer line and never include virtual space.

If you get a coordinate in ViewCol coordinates, then you should only call methods that take CharIndex coordinates after making sure that the ViewCol coordinate does not lie in the virtual space region. For example, if you call the following:

long iLine;

long cCount;

ViewCol iCol;

IVsTextView::SomeMethod(&iLine, &icol);

Then you must check to be sure that the following is true:

IVsTextBuffer::GetLengthOfLine(iLine, &cCount);

iCol < cCount

Then call the following:

IVsTextView::SomeOtherMethod(ViewCol(iCol ))

// where SomeOtherMethod takes ViewCol coordinates

See illustrations of the implementation and/or calling of this interface in the sample Figures Language Service.

Notes to Callers

Called by clients who want to manage their view.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft