通知语言服务提供的自定义可着色项的代码编辑器。
命名空间: Microsoft.VisualStudio.TextManager.Interop
程序集: Microsoft.VisualStudio.TextManager.Interop(在 Microsoft.VisualStudio.TextManager.Interop.dll 中)
语法
声明
<GuidAttribute("100B9A33-905C-4312-B2A2-452189F19AB9")> _
<InterfaceTypeAttribute()> _
Public Interface IVsProvideColorableItems
[GuidAttribute("100B9A33-905C-4312-B2A2-452189F19AB9")]
[InterfaceTypeAttribute()]
public interface IVsProvideColorableItems
[GuidAttribute(L"100B9A33-905C-4312-B2A2-452189F19AB9")]
[InterfaceTypeAttribute()]
public interface class IVsProvideColorableItems
[<GuidAttribute("100B9A33-905C-4312-B2A2-452189F19AB9")>]
[<InterfaceTypeAttribute()>]
type IVsProvideColorableItems = interface end
public interface IVsProvideColorableItems
IVsProvideColorableItems 类型公开以下成员。
方法
名称 | 说明 | |
---|---|---|
![]() |
GetColorableItem | 确定语言服务提供的每个自定义可着色项的项目信息。 |
![]() |
GetItemCount | 确定语言服务提供的自定义可着色项的数目。 |
页首
备注
通过实现 IVsProvideColorableItems,您提供自定义可着色项对核心编辑器并通知核心编辑器提供的可着色项的数量,以及它们的默认颜色/粗体设置为。 核心编辑器管理可着色项的用户的当前颜色选择不当 (如设置在 工具 菜单的 选项 对话框)。 与默认可着色项,语言没有与其在指定其默认值以外的可着色项的可视化外观直接控件。
此接口用于通知语言元素的编辑器在 DEFAULTITEMS提供的值。 不要尝试重新定义现有语言元素 (例如,注释或关键字) 和不要使用名称和存在相同也不要默认语言元素。
对实现者的说明
若要支持自定义可着色项在语言服务,您必须实现在实现 IVsLanguageInfo 接口的同一类的此接口并提供用于访问接口支持通过 QueryInterface 方法。 若要在 IVsProvideColorableItems 接口的方法,需要 IVsColorableItem列表提供在需要时 (有关示例说明如何参见 IVsColorableItem 接口构建自定义可着色项列表)。
对调用者的说明
编辑通过调用委托语言服务的 IVsLanguageInfo 接口的 QueryInterface 方法获取此接口。
示例
这是示例的此接口如何在语言服务中实现。 在 IVsColorableItem 接口的示例演示如何实现 MyColorableItem 类。
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;
}
}
}