次の方法で共有


IVsColorizer.ColorizeLine Method

Colorizes the given text.

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

Syntax

'宣言
Function ColorizeLine ( _
    iLine As Integer, _
    iLength As Integer, _
    pszText As IntPtr, _
    iState As Integer, _
    <OutAttribute> pAttributes As UInteger() _
) As Integer
int ColorizeLine(
    int iLine,
    int iLength,
    IntPtr pszText,
    int iState,
    uint[] pAttributes
)
int ColorizeLine(
    [InAttribute] int iLine, 
    [InAttribute] int iLength, 
    [InAttribute] IntPtr pszText, 
    [InAttribute] int iState, 
    [OutAttribute] array<unsigned int>^ pAttributes
)
abstract ColorizeLine : 
        iLine:int * 
        iLength:int * 
        pszText:IntPtr * 
        iState:int * 
        pAttributes:uint32[] byref -> int 
function ColorizeLine(
    iLine : int, 
    iLength : int, 
    pszText : IntPtr, 
    iState : int, 
    pAttributes : uint[]
) : int

Parameters

  • iLength
    Type: System.Int32
    [in] Length of the line minus the end-of-line marker (CR, LF, CRLF pair, or 0 (EOF)).
  • pszText
    Type: System.IntPtr
    [in] The line's text (examine up to iLength characters).
  • iState
    Type: System.Int32
    [in] The colorizer's state at the beginning of the line.
  • pAttributes
    Type: array<System.UInt32[]
    [out] An array of color attributes to be filled in for the text. The array contains one member for each character in the line colorized, and an additional element which represents the background color of the space to the right of the last character. This array is iLength + 1 characters long.
    Members of the pAttributes array may contain bits that can be masked with the various values provided in the COLORIZER_ATTRIBUTE enumeration to get the information required. For more information, see COLORIZER_ATTRIBUTE.

Return Value

Type: System.Int32
Returns the colorizer's state at the end of the line.

Remarks

COM Signature

From textmgr.idl:

HRESULT IVsColorizer::ColorizeLine(
   [in] long iLine,
   [in] long iLength,
   [in] const WCHAR *pszText,
   [in] long iState,
   [out] ULONG * pAttributes
);

Any implementation of this method must parse the input line (pszText) for tokens to colorize.

For each character in a given line, the corresponding array element returned in pAttributes contains an index into the language service's array of colorizable items, such as comments, identifiers, and numbers.

The values returned in the pAttributes array are indices into the default colorable items supplied by Visual Studio or into the custom colorable items supplied by the language service (see GetColorableItem in the IVsProvideColorableItems interface). An index of 0 always means the default text color as supplied by Visual Studio.

The colorizer should start in the state provided, and return its current state, which is cached and provided later as the start state when the next line is colorized. The index array given is guaranteed to be one element longer than the number of characters in the line. The last element is used to determine the background color of the space to the right of the last character on the line.

A colorizer should mark text to be treated as human natural-language text with the HUMAN_TEXT_ATTR bit. This bit should be set for the contents of comments and strings, excluding delimiters and is used to obtain the correct layout of bi-directional text. The HUMAN_TEXT_ATTR bit is also used to determine when to apply natural language rules instead of programming language rules, for example, for spell checking and word boundaries.

.NET Framework Security

See Also

Reference

IVsColorizer Interface

Microsoft.VisualStudio.TextManager.Interop Namespace