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