xterm
[VSoRC/.git] / node_modules / xterm / src / common / buffer / Constants.ts
1 /**
2  * Copyright (c) 2019 The xterm.js authors. All rights reserved.
3  * @license MIT
4  */
5
6 export const DEFAULT_COLOR = 256;
7 export const DEFAULT_ATTR = (0 << 18) | (DEFAULT_COLOR << 9) | (256 << 0);
8
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;
13
14 /**
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.
18  */
19 export const NULL_CELL_CHAR = '';
20 export const NULL_CELL_WIDTH = 1;
21 export const NULL_CELL_CODE = 0;
22
23 /**
24  * Whitespace cell.
25  * This is meant as a replacement for empty cells when needed
26  * during rendering lines to preserve correct aligment.
27  */
28 export const WHITESPACE_CELL_CHAR = ' ';
29 export const WHITESPACE_CELL_WIDTH = 1;
30 export const WHITESPACE_CELL_CODE = 32;
31
32 /**
33  * Bitmasks for accessing data in `content`.
34  */
35 export const enum Content {
36   /**
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;`
42    */
43   CODEPOINT_MASK = 0x1FFFFF,
44
45   /**
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;`
50    */
51   IS_COMBINED_MASK = 0x200000,  // 1 << 21
52
53   /**
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)`
58    */
59   HAS_CONTENT_MASK = 0x3FFFFF,
60
61   /**
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;`
70    */
71   WIDTH_MASK = 0xC00000,   // 3 << 22
72   WIDTH_SHIFT = 22
73 }
74
75 export const enum Attributes {
76   /**
77    * bit 1..8     blue in RGB, color in P256 and P16
78    */
79   BLUE_MASK = 0xFF,
80   BLUE_SHIFT = 0,
81   PCOLOR_MASK = 0xFF,
82   PCOLOR_SHIFT = 0,
83
84   /**
85    * bit 9..16    green in RGB
86    */
87   GREEN_MASK = 0xFF00,
88   GREEN_SHIFT = 8,
89
90   /**
91    * bit 17..24   red in RGB
92    */
93   RED_MASK = 0xFF0000,
94   RED_SHIFT = 16,
95
96   /**
97    * bit 25..26   color mode: DEFAULT (0) | P16 (1) | P256 (2) | RGB (3)
98    */
99   CM_MASK = 0x3000000,
100   CM_DEFAULT = 0,
101   CM_P16 = 0x1000000,
102   CM_P256 = 0x2000000,
103   CM_RGB = 0x3000000,
104
105   /**
106    * bit 1..24  RGB room
107    */
108   RGB_MASK = 0xFFFFFF
109 }
110
111 export const enum FgFlags {
112   /**
113    * bit 27..31 (32th bit unused)
114    */
115   INVERSE = 0x4000000,
116   BOLD = 0x8000000,
117   UNDERLINE = 0x10000000,
118   BLINK = 0x20000000,
119   INVISIBLE = 0x40000000
120 }
121
122 export const enum BgFlags {
123   /**
124    * bit 27..32 (upper 4 unused)
125    */
126   ITALIC = 0x4000000,
127   DIM = 0x8000000
128 }