Skip to content

vyaz-monorepo / renderers/src / renderSelection

Function: renderSelection()

renderSelection(ctx, lines, start, end, color?): void

Defined in: renderers/src/CanvasRenderer.ts:452

Render a text selection highlight overlay.

Draws a semi-transparent blue rectangle for each character in the range [start, end). Supports cross-line selections.

If start and end are in different lines, the full width of intermediate lines is highlighted.

Parameters

ctx

CanvasRenderingContext2D

— Canvas 2D rendering context

lines

Line[]

— layout lines

start

CharPos

— selection start position (inclusive)

end

CharPos

— selection end position (exclusive)

color?

string = 'rgba(100, 150, 255, 0.3)'

— highlight color. Default: 'rgba(100, 150, 255, 0.3)'

Returns

void

Released under the MIT License.