How to: Provide Hidden Text Support

In addition to outline regions, you can also create hidden text regions. Hidden text regions can be client or editor-controlled and are used to completely hide a region of text in the editor. The editor denotes the presence of a hidden region using horizontal lines. An example of this is demonstrated in the Script Only view in the HTML editor.

Procedure

To implement a hidden text region

  1. Call QueryService for SVsTextManager.

    This returns a pointer to IVsHiddenTextManager.

  2. Call GetHiddenTextSession, passing in a pointer for a given text buffer. This determines if a hidden text session already exists for the buffer. If one already exists, then you do not need to create one and a pointer to the existing IVsHiddenTextSession object is returned. Use this pointer to enumerate and create hidden text regions.

  3. Otherwise, call CreateHiddenTextSession to create a hidden text session for the buffer.

    A pointer to the IVsHiddenTextSession object is returned.

    注意

    When you call CreateHiddenTextSession, you can specify a hidden text client (that is, IVsHiddenTextClient). The hidden text client notifies you when hidden text or outlining is expanded or collapsed by the user.

  4. Call AddHiddenRegions to add one or more new outline regions at a time, specifying the following information in the reHidReg (NewHiddenRegion) parameter:

    1. Specify a value of hrtConcealed in the iType member of the NewHiddenRegion structure to indicate that you are creating a hidden region, rather than an outline region.

      注意

      When concealed regions are hidden, the editor automatically displays lines around the hidden regions to indicate their presence.

    2. Specify whether the region is client-controlled or editor-controlled in the dwBehavior members of the NewHiddenRegion structure. Your smart outlining implementation can contain a mix of editor- and client-controlled outline and hidden text regions.

See Also

Concepts

Code Development Aids