Debian Codegraph @

node/@xterm/addon-webgl/src/RenderModel.ts

raw
1 /**
2 * Copyright (c) 2018 The xterm.js authors. All rights reserved.
3 * @license MIT
4 */
5
6 import { ICursorRenderModel, IRenderModel } from './Types';
7 import { ISelectionRenderModel } from 'browser/renderer/shared/Types';
8 import { createSelectionRenderModel } from 'browser/renderer/shared/SelectionRenderModel';
9
10 export const RENDER_MODEL_INDICIES_PER_CELL = 4;
11 export const RENDER_MODEL_BG_OFFSET = 1;
12 export const RENDER_MODEL_FG_OFFSET = 2;
13 export const RENDER_MODEL_EXT_OFFSET = 3;
14
15 export const COMBINED_CHAR_BIT_MASK = 0x80000000;
16
17 export class RenderModel implements IRenderModel {
18 public cells: Uint32Array;
19 public lineLengths: Uint32Array;
20 public selection: ISelectionRenderModel;
21 public cursor?: ICursorRenderModel;
22
23 constructor() {
24 this.cells = new Uint32Array(0);
25 this.lineLengths = new Uint32Array(0);
26 this.selection = createSelectionRenderModel();
27 }
28
29 public resize(cols: number, rows: number): void {
30 const indexCount = cols * rows * RENDER_MODEL_INDICIES_PER_CELL;
31 if (indexCount !== this.cells.length) {
32 this.cells = new Uint32Array(indexCount);
33 this.lineLengths = new Uint32Array(rows);
34 }
35 }
36
37 public clear(): void {
38 this.cells.fill(0, 0);
39 this.lineLengths.fill(0, 0);
40 }
41 }