| 1 |
/** |
| 2 |
* Copyright (c) 2018 The xterm.js authors. All rights reserved. |
| 3 |
* @license MIT |
| 4 |
*/ |
| 5 |
|
| 6 |
import { FontWeight } from '@xterm/xterm'; |
| 7 |
import { IColorSet } from 'browser/Types'; |
| 8 |
import { ISelectionRenderModel } from 'browser/renderer/shared/Types'; |
| 9 |
import { CursorInactiveStyle, CursorStyle, type IDisposable } from 'common/Types'; |
| 10 |
import type { Event } from 'vs/base/common/event'; |
| 11 |
|
| 12 |
export interface IRenderModel { |
| 13 |
cells: Uint32Array; |
| 14 |
lineLengths: Uint32Array; |
| 15 |
selection: ISelectionRenderModel; |
| 16 |
cursor?: ICursorRenderModel; |
| 17 |
} |
| 18 |
|
| 19 |
export interface ICursorRenderModel { |
| 20 |
x: number; |
| 21 |
y: number; |
| 22 |
width: number; |
| 23 |
style: CursorStyle | CursorInactiveStyle; |
| 24 |
cursorWidth: number; |
| 25 |
dpr: number; |
| 26 |
} |
| 27 |
|
| 28 |
export interface IWebGL2RenderingContext extends WebGLRenderingContext { |
| 29 |
vertexAttribDivisor(index: number, divisor: number): void; |
| 30 |
createVertexArray(): IWebGLVertexArrayObject; |
| 31 |
bindVertexArray(vao: IWebGLVertexArrayObject): void; |
| 32 |
drawElementsInstanced(mode: number, count: number, type: number, offset: number, instanceCount: number): void; |
| 33 |
} |
| 34 |
|
| 35 |
export interface IWebGLVertexArrayObject { |
| 36 |
} |
| 37 |
|
| 38 |
export interface ICharAtlasConfig { |
| 39 |
customGlyphs: boolean; |
| 40 |
devicePixelRatio: number; |
| 41 |
deviceMaxTextureSize: number; |
| 42 |
letterSpacing: number; |
| 43 |
lineHeight: number; |
| 44 |
fontSize: number; |
| 45 |
fontFamily: string; |
| 46 |
fontWeight: FontWeight; |
| 47 |
fontWeightBold: FontWeight; |
| 48 |
deviceCellWidth: number; |
| 49 |
deviceCellHeight: number; |
| 50 |
deviceCharWidth: number; |
| 51 |
deviceCharHeight: number; |
| 52 |
allowTransparency: boolean; |
| 53 |
drawBoldTextInBrightColors: boolean; |
| 54 |
minimumContrastRatio: number; |
| 55 |
colors: IColorSet; |
| 56 |
} |
| 57 |
|
| 58 |
export interface ITextureAtlas extends IDisposable { |
| 59 |
readonly pages: { canvas: HTMLCanvasElement, version: number }[]; |
| 60 |
|
| 61 |
onAddTextureAtlasCanvas: Event<HTMLCanvasElement>; |
| 62 |
onRemoveTextureAtlasCanvas: Event<HTMLCanvasElement>; |
| 63 |
|
| 64 |
/** |
| 65 |
* Warm up the texture atlas, adding common glyphs to avoid slowing early frame. |
| 66 |
*/ |
| 67 |
warmUp(): void; |
| 68 |
|
| 69 |
/** |
| 70 |
* Call when a frame is being drawn, this will return true if the atlas was cleared to make room |
| 71 |
* for a new set of glyphs. |
| 72 |
*/ |
| 73 |
beginFrame(): boolean; |
| 74 |
|
| 75 |
/** |
| 76 |
* Clear all glyphs from the texture atlas. |
| 77 |
*/ |
| 78 |
clearTexture(): void; |
| 79 |
getRasterizedGlyph(code: number, bg: number, fg: number, ext: number, restrictToCellHeight: boolean, domContainer: HTMLElement | undefined): IRasterizedGlyph; |
| 80 |
getRasterizedGlyphCombinedChar(chars: string, bg: number, fg: number, ext: number, restrictToCellHeight: boolean, domContainer: HTMLElement | undefined): IRasterizedGlyph; |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Represents a rasterized glyph within a texture atlas. Some numbers are |
| 85 |
* tracked in CSS pixels as well in order to reduce calculations during the |
| 86 |
* render loop. |
| 87 |
*/ |
| 88 |
export interface IRasterizedGlyph { |
| 89 |
/** |
| 90 |
* The x and y offset between the glyph's top/left and the top/left of a cell |
| 91 |
* in pixels. |
| 92 |
*/ |
| 93 |
offset: IVector; |
| 94 |
/** |
| 95 |
* The index of the texture page that the glyph is on. |
| 96 |
*/ |
| 97 |
texturePage: number; |
| 98 |
/** |
| 99 |
* the x and y position of the glyph in the texture in pixels. |
| 100 |
*/ |
| 101 |
texturePosition: IVector; |
| 102 |
/** |
| 103 |
* the x and y position of the glyph in the texture in clip space coordinates. |
| 104 |
*/ |
| 105 |
texturePositionClipSpace: IVector; |
| 106 |
/** |
| 107 |
* The width and height of the glyph in the texture in pixels. |
| 108 |
*/ |
| 109 |
size: IVector; |
| 110 |
/** |
| 111 |
* The width and height of the glyph in the texture in clip space coordinates. |
| 112 |
*/ |
| 113 |
sizeClipSpace: IVector; |
| 114 |
} |
| 115 |
|
| 116 |
export interface IVector { |
| 117 |
x: number; |
| 118 |
y: number; |
| 119 |
} |
| 120 |
|
| 121 |
export interface IBoundingBox { |
| 122 |
top: number; |
| 123 |
left: number; |
| 124 |
right: number; |
| 125 |
bottom: number; |
| 126 |
} |