Class PineColorProvider

The PineColorProvider class provides color information for Pine scripts in VSCode. It implements the vscode.DocumentColorProvider interface.

Implements

  • DocumentColorProvider

Constructors

Properties

literalColors: Record<string, string> = ...
regexColorNew: RegExp = ...
regexColorRgb: RegExp = ...
regexHex: RegExp = ...
regexLiteral: RegExp = ...

Methods

  • Converts a vscode.Color object to a hex color string.

    Parameters

    • color: Color

      The vscode.Color object to convert.

    • includeAlphaOrLiteral: string = 'alpha'

      Determines whether to include the alpha channel or a color literal.

    Returns string

    A hex color string.

  • Converts a vscode.Color object to a new color string.

    Parameters

    • color: Color

      The vscode.Color object to convert.

    Returns string

    A new color string.

  • Converts a vscode.Color object to an RGB color string.

    Parameters

    • color: Color

      The vscode.Color object to convert.

    Returns string

    An RGB color string.

  • Denormalizes a number from the 0-1 range to the 0-255 range.

    Parameters

    • num: number

      The number to denormalize.

    Returns number

    The denormalized number.

  • Denormalizes an alpha value from the 0-1 range to the 0-100 range.

    Parameters

    • alpha: number

      The alpha value to denormalize.

    Returns number

    The denormalized alpha value.

  • Extracts a range from a document.

    Parameters

    • document: TextDocument

      The document to extract the range from.

    • startIndex: number

      The start index of the range.

    • colorString: string

      The color string to determine the end of the range.

    Returns Range

    A vscode.Range object.

  • Finds colors in a given text using a regex pattern.

    Parameters

    • text: string

      The text to find colors in.

    • document: TextDocument

      The document the text is from.

    • regex: RegExp

      The regex pattern to use for finding colors.

    Returns ColorInformation[]

    An array of vscode.ColorInformation objects.

  • Creates a new color from a hex color string and a transparency value.

    Parameters

    • hex: string

      The hex color string.

    • transparency: number

      The transparency value.

    Returns Color

    A vscode.Color object.

  • Gets the literal color name for a given hex color.

    Parameters

    • hexColor: string

      The hex color to get the literal color name for.

    Returns null | string

    The literal color name, or null if not found.

  • Handles the creation of a new color.

    Parameters

    • colorString: string

      The color string to be processed.

    Returns Color

    A vscode.Color object.

  • Handles the creation of a color from an RGB color string.

    Parameters

    • colorString: string

      The RGB color string to be processed.

    Returns Color

    A vscode.Color object.

  • Converts a hex color string to a vscode.Color object.

    Parameters

    • hex: string

      The hex color string to convert.

    Returns Color

    A vscode.Color object.

  • Converts a number to a hex string.

    Parameters

    • color: number

      The number to convert.

    Returns string

    The hex string.

  • Checks if a position is within a comment in a document.

    Parameters

    • document: TextDocument

      The document to check.

    • position: Position

      The position to check.

    Returns boolean

    A boolean indicating if the position is within a comment.

  • Normalizes a number from the 0-255 range to the 0-1 range.

    Parameters

    • num: number

      The number to normalize.

    Returns number

    The normalized number.

  • Normalizes an alpha value from the 0-100 range to the 0-1 range.

    Parameters

    • alpha: number

      The alpha value to normalize.

    Returns number

    The normalized alpha value.

  • Parses a color string and returns a vscode.Color object.

    Parameters

    • colorString: string

      The color string to parse.

    Returns null | Color

    A vscode.Color object, or null if the color string is invalid.

  • Provides color presentations for a given color in a document.

    Parameters

    • color: Color

      The vscode.Color object to provide presentations for.

    • context: {
          document: TextDocument;
          range: Range;
      }

      The context in which the color presentations are provided.

      • document: TextDocument
      • range: Range

    Returns ProviderResult<ColorPresentation[]>

    An array of vscode.ColorPresentation objects, or an empty array if an error occurs.

  • Provides color information for a given document.

    Parameters

    • document: TextDocument

      The document to provide color information for.

    Returns ColorInformation[]

    An array of vscode.ColorInformation objects.

Generated using TypeDoc