@socketsecurity/cli-with-sentry 0.14.136 → 0.14.138

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 (112) hide show
  1. package/dist/blessed/LICENSE +20 -0
  2. package/dist/blessed/lib/alias.js +519 -0
  3. package/dist/blessed/lib/blessed.js +32 -0
  4. package/dist/blessed/lib/colors.js +490 -0
  5. package/dist/blessed/lib/events.js +195 -0
  6. package/dist/blessed/lib/gpmclient.js +245 -0
  7. package/dist/blessed/lib/helpers.js +170 -0
  8. package/dist/blessed/lib/keys.js +512 -0
  9. package/dist/blessed/lib/program.js +4530 -0
  10. package/dist/blessed/lib/tput.js +3111 -0
  11. package/dist/blessed/lib/unicode.js +912 -0
  12. package/dist/blessed/lib/widget.js +60 -0
  13. package/dist/blessed/lib/widgets/ansiimage.js +173 -0
  14. package/dist/blessed/lib/widgets/bigtext.js +170 -0
  15. package/dist/blessed/lib/widgets/box.js +34 -0
  16. package/dist/blessed/lib/widgets/button.js +62 -0
  17. package/dist/blessed/lib/widgets/checkbox.js +95 -0
  18. package/dist/blessed/lib/widgets/element.js +2871 -0
  19. package/dist/blessed/lib/widgets/filemanager.js +223 -0
  20. package/dist/blessed/lib/widgets/form.js +301 -0
  21. package/dist/blessed/lib/widgets/image.js +71 -0
  22. package/dist/blessed/lib/widgets/input.js +34 -0
  23. package/dist/blessed/lib/widgets/layout.js +249 -0
  24. package/dist/blessed/lib/widgets/line.js +59 -0
  25. package/dist/blessed/lib/widgets/list.js +652 -0
  26. package/dist/blessed/lib/widgets/listbar.js +452 -0
  27. package/dist/blessed/lib/widgets/listtable.js +265 -0
  28. package/dist/blessed/lib/widgets/loading.js +88 -0
  29. package/dist/blessed/lib/widgets/log.js +82 -0
  30. package/dist/blessed/lib/widgets/message.js +145 -0
  31. package/dist/blessed/lib/widgets/node.js +314 -0
  32. package/dist/blessed/lib/widgets/overlayimage.js +794 -0
  33. package/dist/blessed/lib/widgets/progressbar.js +166 -0
  34. package/dist/blessed/lib/widgets/prompt.js +127 -0
  35. package/dist/blessed/lib/widgets/question.js +129 -0
  36. package/dist/blessed/lib/widgets/radiobutton.js +62 -0
  37. package/dist/blessed/lib/widgets/radioset.js +36 -0
  38. package/dist/blessed/lib/widgets/screen.js +2485 -0
  39. package/dist/blessed/lib/widgets/scrollablebox.js +415 -0
  40. package/dist/blessed/lib/widgets/scrollabletext.js +35 -0
  41. package/dist/blessed/lib/widgets/table.js +383 -0
  42. package/dist/blessed/lib/widgets/terminal.js +452 -0
  43. package/dist/blessed/lib/widgets/text.js +35 -0
  44. package/dist/blessed/lib/widgets/textarea.js +376 -0
  45. package/dist/blessed/lib/widgets/textbox.js +79 -0
  46. package/dist/blessed/lib/widgets/video.js +130 -0
  47. package/dist/blessed/usr/fonts/AUTHORS +1 -0
  48. package/dist/blessed/usr/fonts/LICENSE +94 -0
  49. package/dist/blessed/usr/fonts/README +340 -0
  50. package/dist/blessed/usr/fonts/ter-u14b.json +17826 -0
  51. package/dist/blessed/usr/fonts/ter-u14n.json +17826 -0
  52. package/dist/blessed/usr/linux +0 -0
  53. package/dist/blessed/usr/windows-ansi +0 -0
  54. package/dist/blessed/usr/xterm +0 -0
  55. package/dist/blessed/usr/xterm-256color +0 -0
  56. package/dist/blessed/usr/xterm.termcap +243 -0
  57. package/dist/blessed/usr/xterm.terminfo +1977 -0
  58. package/dist/blessed/vendor/tng.js +1876 -0
  59. package/dist/blessed-contrib/LICENSE.md +21 -0
  60. package/dist/blessed-contrib/lib/layout/carousel.js +82 -0
  61. package/dist/blessed-contrib/lib/layout/grid.js +46 -0
  62. package/dist/blessed-contrib/lib/server-utils.js +83 -0
  63. package/dist/blessed-contrib/lib/utils.js +73 -0
  64. package/dist/blessed-contrib/lib/widget/canvas.js +52 -0
  65. package/dist/blessed-contrib/lib/widget/charts/bar.js +99 -0
  66. package/dist/blessed-contrib/lib/widget/charts/line.js +311 -0
  67. package/dist/blessed-contrib/lib/widget/charts/stacked-bar.js +245 -0
  68. package/dist/blessed-contrib/lib/widget/donut.js +183 -0
  69. package/dist/blessed-contrib/lib/widget/gauge-list.js +111 -0
  70. package/dist/blessed-contrib/lib/widget/gauge.js +127 -0
  71. package/dist/blessed-contrib/lib/widget/lcd.js +497 -0
  72. package/dist/blessed-contrib/lib/widget/log.js +32 -0
  73. package/dist/blessed-contrib/lib/widget/map.js +97 -0
  74. package/dist/blessed-contrib/lib/widget/markdown.js +68 -0
  75. package/dist/blessed-contrib/lib/widget/picture.js +61 -0
  76. package/dist/blessed-contrib/lib/widget/sparkline.js +66 -0
  77. package/dist/blessed-contrib/lib/widget/table.js +141 -0
  78. package/dist/blessed-contrib/lib/widget/tree.js +179 -0
  79. package/dist/blessed-contrib/node_modules/ansi-regex/index.js +6 -0
  80. package/dist/blessed-contrib/node_modules/ansi-regex/license +21 -0
  81. package/dist/blessed-contrib/node_modules/ansi-regex/package.json +64 -0
  82. package/dist/blessed-contrib/node_modules/ansi-regex/readme.md +39 -0
  83. package/dist/blessed-contrib/node_modules/ansi-styles/index.js +67 -0
  84. package/dist/blessed-contrib/node_modules/ansi-styles/license +21 -0
  85. package/dist/blessed-contrib/node_modules/ansi-styles/package.json +50 -0
  86. package/dist/blessed-contrib/node_modules/ansi-styles/readme.md +86 -0
  87. package/dist/blessed-contrib/node_modules/chalk/index.js +118 -0
  88. package/dist/blessed-contrib/node_modules/chalk/license +21 -0
  89. package/dist/blessed-contrib/node_modules/chalk/package.json +70 -0
  90. package/dist/blessed-contrib/node_modules/chalk/readme.md +213 -0
  91. package/dist/blessed-contrib/node_modules/escape-string-regexp/index.js +13 -0
  92. package/dist/blessed-contrib/node_modules/escape-string-regexp/license +21 -0
  93. package/dist/blessed-contrib/node_modules/escape-string-regexp/package.json +41 -0
  94. package/dist/blessed-contrib/node_modules/escape-string-regexp/readme.md +27 -0
  95. package/dist/blessed-contrib/node_modules/strip-ansi/index.js +8 -0
  96. package/dist/blessed-contrib/node_modules/strip-ansi/license +21 -0
  97. package/dist/blessed-contrib/node_modules/strip-ansi/package.json +57 -0
  98. package/dist/blessed-contrib/node_modules/strip-ansi/readme.md +33 -0
  99. package/dist/blessed-contrib/node_modules/supports-color/index.js +52 -0
  100. package/dist/blessed-contrib/node_modules/supports-color/license +21 -0
  101. package/dist/blessed-contrib/node_modules/supports-color/package.json +49 -0
  102. package/dist/blessed-contrib/node_modules/supports-color/readme.md +36 -0
  103. package/dist/cli.js +9 -8
  104. package/dist/cli.js.map +1 -1
  105. package/dist/constants.js.map +1 -1
  106. package/dist/instrument-with-sentry.js +2 -2
  107. package/dist/instrument-with-sentry.js.map +1 -1
  108. package/dist/shadow-npm-inject.js +2 -2
  109. package/dist/shadow-npm-inject.js.map +1 -1
  110. package/dist/vendor.js +19 -5
  111. package/dist/vendor.js.map +1 -1
  112. package/package.json +7 -8
