@teaui/core 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/.dist/Buffer.d.ts +21 -0
  2. package/.dist/Buffer.js +140 -0
  3. package/.dist/Buffer.js.map +1 -0
  4. package/.dist/Color.d.ts +7 -0
  5. package/.dist/Color.js +39 -0
  6. package/.dist/Color.js.map +1 -0
  7. package/.dist/Container.d.ts +21 -0
  8. package/.dist/Container.js +138 -0
  9. package/.dist/Container.js.map +1 -0
  10. package/.dist/Screen.d.ts +54 -0
  11. package/.dist/Screen.js +278 -0
  12. package/.dist/Screen.js.map +1 -0
  13. package/.dist/Style.d.ts +46 -0
  14. package/.dist/Style.js +433 -0
  15. package/.dist/Style.js.map +1 -0
  16. package/.dist/System.d.ts +13 -0
  17. package/.dist/System.js +26 -0
  18. package/.dist/System.js.map +1 -0
  19. package/.dist/Theme.d.ts +56 -0
  20. package/.dist/Theme.js +157 -0
  21. package/.dist/Theme.js.map +1 -0
  22. package/.dist/UI.d.ts +2 -0
  23. package/.dist/UI.js +28 -0
  24. package/.dist/UI.js.map +1 -0
  25. package/.dist/View.d.ts +99 -0
  26. package/.dist/View.js +374 -0
  27. package/.dist/View.js.map +1 -0
  28. package/.dist/Viewport.d.ts +89 -0
  29. package/.dist/Viewport.js +295 -0
  30. package/.dist/Viewport.js.map +1 -0
  31. package/.dist/ansi.d.ts +31 -0
  32. package/.dist/ansi.js +139 -0
  33. package/.dist/ansi.js.map +1 -0
  34. package/.dist/components/Accordion.d.ts +47 -0
  35. package/.dist/components/Accordion.js +294 -0
  36. package/.dist/components/Accordion.js.map +1 -0
  37. package/.dist/components/Box.d.ts +67 -0
  38. package/.dist/components/Box.js +211 -0
  39. package/.dist/components/Box.js.map +1 -0
  40. package/.dist/components/Button.d.ts +28 -0
  41. package/.dist/components/Button.js +118 -0
  42. package/.dist/components/Button.js.map +1 -0
  43. package/.dist/components/Checkbox.d.ts +31 -0
  44. package/.dist/components/Checkbox.js +106 -0
  45. package/.dist/components/Checkbox.js.map +1 -0
  46. package/.dist/components/Collapsible.d.ts +32 -0
  47. package/.dist/components/Collapsible.js +109 -0
  48. package/.dist/components/Collapsible.js.map +1 -0
  49. package/.dist/components/CollapsibleText.d.ts +21 -0
  50. package/.dist/components/CollapsibleText.js +113 -0
  51. package/.dist/components/CollapsibleText.js.map +1 -0
  52. package/.dist/components/Digits.d.ts +20 -0
  53. package/.dist/components/Digits.js +843 -0
  54. package/.dist/components/Digits.js.map +1 -0
  55. package/.dist/components/Drawer.d.ts +44 -0
  56. package/.dist/components/Drawer.js +473 -0
  57. package/.dist/components/Drawer.js.map +1 -0
  58. package/.dist/components/Dropdown.d.ts +61 -0
  59. package/.dist/components/Dropdown.js +367 -0
  60. package/.dist/components/Dropdown.js.map +1 -0
  61. package/.dist/components/Header.d.ts +25 -0
  62. package/.dist/components/Header.js +106 -0
  63. package/.dist/components/Header.js.map +1 -0
  64. package/.dist/components/HotKey.d.ts +14 -0
  65. package/.dist/components/HotKey.js +31 -0
  66. package/.dist/components/HotKey.js.map +1 -0
  67. package/.dist/components/Input.d.ts +45 -0
  68. package/.dist/components/Input.js +1109 -0
  69. package/.dist/components/Input.js.map +1 -0
  70. package/.dist/components/Log.d.ts +16 -0
  71. package/.dist/components/Log.js +122 -0
  72. package/.dist/components/Log.js.map +1 -0
  73. package/.dist/components/Progress.d.ts +21 -0
  74. package/.dist/components/Progress.js +200 -0
  75. package/.dist/components/Progress.js.map +1 -0
  76. package/.dist/components/Scrollable.d.ts +50 -0
  77. package/.dist/components/Scrollable.js +226 -0
  78. package/.dist/components/Scrollable.js.map +1 -0
  79. package/.dist/components/ScrollableList.d.ts +70 -0
  80. package/.dist/components/ScrollableList.js +354 -0
  81. package/.dist/components/ScrollableList.js.map +1 -0
  82. package/.dist/components/Separator.d.ts +21 -0
  83. package/.dist/components/Separator.js +67 -0
  84. package/.dist/components/Separator.js.map +1 -0
  85. package/.dist/components/Slider.d.ts +60 -0
  86. package/.dist/components/Slider.js +341 -0
  87. package/.dist/components/Slider.js.map +1 -0
  88. package/.dist/components/Space.d.ts +19 -0
  89. package/.dist/components/Space.js +45 -0
  90. package/.dist/components/Space.js.map +1 -0
  91. package/.dist/components/Spinner.d.ts +16 -0
  92. package/.dist/components/Spinner.js +48 -0
  93. package/.dist/components/Spinner.js.map +1 -0
  94. package/.dist/components/Stack.d.ts +33 -0
  95. package/.dist/components/Stack.js +285 -0
  96. package/.dist/components/Stack.js.map +1 -0
  97. package/.dist/components/Tabs.d.ts +52 -0
  98. package/.dist/components/Tabs.js +312 -0
  99. package/.dist/components/Tabs.js.map +1 -0
  100. package/.dist/components/Text.d.ts +35 -0
  101. package/.dist/components/Text.js +242 -0
  102. package/.dist/components/Text.js.map +1 -0
  103. package/.dist/components/ToggleGroup.d.ts +26 -0
  104. package/.dist/components/ToggleGroup.js +279 -0
  105. package/.dist/components/ToggleGroup.js.map +1 -0
  106. package/.dist/components/Tree.d.ts +21 -0
  107. package/.dist/components/Tree.js +233 -0
  108. package/.dist/components/Tree.js.map +1 -0
  109. package/.dist/components/Window.d.ts +6 -0
  110. package/.dist/components/Window.js +17 -0
  111. package/.dist/components/Window.js.map +1 -0
  112. package/.dist/components/fonts.d.ts +2 -0
  113. package/.dist/components/fonts.js +39 -0
  114. package/.dist/components/fonts.js.map +1 -0
  115. package/.dist/components/index.d.ts +27 -0
  116. package/.dist/components/index.js +48 -0
  117. package/.dist/components/index.js.map +1 -0
  118. package/.dist/components/types.d.ts +6 -0
  119. package/.dist/components/types.js +20 -0
  120. package/.dist/components/types.js.map +1 -0
  121. package/.dist/components/utility/TrackMouse.d.ts +16 -0
  122. package/.dist/components/utility/TrackMouse.js +53 -0
  123. package/.dist/components/utility/TrackMouse.js.map +1 -0
  124. package/.dist/components/utility/index.d.ts +1 -0
  125. package/.dist/components/utility/index.js +6 -0
  126. package/.dist/components/utility/index.js.map +1 -0
  127. package/.dist/events/index.d.ts +12 -0
  128. package/.dist/events/index.js +20 -0
  129. package/.dist/events/index.js.map +1 -0
  130. package/.dist/events/key.d.ts +15 -0
  131. package/.dist/events/key.js +105 -0
  132. package/.dist/events/key.js.map +1 -0
  133. package/.dist/events/mouse.d.ts +65 -0
  134. package/.dist/events/mouse.js +68 -0
  135. package/.dist/events/mouse.js.map +1 -0
  136. package/.dist/events/window.d.ts +6 -0
  137. package/.dist/events/window.js +3 -0
  138. package/.dist/events/window.js.map +1 -0
  139. package/.dist/geometry.d.ts +178 -0
  140. package/.dist/geometry.js +315 -0
  141. package/.dist/geometry.js.map +1 -0
  142. package/.dist/iTerm2.d.ts +20 -0
  143. package/.dist/iTerm2.js +60 -0
  144. package/.dist/iTerm2.js.map +1 -0
  145. package/.dist/index.d.ts +18 -0
  146. package/.dist/index.js +37 -0
  147. package/.dist/index.js.map +1 -0
  148. package/.dist/inspect.d.ts +2 -0
  149. package/.dist/inspect.js +118 -0
  150. package/.dist/inspect.js.map +1 -0
  151. package/.dist/log.d.ts +12 -0
  152. package/.dist/log.js +56 -0
  153. package/.dist/log.js.map +1 -0
  154. package/.dist/managers/FocusManager.d.ts +28 -0
  155. package/.dist/managers/FocusManager.js +143 -0
  156. package/.dist/managers/FocusManager.js.map +1 -0
  157. package/.dist/managers/ModalManager.d.ts +10 -0
  158. package/.dist/managers/ModalManager.js +67 -0
  159. package/.dist/managers/ModalManager.js.map +1 -0
  160. package/.dist/managers/MouseManager.d.ts +21 -0
  161. package/.dist/managers/MouseManager.js +313 -0
  162. package/.dist/managers/MouseManager.js.map +1 -0
  163. package/.dist/managers/TickManager.d.ts +11 -0
  164. package/.dist/managers/TickManager.js +63 -0
  165. package/.dist/managers/TickManager.js.map +1 -0
  166. package/.dist/sys/alias.d.ts +470 -0
  167. package/.dist/sys/alias.js +487 -0
  168. package/.dist/sys/alias.js.map +1 -0
  169. package/.dist/sys/colors.d.ts +10 -0
  170. package/.dist/sys/colors.js +285 -0
  171. package/.dist/sys/colors.js.map +1 -0
  172. package/.dist/sys/gpmclient.d.ts +11 -0
  173. package/.dist/sys/gpmclient.js +193 -0
  174. package/.dist/sys/gpmclient.js.map +1 -0
  175. package/.dist/sys/index.d.ts +4 -0
  176. package/.dist/sys/index.js +41 -0
  177. package/.dist/sys/index.js.map +1 -0
  178. package/.dist/sys/keys.d.ts +4 -0
  179. package/.dist/sys/keys.js +531 -0
  180. package/.dist/sys/keys.js.map +1 -0
  181. package/.dist/sys/program.d.ts +356 -0
  182. package/.dist/sys/program.js +3739 -0
  183. package/.dist/sys/program.js.map +1 -0
  184. package/.dist/sys/tput.d.ts +297 -0
  185. package/.dist/sys/tput.js +2708 -0
  186. package/.dist/sys/tput.js.map +1 -0
  187. package/.dist/sys/unicode.d.ts +11 -0
  188. package/.dist/sys/unicode.js +619 -0
  189. package/.dist/sys/unicode.js.map +1 -0
  190. package/.dist/sys/usr/linux +0 -0
  191. package/.dist/sys/usr/windows-ansi +0 -0
  192. package/.dist/sys/usr/xterm +0 -0
  193. package/.dist/sys/usr/xterm-256color +0 -0
  194. package/.dist/sys/usr/xterm.termcap +243 -0
  195. package/.dist/sys/usr/xterm.terminfo +1977 -0
  196. package/.dist/terminal.d.ts +7 -0
  197. package/.dist/terminal.js +3 -0
  198. package/.dist/terminal.js.map +1 -0
  199. package/.dist/util.d.ts +22 -0
  200. package/.dist/util.js +79 -0
  201. package/.dist/util.js.map +1 -0
  202. package/LICENSE +24 -0
  203. package/package.json +49 -0
