1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | "use strict" ;
|
28 |
|
29 |
|
30 |
|
31 | const tree = require( 'tree-kit' ) ;
|
32 | const xterm = require( './xterm.js' ) ;
|
33 |
|
34 |
|
35 |
|
36 | const bold = '\x1b[1m' ;
|
37 | const noBold = '\x1b[22m' ;
|
38 | const blink = '\x1b[5m' ;
|
39 | const noBlink = '\x1b[25m' ;
|
40 | const defaultColor = '\x1b[39m' + noBold ;
|
41 | const bgDefaultColor = '\x1b[49m' + noBlink ;
|
42 |
|
43 |
|
44 |
|
45 | const esc = tree.extend( null , Object.create( xterm.esc ) , {
|
46 |
|
47 | setClipboardLL: { na: true } ,
|
48 | requestClipboard: { na: true } ,
|
49 |
|
50 |
|
51 | defaultColor: { on: defaultColor } ,
|
52 | brightBlack: { on: bold + '\x1b[30m' , off: defaultColor } ,
|
53 | brightRed: { on: bold + '\x1b[31m' , off: defaultColor } ,
|
54 | brightGreen: { on: bold + '\x1b[32m' , off: defaultColor } ,
|
55 | brightYellow: { on: bold + '\x1b[33m' , off: defaultColor } ,
|
56 | brightBlue: { on: bold + '\x1b[34m' , off: defaultColor } ,
|
57 | brightMagenta: { on: bold + '\x1b[35m' , off: defaultColor } ,
|
58 | brightCyan: { on: bold + '\x1b[36m' , off: defaultColor } ,
|
59 | brightWhite: { on: bold + '\x1b[37m' , off: defaultColor } ,
|
60 | brightColor: { on: bold + '\x1b[3%um' , off: defaultColor } ,
|
61 |
|
62 |
|
63 | bgDefaultColor: { on: bgDefaultColor } ,
|
64 | bgBrightBlack: { on: blink + '\x1b[40m' , off: bgDefaultColor } ,
|
65 | bgBrightRed: { on: blink + '\x1b[41m' , off: bgDefaultColor } ,
|
66 | bgBrightGreen: { on: blink + '\x1b[42m' , off: bgDefaultColor } ,
|
67 | bgBrightYellow: { on: blink + '\x1b[43m' , off: bgDefaultColor } ,
|
68 | bgBrightBlue: { on: blink + '\x1b[44m' , off: bgDefaultColor } ,
|
69 | bgBrightMagenta: { on: blink + '\x1b[45m' , off: bgDefaultColor } ,
|
70 | bgBrightCyan: { on: blink + '\x1b[46m' , off: bgDefaultColor } ,
|
71 | bgBrightWhite: { on: blink + '\x1b[47m' , off: bgDefaultColor } ,
|
72 | bgBrightColor: { on: blink + '\x1b[4%um' , off: bgDefaultColor } ,
|
73 |
|
74 |
|
75 | blockCursor: { on: '' , na: true } ,
|
76 | blinkingBlockCursor: { on: '' , na: true } ,
|
77 | underlineCursor: { on: '' , na: true } ,
|
78 | blinkingUnderlineCursor: { on: '' , na: true } ,
|
79 | beamCursor: { on: '' , na: true } ,
|
80 | blinkingBeamCursor: { on: '' , na: true } ,
|
81 |
|
82 |
|
83 | mouseDrag: { on: '\x1b[?1000h' , off: '\x1b[?1000l' , fb: true } ,
|
84 | mouseMotion: { on: '\x1b[?1000h' , off: '\x1b[?1000l' , fb: true } ,
|
85 |
|
86 | requestColor: { on: '%D' , na: true }
|
87 | } ) ;
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 | const keymap = tree.extend( null , Object.create( xterm.keymap ) , {
|
98 | F1: '\x1b[11~' ,
|
99 | F2: '\x1b[12~' ,
|
100 | F3: '\x1b[13~' ,
|
101 | F4: '\x1b[14~' ,
|
102 |
|
103 |
|
104 |
|
105 | SHIFT_F3: '\x1b[25~' ,
|
106 | SHIFT_F4: '\x1b[26~' ,
|
107 | SHIFT_F5: '\x1b[28~' ,
|
108 | SHIFT_F6: '\x1b[29~' ,
|
109 | SHIFT_F7: '\x1b[31~' ,
|
110 | SHIFT_F8: '\x1b[32~' ,
|
111 | SHIFT_F9: '\x1b[33~' ,
|
112 | SHIFT_F10: '\x1b[34~' ,
|
113 | SHIFT_F11: '\x1b[23$' ,
|
114 | SHIFT_F12: '\x1b[24$' ,
|
115 |
|
116 | CTRL_F1: '\x1b[11^' ,
|
117 | CTRL_F2: '\x1b[12^' ,
|
118 | CTRL_F3: '\x1b[13^' ,
|
119 | CTRL_F4: '\x1b[14^' ,
|
120 | CTRL_F5: '\x1b[15^' ,
|
121 | CTRL_F6: '\x1b[17^' ,
|
122 | CTRL_F7: '\x1b[18^' ,
|
123 | CTRL_F8: '\x1b[19^' ,
|
124 | CTRL_F9: '\x1b[20^' ,
|
125 | CTRL_F10: '\x1b[21^' ,
|
126 | CTRL_F11: '\x1b[23^' ,
|
127 | CTRL_F12: '\x1b[24^' ,
|
128 |
|
129 |
|
130 |
|
131 | CTRL_SHIFT_F3: '\x1b[25^' ,
|
132 | CTRL_SHIFT_F4: '\x1b[26^' ,
|
133 | CTRL_SHIFT_F5: '\x1b[28^' ,
|
134 | CTRL_SHIFT_F6: '\x1b[29^' ,
|
135 | CTRL_SHIFT_F7: '\x1b[31^' ,
|
136 | CTRL_SHIFT_F8: '\x1b[32^' ,
|
137 | CTRL_SHIFT_F9: '\x1b[33^' ,
|
138 | CTRL_SHIFT_F10: '\x1b[34^' ,
|
139 | CTRL_SHIFT_F11: '\x1b[23@' ,
|
140 | CTRL_SHIFT_F12: '\x1b[24@'
|
141 |
|
142 | } ) ;
|
143 |
|
144 |
|
145 |
|
146 | const handler = Object.create( xterm.handler ) ;
|
147 |
|
148 |
|
149 |
|
150 | module.exports = {
|
151 | esc: esc ,
|
152 | keymap: keymap ,
|
153 | handler: handler ,
|
154 | support: {
|
155 | deltaEscapeSequence: true ,
|
156 | "256colors": false ,
|
157 | "24bitsColors": false ,
|
158 | "trueColor": false
|
159 | } ,
|
160 | colorRegister: require( '../colorScheme/xterm.json' )
|
161 | } ;
|
162 |
|