Debian Codegraph @

node/@xterm/xterm/src/common/buffer/Constants.ts

raw
1 /**
2 * Copyright (c) 2019 The xterm.js authors. All rights reserved.
3 * @license MIT
4 */
5
6 export const DEFAULT_COLOR = 0;
7 export const DEFAULT_ATTR = (0 << 18) | (DEFAULT_COLOR << 9) | (256 << 0);
8 export const DEFAULT_EXT = 0;
9
10 export const CHAR_DATA_ATTR_INDEX = 0;
11 export const CHAR_DATA_CHAR_INDEX = 1;
12 export const CHAR_DATA_WIDTH_INDEX = 2;
13 export const CHAR_DATA_CODE_INDEX = 3;
14
15 /**
16 * Null cell - a real empty cell (containing nothing).
17 * Note that code should always be 0 for a null cell as
18 * several test condition of the buffer line rely on this.
19 */
20 export const NULL_CELL_CHAR = '';
21 export const NULL_CELL_WIDTH = 1;
22 export const NULL_CELL_CODE = 0;
23
24 /**
25 * Whitespace cell.
26 * This is meant as a replacement for empty cells when needed
27 * during rendering lines to preserve correct aligment.
28 */
29 export const WHITESPACE_CELL_CHAR = ' ';
30 export const WHITESPACE_CELL_WIDTH = 1;
31 export const WHITESPACE_CELL_CODE = 32;
32
33 /**
34 * Bitmasks for accessing data in `content`.
35 */
36 export const enum Content {
37 /**
38 * bit 1..21 codepoint, max allowed in UTF32 is 0x10FFFF (21 bits taken)
39 * read: `codepoint = content & Content.codepointMask;`
40 * write: `content |= codepoint & Content.codepointMask;`
41 * shortcut if precondition `codepoint <= 0x10FFFF` is met:
42 * `content |= codepoint;`
43 */
44 CODEPOINT_MASK = 0x1FFFFF,
45
46 /**
47 * bit 22 flag indication whether a cell contains combined content
48 * read: `isCombined = content & Content.isCombined;`
49 * set: `content |= Content.isCombined;`
50 * clear: `content &= ~Content.isCombined;`
51 */
52 IS_COMBINED_MASK = 0x200000, // 1 << 21
53
54 /**
55 * bit 1..22 mask to check whether a cell contains any string data
56 * we need to check for codepoint and isCombined bits to see
57 * whether a cell contains anything
58 * read: `isEmpty = !(content & Content.hasContent)`
59 */
60 HAS_CONTENT_MASK = 0x3FFFFF,
61
62 /**
63 * bit 23..24 wcwidth value of cell, takes 2 bits (ranges from 0..2)
64 * read: `width = (content & Content.widthMask) >> Content.widthShift;`
65 * `hasWidth = content & Content.widthMask;`
66 * as long as wcwidth is highest value in `content`:
67 * `width = content >> Content.widthShift;`
68 * write: `content |= (width << Content.widthShift) & Content.widthMask;`
69 * shortcut if precondition `0 <= width <= 3` is met:
70 * `content |= width << Content.widthShift;`
71 */
72 WIDTH_MASK = 0xC00000, // 3 << 22
73 WIDTH_SHIFT = 22
74 }
75
76 export const enum Attributes {
77 /**
78 * bit 1..8 blue in RGB, color in P256 and P16
79 */
80 BLUE_MASK = 0xFF,
81 BLUE_SHIFT = 0,
82 PCOLOR_MASK = 0xFF,
83 PCOLOR_SHIFT = 0,
84
85 /**
86 * bit 9..16 green in RGB
87 */
88 GREEN_MASK = 0xFF00,
89 GREEN_SHIFT = 8,
90
91 /**
92 * bit 17..24 red in RGB
93 */
94 RED_MASK = 0xFF0000,
95 RED_SHIFT = 16,
96
97 /**
98 * bit 25..26 color mode: DEFAULT (0) | P16 (1) | P256 (2) | RGB (3)
99 */
100 CM_MASK = 0x3000000,
101 CM_DEFAULT = 0,
102 CM_P16 = 0x1000000,
103 CM_P256 = 0x2000000,
104 CM_RGB = 0x3000000,
105
106 /**
107 * bit 1..24 RGB room
108 */
109 RGB_MASK = 0xFFFFFF
110 }
111
112 export const enum FgFlags {
113 /**
114 * bit 27..32
115 */
116 INVERSE = 0x4000000,
117 BOLD = 0x8000000,
118 UNDERLINE = 0x10000000,
119 BLINK = 0x20000000,
120 INVISIBLE = 0x40000000,
121 STRIKETHROUGH = 0x80000000,
122 }
123
124 export const enum BgFlags {
125 /**
126 * bit 27..32 (upper 2 unused)
127 */
128 ITALIC = 0x4000000,
129 DIM = 0x8000000,
130 HAS_EXTENDED = 0x10000000,
131 PROTECTED = 0x20000000,
132 OVERLINE = 0x40000000
133 }
134
135 export const enum ExtFlags {
136 /**
137 * bit 27..29
138 */
139 UNDERLINE_STYLE = 0x1C000000,
140
141 /**
142 * bit 30..32
143 *
144 * An optional variant for the glyph, this can be used for example to offset underlines by a
145 * number of pixels to create a perfect pattern.
146 */
147 VARIANT_OFFSET = 0xE0000000
148 }
149
150 export const enum UnderlineStyle {
151 NONE = 0,
152 SINGLE = 1,
153 DOUBLE = 2,
154 CURLY = 3,
155 DOTTED = 4,
156 DASHED = 5
157 }