IVsProvideColorableItems Interface

Definition

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

public interface class IVsProvideColorableItems
public interface class IVsProvideColorableItems
__interface IVsProvideColorableItems
[System.Runtime.InteropServices.Guid("100B9A33-905C-4312-B2A2-452189F19AB9")]
[System.Runtime.InteropServices.InterfaceType(1)]
public interface IVsProvideColorableItems
[System.Runtime.InteropServices.Guid("100B9A33-905C-4312-B2A2-452189F19AB9")]
[System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)]
public interface IVsProvideColorableItems
[<System.Runtime.InteropServices.Guid("100B9A33-905C-4312-B2A2-452189F19AB9")>]
[<System.Runtime.InteropServices.InterfaceType(1)>]
type IVsProvideColorableItems = interface
[<System.Runtime.InteropServices.Guid("100B9A33-905C-4312-B2A2-452189F19AB9")>]
[<System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)>]
type IVsProvideColorableItems = interface
Public Interface IVsProvideColorableItems
Derived
Attributes

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;  
        }  
    }  
}  

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.

Methods

GetColorableItem(Int32, IVsColorableItem)

Determines the item information for each custom colorable item proffered by the language service.

GetItemCount(Int32)

Determines the number of custom colorable items proffered by the language service.

Applies to