다음을 통해 공유


IVsColorizer.ColorizeLine(Int32, Int32, IntPtr, Int32, UInt32[]) Method

Definition

Colorizes the given text.

public:
 int ColorizeLine(int iLine, int iLength, IntPtr pszText, int iState, cli::array <System::UInt32> ^ pAttributes);
public int ColorizeLine (int iLine, int iLength, IntPtr pszText, int iState, uint[] pAttributes);
abstract member ColorizeLine : int * int * nativeint * int * uint32[] -> int
Public Function ColorizeLine (iLine As Integer, iLength As Integer, pszText As IntPtr, iState As Integer, pAttributes As UInteger()) As Integer

Parameters

iLine
Int32

[in] Line to be colorized.

iLength
Int32

[in] Length of the line minus the end-of-line marker (CR, LF, CRLF pair, or 0 (EOF)).

pszText
IntPtr

nativeint

[in] The line's text (examine up to iLength characters).

iState
Int32

[in] The colorizer's state at the beginning of the line.

pAttributes
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.

Returns

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.

Applies to