@@ -0,0 +1,2708 @@
1
+ "use strict";
2
+ /**
3
+ * tput.js - parse and compile terminfo caps to javascript.
4
+ * Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
5
+ * https://github.com/chjj/blessed
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || function (mod) {
24
+ if (mod && mod.__esModule) return mod;
25
+ var result = {};
26
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
+ __setModuleDefault(result, mod);
28
+ return result;
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.Tput = Tput;
35
+ exports.tryRead = tryRead;
36
+ exports.sprintf = sprintf;
37
+ // Resources:
38
+ // $ man term
39
+ // $ man terminfo
40
+ // http://invisible-island.net/ncurses/man/term.5.html
41
+ // https://en.wikipedia.org/wiki/Terminfo
42
+ // Todo:
43
+ // - xterm's XT (set-title capability?) value should
44
+ // be true (at least tmux thinks it should).
45
+ // It's not parsed as true. Investigate.
46
+ // - Possibly switch to other method of finding the
47
+ // extended data string table: i += h.symOffsetCount * 2;
48
+ /**
49
+ * Modules
50
+ */
51
+ const node_assert_1 = __importDefault(require("node:assert"));
52
+ const node_path_1 = __importDefault(require("node:path"));
53
+ const node_fs_1 = __importDefault(require("node:fs"));
54
+ const node_child_process_1 = __importDefault(require("node:child_process"));
55
+ const alias = __importStar(require("./alias"));
56
+ /**
57
+ * Tput
58
+ */
59
+ function Tput(options) {
60
+ if (!(this instanceof Tput)) {
61
+ return new Tput(options);
62
+ }
63
+ options = options || {};
64
+ if (typeof options === 'string') {
65
+ options = { terminal: options };
66
+ }
67
+ this.options = options;
68
+ this.terminal =
69
+ options.terminal ||
70
+ options.term ||
71
+ process.env.TERM ||
72
+ (process.platform === 'win32' ? 'windows-ansi' : 'xterm');
73
+ this.terminal = this.terminal.toLowerCase();
74
+ this.debug = options.debug;
75
+ this.padding = options.padding;
76
+ this.extended = options.extended;
77
+ this.printf = options.printf;
78
+ this.termcap = options.termcap;
79
+ this.error = null;
80
+ this.terminfoPrefix = options.terminfoPrefix;
81
+ this.terminfoFile = options.terminfoFile;
82
+ this.termcapFile = options.termcapFile;
83
+ if (options.terminal || options.term) {
84
+ this.setup();
85
+ }
86
+ }
87
+ Tput.prototype.setup = function () {
88
+ this.error = null;
89
+ try {
90
+ if (this.termcap) {
91
+ try {
92
+ this.injectTermcap();
93
+ }
94
+ catch (_e) {
95
+ if (this.debug)
96
+ throw e;
97
+ this.error = new Error('Termcap parse error.');
98
+ this._useInternalCap(this.terminal);
99
+ }
100
+ }
101
+ else {
102
+ try {
103
+ this.injectTerminfo();
104
+ }
105
+ catch (_e) {
106
+ if (this.debug)
107
+ throw e;
108
+ this.error = new Error('Terminfo parse error.');
109
+ this._useInternalInfo(this.terminal);
110
+ }
111
+ }
112
+ }
113
+ catch (_e) {
114
+ // If there was an error, fallback
115
+ // to an internally stored terminfo/cap.
116
+ if (this.debug)
117
+ throw e;
118
+ this.error = new Error('Terminfo not found.');
119
+ this._useXtermInfo();
120
+ }
121
+ };
122
+ Tput.prototype.term = function (is) {
123
+ return this.terminal.indexOf(is) === 0;
124
+ };
125
+ Tput.prototype._debug = function () {
126
+ if (!this.debug)
127
+ return;
128
+ return console.debug.apply(console, arguments);
129
+ };
130
+ /**
131
+ * Fallback
132
+ */
133
+ Tput.prototype._useVt102Cap = function () {
134
+ return this.injectTermcap('vt102');
135
+ };
136
+ Tput.prototype._useXtermCap = function () {
137
+ return this.injectTermcap(__dirname + '/usr/xterm.termcap');
138
+ };
139
+ Tput.prototype._useXtermInfo = function () {
140
+ return this.injectTerminfo(__dirname + '/usr/xterm');
141
+ };
142
+ Tput.prototype._useInternalInfo = function (name) {
143
+ name = node_path_1.default.basename(name);
144
+ return this.injectTerminfo(__dirname + '/usr/' + name);
145
+ };
146
+ Tput.prototype._useInternalCap = function (name) {
147
+ name = node_path_1.default.basename(name);
148
+ return this.injectTermcap(__dirname + '/usr/' + name + '.termcap');
149
+ };
150
+ /**
151
+ * Terminfo
152
+ */
153
+ Tput.ipaths = [
154
+ process.env.TERMINFO || '',
155
+ (process.env.TERMINFO_DIRS || '').split(':'),
156
+ (process.env.HOME || '') + '/.terminfo',
157
+ '/usr/share/terminfo',
158
+ '/usr/share/lib/terminfo',
159
+ '/usr/lib/terminfo',
160
+ '/usr/local/share/terminfo',
161
+ '/usr/local/share/lib/terminfo',
162
+ '/usr/local/lib/terminfo',
163
+ '/usr/local/ncurses/lib/terminfo',
164
+ '/lib/terminfo',
165
+ ];
166
+ Tput.prototype.readTerminfo = function (term) {
167
+ var data, file, info;
168
+ term = term || this.terminal;
169
+ file = node_path_1.default.normalize(this._prefix(term));
170
+ data = node_fs_1.default.readFileSync(file);
171
+ info = this.parseTerminfo(data, file);
172
+ if (this.debug) {
173
+ this._terminfo = info;
174
+ }
175
+ return info;
176
+ };
177
+ Tput._prefix = Tput.prototype._prefix = function (term) {
178
+ // If we have a terminfoFile, or our
179
+ // term looks like a filename, use it.
180
+ if (term) {
181
+ if (~term.indexOf(node_path_1.default.sep)) {
182
+ return term;
183
+ }
184
+ if (this.terminfoFile) {
185
+ return this.terminfoFile;
186
+ }
187
+ }
188
+ var paths = Tput.ipaths.slice(), file;
189
+ if (this.terminfoPrefix) {
190
+ paths.unshift(this.terminfoPrefix);
191
+ }
192
+ // Try exact matches.
193
+ file = this._tprefix(paths, term);
194
+ if (file)
195
+ return file;
196
+ // Try similar matches.
197
+ file = this._tprefix(paths, term, true);
198
+ if (file)
199
+ return file;
200
+ // Not found.
201
+ throw new Error('Terminfo directory not found.');
202
+ };
203
+ Tput._tprefix = Tput.prototype._tprefix = function (prefix, term, soft) {
204
+ if (!prefix)
205
+ return;
206
+ var file, dir, i, sdiff, sfile, list;
207
+ if (Array.isArray(prefix)) {
208
+ for (i = 0; i < prefix.length; i++) {
209
+ file = this._tprefix(prefix[i], term, soft);
210
+ if (file)
211
+ return file;
212
+ }
213
+ return;
214
+ }
215
+ var find = function (word) {
216
+ var file, ch;
217
+ file = node_path_1.default.resolve(prefix, word[0]);
218
+ try {
219
+ node_fs_1.default.statSync(file);
220
+ return file;
221
+ }
222
+ catch (_e) { }
223
+ ch = word[0].charCodeAt(0).toString(16);
224
+ if (ch.length < 2)
225
+ ch = '0' + ch;
226
+ file = node_path_1.default.resolve(prefix, ch);
227
+ try {
228
+ node_fs_1.default.statSync(file);
229
+ return file;
230
+ }
231
+ catch (_e) { }
232
+ };
233
+ if (!term) {
234
+ // Make sure the directory's sub-directories
235
+ // are all one-letter, or hex digits.
236
+ // return find('x') ? prefix : null;
237
+ try {
238
+ dir = node_fs_1.default.readdirSync(prefix).filter(function (file) {
239
+ return file.length !== 1 && !/^[0-9a-fA-F]{2}$/.test(file);
240
+ });
241
+ if (!dir.length) {
242
+ return prefix;
243
+ }
244
+ }
245
+ catch (_e) { }
246
+ return;
247
+ }
248
+ term = node_path_1.default.basename(term);
249
+ dir = find(term);
250
+ if (!dir)
251
+ return;
252
+ if (soft) {
253
+ try {
254
+ list = node_fs_1.default.readdirSync(dir);
255
+ }
256
+ catch (_e) {
257
+ return;
258
+ }
259
+ list.forEach(function (file) {
260
+ if (file.indexOf(term) === 0) {
261
+ var diff = file.length - term.length;
262
+ if (!sfile || diff < sdiff) {
263
+ sdiff = diff;
264
+ sfile = file;
265
+ }
266
+ }
267
+ });
268
+ return sfile && (soft || sdiff === 0) ? node_path_1.default.resolve(dir, sfile) : null;
269
+ }
270
+ file = node_path_1.default.resolve(dir, term);
271
+ try {
272
+ node_fs_1.default.statSync(file);
273
+ return file;
274
+ }
275
+ catch (_e) { }
276
+ };
277
+ /**
278
+ * Terminfo Parser
279
+ * All shorts are little-endian
280
+ */
281
+ Tput.prototype.parseTerminfo = function (data, file) {
282
+ var info = {}, extended, l = data.length, i = 0, v, o;
283
+ var h = (info.header = {
284
+ dataSize: data.length,
285
+ headerSize: 12,
286
+ magicNumber: (data[1] << 8) | data[0],
287
+ namesSize: (data[3] << 8) | data[2],
288
+ boolCount: (data[5] << 8) | data[4],
289
+ numCount: (data[7] << 8) | data[6],
290
+ strCount: (data[9] << 8) | data[8],
291
+ strTableSize: (data[11] << 8) | data[10],
292
+ });
293
+ h.total =
294
+ h.headerSize +
295
+ h.namesSize +
296
+ h.boolCount +
297
+ h.numCount * 2 +
298
+ h.strCount * 2 +
299
+ h.strTableSize;
300
+ i += h.headerSize;
301
+ // Names Section
302
+ var names = data.toString('ascii', i, i + h.namesSize - 1), parts = names.split('|'), name = parts[0], desc = parts.pop();
303
+ info.name = name;
304
+ info.names = parts;
305
+ info.desc = desc;
306
+ info.dir = node_path_1.default.resolve(file, '..', '..');
307
+ info.file = file;
308
+ i += h.namesSize - 1;
309
+ // Names is nul-terminated.
310
+ node_assert_1.default.equal(data[i], 0);
311
+ i++;
312
+ // Booleans Section
313
+ // One byte for each flag
314
+ // Same order as <term.h>
315
+ info.bools = {};
316
+ l = i + h.boolCount;
317
+ o = 0;
318
+ for (; i < l; i++) {
319
+ v = Tput.bools[o++];
320
+ info.bools[v] = data[i] === 1;
321
+ }
322
+ // Null byte in between to make sure numbers begin on an even byte.
323
+ if (i % 2) {
324
+ node_assert_1.default.equal(data[i], 0);
325
+ i++;
326
+ }
327
+ // Numbers Section
328
+ info.numbers = {};
329
+ l = i + h.numCount * 2;
330
+ o = 0;
331
+ for (; i < l; i += 2) {
332
+ v = Tput.numbers[o++];
333
+ if (data[i + 1] === 0xff && data[i] === 0xff) {
334
+ info.numbers[v] = -1;
335
+ }
336
+ else {
337
+ info.numbers[v] = (data[i + 1] << 8) | data[i];
338
+ }
339
+ }
340
+ // Strings Section
341
+ info.strings = {};
342
+ l = i + h.strCount * 2;
343
+ o = 0;
344
+ for (; i < l; i += 2) {
345
+ v = Tput.strings[o++];
346
+ if (data[i + 1] === 0xff && data[i] === 0xff) {
347
+ info.strings[v] = -1;
348
+ }
349
+ else {
350
+ info.strings[v] = (data[i + 1] << 8) | data[i];
351
+ }
352
+ }
353
+ // String Table
354
+ Object.keys(info.strings).forEach(function (key) {
355
+ if (info.strings[key] === -1) {
356
+ delete info.strings[key];
357
+ return;
358
+ }
359
+ // Workaround: fix an odd bug in the screen-256color terminfo where it tries
360
+ // to set -1, but it appears to have {0xfe, 0xff} instead of {0xff, 0xff}.
361
+ // TODO: Possibly handle errors gracefully below, as well as in the
362
+ // extended info. Also possibly do: `if (info.strings[key] >= data.length)`.
363
+ if (info.strings[key] === 65534) {
364
+ delete info.strings[key];
365
+ return;
366
+ }
367
+ var s = i + info.strings[key], j = s;
368
+ while (data[j])
369
+ j++;
370
+ (0, node_assert_1.default)(j < data.length);
371
+ info.strings[key] = data.toString('ascii', s, j);
372
+ });
373
+ // Extended Header
374
+ if (this.extended !== false) {
375
+ i--;
376
+ i += h.strTableSize;
377
+ if (i % 2) {
378
+ node_assert_1.default.equal(data[i], 0);
379
+ i++;
380
+ }
381
+ l = data.length;
382
+ if (i < l - 1) {
383
+ try {
384
+ extended = this.parseExtended(data.slice(i));
385
+ }
386
+ catch (_e) {
387
+ if (this.debug) {
388
+ throw e;
389
+ }
390
+ return info;
391
+ }
392
+ info.header.extended = extended.header;
393
+ ['bools', 'numbers', 'strings'].forEach(function (key) {
394
+ merge(info[key], extended[key]);
395
+ });
396
+ }
397
+ }
398
+ return info;
399
+ };
400
+ /**
401
+ * Extended Parsing
402
+ */
403
+ // Some data to help understand:
404
+ // For xterm, non-extended header:
405
+ // { dataSize: 3270,
406
+ // headerSize: 12,
407
+ // magicNumber: 282,
408
+ // namesSize: 48,
409
+ // boolCount: 38,
410
+ // numCount: 15,
411
+ // strCount: 413,
412
+ // strTableSize: 1388,
413
+ // total: 2342 }
414
+ // For xterm, header:
415
+ // Offset: 2342
416
+ // { header:
417
+ // { dataSize: 928,
418
+ // headerSize: 10,
419
+ // boolCount: 2,
420
+ // numCount: 1,
421
+ // strCount: 57,
422
+ // strTableSize: 117,
423
+ // lastStrTableOffset: 680,
424
+ // total: 245 },
425
+ // For xterm, layout:
426
+ // { header: '0 - 10', // length: 10
427
+ // bools: '10 - 12', // length: 2
428
+ // numbers: '12 - 14', // length: 2
429
+ // strings: '14 - 128', // length: 114 (57 short)
430
+ // symoffsets: '128 - 248', // length: 120 (60 short)
431
+ // stringtable: '248 - 612', // length: 364
432
+ // sym: '612 - 928' } // length: 316
433
+ //
434
+ // How lastStrTableOffset works:
435
+ // data.length - h.lastStrTableOffset === 248
436
+ // (sym-offset end, string-table start)
437
+ // 364 + 316 === 680 (lastStrTableOffset)
438
+ // How strTableSize works:
439
+ // h.strCount + [symOffsetCount] === h.strTableSize
440
+ // 57 + 60 === 117 (strTableSize)
441
+ // symOffsetCount doesn't actually exist in the header. it's just implied.
442
+ // Getting the number of sym offsets:
443
+ // h.symOffsetCount = h.strTableSize - h.strCount;
444
+ // h.symOffsetSize = (h.strTableSize - h.strCount) * 2;
445
+ Tput.prototype.parseExtended = function (data) {
446
+ var info = {}, l = data.length, i = 0;
447
+ var h = (info.header = {
448
+ dataSize: data.length,
449
+ headerSize: 10,
450
+ boolCount: (data[i + 1] << 8) | data[i + 0],
451
+ numCount: (data[i + 3] << 8) | data[i + 2],
452
+ strCount: (data[i + 5] << 8) | data[i + 4],
453
+ strTableSize: (data[i + 7] << 8) | data[i + 6],
454
+ lastStrTableOffset: (data[i + 9] << 8) | data[i + 8],
455
+ });
456
+ // h.symOffsetCount = h.strTableSize - h.strCount;
457
+ h.total =
458
+ h.headerSize +
459
+ h.boolCount +
460
+ h.numCount * 2 +
461
+ h.strCount * 2 +
462
+ h.strTableSize;
463
+ i += h.headerSize;
464
+ // Booleans Section
465
+ // One byte for each flag
466
+ var _bools = [];
467
+ l = i + h.boolCount;
468
+ for (; i < l; i++) {
469
+ _bools.push(data[i] === 1);
470
+ }
471
+ // Null byte in between to make sure numbers begin on an even byte.
472
+ if (i % 2) {
473
+ node_assert_1.default.equal(data[i], 0);
474
+ i++;
475
+ }
476
+ // Numbers Section
477
+ var _numbers = [];
478
+ l = i + h.numCount * 2;
479
+ for (; i < l; i += 2) {
480
+ if (data[i + 1] === 0xff && data[i] === 0xff) {
481
+ _numbers.push(-1);
482
+ }
483
+ else {
484
+ _numbers.push((data[i + 1] << 8) | data[i]);
485
+ }
486
+ }
487
+ // Strings Section
488
+ var _strings = [];
489
+ l = i + h.strCount * 2;
490
+ for (; i < l; i += 2) {
491
+ if (data[i + 1] === 0xff && data[i] === 0xff) {
492
+ _strings.push(-1);
493
+ }
494
+ else {
495
+ _strings.push((data[i + 1] << 8) | data[i]);
496
+ }
497
+ }
498
+ // Pass over the sym offsets and get to the string table.
499
+ i = data.length - h.lastStrTableOffset;
500
+ // Might be better to do this instead if the file has trailing bytes:
501
+ // i += h.symOffsetCount * 2;
502
+ // String Table
503
+ var high = 0;
504
+ _strings.forEach(function (offset, k) {
505
+ if (offset === -1) {
506
+ _strings[k] = '';
507
+ return;
508
+ }
509
+ var s = i + offset, j = s;
510
+ while (data[j])
511
+ j++;
512
+ (0, node_assert_1.default)(j < data.length);
513
+ // Find out where the string table ends by
514
+ // getting the highest string length.
515
+ if (high < j - i) {
516
+ high = j - i;
517
+ }
518
+ _strings[k] = data.toString('ascii', s, j);
519
+ });
520
+ // Symbol Table
521
+ // Add one to the highest string length because we didn't count \0.
522
+ i += high + 1;
523
+ l = data.length;
524
+ var sym = [], j;
525
+ for (; i < l; i++) {
526
+ j = i;
527
+ while (data[j])
528
+ j++;
529
+ sym.push(data.toString('ascii', i, j));
530
+ i = j;
531
+ }
532
+ // Identify by name
533
+ j = 0;
534
+ info.bools = {};
535
+ _bools.forEach(function (bool) {
536
+ info.bools[sym[j++]] = bool;
537
+ });
538
+ info.numbers = {};
539
+ _numbers.forEach(function (number) {
540
+ info.numbers[sym[j++]] = number;
541
+ });
542
+ info.strings = {};
543
+ _strings.forEach(function (string) {
544
+ info.strings[sym[j++]] = string;
545
+ });
546
+ // Should be the very last bit of data.
547
+ node_assert_1.default.equal(i, data.length);
548
+ return info;
549
+ };
550
+ Tput.prototype.compileTerminfo = function (term) {
551
+ return this.compile(this.readTerminfo(term));
552
+ };
553
+ Tput.prototype.injectTerminfo = function (term) {
554
+ return this.inject(this.compileTerminfo(term));
555
+ };
556
+ /**
557
+ * Compiler - terminfo cap->javascript
558
+ */
559
+ Tput.prototype.compile = function (info) {
560
+ var self = this;
561
+ if (!info) {
562
+ throw new Error('Terminal not found.');
563
+ }
564
+ this.detectFeatures(info);
565
+ this._debug(info);
566
+ info.all = {};
567
+ info.methods = {};
568
+ ['bools', 'numbers', 'strings'].forEach(function (type) {
569
+ Object.keys(info[type]).forEach(function (key) {
570
+ info.all[key] = info[type][key];
571
+ info.methods[key] = self._compile(info, key, info.all[key]);
572
+ });
573
+ });
574
+ Tput.bools.forEach(function (key) {
575
+ if (info.methods[key] == null)
576
+ info.methods[key] = false;
577
+ });
578
+ Tput.numbers.forEach(function (key) {
579
+ if (info.methods[key] == null)
580
+ info.methods[key] = -1;
581
+ });
582
+ Tput.strings.forEach(function (key) {
583
+ if (!info.methods[key])
584
+ info.methods[key] = noop;
585
+ });
586
+ Object.keys(info.methods).forEach(function (key) {
587
+ if (!Tput.alias[key])
588
+ return;
589
+ Tput.alias[key].forEach(function (alias) {
590
+ info.methods[alias] = info.methods[key];
591
+ });
592
+ // Could just use:
593
+ // Object.keys(Tput.aliasMap).forEach(function(key) {
594
+ // info.methods[key] = info.methods[Tput.aliasMap[key]];
595
+ // });
596
+ });
597
+ return info;
598
+ };
599
+ Tput.prototype.inject = function (info) {
600
+ var self = this, methods = info.methods || info;
601
+ Object.keys(methods).forEach(function (key) {
602
+ if (typeof methods[key] !== 'function') {
603
+ self[key] = methods[key];
604
+ return;
605
+ }
606
+ self[key] = function () {
607
+ var args = Array.prototype.slice.call(arguments);
608
+ return methods[key].call(self, args);
609
+ };
610
+ });
611
+ this.info = info;
612
+ this.all = info.all;
613
+ this.methods = info.methods;
614
+ this.bools = info.bools;
615
+ this.numbers = info.numbers;
616
+ this.strings = info.strings;
617
+ if (!~info.names.indexOf(this.terminal)) {
618
+ this.terminal = info.name;
619
+ }
620
+ this.features = info.features;
621
+ Object.keys(info.features).forEach(function (key) {
622
+ if (key === 'padding') {
623
+ if (!info.features.padding && self.options.padding !== true) {
624
+ self.padding = false;
625
+ }
626
+ return;
627
+ }
628
+ self[key] = info.features[key];
629
+ });
630
+ };
631
+ // See:
632
+ // ~/ncurses/ncurses/tinfo/lib_tparm.c
633
+ // ~/ncurses/ncurses/tinfo/comp_scan.c
634
+ Tput.prototype._compile = function (info, key, str) {
635
+ var v;
636
+ this._debug('Compiling %s: %s', key, JSON.stringify(str));
637
+ switch (typeof str) {
638
+ case 'boolean':
639
+ return str;
640
+ case 'number':
641
+ return str;
642
+ case 'string':
643
+ break;
644
+ default:
645
+ return noop;
646
+ }
647
+ if (!str) {
648
+ return noop;
649
+ }
650
+ // See:
651
+ // ~/ncurses/progs/tput.c - tput() - L149
652
+ // ~/ncurses/progs/tset.c - set_init() - L992
653
+ if (key === 'init_file' || key === 'reset_file') {
654
+ try {
655
+ str = node_fs_1.default.readFileSync(str, 'utf8');
656
+ if (this.debug) {
657
+ v = ('return ' + JSON.stringify(str) + ';')
658
+ // eslint-disable-next-line no-control-regex
659
+ .replace(/\x1b/g, '\\x1b')
660
+ .replace(/\r/g, '\\r')
661
+ .replace(/\n/g, '\\n');
662
+ process.stdout.write(v + '\n');
663
+ }
664
+ return function () {
665
+ return str;
666
+ };
667
+ }
668
+ catch (_e) {
669
+ return noop;
670
+ }
671
+ }
672
+ var tkey = info.name + '.' + key, header = 'var v, dyn = {}, stat = {}, stack = [], out = [];', footer = ';return out.join("");', code = header, val = str, buff = '', cap, ch, fi, then, els, end;
673
+ function read(regex, no) {
674
+ cap = regex.exec(val);
675
+ if (!cap)
676
+ return;
677
+ val = val.substring(cap[0].length);
678
+ ch = cap[1];
679
+ if (!no)
680
+ clear();
681
+ return cap;
682
+ }
683
+ function stmt(c) {
684
+ if (code[code.length - 1] === ',') {
685
+ code = code.slice(0, -1);
686
+ }
687
+ code += c;
688
+ }
689
+ function expr(c) {
690
+ code += c + ',';
691
+ }
692
+ function echo(c) {
693
+ if (c === '""')
694
+ return;
695
+ expr('out.push(' + c + ')');
696
+ }
697
+ function print(c) {
698
+ buff += c;
699
+ }
700
+ function clear() {
701
+ if (buff) {
702
+ echo(JSON.stringify(buff).replace(/\\u00([0-9a-fA-F]{2})/g, '\\x$1'));
703
+ buff = '';
704
+ }
705
+ }
706
+ while (val) {
707
+ // Ignore newlines
708
+ if (read(/^\n /, true)) {
709
+ continue;
710
+ }
711
+ // '^A' -> ^A
712
+ if (read(/^\^(.)/i, true)) {
713
+ if (!(ch >= ' ' && ch <= '~')) {
714
+ this._debug('%s: bad caret char.', tkey);
715
+ // NOTE: ncurses appears to simply
716
+ // continue in this situation, but
717
+ // I could be wrong.
718
+ print(cap[0]);
719
+ continue;
720
+ }
721
+ if (ch === '?') {
722
+ ch = '\x7f';
723
+ }
724
+ else {
725
+ ch = ch.charCodeAt(0) & 31;
726
+ if (ch === 0)
727
+ ch = 128;
728
+ ch = String.fromCharCode(ch);
729
+ }
730
+ print(ch);
731
+ continue;
732
+ }
733
+ // 3 octal digits -> character
734
+ if (read(/^\\([0-7]{3})/, true)) {
735
+ print(String.fromCharCode(parseInt(ch, 8)));
736
+ continue;
737
+ }
738
+ // '\e' -> ^[
739
+ // '\n' -> \n
740
+ // '\r' -> \r
741
+ // '\0' -> \200 (special case)
742
+ if (read(/^\\([eEnlrtbfs^\\,:0]|.)/, true)) {
743
+ switch (ch) {
744
+ case 'e':
745
+ case 'E':
746
+ ch = '\x1b';
747
+ break;
748
+ case 'n':
749
+ ch = '\n';
750
+ break;
751
+ case 'l':
752
+ ch = '\x85';
753
+ break;
754
+ case 'r':
755
+ ch = '\r';
756
+ break;
757
+ case 't':
758
+ ch = '\t';
759
+ break;
760
+ case 'b':
761
+ ch = '\x08';
762
+ break;
763
+ case 'f':
764
+ ch = '\x0c';
765
+ break;
766
+ case 's':
767
+ ch = ' ';
768
+ break;
769
+ case '^':
770
+ ch = '^';
771
+ break;
772
+ case '\\':
773
+ ch = '\\';
774
+ break;
775
+ case ',':
776
+ ch = ',';
777
+ break;
778
+ case ':':
779
+ ch = ':';
780
+ break;
781
+ case '0':
782
+ ch = '\x80';
783
+ break;
784
+ case 'a':
785
+ ch = '\x07';
786
+ break;
787
+ default:
788
+ this._debug('%s: bad backslash char.', tkey);
789
+ ch = cap[0];
790
+ break;
791
+ }
792
+ print(ch);
793
+ continue;
794
+ }
795
+ // $<5> -> padding
796
+ // e.g. flash_screen: '\u001b[?5h$<100/>\u001b[?5l',
797
+ if (read(/^\$<(\d+)([*/]{0,2})>/, true)) {
798
+ if (this.padding)
799
+ print(cap[0]);
800
+ continue;
801
+ }
802
+ // %% outputs `%'
803
+ if (read(/^%%/, true)) {
804
+ print('%');
805
+ continue;
806
+ }
807
+ // %[[:]flags][width[.precision]][doxXs]
808
+ // as in printf, flags are [-+#] and space. Use a `:' to allow the
809
+ // next character to be a `-' flag, avoiding interpreting "%-" as an
810
+ // operator.
811
+ // %c print pop() like %c in printf
812
+ // Example from screen terminfo:
813
+ // S0: "\u001b(%p1%c"
814
+ // %d print pop()
815
+ // "Print (e.g., "%d") is a special case."
816
+ // %s print pop() like %s in printf
817
+ if (read(/^%((?::-|[+# ]){1,4})?(\d+(?:\.\d+)?)?([doxXsc])/)) {
818
+ if (this.printf || cap[1] || cap[2] || ~'oxX'.indexOf(cap[3])) {
819
+ echo('sprintf("' + cap[0].replace(':-', '-') + '", stack.pop())');
820
+ }
821
+ else if (cap[3] === 'c') {
822
+ echo('(v = stack.pop(), isFinite(v) ' +
823
+ '? String.fromCharCode(v || 0200) : "")');
824
+ }
825
+ else {
826
+ echo('stack.pop()');
827
+ }
828
+ continue;
829
+ }
830
+ // %p[1-9]
831
+ // push i'th parameter
832
+ if (read(/^%p([1-9])/)) {
833
+ expr('(stack.push(v = params[' + (ch - 1) + ']), v)');
834
+ continue;
835
+ }
836
+ // %P[a-z]
837
+ // set dynamic variable [a-z] to pop()
838
+ if (read(/^%P([a-z])/)) {
839
+ expr('dyn.' + ch + ' = stack.pop()');
840
+ continue;
841
+ }
842
+ // %g[a-z]
843
+ // get dynamic variable [a-z] and push it
844
+ if (read(/^%g([a-z])/)) {
845
+ expr('(stack.push(dyn.' + ch + '), dyn.' + ch + ')');
846
+ continue;
847
+ }
848
+ // %P[A-Z]
849
+ // set static variable [a-z] to pop()
850
+ if (read(/^%P([A-Z])/)) {
851
+ expr('stat.' + ch + ' = stack.pop()');
852
+ continue;
853
+ }
854
+ // %g[A-Z]
855
+ // get static variable [a-z] and push it
856
+ // The terms "static" and "dynamic" are misleading. Historically,
857
+ // these are simply two different sets of variables, whose values are
858
+ // not reset between calls to tparm. However, that fact is not
859
+ // documented in other implementations. Relying on it will adversely
860
+ // impact portability to other implementations.
861
+ if (read(/^%g([A-Z])/)) {
862
+ expr('(stack.push(v = stat.' + ch + '), v)');
863
+ continue;
864
+ }
865
+ // %'c' char constant c
866
+ // NOTE: These are stored as c chars, exemplified by:
867
+ // cursor_address: "\u001b=%p1%' '%+%c%p2%' '%+%c"
868
+ if (read(/^%'(.)'/)) {
869
+ expr('(stack.push(v = ' + ch.charCodeAt(0) + '), v)');
870
+ continue;
871
+ }
872
+ // %{nn}
873
+ // integer constant nn
874
+ if (read(/^%\{(\d+)\}/)) {
875
+ expr('(stack.push(v = ' + ch + '), v)');
876
+ continue;
877
+ }
878
+ // %l push strlen(pop)
879
+ if (read(/^%l/)) {
880
+ expr('(stack.push(v = (stack.pop() || "").length || 0), v)');
881
+ continue;
882
+ }
883
+ // %+ %- %* %/ %m
884
+ // arithmetic (%m is mod): push(pop() op pop())
885
+ // %& %| %^
886
+ // bit operations (AND, OR and exclusive-OR): push(pop() op pop())
887
+ // %= %> %<
888
+ // logical operations: push(pop() op pop())
889
+ if (read(/^%([+\-*/m&|^=><])/)) {
890
+ if (ch === '=')
891
+ ch = '===';
892
+ else if (ch === 'm')
893
+ ch = '%';
894
+ expr('(v = stack.pop(),' +
895
+ ' stack.push(v = (stack.pop() ' +
896
+ ch +
897
+ ' v) || 0),' +
898
+ ' v)');
899
+ continue;
900
+ }
901
+ // %A, %O
902
+ // logical AND and OR operations (for conditionals)
903
+ if (read(/^%([AO])/)) {
904
+ // Are we supposed to store the result on the stack?
905
+ expr('(stack.push(v = (stack.pop() ' +
906
+ (ch === 'A' ? '&&' : '||') +
907
+ ' stack.pop())), v)');
908
+ continue;
909
+ }
910
+ // %! %~
911
+ // unary operations (logical and bit complement): push(op pop())
912
+ if (read(/^%([!~])/)) {
913
+ expr('(stack.push(v = ' + ch + 'stack.pop()), v)');
914
+ continue;
915
+ }
916
+ // %i add 1 to first two parameters (for ANSI terminals)
917
+ if (read(/^%i/)) {
918
+ // Are these supposed to go on the stack in certain situations?
919
+ // ncurses doesn't seem to put them on the stack, but xterm.user6
920
+ // seems to assume they're on the stack for some reason. Could
921
+ // just be a bad terminfo string.
922
+ // user6: "\u001b[%i%d;%dR" - possibly a termcap-style string.
923
+ // expr('(params[0] |= 0, params[1] |= 0, params[0]++, params[1]++)');
924
+ expr('(params[0]++, params[1]++)');
925
+ continue;
926
+ }
927
+ // %? expr %t thenpart %e elsepart %;
928
+ // This forms an if-then-else. The %e elsepart is optional. Usually
929
+ // the %? expr part pushes a value onto the stack, and %t pops it from
930
+ // the stack, testing if it is nonzero (true). If it is zero (false),
931
+ // control passes to the %e (else) part.
932
+ // It is possible to form else-if's a la Algol 68:
933
+ // %? c1 %t b1 %e c2 %t b2 %e c3 %t b3 %e c4 %t b4 %e %;
934
+ // where ci are conditions, bi are bodies.
935
+ if (read(/^%\?/)) {
936
+ end = -1;
937
+ stmt(';if (');
938
+ continue;
939
+ }
940
+ if (read(/^%t/)) {
941
+ end = -1;
942
+ // Technically this is supposed to pop everything off the stack that was
943
+ // pushed onto the stack after the if statement, see man terminfo.
944
+ // Right now, we don't pop anything off. This could cause compat issues.
945
+ // Perhaps implement a "pushed" counter from the time the if statement
946
+ // is added, to the time the then statement is added, and pop off
947
+ // the appropriate number of elements.
948
+ // while (pushed--) expr('stack.pop()');
949
+ stmt(') {');
950
+ continue;
951
+ }
952
+ // Terminfo does elseif's like
953
+ // this: %?[expr]%t...%e[expr]%t...%;
954
+ if (read(/^%e/)) {
955
+ fi = val.indexOf('%?');
956
+ then = val.indexOf('%t');
957
+ els = val.indexOf('%e');
958
+ end = val.indexOf('%;');
959
+ if (end === -1)
960
+ end = Infinity;
961
+ if (then !== -1 &&
962
+ then < end &&
963
+ (fi === -1 || then < fi) &&
964
+ (els === -1 || then < els)) {
965
+ stmt('} else if (');
966
+ }
967
+ else {
968
+ stmt('} else {');
969
+ }
970
+ continue;
971
+ }
972
+ if (read(/^%;/)) {
973
+ end = null;
974
+ if (str.indexOf('%?') !== -1) {
975
+ stmt('}');
976
+ }
977
+ continue;
978
+ }
979
+ buff += val[0];
980
+ val = val.substring(1);
981
+ }
982
+ // Clear the buffer of any remaining text.
983
+ clear();
984
+ // Some terminfos (I'm looking at you, atari-color), don't end an if
985
+ // statement. It's assumed terminfo will automatically end it for
986
+ // them, because they are a bunch of lazy bastards.
987
+ if (end != null) {
988
+ stmt('}');
989
+ }
990
+ // Add the footer.
991
+ stmt(footer);
992
+ // Optimize and cleanup generated code.
993
+ v = code.slice(header.length, -footer.length);
994
+ if (!v.length) {
995
+ code = 'return "";';
996
+ }
997
+ else if ((v = /^out\.push\(("(?:[^"]|\\")+")\)$/.exec(v))) {
998
+ code = 'return ' + v[1] + ';';
999
+ }
1000
+ else {
1001
+ // Turn `(stack.push(v = params[0]), v),out.push(stack.pop())`
1002
+ // into `out.push(params[0])`.
1003
+ code = code.replace(/\(stack\.push\(v = params\[(\d+)\]\), v\),out\.push\(stack\.pop\(\)\)/g, 'out.push(params[$1])');
1004
+ // Remove unnecessary variable initializations.
1005
+ v = code.slice(header.length, -footer.length);
1006
+ if (!~v.indexOf('v = '))
1007
+ code = code.replace('v, ', '');
1008
+ if (!~v.indexOf('dyn'))
1009
+ code = code.replace('dyn = {}, ', '');
1010
+ if (!~v.indexOf('stat'))
1011
+ code = code.replace('stat = {}, ', '');
1012
+ if (!~v.indexOf('stack'))
1013
+ code = code.replace('stack = [], ', '');
1014
+ // Turn `var out = [];out.push("foo"),` into `var out = ["foo"];`.
1015
+ code = code.replace(/out = \[\];out\.push\(("(?:[^"]|\\")+")\),/, 'out = [$1];');
1016
+ }
1017
+ // Terminfos `wyse350-vb`, and `wy350-w`
1018
+ // seem to have a few broken strings.
1019
+ if (str === '\u001b%?') {
1020
+ code = 'return "\\x1b";';
1021
+ }
1022
+ if (this.debug) {
1023
+ v = code
1024
+ // eslint-disable-next-line no-control-regex
1025
+ .replace(/\x1b/g, '\\x1b')
1026
+ .replace(/\r/g, '\\r')
1027
+ .replace(/\n/g, '\\n');
1028
+ process.stdout.write(v + '\n');
1029
+ }
1030
+ try {
1031
+ if (this.options.stringify && code.indexOf('return ') === 0) {
1032
+ return new Function('', code)();
1033
+ }
1034
+ return this.printf || ~code.indexOf('sprintf(')
1035
+ ? new Function('sprintf, params', code).bind(null, sprintf)
1036
+ : new Function('params', code);
1037
+ }
1038
+ catch (_e) {
1039
+ console.error('');
1040
+ console.error('Error on:', tkey);
1041
+ console.error(JSON.stringify(str));
1042
+ console.error('');
1043
+ console.error(code.replace(/(,|;)/g, '$1\n'));
1044
+ console.error(_e);
1045
+ // eslint-disable-next-line no-control-regex
1046
+ e.stack = e.stack.replace(/\x1b/g, '\\x1b');
1047
+ throw e;
1048
+ }
1049
+ };
1050
+ // See: ~/ncurses/ncurses/tinfo/lib_tputs.c
1051
+ Tput.prototype._print = function (code, print, done) {
1052
+ var xon = !this.bools.needs_xon_xoff || this.bools.xon_xoff;
1053
+ print = print || write;
1054
+ done = done || noop;
1055
+ if (!this.padding) {
1056
+ print(code);
1057
+ return done();
1058
+ }
1059
+ var parts = code.split(/(?=\$<[\d.]+[*/]{0,2}>)/), i = 0;
1060
+ (function next() {
1061
+ if (i === parts.length) {
1062
+ return done();
1063
+ }
1064
+ var part = parts[i++], padding = /^\$<([\d.]+)([*/]{0,2})>/.exec(part), amount, suffix;
1065
+ // , affect;
1066
+ if (!padding) {
1067
+ print(part);
1068
+ return next();
1069
+ }
1070
+ part = part.substring(padding[0].length);
1071
+ amount = +padding[1];
1072
+ suffix = padding[2];
1073
+ // A `/' suffix indicates that the padding is mandatory and forces a
1074
+ // delay of the given number of milliseconds even on devices for which xon
1075
+ // is present to indicate flow control.
1076
+ if (xon && !~suffix.indexOf('/')) {
1077
+ print(part);
1078
+ return next();
1079
+ }
1080
+ // A `*' indicates that the padding required is proportional to the number
1081
+ // of lines affected by the operation, and the amount given is the
1082
+ // per-affected-unit padding required. (In the case of insert character,
1083
+ // the factor is still the number of lines affected.) Normally, padding is
1084
+ // advisory if the device has the xon capability; it is used for cost
1085
+ // computation but does not trigger delays.
1086
+ if (~suffix.indexOf('*')) {
1087
+ // XXX Disable this for now.
1088
+ amount = amount;
1089
+ // if (affect = /\x1b\[(\d+)[LM]/.exec(part)) {
1090
+ // amount *= +affect[1];
1091
+ // }
1092
+ // The above is a huge workaround. In reality, we need to compile
1093
+ // `_print` into the string functions and check the cap name and
1094
+ // params.
1095
+ // if (cap === 'insert_line' || cap === 'delete_line') {
1096
+ // amount *= params[0];
1097
+ // }
1098
+ // if (cap === 'clear_screen') {
1099
+ // amount *= process.stdout.rows;
1100
+ // }
1101
+ }
1102
+ return setTimeout(function () {
1103
+ print(part);
1104
+ return next();
1105
+ }, amount);
1106
+ })();
1107
+ };
1108
+ // A small helper function if we want
1109
+ // to easily output text with setTimeouts.
1110
+ Tput.print = function () {
1111
+ var fake = {
1112
+ padding: true,
1113
+ bools: { needs_xon_xoff: true, xon_xoff: false },
1114
+ };
1115
+ return Tput.prototype._print.apply(fake, arguments);
1116
+ };
1117
+ /**
1118
+ * Termcap
1119
+ */
1120
+ Tput.cpaths = [
1121
+ process.env.TERMCAP || '',
1122
+ (process.env.TERMPATH || '').split(/[: ]/),
1123
+ (process.env.HOME || '') + '/.termcap',
1124
+ '/usr/share/misc/termcap',
1125
+ '/etc/termcap',
1126
+ ];
1127
+ Tput.prototype.readTermcap = function (term) {
1128
+ var self = this, terms, term_, root, paths;
1129
+ term = term || this.terminal;
1130
+ // Termcap has a bunch of terminals usually stored in one file/string,
1131
+ // so we need to find the one containing our desired terminal.
1132
+ if (~term.indexOf(node_path_1.default.sep) && (terms = this._tryCap(node_path_1.default.resolve(term)))) {
1133
+ term_ = node_path_1.default.basename(term).split('.')[0];
1134
+ if (terms[process.env.TERM]) {
1135
+ term = process.env.TERM;
1136
+ }
1137
+ else if (terms[term_]) {
1138
+ term = term_;
1139
+ }
1140
+ else {
1141
+ term = Object.keys(terms)[0];
1142
+ }
1143
+ }
1144
+ else {
1145
+ paths = Tput.cpaths.slice();
1146
+ if (this.termcapFile) {
1147
+ paths.unshift(this.termcapFile);
1148
+ }
1149
+ paths.push(Tput.termcap);
1150
+ terms = this._tryCap(paths, term);
1151
+ }
1152
+ if (!terms) {
1153
+ throw new Error('Cannot find termcap for: ' + term);
1154
+ }
1155
+ root = terms[term];
1156
+ if (this.debug) {
1157
+ this._termcap = terms;
1158
+ }
1159
+ ;
1160
+ (function tc(term) {
1161
+ if (term && term.strings.tc) {
1162
+ root.inherits = root.inherits || [];
1163
+ root.inherits.push(term.strings.tc);
1164
+ var names = terms[term.strings.tc]
1165
+ ? terms[term.strings.tc].names
1166
+ : [term.strings.tc];
1167
+ self._debug('%s inherits from %s.', term.names.join('/'), names.join('/'));
1168
+ var inherit = tc(terms[term.strings.tc]);
1169
+ if (inherit) {
1170
+ ;
1171
+ ['bools', 'numbers', 'strings'].forEach(function (type) {
1172
+ merge(term[type], inherit[type]);
1173
+ });
1174
+ }
1175
+ }
1176
+ return term;
1177
+ })(root);
1178
+ // Translate termcap names to terminfo-style names.
1179
+ root = this.translateTermcap(root);
1180
+ return root;
1181
+ };
1182
+ Tput.prototype._tryCap = function (file, term) {
1183
+ if (!file)
1184
+ return;
1185
+ var terms, data, i;
1186
+ if (Array.isArray(file)) {
1187
+ for (i = 0; i < file.length; i++) {
1188
+ data = this._tryCap(file[i], term);
1189
+ if (data)
1190
+ return data;
1191
+ }
1192
+ return;
1193
+ }
1194
+ // If the termcap string starts with `/`,
1195
+ // ncurses considers it a filename.
1196
+ data = file[0] === '/' ? tryRead(file) : file;
1197
+ if (!data)
1198
+ return;
1199
+ terms = this.parseTermcap(data, file);
1200
+ if (term && !terms[term]) {
1201
+ return;
1202
+ }
1203
+ return terms;
1204
+ };
1205
+ /**
1206
+ * Termcap Parser
1207
+ * http://en.wikipedia.org/wiki/Termcap
1208
+ * http://www.gnu.org/software
1209
+ * /termutils/manual/termcap-1.3/html_mono/termcap.html
1210
+ * http://www.gnu.org/software
1211
+ * /termutils/manual/termcap-1.3/html_mono/termcap.html#SEC17
1212
+ * http://tldp.org/HOWTO/Text-Terminal-HOWTO.html#toc16
1213
+ * man termcap
1214
+ */
1215
+ // Example:
1216
+ // vt102|dec vt102:\
1217
+ // :do=^J:co#80:li#24:cl=50\E[;H\E[2J:\
1218
+ // :le=^H:bs:cm=5\E[%i%d;%dH:nd=2\E[C:up=2\E[A:\
1219
+ // :ce=3\E[K:cd=50\E[J:so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:\
1220
+ // :md=2\E[1m:mr=2\E[7m:mb=2\E[5m:me=2\E[m:is=\E[1;24r\E[24;1H:\
1221
+ // :rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:ks=\E[?1h\E=:ke=\E[?1l\E>:\
1222
+ // :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\
1223
+ // :ho=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:pt:sr=5\EM:vt#3:\
1224
+ // :sc=\E7:rc=\E8:cs=\E[%i%d;%dr:vs=\E[?7l:ve=\E[?7h:\
1225
+ // :mi:al=\E[L:dc=\E[P:dl=\E[M:ei=\E[4l:im=\E[4h:
1226
+ Tput.prototype.parseTermcap = function (data, file) {
1227
+ var terms = {}, parts, term, entries, fields, field, names, i, j, k;
1228
+ // remove escaped newlines
1229
+ data = data.replace(/\\\n[ \t]*/g, '');
1230
+ // remove comments
1231
+ data = data.replace(/^#[^\n]+/gm, '');
1232
+ // split entries
1233
+ entries = data.trim().split(/\n+/);
1234
+ for (i = 0; i < entries.length; i++) {
1235
+ fields = entries[i].split(/:+/);
1236
+ for (j = 0; j < fields.length; j++) {
1237
+ field = fields[j].trim();
1238
+ if (!field)
1239
+ continue;
1240
+ if (j === 0) {
1241
+ names = field.split('|');
1242
+ term = {
1243
+ name: names[0],
1244
+ names: names,
1245
+ desc: names.pop(),
1246
+ file: ~file.indexOf(node_path_1.default.sep) ? node_path_1.default.resolve(file) : file,
1247
+ termcap: true,
1248
+ };
1249
+ for (k = 0; k < names.length; k++) {
1250
+ terms[names[k]] = term;
1251
+ }
1252
+ term.bools = {};
1253
+ term.numbers = {};
1254
+ term.strings = {};
1255
+ continue;
1256
+ }
1257
+ if (~field.indexOf('=')) {
1258
+ parts = field.split('=');
1259
+ term.strings[parts[0]] = parts.slice(1).join('=');
1260
+ }
1261
+ else if (~field.indexOf('#')) {
1262
+ parts = field.split('#');
1263
+ term.numbers[parts[0]] = +parts.slice(1).join('#');
1264
+ }
1265
+ else {
1266
+ term.bools[field] = true;
1267
+ }
1268
+ }
1269
+ }
1270
+ return terms;
1271
+ };
1272
+ /**
1273
+ * Termcap Compiler
1274
+ * man termcap
1275
+ */
1276
+ Tput.prototype.translateTermcap = function (info) {
1277
+ var self = this, out = {};
1278
+ if (!info)
1279
+ return;
1280
+ this._debug(info);
1281
+ ['name', 'names', 'desc', 'file', 'termcap'].forEach(function (key) {
1282
+ out[key] = info[key];
1283
+ });
1284
+ // Separate aliases for termcap
1285
+ var map = (function () {
1286
+ var out = {};
1287
+ Object.keys(Tput.alias).forEach(function (key) {
1288
+ var aliases = Tput.alias[key];
1289
+ out[aliases.termcap] = key;
1290
+ });
1291
+ return out;
1292
+ })();
1293
+ ['bools', 'numbers', 'strings'].forEach(function (key) {
1294
+ out[key] = {};
1295
+ Object.keys(info[key]).forEach(function (cap) {
1296
+ if (key === 'strings') {
1297
+ info.strings[cap] = self._captoinfo(cap, info.strings[cap], 1);
1298
+ }
1299
+ if (map[cap]) {
1300
+ out[key][map[cap]] = info[key][cap];
1301
+ }
1302
+ else {
1303
+ // NOTE: Possibly include all termcap names
1304
+ // in a separate alias.js file. Some are
1305
+ // missing from the terminfo alias.js file
1306
+ // which is why we have to do this:
1307
+ // See: $ man termcap
1308
+ out[key][cap] = info[key][cap];
1309
+ }
1310
+ });
1311
+ });
1312
+ return out;
1313
+ };
1314
+ Tput.prototype.compileTermcap = function (term) {
1315
+ return this.compile(this.readTermcap(term));
1316
+ };
1317
+ Tput.prototype.injectTermcap = function (term) {
1318
+ return this.inject(this.compileTermcap(term));
1319
+ };
1320
+ /**
1321
+ * _nc_captoinfo - ported to javascript directly from ncurses.
1322
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.
1323
+ * See: ~/ncurses/ncurses/tinfo/captoinfo.c
1324
+ *
1325
+ * Convert a termcap string to terminfo format.
1326
+ * 'cap' is the relevant terminfo capability index.
1327
+ * 's' is the string value of the capability.
1328
+ * 'parameterized' tells what type of translations to do:
1329
+ * % translations if 1
1330
+ * pad translations if >=0
1331
+ */
1332
+ Tput.prototype._captoinfo = function (cap, s, parameterized) {
1333
+ var self = this;
1334
+ var capstart;
1335
+ if (parameterized == null) {
1336
+ parameterized = 0;
1337
+ }
1338
+ var MAX_PUSHED = 16, stack = [];
1339
+ var stackptr = 0, onstack = 0, seenm = 0, seenn = 0, seenr = 0, param = 1, i = 0, out = '';
1340
+ function warn() {
1341
+ var args = Array.prototype.slice.call(arguments);
1342
+ args[0] = 'captoinfo: ' + (args[0] || '');
1343
+ return self._debug.apply(self, args);
1344
+ }
1345
+ function isdigit(ch) {
1346
+ return ch >= '0' && ch <= '9';
1347
+ }
1348
+ function isgraph(ch) {
1349
+ return ch > ' ' && ch <= '~';
1350
+ }
1351
+ // convert a character to a terminfo push
1352
+ function cvtchar(sp) {
1353
+ var c = '\0', len;
1354
+ var j = i;
1355
+ switch (sp[j]) {
1356
+ case '\\':
1357
+ switch (sp[++j]) {
1358
+ case "'":
1359
+ case '$':
1360
+ case '\\':
1361
+ case '%':
1362
+ c = sp[j];
1363
+ len = 2;
1364
+ break;
1365
+ case '\0':
1366
+ c = '\\';
1367
+ len = 1;
1368
+ break;
1369
+ case '0':
1370
+ case '1':
1371
+ case '2':
1372
+ case '3':
1373
+ len = 1;
1374
+ while (isdigit(sp[j])) {
1375
+ c = String.fromCharCode(8 * c.charCodeAt(0) +
1376
+ (sp[j++].charCodeAt(0) - '0'.charCodeAt(0)));
1377
+ len++;
1378
+ }
1379
+ break;
1380
+ default:
1381
+ c = sp[j];
1382
+ len = 2;
1383
+ break;
1384
+ }
1385
+ break;
1386
+ case '^':
1387
+ c = String.fromCharCode(sp[++j].charCodeAt(0) & 0x1f);
1388
+ len = 2;
1389
+ break;
1390
+ default:
1391
+ c = sp[j];
1392
+ len = 1;
1393
+ }
1394
+ if (isgraph(c) && c !== ',' && c !== "'" && c !== '\\' && c !== ':') {
1395
+ out += "%'";
1396
+ out += c;
1397
+ out += "'";
1398
+ }
1399
+ else {
1400
+ out += '%{';
1401
+ if (c.charCodeAt(0) > 99) {
1402
+ out += String.fromCharCode(((c.charCodeAt(0) / 100) | 0) + '0'.charCodeAt(0));
1403
+ }
1404
+ if (c.charCodeAt(0) > 9) {
1405
+ out += String.fromCharCode((((c.charCodeAt(0) / 10) | 0) % 10) + '0'.charCodeAt(0));
1406
+ }
1407
+ out += String.fromCharCode((c.charCodeAt(0) % 10) + '0'.charCodeAt(0));
1408
+ out += '}';
1409
+ }
1410
+ return len;
1411
+ }
1412
+ // push n copies of param on the terminfo stack if not already there
1413
+ function getparm(parm, n) {
1414
+ if (seenr) {
1415
+ if (parm === 1) {
1416
+ parm = 2;
1417
+ }
1418
+ else if (parm === 2) {
1419
+ parm = 1;
1420
+ }
1421
+ }
1422
+ if (onstack === parm) {
1423
+ if (n > 1) {
1424
+ warn('string may not be optimal');
1425
+ out += '%Pa';
1426
+ while (n--) {
1427
+ out += '%ga';
1428
+ }
1429
+ }
1430
+ return;
1431
+ }
1432
+ if (onstack !== 0) {
1433
+ push();
1434
+ }
1435
+ onstack = parm;
1436
+ while (n--) {
1437
+ out += '%p';
1438
+ out += String.fromCharCode('0'.charCodeAt(0) + parm);
1439
+ }
1440
+ if (seenn && parm < 3) {
1441
+ out += '%{96}%^';
1442
+ }
1443
+ if (seenm && parm < 3) {
1444
+ out += '%{127}%^';
1445
+ }
1446
+ }
1447
+ // push onstack on to the stack
1448
+ function push() {
1449
+ if (stackptr >= MAX_PUSHED) {
1450
+ warn('string too complex to convert');
1451
+ }
1452
+ else {
1453
+ stack[stackptr++] = onstack;
1454
+ }
1455
+ }
1456
+ // pop the top of the stack into onstack
1457
+ function pop() {
1458
+ if (stackptr === 0) {
1459
+ if (onstack === 0) {
1460
+ warn("I'm confused");
1461
+ }
1462
+ else {
1463
+ onstack = 0;
1464
+ }
1465
+ }
1466
+ else {
1467
+ onstack = stack[--stackptr];
1468
+ }
1469
+ param++;
1470
+ }
1471
+ function see03() {
1472
+ getparm(param, 1);
1473
+ out += '%3d';
1474
+ pop();
1475
+ }
1476
+ function invalid() {
1477
+ out += '%';
1478
+ i--;
1479
+ warn('unknown %% code %s (%#x) in %s', JSON.stringify(s[i]), s[i].charCodeAt(0), cap);
1480
+ }
1481
+ // skip the initial padding (if we haven't been told not to)
1482
+ capstart = null;
1483
+ if (s == null)
1484
+ s = '';
1485
+ if (parameterized >= 0 && isdigit(s[i])) {
1486
+ for (capstart = i;; i++) {
1487
+ if (!(isdigit(s[i]) || s[i] === '*' || s[i] === '.')) {
1488
+ break;
1489
+ }
1490
+ }
1491
+ }
1492
+ while (s[i]) {
1493
+ switch (s[i]) {
1494
+ case '%':
1495
+ i++;
1496
+ if (parameterized < 1) {
1497
+ out += '%';
1498
+ break;
1499
+ }
1500
+ switch (s[i++]) {
1501
+ case '%':
1502
+ out += '%';
1503
+ break;
1504
+ case 'r':
1505
+ if (seenr++ === 1) {
1506
+ warn('saw %%r twice in %s', cap);
1507
+ }
1508
+ break;
1509
+ case 'm':
1510
+ if (seenm++ === 1) {
1511
+ warn('saw %%m twice in %s', cap);
1512
+ }
1513
+ break;
1514
+ case 'n':
1515
+ if (seenn++ === 1) {
1516
+ warn('saw %%n twice in %s', cap);
1517
+ }
1518
+ break;
1519
+ case 'i':
1520
+ out += '%i';
1521
+ break;
1522
+ case '6':
1523
+ case 'B':
1524
+ getparm(param, 1);
1525
+ out += '%{10}%/%{16}%*';
1526
+ getparm(param, 1);
1527
+ out += '%{10}%m%+';
1528
+ break;
1529
+ case '8':
1530
+ case 'D':
1531
+ getparm(param, 2);
1532
+ out += '%{2}%*%-';
1533
+ break;
1534
+ case '>':
1535
+ getparm(param, 2);
1536
+ // %?%{x}%>%t%{y}%+%;
1537
+ out += '%?';
1538
+ i += cvtchar(s);
1539
+ out += '%>%t';
1540
+ i += cvtchar(s);
1541
+ out += '%+%;';
1542
+ break;
1543
+ case 'a':
1544
+ if ((s[i] === '=' ||
1545
+ s[i] === '+' ||
1546
+ s[i] === '-' ||
1547
+ s[i] === '*' ||
1548
+ s[i] === '/') &&
1549
+ (s[i + 1] === 'p' || s[i + 1] === 'c') &&
1550
+ s[i + 2] !== '\0' &&
1551
+ s[i + 2]) {
1552
+ var l;
1553
+ l = 2;
1554
+ if (s[i] !== '=') {
1555
+ getparm(param, 1);
1556
+ }
1557
+ if (s[i + 1] === 'p') {
1558
+ getparm(param + s[i + 2].charCodeAt(0) - '@'.charCodeAt(0), 1);
1559
+ if (param !== onstack) {
1560
+ pop();
1561
+ param--;
1562
+ }
1563
+ l++;
1564
+ }
1565
+ else {
1566
+ ;
1567
+ (i += 2), (l += cvtchar(s)), (i -= 2);
1568
+ }
1569
+ switch (s[i]) {
1570
+ case '+':
1571
+ out += '%+';
1572
+ break;
1573
+ case '-':
1574
+ out += '%-';
1575
+ break;
1576
+ case '*':
1577
+ out += '%*';
1578
+ break;
1579
+ case '/':
1580
+ out += '%/';
1581
+ break;
1582
+ case '=':
1583
+ if (seenr) {
1584
+ if (param === 1) {
1585
+ onstack = 2;
1586
+ }
1587
+ else if (param === 2) {
1588
+ onstack = 1;
1589
+ }
1590
+ else {
1591
+ onstack = param;
1592
+ }
1593
+ }
1594
+ else {
1595
+ onstack = param;
1596
+ }
1597
+ break;
1598
+ }
1599
+ i += l;
1600
+ break;
1601
+ }
1602
+ getparm(param, 1);
1603
+ i += cvtchar(s);
1604
+ out += '%+';
1605
+ break;
1606
+ case '+':
1607
+ getparm(param, 1);
1608
+ i += cvtchar(s);
1609
+ out += '%+%c';
1610
+ pop();
1611
+ break;
1612
+ case 's':
1613
+ // #ifdef WATERLOO
1614
+ // i += cvtchar(s);
1615
+ // getparm(param, 1);
1616
+ // out += '%-';
1617
+ // #else
1618
+ getparm(param, 1);
1619
+ out += '%s';
1620
+ pop();
1621
+ // #endif /* WATERLOO */
1622
+ break;
1623
+ case '-':
1624
+ i += cvtchar(s);
1625
+ getparm(param, 1);
1626
+ out += '%-%c';
1627
+ pop();
1628
+ break;
1629
+ case '.':
1630
+ getparm(param, 1);
1631
+ out += '%c';
1632
+ pop();
1633
+ break;
1634
+ case '0': // not clear any of the historical termcaps did this
1635
+ if (s[i] === '3') {
1636
+ see03(); // goto
1637
+ break;
1638
+ }
1639
+ else if (s[i] !== '2') {
1640
+ invalid(); // goto
1641
+ break;
1642
+ }
1643
+ // FALLTHRU
1644
+ case '2':
1645
+ getparm(param, 1);
1646
+ out += '%2d';
1647
+ pop();
1648
+ break;
1649
+ case '3':
1650
+ see03();
1651
+ break;
1652
+ case 'd':
1653
+ getparm(param, 1);
1654
+ out += '%d';
1655
+ pop();
1656
+ break;
1657
+ case 'f':
1658
+ param++;
1659
+ break;
1660
+ case 'b':
1661
+ param--;
1662
+ break;
1663
+ case '\\':
1664
+ out += '%\\';
1665
+ break;
1666
+ default:
1667
+ invalid();
1668
+ break;
1669
+ }
1670
+ break;
1671
+ // #ifdef REVISIBILIZE
1672
+ // case '\\':
1673
+ // out += s[i++];
1674
+ // out += s[i++];
1675
+ // break;
1676
+ // case '\n':
1677
+ // out += '\\n';
1678
+ // i++;
1679
+ // break;
1680
+ // case '\t':
1681
+ // out += '\\t';
1682
+ // i++;
1683
+ // break;
1684
+ // case '\r':
1685
+ // out += '\\r';
1686
+ // i++;
1687
+ // break;
1688
+ // case '\200':
1689
+ // out += '\\0';
1690
+ // i++;
1691
+ // break;
1692
+ // case '\f':
1693
+ // out += '\\f';
1694
+ // i++;
1695
+ // break;
1696
+ // case '\b':
1697
+ // out += '\\b';
1698
+ // i++;
1699
+ // break;
1700
+ // case ' ':
1701
+ // out += '\\s';
1702
+ // i++;
1703
+ // break;
1704
+ // case '^':
1705
+ // out += '\\^';
1706
+ // i++;
1707
+ // break;
1708
+ // case ':':
1709
+ // out += '\\:';
1710
+ // i++;
1711
+ // break;
1712
+ // case ',':
1713
+ // out += '\\,';
1714
+ // i++;
1715
+ // break;
1716
+ // default:
1717
+ // if (s[i] === '\033') {
1718
+ // out += '\\E';
1719
+ // i++;
1720
+ // } else if (s[i].charCodeAt(0) > 0 && s[i].charCodeAt(0) < 32) {
1721
+ // out += '^';
1722
+ // out += String.fromCharCode(s[i].charCodeAt(0) + '@'.charCodeAt(0));
1723
+ // i++;
1724
+ // } else if (s[i].charCodeAt(0) <= 0 || s[i].charCodeAt(0) >= 127) {
1725
+ // out += '\\';
1726
+ // out += String.fromCharCode(
1727
+ // ((s[i].charCodeAt(0) & 0300) >> 6) + '0'.charCodeAt(0));
1728
+ // out += String.fromCharCode(
1729
+ // ((s[i].charCodeAt(0) & 0070) >> 3) + '0'.charCodeAt(0));
1730
+ // out += String.fromCharCode(
1731
+ // (s[i].charCodeAt(0) & 0007) + '0'.charCodeAt(0));
1732
+ // i++;
1733
+ // } else {
1734
+ // out += s[i++];
1735
+ // }
1736
+ // break;
1737
+ // #else
1738
+ default:
1739
+ out += s[i++];
1740
+ break;
1741
+ // #endif
1742
+ }
1743
+ }
1744
+ // Now, if we stripped off some leading padding, add it at the end
1745
+ // of the string as mandatory padding.
1746
+ if (capstart != null) {
1747
+ out += '$<';
1748
+ for (i = capstart;; i++) {
1749
+ if (isdigit(s[i]) || s[i] === '*' || s[i] === '.') {
1750
+ out += s[i];
1751
+ }
1752
+ else {
1753
+ break;
1754
+ }
1755
+ }
1756
+ out += '/>';
1757
+ }
1758
+ if (s !== out) {
1759
+ warn('Translating %s from %s to %s.', cap, JSON.stringify(s), JSON.stringify(out));
1760
+ }
1761
+ return out;
1762
+ };
1763
+ /**
1764
+ * Compile All Terminfo
1765
+ */
1766
+ Tput.prototype.getAll = function () {
1767
+ var dir = this._prefix(), list = asort(node_fs_1.default.readdirSync(dir)), infos = [];
1768
+ list.forEach(function (letter) {
1769
+ var terms = asort(node_fs_1.default.readdirSync(node_path_1.default.resolve(dir, letter)));
1770
+ infos.push.apply(infos, terms);
1771
+ });
1772
+ function asort(obj) {
1773
+ return obj.sort(function (a, b) {
1774
+ a = a.toLowerCase().charCodeAt(0);
1775
+ b = b.toLowerCase().charCodeAt(0);
1776
+ return a - b;
1777
+ });
1778
+ }
1779
+ return infos;
1780
+ };
1781
+ Tput.prototype.compileAll = function (start) {
1782
+ var self = this, all = {};
1783
+ this.getAll().forEach(function (name) {
1784
+ if (start && name !== start) {
1785
+ return;
1786
+ }
1787
+ else {
1788
+ start = null;
1789
+ }
1790
+ all[name] = self.compileTerminfo(name);
1791
+ });
1792
+ return all;
1793
+ };
1794
+ /**
1795
+ * Detect Features / Quirks
1796
+ */
1797
+ Tput.prototype.detectFeatures = function (info) {
1798
+ var data = this.parseACS(info);
1799
+ info.features = {
1800
+ unicode: this.detectUnicode(info),
1801
+ brokenACS: this.detectBrokenACS(info),
1802
+ PCRomSet: this.detectPCRomSet(info),
1803
+ magicCookie: this.detectMagicCookie(info),
1804
+ padding: this.detectPadding(info),
1805
+ setbuf: this.detectSetbuf(info),
1806
+ acsc: data.acsc,
1807
+ acscr: data.acscr,
1808
+ };
1809
+ return info.features;
1810
+ };
1811
+ Tput.prototype.detectUnicode = function () {
1812
+ if (process.env.NCURSES_FORCE_UNICODE != null) {
1813
+ return !!+process.env.NCURSES_FORCE_UNICODE;
1814
+ }
1815
+ if (this.options.forceUnicode != null) {
1816
+ return this.options.forceUnicode;
1817
+ }
1818
+ var LANG = process.env.LANG +
1819
+ ':' +
1820
+ process.env.LANGUAGE +
1821
+ ':' +
1822
+ process.env.LC_ALL +
1823
+ ':' +
1824
+ process.env.LC_CTYPE;
1825
+ return /utf-?8/i.test(LANG) || this.GetConsoleCP() === 65001;
1826
+ };
1827
+ // For some reason TERM=linux has smacs/rmacs, but it maps to `^[[11m`
1828
+ // and it does not switch to the DEC SCLD character set. What the hell?
1829
+ // xterm: \x1b(0, screen: \x0e, linux: \x1b[11m (doesn't work)
1830
+ // `man console_codes` says:
1831
+ // 11 select null mapping, set display control flag, reset tog‐
1832
+ // gle meta flag (ECMA-48 says "first alternate font").
1833
+ // See ncurses:
1834
+ // ~/ncurses/ncurses/base/lib_set_term.c
1835
+ // ~/ncurses/ncurses/tinfo/lib_acs.c
1836
+ // ~/ncurses/ncurses/tinfo/tinfo_driver.c
1837
+ // ~/ncurses/ncurses/tinfo/lib_setup.c
1838
+ Tput.prototype.detectBrokenACS = function (info) {
1839
+ // ncurses-compatible env variable.
1840
+ if (process.env.NCURSES_NO_UTF8_ACS != null) {
1841
+ return !!+process.env.NCURSES_NO_UTF8_ACS;
1842
+ }
1843
+ // If the terminal supports unicode, we don't need ACS.
1844
+ if (info.numbers.U8 >= 0) {
1845
+ return !!info.numbers.U8;
1846
+ }
1847
+ // The linux console is just broken for some reason.
1848
+ // Apparently the Linux console does not support ACS,
1849
+ // but it does support the PC ROM character set.
1850
+ if (info.name === 'linux') {
1851
+ return true;
1852
+ }
1853
+ // PC alternate charset
1854
+ // if (acsc.indexOf('+\x10,\x11-\x18.\x190') === 0) {
1855
+ if (this.detectPCRomSet(info)) {
1856
+ return true;
1857
+ }
1858
+ // screen termcap is bugged?
1859
+ if (this.termcap &&
1860
+ info.name.indexOf('screen') === 0 &&
1861
+ process.env.TERMCAP &&
1862
+ ~process.env.TERMCAP.indexOf('screen') &&
1863
+ ~process.env.TERMCAP.indexOf('hhII00')) {
1864
+ if (~info.strings.enter_alt_charset_mode.indexOf('\x0e') ||
1865
+ ~info.strings.enter_alt_charset_mode.indexOf('\x0f') ||
1866
+ ~info.strings.set_attributes.indexOf('\x0e') ||
1867
+ ~info.strings.set_attributes.indexOf('\x0f')) {
1868
+ return true;
1869
+ }
1870
+ }
1871
+ return false;
1872
+ };
1873
+ // If enter_pc_charset is the same as enter_alt_charset,
1874
+ // the terminal does not support SCLD as ACS.
1875
+ // See: ~/ncurses/ncurses/tinfo/lib_acs.c
1876
+ Tput.prototype.detectPCRomSet = function (info) {
1877
+ var s = info.strings;
1878
+ if (s.enter_pc_charset_mode &&
1879
+ s.enter_alt_charset_mode &&
1880
+ s.enter_pc_charset_mode === s.enter_alt_charset_mode &&
1881
+ s.exit_pc_charset_mode === s.exit_alt_charset_mode) {
1882
+ return true;
1883
+ }
1884
+ return false;
1885
+ };
1886
+ Tput.prototype.detectMagicCookie = function () {
1887
+ return process.env.NCURSES_NO_MAGIC_COOKIE == null;
1888
+ };
1889
+ Tput.prototype.detectPadding = function () {
1890
+ return process.env.NCURSES_NO_PADDING == null;
1891
+ };
1892
+ Tput.prototype.detectSetbuf = function () {
1893
+ return process.env.NCURSES_NO_SETBUF == null;
1894
+ };
1895
+ Tput.prototype.parseACS = function (info) {
1896
+ var data = {};
1897
+ data.acsc = {};
1898
+ data.acscr = {};
1899
+ // Possibly just return an empty object, as done here, instead of
1900
+ // specifically saying ACS is "broken" above. This would be more
1901
+ // accurate to ncurses logic. But it doesn't really matter.
1902
+ if (this.detectPCRomSet(info)) {
1903
+ return data;
1904
+ }
1905
+ // See: ~/ncurses/ncurses/tinfo/lib_acs.c: L208
1906
+ Object.keys(Tput.acsc).forEach(function (ch) {
1907
+ var acs_chars = info.strings.acs_chars || '', i = acs_chars.indexOf(ch), next = acs_chars[i + 1];
1908
+ if (!next || i === -1 || !Tput.acsc[next]) {
1909
+ return;
1910
+ }
1911
+ data.acsc[ch] = Tput.acsc[next];
1912
+ data.acscr[Tput.acsc[next]] = ch;
1913
+ });
1914
+ return data;
1915
+ };
1916
+ Tput.prototype.GetConsoleCP = function () {
1917
+ var ccp;
1918
+ if (process.platform !== 'win32') {
1919
+ return -1;
1920
+ }
1921
+ // Allow unicode on all windows consoles for now:
1922
+ if (+process.env.NCURSES_NO_WINDOWS_UNICODE !== 1) {
1923
+ return 65001;
1924
+ }
1925
+ // cp.execSync('chcp 65001', { stdio: 'ignore', timeout: 1500 });
1926
+ try {
1927
+ // Produces something like: 'Active code page: 437\n\n'
1928
+ ccp = node_child_process_1.default.execFileSync(process.env.WINDIR + '\\system32\\chcp.com', [], {
1929
+ stdio: ['ignore', 'pipe', 'ignore'],
1930
+ encoding: 'ascii',
1931
+ timeout: 1500,
1932
+ });
1933
+ // ccp = cp.execSync('chcp', {
1934
+ // stdio: ['ignore', 'pipe', 'ignore'],
1935
+ // encoding: 'ascii',
1936
+ // timeout: 1500
1937
+ // });
1938
+ }
1939
+ catch (_e) { }
1940
+ ccp = /\d+/.exec(ccp);
1941
+ if (!ccp) {
1942
+ return -1;
1943
+ }
1944
+ ccp = +ccp[0];
1945
+ return ccp;
1946
+ };
1947
+ /**
1948
+ * Helpers
1949
+ */
1950
+ function noop() {
1951
+ return '';
1952
+ }
1953
+ noop.unsupported = true;
1954
+ function merge(a, b) {
1955
+ Object.keys(b).forEach(function (key) {
1956
+ a[key] = b[key];
1957
+ });
1958
+ return a;
1959
+ }
1960
+ function write(data) {
1961
+ return process.stdout.write(data);
1962
+ }
1963
+ function tryRead(file) {
1964
+ if (Array.isArray(file)) {
1965
+ for (var i = 0; i < file.length; i++) {
1966
+ var data = tryRead(file[i]);
1967
+ if (data)
1968
+ return data;
1969
+ }
1970
+ return '';
1971
+ }
1972
+ if (!file)
1973
+ return '';
1974
+ file = node_path_1.default.resolve.apply(node_path_1.default, arguments);
1975
+ try {
1976
+ return node_fs_1.default.readFileSync(file, 'utf8');
1977
+ }
1978
+ catch (_e) {
1979
+ return '';
1980
+ }
1981
+ }
1982
+ /**
1983
+ * sprintf
1984
+ * http://www.cplusplus.com/reference/cstdio/printf/
1985
+ */
1986
+ function sprintf(src) {
1987
+ var params = Array.prototype.slice.call(arguments, 1), rule = /%([\-+# ]{1,4})?(\d+(?:\.\d+)?)?([doxXsc])/g, i = 0;
1988
+ return src.replace(rule, function (_, flag, width, type) {
1989
+ var flags = (flag || '').split(''), param = params[i] != null ? params[i] : '', initial = param,
1990
+ // , width = +width
1991
+ opt = {}, pre = '';
1992
+ i++;
1993
+ switch (type) {
1994
+ case 'd': // signed int
1995
+ param = (+param).toString(10);
1996
+ break;
1997
+ case 'o': // unsigned octal
1998
+ param = (+param).toString(8);
1999
+ break;
2000
+ case 'x': // unsigned hex int
2001
+ param = (+param).toString(16);
2002
+ break;
2003
+ case 'X': // unsigned hex int uppercase
2004
+ param = (+param).toString(16).toUppercase();
2005
+ break;
2006
+ case 's': // string
2007
+ break;
2008
+ case 'c': // char
2009
+ param = isFinite(param) ? String.fromCharCode(param || 0x80) : '';
2010
+ break;
2011
+ }
2012
+ flags.forEach(function (flag) {
2013
+ switch (flag) {
2014
+ // left-justify by width
2015
+ case '-':
2016
+ opt.left = true;
2017
+ break;
2018
+ // always precede numbers with their signs
2019
+ case '+':
2020
+ opt.signs = true;
2021
+ break;
2022
+ // used with o, x, X - value is preceded with 0, 0x, or 0X respectively.
2023
+ // used with a, A, e, E, f, F, g, G - forces written output to contain
2024
+ // a decimal point even if no more digits follow
2025
+ case '#':
2026
+ opt.hexpoint = true;
2027
+ break;
2028
+ // if no sign is going to be written, black space in front of the value
2029
+ case ' ':
2030
+ opt.space = true;
2031
+ break;
2032
+ }
2033
+ });
2034
+ width = +width.split('.')[0];
2035
+ // Should this be for opt.left too?
2036
+ // Example: %2.2X - turns 0 into 00
2037
+ if (width && !opt.left) {
2038
+ param = param + '';
2039
+ while (param.length < width) {
2040
+ param = '0' + param;
2041
+ }
2042
+ }
2043
+ if (opt.signs) {
2044
+ if (+initial >= 0) {
2045
+ pre += '+';
2046
+ }
2047
+ }
2048
+ if (opt.space) {
2049
+ if (!opt.signs && +initial >= 0) {
2050
+ pre += ' ';
2051
+ }
2052
+ }
2053
+ if (opt.hexpoint) {
2054
+ switch (type) {
2055
+ case 'o': // unsigned octal
2056
+ pre += '0';
2057
+ break;
2058
+ case 'x': // unsigned hex int
2059
+ pre += '0x';
2060
+ break;
2061
+ case 'X': // unsigned hex int uppercase
2062
+ pre += '0X';
2063
+ break;
2064
+ }
2065
+ }
2066
+ if (opt.left) {
2067
+ if (width > pre.length + param.length) {
2068
+ width -= pre.length + param.length;
2069
+ pre = Array(width + 1).join(' ') + pre;
2070
+ }
2071
+ }
2072
+ return pre + param;
2073
+ });
2074
+ }
2075
+ /**
2076
+ * Aliases
2077
+ */
2078
+ Tput._alias = alias;
2079
+ Tput.alias = {};
2080
+ ['bools', 'numbers', 'strings'].forEach(function (type) {
2081
+ Object.keys(Tput._alias[type]).forEach(function (key) {
2082
+ var aliases = Tput._alias[type][key];
2083
+ Tput.alias[key] = [aliases[0]];
2084
+ Tput.alias[key].terminfo = aliases[0];
2085
+ Tput.alias[key].termcap = aliases[1];
2086
+ });
2087
+ });
2088
+ // Bools
2089
+ Tput.alias.no_esc_ctlc.push('beehive_glitch');
2090
+ Tput.alias.dest_tabs_magic_smso.push('teleray_glitch');
2091
+ // Numbers
2092
+ Tput.alias.micro_col_size.push('micro_char_size');
2093
+ /**
2094
+ * Feature Checking
2095
+ */
2096
+ Tput.aliasMap = {};
2097
+ Object.keys(Tput.alias).forEach(function (key) {
2098
+ Tput.aliasMap[key] = key;
2099
+ Tput.alias[key].forEach(function (k) {
2100
+ Tput.aliasMap[k] = key;
2101
+ });
2102
+ });
2103
+ Tput.prototype.has = function (name) {
2104
+ name = Tput.aliasMap[name];
2105
+ var val = this.all[name];
2106
+ if (!name)
2107
+ return false;
2108
+ if (typeof val === 'number') {
2109
+ return val !== -1;
2110
+ }
2111
+ return !!val;
2112
+ };
2113
+ /**
2114
+ * Fallback Termcap Entry
2115
+ */
2116
+ Tput.termcap =
2117
+ '' +
2118
+ 'vt102|dec vt102:' +
2119
+ ':do=^J:co#80:li#24:cl=50\\E[;H\\E[2J:' +
2120
+ ':le=^H:bs:cm=5\\E[%i%d;%dH:nd=2\\E[C:up=2\\E[A:' +
2121
+ ':ce=3\\E[K:cd=50\\E[J:so=2\\E[7m:se=2\\E[m:us=2\\E[4m:ue=2\\E[m:' +
2122
+ ':md=2\\E[1m:mr=2\\E[7m:mb=2\\E[5m:me=2\\E[m:is=\\E[1;24r\\E[24;1H:' +
2123
+ ':rs=\\E>\\E[?3l\\E[?4l\\E[?5l\\E[?7h\\E[?8h:ks=\\E[?1h\\E=:ke=\\E[?1l\\E>:' +
2124
+ ':ku=\\EOA:kd=\\EOB:kr=\\EOC:kl=\\EOD:kb=^H:\\\n' +
2125
+ ':ho=\\E[H:k1=\\EOP:k2=\\EOQ:k3=\\EOR:k4=\\EOS:pt:sr=5\\EM:vt#3:' +
2126
+ ':sc=\\E7:rc=\\E8:cs=\\E[%i%d;%dr:vs=\\E[?7l:ve=\\E[?7h:' +
2127
+ ':mi:al=\\E[L:dc=\\E[P:dl=\\E[M:ei=\\E[4l:im=\\E[4h:';
2128
+ /**
2129
+ * Terminfo Data
2130
+ */
2131
+ Tput.bools = [
2132
+ 'auto_left_margin',
2133
+ 'auto_right_margin',
2134
+ 'no_esc_ctlc',
2135
+ 'ceol_standout_glitch',
2136
+ 'eat_newline_glitch',
2137
+ 'erase_overstrike',
2138
+ 'generic_type',
2139
+ 'hard_copy',
2140
+ 'has_meta_key',
2141
+ 'has_status_line',
2142
+ 'insert_null_glitch',
2143
+ 'memory_above',
2144
+ 'memory_below',
2145
+ 'move_insert_mode',
2146
+ 'move_standout_mode',
2147
+ 'over_strike',
2148
+ 'status_line_esc_ok',
2149
+ 'dest_tabs_magic_smso',
2150
+ 'tilde_glitch',
2151
+ 'transparent_underline',
2152
+ 'xon_xoff',
2153
+ 'needs_xon_xoff',
2154
+ 'prtr_silent',
2155
+ 'hard_cursor',
2156
+ 'non_rev_rmcup',
2157
+ 'no_pad_char',
2158
+ 'non_dest_scroll_region',
2159
+ 'can_change',
2160
+ 'back_color_erase',
2161
+ 'hue_lightness_saturation',
2162
+ 'col_addr_glitch',
2163
+ 'cr_cancels_micro_mode',
2164
+ 'has_print_wheel',
2165
+ 'row_addr_glitch',
2166
+ 'semi_auto_right_margin',
2167
+ 'cpi_changes_res',
2168
+ 'lpi_changes_res',
2169
+ // #ifdef __INTERNAL_CAPS_VISIBLE
2170
+ 'backspaces_with_bs',
2171
+ 'crt_no_scrolling',
2172
+ 'no_correctly_working_cr',
2173
+ 'gnu_has_meta_key',
2174
+ 'linefeed_is_newline',
2175
+ 'has_hardware_tabs',
2176
+ 'return_does_clr_eol',
2177
+ ];
2178
+ Tput.numbers = [
2179
+ 'columns',
2180
+ 'init_tabs',
2181
+ 'lines',
2182
+ 'lines_of_memory',
2183
+ 'magic_cookie_glitch',
2184
+ 'padding_baud_rate',
2185
+ 'virtual_terminal',
2186
+ 'width_status_line',
2187
+ 'num_labels',
2188
+ 'label_height',
2189
+ 'label_width',
2190
+ 'max_attributes',
2191
+ 'maximum_windows',
2192
+ 'max_colors',
2193
+ 'max_pairs',
2194
+ 'no_color_video',
2195
+ 'buffer_capacity',
2196
+ 'dot_vert_spacing',
2197
+ 'dot_horz_spacing',
2198
+ 'max_micro_address',
2199
+ 'max_micro_jump',
2200
+ 'micro_col_size',
2201
+ 'micro_line_size',
2202
+ 'number_of_pins',
2203
+ 'output_res_char',
2204
+ 'output_res_line',
2205
+ 'output_res_horz_inch',
2206
+ 'output_res_vert_inch',
2207
+ 'print_rate',
2208
+ 'wide_char_size',
2209
+ 'buttons',
2210
+ 'bit_image_entwining',
2211
+ 'bit_image_type',
2212
+ // #ifdef __INTERNAL_CAPS_VISIBLE
2213
+ 'magic_cookie_glitch_ul',
2214
+ 'carriage_return_delay',
2215
+ 'new_line_delay',
2216
+ 'backspace_delay',
2217
+ 'horizontal_tab_delay',
2218
+ 'number_of_function_keys',
2219
+ ];
2220
+ Tput.strings = [
2221
+ 'back_tab',
2222
+ 'bell',
2223
+ 'carriage_return',
2224
+ 'change_scroll_region',
2225
+ 'clear_all_tabs',
2226
+ 'clear_screen',
2227
+ 'clreol',
2228
+ 'clreos',
2229
+ 'column_address',
2230
+ 'command_character',
2231
+ 'cursor_address',
2232
+ 'cursor_down',
2233
+ 'cursor_home',
2234
+ 'cursor_invisible',
2235
+ 'cursor_left',
2236
+ 'cursor_mem_address',
2237
+ 'cursor_normal',
2238
+ 'cursor_right',
2239
+ 'cursor_to_ll',
2240
+ 'cursor_up',
2241
+ 'cursor_visible',
2242
+ 'delete_character',
2243
+ 'delete_line',
2244
+ 'dis_status_line',
2245
+ 'down_half_line',
2246
+ 'enter_alt_charset_mode',
2247
+ 'enter_blink_mode',
2248
+ 'enter_bold_mode',
2249
+ 'enter_ca_mode',
2250
+ 'enter_delete_mode',
2251
+ 'enter_dim_mode',
2252
+ 'enter_insert_mode',
2253
+ 'enter_secure_mode',
2254
+ 'enter_protected_mode',
2255
+ 'enter_reverse_mode',
2256
+ 'enter_standout_mode',
2257
+ 'enter_underline_mode',
2258
+ 'erase_chars',
2259
+ 'exit_alt_charset_mode',
2260
+ 'exit_attribute_mode',
2261
+ 'exit_ca_mode',
2262
+ 'exit_delete_mode',
2263
+ 'exit_insert_mode',
2264
+ 'exit_standout_mode',
2265
+ 'exit_underline_mode',
2266
+ 'flash_screen',
2267
+ 'form_feed',
2268
+ 'from_status_line',
2269
+ 'init_1string',
2270
+ 'init_2string',
2271
+ 'init_3string',
2272
+ 'init_file',
2273
+ 'insert_character',
2274
+ 'insert_line',
2275
+ 'insert_padding',
2276
+ 'key_backspace',
2277
+ 'key_catab',
2278
+ 'key_clear',
2279
+ 'key_ctab',
2280
+ 'key_dc',
2281
+ 'key_dl',
2282
+ 'key_down',
2283
+ 'key_eic',
2284
+ 'key_eol',
2285
+ 'key_eos',
2286
+ 'key_f0',
2287
+ 'key_f1',
2288
+ 'key_f10',
2289
+ 'key_f2',
2290
+ 'key_f3',
2291
+ 'key_f4',
2292
+ 'key_f5',
2293
+ 'key_f6',
2294
+ 'key_f7',
2295
+ 'key_f8',
2296
+ 'key_f9',
2297
+ 'key_home',
2298
+ 'key_ic',
2299
+ 'key_il',
2300
+ 'key_left',
2301
+ 'key_ll',
2302
+ 'key_npage',
2303
+ 'key_ppage',
2304
+ 'key_right',
2305
+ 'key_sf',
2306
+ 'key_sr',
2307
+ 'key_stab',
2308
+ 'key_up',
2309
+ 'keypad_local',
2310
+ 'keypad_xmit',
2311
+ 'lab_f0',
2312
+ 'lab_f1',
2313
+ 'lab_f10',
2314
+ 'lab_f2',
2315
+ 'lab_f3',
2316
+ 'lab_f4',
2317
+ 'lab_f5',
2318
+ 'lab_f6',
2319
+ 'lab_f7',
2320
+ 'lab_f8',
2321
+ 'lab_f9',
2322
+ 'meta_off',
2323
+ 'meta_on',
2324
+ 'newline',
2325
+ 'pad_char',
2326
+ 'parm_dch',
2327
+ 'parm_delete_line',
2328
+ 'parm_down_cursor',
2329
+ 'parm_ich',
2330
+ 'parm_index',
2331
+ 'parm_insert_line',
2332
+ 'parm_left_cursor',
2333
+ 'parm_right_cursor',
2334
+ 'parm_rindex',
2335
+ 'parm_up_cursor',
2336
+ 'pkey_key',
2337
+ 'pkey_local',
2338
+ 'pkey_xmit',
2339
+ 'print_screen',
2340
+ 'prtr_off',
2341
+ 'prtr_on',
2342
+ 'repeat_char',
2343
+ 'reset_1string',
2344
+ 'reset_2string',
2345
+ 'reset_3string',
2346
+ 'reset_file',
2347
+ 'restore_cursor',
2348
+ 'row_address',
2349
+ 'save_cursor',
2350
+ 'scroll_forward',
2351
+ 'scroll_reverse',
2352
+ 'set_attributes',
2353
+ 'set_tab',
2354
+ 'set_window',
2355
+ 'tab',
2356
+ 'to_status_line',
2357
+ 'underline_char',
2358
+ 'up_half_line',
2359
+ 'init_prog',
2360
+ 'key_a1',
2361
+ 'key_a3',
2362
+ 'key_b2',
2363
+ 'key_c1',
2364
+ 'key_c3',
2365
+ 'prtr_non',
2366
+ 'char_padding',
2367
+ 'acs_chars',
2368
+ 'plab_norm',
2369
+ 'key_btab',
2370
+ 'enter_xon_mode',
2371
+ 'exit_xon_mode',
2372
+ 'enter_am_mode',
2373
+ 'exit_am_mode',
2374
+ 'xon_character',
2375
+ 'xoff_character',
2376
+ 'ena_acs',
2377
+ 'label_on',
2378
+ 'label_off',
2379
+ 'key_beg',
2380
+ 'key_cancel',
2381
+ 'key_close',
2382
+ 'key_command',
2383
+ 'key_copy',
2384
+ 'key_create',
2385
+ 'key_end',
2386
+ 'key_enter',
2387
+ 'key_exit',
2388
+ 'key_find',
2389
+ 'key_help',
2390
+ 'key_mark',
2391
+ 'key_message',
2392
+ 'key_move',
2393
+ 'key_next',
2394
+ 'key_open',
2395
+ 'key_options',
2396
+ 'key_previous',
2397
+ 'key_print',
2398
+ 'key_redo',
2399
+ 'key_reference',
2400
+ 'key_refresh',
2401
+ 'key_replace',
2402
+ 'key_restart',
2403
+ 'key_resume',
2404
+ 'key_save',
2405
+ 'key_suspend',
2406
+ 'key_undo',
2407
+ 'key_sbeg',
2408
+ 'key_scancel',
2409
+ 'key_scommand',
2410
+ 'key_scopy',
2411
+ 'key_screate',
2412
+ 'key_sdc',
2413
+ 'key_sdl',
2414
+ 'key_select',
2415
+ 'key_send',
2416
+ 'key_seol',
2417
+ 'key_sexit',
2418
+ 'key_sfind',
2419
+ 'key_shelp',
2420
+ 'key_shome',
2421
+ 'key_sic',
2422
+ 'key_sleft',
2423
+ 'key_smessage',
2424
+ 'key_smove',
2425
+ 'key_snext',
2426
+ 'key_soptions',
2427
+ 'key_sprevious',
2428
+ 'key_sprint',
2429
+ 'key_sredo',
2430
+ 'key_sreplace',
2431
+ 'key_sright',
2432
+ 'key_srsume',
2433
+ 'key_ssave',
2434
+ 'key_ssuspend',
2435
+ 'key_sundo',
2436
+ 'req_for_input',
2437
+ 'key_f11',
2438
+ 'key_f12',
2439
+ 'key_f13',
2440
+ 'key_f14',
2441
+ 'key_f15',
2442
+ 'key_f16',
2443
+ 'key_f17',
2444
+ 'key_f18',
2445
+ 'key_f19',
2446
+ 'key_f20',
2447
+ 'key_f21',
2448
+ 'key_f22',
2449
+ 'key_f23',
2450
+ 'key_f24',
2451
+ 'key_f25',
2452
+ 'key_f26',
2453
+ 'key_f27',
2454
+ 'key_f28',
2455
+ 'key_f29',
2456
+ 'key_f30',
2457
+ 'key_f31',
2458
+ 'key_f32',
2459
+ 'key_f33',
2460
+ 'key_f34',
2461
+ 'key_f35',
2462
+ 'key_f36',
2463
+ 'key_f37',
2464
+ 'key_f38',
2465
+ 'key_f39',
2466
+ 'key_f40',
2467
+ 'key_f41',
2468
+ 'key_f42',
2469
+ 'key_f43',
2470
+ 'key_f44',
2471
+ 'key_f45',
2472
+ 'key_f46',
2473
+ 'key_f47',
2474
+ 'key_f48',
2475
+ 'key_f49',
2476
+ 'key_f50',
2477
+ 'key_f51',
2478
+ 'key_f52',
2479
+ 'key_f53',
2480
+ 'key_f54',
2481
+ 'key_f55',
2482
+ 'key_f56',
2483
+ 'key_f57',
2484
+ 'key_f58',
2485
+ 'key_f59',
2486
+ 'key_f60',
2487
+ 'key_f61',
2488
+ 'key_f62',
2489
+ 'key_f63',
2490
+ 'clr_bol',
2491
+ 'clear_margins',
2492
+ 'set_left_margin',
2493
+ 'set_right_margin',
2494
+ 'label_format',
2495
+ 'set_clock',
2496
+ 'display_clock',
2497
+ 'remove_clock',
2498
+ 'create_window',
2499
+ 'goto_window',
2500
+ 'hangup',
2501
+ 'dial_phone',
2502
+ 'quick_dial',
2503
+ 'tone',
2504
+ 'pulse',
2505
+ 'flash_hook',
2506
+ 'fixed_pause',
2507
+ 'wait_tone',
2508
+ 'user0',
2509
+ 'user1',
2510
+ 'user2',
2511
+ 'user3',
2512
+ 'user4',
2513
+ 'user5',
2514
+ 'user6',
2515
+ 'user7',
2516
+ 'user8',
2517
+ 'user9',
2518
+ 'orig_pair',
2519
+ 'orig_colors',
2520
+ 'initialize_color',
2521
+ 'initialize_pair',
2522
+ 'set_color_pair',
2523
+ 'set_foreground',
2524
+ 'set_background',
2525
+ 'change_char_pitch',
2526
+ 'change_line_pitch',
2527
+ 'change_res_horz',
2528
+ 'change_res_vert',
2529
+ 'define_char',
2530
+ 'enter_doublewide_mode',
2531
+ 'enter_draft_quality',
2532
+ 'enter_italics_mode',
2533
+ 'enter_leftward_mode',
2534
+ 'enter_micro_mode',
2535
+ 'enter_near_letter_quality',
2536
+ 'enter_normal_quality',
2537
+ 'enter_shadow_mode',
2538
+ 'enter_subscript_mode',
2539
+ 'enter_superscript_mode',
2540
+ 'enter_upward_mode',
2541
+ 'exit_doublewide_mode',
2542
+ 'exit_italics_mode',
2543
+ 'exit_leftward_mode',
2544
+ 'exit_micro_mode',
2545
+ 'exit_shadow_mode',
2546
+ 'exit_subscript_mode',
2547
+ 'exit_superscript_mode',
2548
+ 'exit_upward_mode',
2549
+ 'micro_column_address',
2550
+ 'micro_down',
2551
+ 'micro_left',
2552
+ 'micro_right',
2553
+ 'micro_row_address',
2554
+ 'micro_up',
2555
+ 'order_of_pins',
2556
+ 'parm_down_micro',
2557
+ 'parm_left_micro',
2558
+ 'parm_right_micro',
2559
+ 'parm_up_micro',
2560
+ 'select_char_set',
2561
+ 'set_bottom_margin',
2562
+ 'set_bottom_margin_parm',
2563
+ 'set_left_margin_parm',
2564
+ 'set_right_margin_parm',
2565
+ 'set_top_margin',
2566
+ 'set_top_margin_parm',
2567
+ 'start_bit_image',
2568
+ 'start_char_set_def',
2569
+ 'stop_bit_image',
2570
+ 'stop_char_set_def',
2571
+ 'subscript_characters',
2572
+ 'superscript_characters',
2573
+ 'these_cause_cr',
2574
+ 'zero_motion',
2575
+ 'char_set_names',
2576
+ 'key_mouse',
2577
+ 'mouse_info',
2578
+ 'req_mouse_pos',
2579
+ 'get_mouse',
2580
+ 'set_a_foreground',
2581
+ 'set_a_background',
2582
+ 'pkey_plab',
2583
+ 'device_type',
2584
+ 'code_set_init',
2585
+ 'set0_des_seq',
2586
+ 'set1_des_seq',
2587
+ 'set2_des_seq',
2588
+ 'set3_des_seq',
2589
+ 'set_lr_margin',
2590
+ 'set_tb_margin',
2591
+ 'bit_image_repeat',
2592
+ 'bit_image_newline',
2593
+ 'bit_image_carriage_return',
2594
+ 'color_names',
2595
+ 'define_bit_image_region',
2596
+ 'end_bit_image_region',
2597
+ 'set_color_band',
2598
+ 'set_page_length',
2599
+ 'display_pc_char',
2600
+ 'enter_pc_charset_mode',
2601
+ 'exit_pc_charset_mode',
2602
+ 'enter_scancode_mode',
2603
+ 'exit_scancode_mode',
2604
+ 'pc_term_options',
2605
+ 'scancode_escape',
2606
+ 'alt_scancode_esc',
2607
+ 'enter_horizontal_hl_mode',
2608
+ 'enter_left_hl_mode',
2609
+ 'enter_low_hl_mode',
2610
+ 'enter_right_hl_mode',
2611
+ 'enter_top_hl_mode',
2612
+ 'enter_vertical_hl_mode',
2613
+ 'set_a_attributes',
2614
+ 'set_pglen_inch',
2615
+ // #ifdef __INTERNAL_CAPS_VISIBLE
2616
+ 'termcap_init2',
2617
+ 'termcap_reset',
2618
+ 'linefeed_if_not_lf',
2619
+ 'backspace_if_not_bs',
2620
+ 'other_non_function_keys',
2621
+ 'arrow_key_map',
2622
+ 'acs_ulcorner',
2623
+ 'acs_llcorner',
2624
+ 'acs_urcorner',
2625
+ 'acs_lrcorner',
2626
+ 'acs_ltee',
2627
+ 'acs_rtee',
2628
+ 'acs_btee',
2629
+ 'acs_ttee',
2630
+ 'acs_hline',
2631
+ 'acs_vline',
2632
+ 'acs_plus',
2633
+ 'memory_lock',
2634
+ 'memory_unlock',
2635
+ 'box_chars_1',
2636
+ ];
2637
+ // DEC Special Character and Line Drawing Set.
2638
+ // Taken from tty.js.
2639
+ Tput.acsc = {
2640
+ // (0
2641
+ '`': '\u25c6', // '◆'
2642
+ a: '\u2592', // '▒'
2643
+ b: '\u0009', // '\t'
2644
+ c: '\u000c', // '\f'
2645
+ d: '\u000d', // '\r'
2646
+ e: '\u000a', // '\n'
2647
+ f: '\u00b0', // '°'
2648
+ g: '\u00b1', // '±'
2649
+ h: '\u2424', // '\u2424' (NL)
2650
+ i: '\u000b', // '\v'
2651
+ j: '\u2518', // '┘'
2652
+ k: '\u2510', // '┐'
2653
+ l: '\u250c', // '┌'
2654
+ m: '\u2514', // '└'
2655
+ n: '\u253c', // '┼'
2656
+ o: '\u23ba', // '⎺'
2657
+ p: '\u23bb', // '⎻'
2658
+ q: '\u2500', // '─'
2659
+ r: '\u23bc', // '⎼'
2660
+ s: '\u23bd', // '⎽'
2661
+ t: '\u251c', // '├'
2662
+ u: '\u2524', // '┤'
2663
+ v: '\u2534', // '┴'
2664
+ w: '\u252c', // '┬'
2665
+ x: '\u2502', // '│'
2666
+ y: '\u2264', // '≤'
2667
+ z: '\u2265', // '≥'
2668
+ '{': '\u03c0', // 'π'
2669
+ '|': '\u2260', // '≠'
2670
+ '}': '\u00a3', // '£'
2671
+ '~': '\u00b7', // '·'
2672
+ };
2673
+ // Convert ACS unicode characters to the
2674
+ // most similar-looking ascii characters.
2675
+ Tput.utoa = Tput.prototype.utoa = {
2676
+ '\u25c6': '*', // '◆'
2677
+ '\u2592': ' ', // '▒'
2678
+ // '\u0009': '\t', // '\t'
2679
+ // '\u000c': '\f', // '\f'
2680
+ // '\u000d': '\r', // '\r'
2681
+ // '\u000a': '\n', // '\n'
2682
+ '\u00b0': '*', // '°'
2683
+ '\u00b1': '+', // '±'
2684
+ '\u2424': '\n', // '\u2424' (NL)
2685
+ // '\u000b': '\v', // '\v'
2686
+ '\u2518': '+', // '┘'
2687
+ '\u2510': '+', // '┐'
2688
+ '\u250c': '+', // '┌'
2689
+ '\u2514': '+', // '└'
2690
+ '\u253c': '+', // '┼'
2691
+ '\u23ba': '-', // '⎺'
2692
+ '\u23bb': '-', // '⎻'
2693
+ '\u2500': '-', // '─'
2694
+ '\u23bc': '-', // '⎼'
2695
+ '\u23bd': '_', // '⎽'
2696
+ '\u251c': '+', // '├'
2697
+ '\u2524': '+', // '┤'
2698
+ '\u2534': '+', // '┴'
2699
+ '\u252c': '+', // '┬'
2700
+ '\u2502': '|', // '│'
2701
+ '\u2264': '<', // '≤'
2702
+ '\u2265': '>', // '≥'
2703
+ '\u03c0': '?', // 'π'
2704
+ '\u2260': '=', // '≠'
2705
+ '\u00a3': '?', // '£'
2706
+ '\u00b7': '*', // '·'
2707
+ };
2708
+ //# sourceMappingURL=tput.js.map