@@ -0,0 +1,452 @@
1
+ /**
2
+ * listbar.js - listbar element for blessed
3
+ * Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
4
+ * https://github.com/chjj/blessed
5
+ */
6
+
7
+ /**
8
+ * Modules
9
+ */
10
+
11
+ const helpers = require('../helpers')
12
+
13
+ const Node = require('./node')
14
+ const Box = require('./box')
15
+
16
+ /**
17
+ * Listbar / HorizontalList
18
+ */
19
+
20
+ function Listbar(options) {
21
+ const self = this
22
+
23
+ if (!(this instanceof Node)) {
24
+ return new Listbar(options)
25
+ }
26
+
27
+ options = options || {}
28
+
29
+ this.items = []
30
+ this.ritems = []
31
+ this.commands = []
32
+
33
+ this.leftBase = 0
34
+ this.leftOffset = 0
35
+
36
+ this.mouse = options.mouse || false
37
+
38
+ Box.call(this, options)
39
+
40
+ if (!this.style.selected) {
41
+ this.style.selected = {}
42
+ }
43
+
44
+ if (!this.style.item) {
45
+ this.style.item = {}
46
+ }
47
+
48
+ if (options.commands || options.items) {
49
+ this.setItems(options.commands || options.items)
50
+ }
51
+
52
+ if (options.keys) {
53
+ this.on('keypress', function (ch, key) {
54
+ if (
55
+ key.name === 'left' ||
56
+ (options.vi && key.name === 'h') ||
57
+ (key.shift && key.name === 'tab')
58
+ ) {
59
+ self.moveLeft()
60
+ self.screen.render()
61
+ // Stop propagation if we're in a form.
62
+ if (key.name === 'tab') {
63
+ return false
64
+ }
65
+ return
66
+ }
67
+ if (
68
+ key.name === 'right' ||
69
+ (options.vi && key.name === 'l') ||
70
+ key.name === 'tab'
71
+ ) {
72
+ self.moveRight()
73
+ self.screen.render()
74
+ // Stop propagation if we're in a form.
75
+ if (key.name === 'tab') {
76
+ return false
77
+ }
78
+ return
79
+ }
80
+ if (
81
+ key.name === 'enter' ||
82
+ (options.vi && key.name === 'k' && !key.shift)
83
+ ) {
84
+ self.emit('action', self.items[self.selected], self.selected)
85
+ self.emit('select', self.items[self.selected], self.selected)
86
+ const item = self.items[self.selected]
87
+ if (item._.cmd.callback) {
88
+ item._.cmd.callback()
89
+ }
90
+ self.screen.render()
91
+ return
92
+ }
93
+ if (key.name === 'escape' || (options.vi && key.name === 'q')) {
94
+ self.emit('action')
95
+ self.emit('cancel')
96
+ return
97
+ }
98
+ })
99
+ }
100
+
101
+ if (options.autoCommandKeys) {
102
+ this.onScreenEvent('keypress', function (ch) {
103
+ if (/^[0-9]$/.test(ch)) {
104
+ let i = +ch - 1
105
+ if (!~i) {
106
+ i = 9
107
+ }
108
+ return self.selectTab(i)
109
+ }
110
+ })
111
+ }
112
+
113
+ this.on('focus', function () {
114
+ self.select(self.selected)
115
+ })
116
+ }
117
+
118
+ Object.setPrototypeOf(Listbar.prototype, Box.prototype)
119
+
120
+ Listbar.prototype.type = 'listbar'
121
+
122
+ Listbar.prototype.__defineGetter__('selected', function () {
123
+ return this.leftBase + this.leftOffset
124
+ })
125
+
126
+ Listbar.prototype.setItems = function (commands) {
127
+ const self = this
128
+
129
+ if (!Array.isArray(commands)) {
130
+ commands = Object.keys(commands).reduce(function (obj, key, i) {
131
+ let cmd = commands[key],
132
+ cb
133
+
134
+ if (typeof cmd === 'function') {
135
+ cb = cmd
136
+ cmd = { callback: cb }
137
+ }
138
+
139
+ if (cmd.text == null) {
140
+ cmd.text = key
141
+ }
142
+ if (cmd.prefix == null) {
143
+ cmd.prefix = ++i + ''
144
+ }
145
+
146
+ if (cmd.text == null && cmd.callback) {
147
+ cmd.text = cmd.callback.name
148
+ }
149
+
150
+ obj.push(cmd)
151
+
152
+ return obj
153
+ }, [])
154
+ }
155
+
156
+ this.items.forEach(function (el) {
157
+ el.detach()
158
+ })
159
+
160
+ this.items = []
161
+ this.ritems = []
162
+ this.commands = []
163
+
164
+ commands.forEach(function (cmd) {
165
+ self.add(cmd)
166
+ })
167
+
168
+ this.emit('set items')
169
+ }
170
+
171
+ Listbar.prototype.add =
172
+ Listbar.prototype.addItem =
173
+ Listbar.prototype.appendItem =
174
+ function (item, callback) {
175
+ let self = this,
176
+ prev = this.items[this.items.length - 1],
177
+ drawn,
178
+ cmd,
179
+ title,
180
+ len
181
+
182
+ if (!this.parent) {
183
+ drawn = 0
184
+ } else {
185
+ drawn = prev ? prev.aleft + prev.width : 0
186
+ if (!this.screen.autoPadding) {
187
+ drawn += this.ileft
188
+ }
189
+ }
190
+
191
+ if (typeof item === 'object') {
192
+ cmd = item
193
+ if (cmd.prefix == null) {
194
+ cmd.prefix = this.items.length + 1 + ''
195
+ }
196
+ }
197
+
198
+ if (typeof item === 'string') {
199
+ cmd = {
200
+ prefix: this.items.length + 1 + '',
201
+ text: item,
202
+ callback: callback
203
+ }
204
+ }
205
+
206
+ if (typeof item === 'function') {
207
+ cmd = {
208
+ prefix: this.items.length + 1 + '',
209
+ text: item.name,
210
+ callback: item
211
+ }
212
+ }
213
+
214
+ if (cmd.keys && cmd.keys[0]) {
215
+ cmd.prefix = cmd.keys[0]
216
+ }
217
+
218
+ const t = helpers.generateTags(this.style.prefix || { fg: 'lightblack' })
219
+
220
+ title =
221
+ (cmd.prefix != null ? t.open + cmd.prefix + t.close + ':' : '') +
222
+ cmd.text
223
+
224
+ len = ((cmd.prefix != null ? cmd.prefix + ':' : '') + cmd.text).length
225
+
226
+ const options = {
227
+ screen: this.screen,
228
+ top: 0,
229
+ left: drawn + 1,
230
+ height: 1,
231
+ content: title,
232
+ width: len + 2,
233
+ align: 'center',
234
+ autoFocus: false,
235
+ tags: true,
236
+ mouse: true,
237
+ style: helpers.merge({}, this.style.item),
238
+ noOverflow: true
239
+ }
240
+
241
+ if (!this.screen.autoPadding) {
242
+ options.top += this.itop
243
+ options.left += this.ileft
244
+ }
245
+
246
+ ;[
247
+ 'bg',
248
+ 'fg',
249
+ 'bold',
250
+ 'underline',
251
+ 'blink',
252
+ 'inverse',
253
+ 'invisible'
254
+ ].forEach(function (name) {
255
+ options.style[name] = function () {
256
+ let attr =
257
+ self.items[self.selected] === el
258
+ ? self.style.selected[name]
259
+ : self.style.item[name]
260
+ if (typeof attr === 'function') {
261
+ attr = attr(el)
262
+ }
263
+ return attr
264
+ }
265
+ })
266
+
267
+ const el = new Box(options)
268
+
269
+ this._[cmd.text] = el
270
+ cmd.element = el
271
+ el._.cmd = cmd
272
+
273
+ this.ritems.push(cmd.text)
274
+ this.items.push(el)
275
+ this.commands.push(cmd)
276
+ this.append(el)
277
+
278
+ if (cmd.callback) {
279
+ if (cmd.keys) {
280
+ this.screen.key(cmd.keys, function () {
281
+ self.emit('action', el, self.selected)
282
+ self.emit('select', el, self.selected)
283
+ if (el._.cmd.callback) {
284
+ el._.cmd.callback()
285
+ }
286
+ self.select(el)
287
+ self.screen.render()
288
+ })
289
+ }
290
+ }
291
+
292
+ if (this.items.length === 1) {
293
+ this.select(0)
294
+ }
295
+
296
+ // XXX May be affected by new element.options.mouse option.
297
+ if (this.mouse) {
298
+ el.on('click', function () {
299
+ self.emit('action', el, self.selected)
300
+ self.emit('select', el, self.selected)
301
+ if (el._.cmd.callback) {
302
+ el._.cmd.callback()
303
+ }
304
+ self.select(el)
305
+ self.screen.render()
306
+ })
307
+ }
308
+
309
+ this.emit('add item')
310
+ }
311
+
312
+ Listbar.prototype.render = function () {
313
+ let self = this,
314
+ drawn = 0
315
+
316
+ if (!this.screen.autoPadding) {
317
+ drawn += this.ileft
318
+ }
319
+
320
+ this.items.forEach(function (el, i) {
321
+ if (i < self.leftBase) {
322
+ el.hide()
323
+ } else {
324
+ el.rleft = drawn + 1
325
+ drawn += el.width + 2
326
+ el.show()
327
+ }
328
+ })
329
+
330
+ return this._render()
331
+ }
332
+
333
+ Listbar.prototype.select = function (offset) {
334
+ if (typeof offset !== 'number') {
335
+ offset = this.items.indexOf(offset)
336
+ }
337
+
338
+ if (offset < 0) {
339
+ offset = 0
340
+ } else if (offset >= this.items.length) {
341
+ offset = this.items.length - 1
342
+ }
343
+
344
+ if (!this.parent) {
345
+ this.emit('select item', this.items[offset], offset)
346
+ return
347
+ }
348
+
349
+ const lpos = this._getCoords()
350
+ if (!lpos) {
351
+ return
352
+ }
353
+
354
+ let self = this,
355
+ width = lpos.xl - lpos.xi - this.iwidth,
356
+ drawn = 0,
357
+ visible = 0,
358
+ el
359
+
360
+ el = this.items[offset]
361
+ if (!el) {
362
+ return
363
+ }
364
+
365
+ this.items.forEach(function (el, i) {
366
+ if (i < self.leftBase) {
367
+ return
368
+ }
369
+
370
+ const lpos = el._getCoords()
371
+ if (!lpos) {
372
+ return
373
+ }
374
+
375
+ if (lpos.xl - lpos.xi <= 0) {
376
+ return
377
+ }
378
+
379
+ drawn += lpos.xl - lpos.xi + 2
380
+
381
+ if (drawn <= width) {
382
+ visible++
383
+ }
384
+ })
385
+
386
+ let diff = offset - (this.leftBase + this.leftOffset)
387
+ if (offset > this.leftBase + this.leftOffset) {
388
+ if (offset > this.leftBase + visible - 1) {
389
+ this.leftOffset = 0
390
+ this.leftBase = offset
391
+ } else {
392
+ this.leftOffset += diff
393
+ }
394
+ } else if (offset < this.leftBase + this.leftOffset) {
395
+ diff = -diff
396
+ if (offset < this.leftBase) {
397
+ this.leftOffset = 0
398
+ this.leftBase = offset
399
+ } else {
400
+ this.leftOffset -= diff
401
+ }
402
+ }
403
+
404
+ // XXX Move `action` and `select` events here.
405
+ this.emit('select item', el, offset)
406
+ }
407
+
408
+ Listbar.prototype.removeItem = function (child) {
409
+ const i = typeof child !== 'number' ? this.items.indexOf(child) : child
410
+
411
+ if (~i && this.items[i]) {
412
+ child = this.items.splice(i, 1)[0]
413
+ this.ritems.splice(i, 1)
414
+ this.commands.splice(i, 1)
415
+ this.remove(child)
416
+ if (i === this.selected) {
417
+ this.select(i - 1)
418
+ }
419
+ }
420
+
421
+ this.emit('remove item')
422
+ }
423
+
424
+ Listbar.prototype.move = function (offset) {
425
+ this.select(this.selected + offset)
426
+ }
427
+
428
+ Listbar.prototype.moveLeft = function (offset) {
429
+ this.move(-(offset || 1))
430
+ }
431
+
432
+ Listbar.prototype.moveRight = function (offset) {
433
+ this.move(offset || 1)
434
+ }
435
+
436
+ Listbar.prototype.selectTab = function (index) {
437
+ const item = this.items[index]
438
+ if (item) {
439
+ if (item._.cmd.callback) {
440
+ item._.cmd.callback()
441
+ }
442
+ this.select(index)
443
+ this.screen.render()
444
+ }
445
+ this.emit('select tab', item, index)
446
+ }
447
+
448
+ /**
449
+ * Expose
450
+ */
451
+
452
+ module.exports = Listbar
@@ -0,0 +1,265 @@
1
+ /**
2
+ * listtable.js - list table element for blessed
3
+ * Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
4
+ * https://github.com/chjj/blessed
5
+ */
6
+
7
+ /**
8
+ * Modules
9
+ */
10
+
11
+ const Node = require('./node')
12
+ const Box = require('./box')
13
+ const List = require('./list')
14
+ const Table = require('./table')
15
+
16
+ /**
17
+ * ListTable
18
+ */
19
+
20
+ function ListTable(options) {
21
+ const self = this
22
+
23
+ if (!(this instanceof Node)) {
24
+ return new ListTable(options)
25
+ }
26
+
27
+ options = options || {}
28
+ options.shrink = true
29
+ options.normalShrink = true
30
+ options.style = options.style || {}
31
+ options.style.border = options.style.border || {}
32
+ options.style.header = options.style.header || {}
33
+ options.style.cell = options.style.cell || {}
34
+ this.__align = options.align || 'center'
35
+ delete options.align
36
+
37
+ options.style.selected = options.style.cell.selected
38
+ options.style.item = options.style.cell
39
+
40
+ List.call(this, options)
41
+
42
+ this._header = new Box({
43
+ parent: this,
44
+ left: this.screen.autoPadding ? 0 : this.ileft,
45
+ top: 0,
46
+ width: 'shrink',
47
+ height: 1,
48
+ style: options.style.header,
49
+ tags: options.parseTags || options.tags
50
+ })
51
+
52
+ this.on('scroll', function () {
53
+ self._header.setFront()
54
+ self._header.rtop = self.childBase
55
+ if (!self.screen.autoPadding) {
56
+ self._header.rtop = self.childBase + (self.border ? 1 : 0)
57
+ }
58
+ })
59
+
60
+ this.pad = options.pad != null ? options.pad : 2
61
+
62
+ this.setData(options.rows || options.data)
63
+
64
+ this.on('attach', function () {
65
+ self.setData(self.rows)
66
+ })
67
+
68
+ this.on('resize', function () {
69
+ const selected = self.selected
70
+ self.setData(self.rows)
71
+ self.select(selected)
72
+ self.screen.render()
73
+ })
74
+ }
75
+
76
+ Object.setPrototypeOf(ListTable.prototype, List.prototype)
77
+
78
+ ListTable.prototype.type = 'list-table'
79
+
80
+ ListTable.prototype._calculateMaxes = Table.prototype._calculateMaxes
81
+
82
+ ListTable.prototype.setRows = ListTable.prototype.setData = function (rows) {
83
+ const self = this,
84
+ align = this.__align
85
+
86
+ if (this.visible && this.lpos) {
87
+ this.clearPos()
88
+ }
89
+
90
+ this.clearItems()
91
+
92
+ this.rows = rows || []
93
+
94
+ this._calculateMaxes()
95
+
96
+ if (!this._maxes) {
97
+ return
98
+ }
99
+
100
+ this.addItem('')
101
+
102
+ this.rows.forEach(function (row, i) {
103
+ const isHeader = i === 0
104
+ let text = ''
105
+ row.forEach(function (cell, i) {
106
+ const width = self._maxes[i]
107
+ let clen = self.strWidth(cell)
108
+
109
+ if (i !== 0) {
110
+ text += ' '
111
+ }
112
+
113
+ while (clen < width) {
114
+ if (align === 'center') {
115
+ cell = ' ' + cell + ' '
116
+ clen += 2
117
+ } else if (align === 'left') {
118
+ cell = cell + ' '
119
+ clen += 1
120
+ } else if (align === 'right') {
121
+ cell = ' ' + cell
122
+ clen += 1
123
+ }
124
+ }
125
+
126
+ if (clen > width) {
127
+ if (align === 'center') {
128
+ cell = cell.substring(1)
129
+ clen--
130
+ } else if (align === 'left') {
131
+ cell = cell.slice(0, -1)
132
+ clen--
133
+ } else if (align === 'right') {
134
+ cell = cell.substring(1)
135
+ clen--
136
+ }
137
+ }
138
+
139
+ text += cell
140
+ })
141
+ if (isHeader) {
142
+ self._header.setContent(text)
143
+ } else {
144
+ self.addItem(text)
145
+ }
146
+ })
147
+
148
+ this._header.setFront()
149
+
150
+ this.select(0)
151
+ }
152
+
153
+ ListTable.prototype._select = ListTable.prototype.select
154
+ ListTable.prototype.select = function (i) {
155
+ if (i === 0) {
156
+ i = 1
157
+ }
158
+ if (i <= this.childBase) {
159
+ this.setScroll(this.childBase - 1)
160
+ }
161
+ return this._select(i)
162
+ }
163
+
164
+ ListTable.prototype.render = function () {
165
+ const self = this
166
+
167
+ const coords = this._render()
168
+ if (!coords) {
169
+ return
170
+ }
171
+
172
+ this._calculateMaxes()
173
+
174
+ if (!this._maxes) {
175
+ return coords
176
+ }
177
+
178
+ let lines = this.screen.lines,
179
+ xi = coords.xi,
180
+ yi = coords.yi,
181
+ rx,
182
+ ry,
183
+ i
184
+
185
+ const battr = this.sattr(this.style.border)
186
+
187
+ const height = coords.yl - coords.yi - this.ibottom
188
+
189
+ if (!this.border || this.options.noCellBorders) {
190
+ return coords
191
+ }
192
+
193
+ // Draw border with correct angles.
194
+ ry = 0
195
+ for (i = 0; i < height + 1; i++) {
196
+ if (!lines[yi + ry]) {
197
+ break
198
+ }
199
+ rx = 0
200
+ self._maxes.slice(0, -1).forEach(function (max) {
201
+ rx += max
202
+ if (!lines[yi + ry][xi + rx + 1]) {
203
+ return
204
+ }
205
+ // center
206
+ if (ry === 0) {
207
+ // top
208
+ rx++
209
+ lines[yi + ry][xi + rx][0] = battr
210
+ lines[yi + ry][xi + rx][1] = '\u252c' // '┬'
211
+ // XXX If we alter iheight and itop for no borders - nothing should be written here
212
+ if (!self.border.top) {
213
+ lines[yi + ry][xi + rx][1] = '\u2502' // '│'
214
+ }
215
+ lines[yi + ry].dirty = true
216
+ } else if (ry === height) {
217
+ // bottom
218
+ rx++
219
+ lines[yi + ry][xi + rx][0] = battr
220
+ lines[yi + ry][xi + rx][1] = '\u2534' // '┴'
221
+ // XXX If we alter iheight and ibottom for no borders - nothing should be written here
222
+ if (!self.border.bottom) {
223
+ lines[yi + ry][xi + rx][1] = '\u2502' // '│'
224
+ }
225
+ lines[yi + ry].dirty = true
226
+ } else {
227
+ // middle
228
+ rx++
229
+ }
230
+ })
231
+ ry += 1
232
+ }
233
+
234
+ // Draw internal borders.
235
+ for (ry = 1; ry < height; ry++) {
236
+ if (!lines[yi + ry]) {
237
+ break
238
+ }
239
+ rx = 0
240
+ self._maxes.slice(0, -1).forEach(function (max) {
241
+ rx += max
242
+ if (!lines[yi + ry][xi + rx + 1]) {
243
+ return
244
+ }
245
+ if (self.options.fillCellBorders !== false) {
246
+ const lbg = lines[yi + ry][xi + rx][0] & 0x1ff
247
+ rx++
248
+ lines[yi + ry][xi + rx][0] = (battr & ~0x1ff) | lbg
249
+ } else {
250
+ rx++
251
+ lines[yi + ry][xi + rx][0] = battr
252
+ }
253
+ lines[yi + ry][xi + rx][1] = '\u2502' // '│'
254
+ lines[yi + ry].dirty = true
255
+ })
256
+ }
257
+
258
+ return coords
259
+ }
260
+
261
+ /**
262
+ * Expose
263
+ */
264
+
265
+ module.exports = ListTable