2 * Copyright (c) 2019 The xterm.js authors. All rights reserved.
6 export const DEFAULT_COLOR = 256;
7 export const DEFAULT_ATTR = (0 << 18) | (DEFAULT_COLOR << 9) | (256 << 0);
9 export const CHAR_DATA_ATTR_INDEX = 0;
10 export const CHAR_DATA_CHAR_INDEX = 1;
11 export const CHAR_DATA_WIDTH_INDEX = 2;
12 export const CHAR_DATA_CODE_INDEX = 3;
15 * Null cell - a real empty cell (containing nothing).
16 * Note that code should always be 0 for a null cell as
17 * several test condition of the buffer line rely on this.
19 export const NULL_CELL_CHAR = '';
20 export const NULL_CELL_WIDTH = 1;
21 export const NULL_CELL_CODE = 0;
25 * This is meant as a replacement for empty cells when needed
26 * during rendering lines to preserve correct aligment.
28 export const WHITESPACE_CELL_CHAR = ' ';
29 export const WHITESPACE_CELL_WIDTH = 1;
30 export const WHITESPACE_CELL_CODE = 32;
33 * Bitmasks for accessing data in `content`.
35 export const enum Content {
37 * bit 1..21 codepoint, max allowed in UTF32 is 0x10FFFF (21 bits taken)
38 * read: `codepoint = content & Content.codepointMask;`
39 * write: `content |= codepoint & Content.codepointMask;`
40 * shortcut if precondition `codepoint <= 0x10FFFF` is met:
41 * `content |= codepoint;`
43 CODEPOINT_MASK = 0x1FFFFF,
46 * bit 22 flag indication whether a cell contains combined content
47 * read: `isCombined = content & Content.isCombined;`
48 * set: `content |= Content.isCombined;`
49 * clear: `content &= ~Content.isCombined;`
51 IS_COMBINED_MASK = 0x200000, // 1 << 21
54 * bit 1..22 mask to check whether a cell contains any string data
55 * we need to check for codepoint and isCombined bits to see
56 * whether a cell contains anything
57 * read: `isEmpty = !(content & Content.hasContent)`
59 HAS_CONTENT_MASK = 0x3FFFFF,
62 * bit 23..24 wcwidth value of cell, takes 2 bits (ranges from 0..2)
63 * read: `width = (content & Content.widthMask) >> Content.widthShift;`
64 * `hasWidth = content & Content.widthMask;`
65 * as long as wcwidth is highest value in `content`:
66 * `width = content >> Content.widthShift;`
67 * write: `content |= (width << Content.widthShift) & Content.widthMask;`
68 * shortcut if precondition `0 <= width <= 3` is met:
69 * `content |= width << Content.widthShift;`
71 WIDTH_MASK = 0xC00000, // 3 << 22
75 export const enum Attributes {
77 * bit 1..8 blue in RGB, color in P256 and P16
85 * bit 9..16 green in RGB
91 * bit 17..24 red in RGB
97 * bit 25..26 color mode: DEFAULT (0) | P16 (1) | P256 (2) | RGB (3)
111 export const enum FgFlags {
113 * bit 27..31 (32th bit unused)
117 UNDERLINE = 0x10000000,
119 INVISIBLE = 0x40000000
122 export const enum BgFlags {
124 * bit 27..32 (upper 4 unused)