Skip to content

Conversation

@Tyriar
Copy link
Member

@Tyriar Tyriar commented May 10, 2022

Fixes #3770

This new feature works by swapping out the the background and foreground colors of the cell. This is slightly different depending on the renderer especially wrt getting the correct cache key to use which is why caching of decoration override glyphs isn't supported at all for the canvas renderer.

Notice how the text is white:

image

Current API shape:

export interface IDecorationOptions {
  readonly backgroundColor?: string;
  readonly foregroundColor?: string;
}

Note the API doesn't allow changing the colors currently as that's not actually a requirement for the search addon.

Remaining work:

  • Webgl renderer tests
  • Expose an interface on IDecorationService to get decorations at a cell to reduce code duplication
  • Maintain a sorted list of decorations (by line) in IDecorationService and utilize it to go from O(n) to O(log n) when iterating over decorations of a line
  • Review TODOs/clean up

Deferred from the PR:

  • Alpha support - can look into it if we need it
  • Allow the webgl renderer to draw decorations on top of the selection - this is required in order to get consistency in how VS Code's editor looks and works. My idea here is to bring selection rendering into the main glyph rendering part similar to how overrides work and then add another decoration option for whether it's above or below the selection. bg/fg decorations should be able to render on top of the selection #3778

Other issues fixed:

  • Minimum contrast ratio was using the wrong channel when determining luminance which would throw the resulting color off.
  • Decorations are now cleared on Terminal.reset()

@Tyriar Tyriar added this to the 4.19.0 milestone May 10, 2022
@Tyriar Tyriar self-assigned this May 10, 2022
@Tyriar Tyriar requested a review from meganrogge May 11, 2022 16:55
@Tyriar Tyriar marked this pull request as ready for review May 11, 2022 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow decorations to change the background of a cell

1 participant