Share via


Colorizer Class

This class implements the IVsColorizer interface and is used to support syntax highlighting in an editor.

This API is not CLS-compliant. 

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Package.Colorizer

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)
  Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)

Syntax

'Declaration
<CLSCompliantAttribute(False)> _
<ComVisibleAttribute(True)> _
Public Class Colorizer _
    Implements IVsColorizer, IDisposable
[CLSCompliantAttribute(false)]
[ComVisibleAttribute(true)]
public class Colorizer : IVsColorizer, IDisposable
[CLSCompliantAttribute(false)]
[ComVisibleAttribute(true)]
public ref class Colorizer : IVsColorizer, 
    IDisposable
[<CLSCompliantAttribute(false)>]
[<ComVisibleAttribute(true)>]
type Colorizer =  
    class 
        interface IVsColorizer 
        interface IDisposable 
    end
public class Colorizer implements IVsColorizer, IDisposable

The Colorizer type exposes the following members.

Constructors

  Name Description
Public method Colorizer Initializes the Colorizer class.

Top

Properties

  Name Description
Public property Scanner Returns the scanner being used.

Top

Methods

  Name Description
Public method CloseColorizer Called when the colorizer is disposed of.
Public method ColorizeLine Obtains color and font attribute information for each character in the specified line of text.
Public method Dispose Disposes the object.
Public method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method Finalize Called when the object is about to be destroyed. (Overrides Object.Finalize().)
Public method GetColorInfo Returns the parsing state at the end of the line without returning any colorization information.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetLineInfo Returns color information about the specified line.
Public method GetStartState Returns the initial parsing state.
Public method GetStateAtEndOfLine Returns the parsing state at the end of the specified line.
Public method GetStateMaintenanceFlag Called to determine if the colorizer requires per line state management.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Resume Called to resume use of the colorizer.
Public method Suspend Called to suspend use of the colorizer.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

The managed package framework (MPF) version of this class uses an IScanner object to handle all parsing tasks. The IScanner object communicates color information through the TokenInfo structure. The Colorizer class also helps the IScanner object track state by passing around a state variable the parser maintains.

This class handles colorization on a line by line basis.

Notes to Implementers

The MPF version of this class performs all the work necessary to colorize a line of code by interacting with the IScanner object. If you find you need additional functionality not supported in the existing Colorizer class, you must derive a class from the Colorizer class and return an instance of your class from GetColorizer.

The default implementation of GetColorizer instantiates the MPF version of Colorizer, passing to the Colorizer constructor an instance of the IScanner object obtained from GetScanner.

Notes to Callers

The colorizer object returned from GetColorizer is stored in the Source object when the Source object is created. The Source object handles all interactions with the colorizer so there is no need for any outside involvement with the colorizer.

The methods of this class are documented in case you need to implement your own version of the Source class.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.VisualStudio.Package Namespace