Compartilhar via


Accessing Text Layers by Using the Legacy API

A text layer typically encapsulates some aspect of text layout. For example, a "function-at-a-time" layer hides text before and after a function containing the caret (text insertion point).

A text layer resides between a buffer and a view, and it modifies the way the view sees the buffer's contents.

Text Layer Information

The following list describes how text layers work in Visual Studio:

  • The text in a text layer can be adorned with syntax coloring and markers.

  • You currently cannot implement your own layers.

  • A layer exposes IVsTextLayer, which is derived from IVsTextLines. The text buffer itself is also implemented as a layer, which enables a view to deal polymorphically with underlying layers.

  • Any number of layers may lie between the view and the buffer. Each layer deals only with the layer below it, and the view deals largely with the top-most layer. (The view does have some information about the buffer.)

  • A layer can affect only layers that are below it. It cannot affect the layers above it beyond originating standard events.

  • In the editor, hidden text, synthetic text, and word wrap are implemented as layers. You can implement hidden and synthetic text without interacting directly with the layers. For more information, see Outlining (Managed Package Framework) and IVsSyntheticTextSession.

  • Each text layer has its own local coordinate system that is exposed through the IVsTextLayer interface. The line-wrap layer, for example, might contain two lines while the underlying text buffer might contain only one line.

  • The view communicates to layers through the IVsLayeredTextView interface. Use this interface to reconcile view coordinates with buffer coordinates.

  • Any layer such as the synthetic text layer that originates text must provide a local implementation of CreateTrackingPoint.

  • Besides IVsTextLayer, a text layer must implement IConnectionPointContainer and fire the events in the IVsTextLinesEvents interface.

See Also

Concepts

Syntax Coloring in Custom Editors

Other Resources

Using Text Markers with the Legacy API

Customizing Editor Controls and Menus by Using the Legacy API