IVsProvideColorableItems Interface

Informs the code editor about custom colorable items proffered by the language service.

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

Syntax

'Declaration
<GuidAttribute("100B9A33-905C-4312-B2A2-452189F19AB9")> _
<InterfaceTypeAttribute()> _
Public Interface IVsProvideColorableItems
'Usage
Dim instance As IVsProvideColorableItems
[GuidAttribute("100B9A33-905C-4312-B2A2-452189F19AB9")]
[InterfaceTypeAttribute()]
public interface IVsProvideColorableItems
[GuidAttribute(L"100B9A33-905C-4312-B2A2-452189F19AB9")]
[InterfaceTypeAttribute()]
public interface class IVsProvideColorableItems
public interface IVsProvideColorableItems

Remarks

By implementing IVsProvideColorableItems, you proffer custom colorable items to the core editor and inform the core editor of the number of colorable items provided and what their default color/bold settings are. The core editor manages the user's current color selections for your colorable items (as set in the Options dialog box on the Tools menu). Like the Default colorable items, the language has no direct control over the visual appearance of its colorable items beyond specifying their default values.

This interface is used to inform the editor about language elements beyond those provided by DEFAULTITEMS. Do not attempt to redefine existing language elements (for example, comments or keywords), and do not use the same name as existing or default language elements.

Notes to Implementers:

To support custom colorable items in your language service, you must implement this interface on the same class that implements the IVsLanguageInfo interface and provide support for accessing the interface through the QueryInterface method. To implement the methods on the IVsProvideColorableItems interface, you need a list of IVsColorableItems to offer up on demand (see the IVsColorableItem interface for an example of how to create a list of custom colorable items).

Notes to Callers:

An editor obtains this interface by calling the QueryInterface method in the IVsLanguageInfo interface that represents a language service.

Examples

Here is an example of how this interface might be implemented on a language service. The example in the IVsColorableItem interface shows how to implement the MyColorableItem class.

using Microsoft.VisualStudio;
using Microsoft.VisualStudio.TextManager.Interop;

namespace MyLanguagePackage
{
    class MyLanguageService : IVsLanguageInfo, IVsProvideColorableItems
    {
        private MyColorableItems colorableItemsList[];
        public MyLanguageService()
        {
            // populate the colorableItemsList here.
        }

        public int GetItemCount(out int piCount)
        {
            piCount = 0;
            if (this.colorableItemsList != null)
            {
                 if (this.colorableItemsList.Length > 0)
                 {
                     // The first color is a placeholder and is
                     // never counted.
                     piCount = this.colorableItemsList.Length - 1;
                 }
            }
            return VSConstants.S_OK;
        }

        public int GetColorableItem(int iIndex, out IVsColorableItem ppItem)
        {
            int retval = VsConstants.E_INVALIDARG;

            ppItem = null;
            if (this.colorableItemList != null &&
                iIndex >= 0 && iIndex < this.colorableItemList.Length)
            {
                 ppItem = this.colorableItemsList[iIndex];
                 retval = VSConstants.S_OK;
            }
            return retval;
        }
    }
}

See Also

Reference

IVsProvideColorableItems Members

Microsoft.VisualStudio.TextManager.Interop Namespace