@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.
- package/dist/blessed/LICENSE +20 -0
- package/dist/blessed/lib/alias.js +519 -0
- package/dist/blessed/lib/blessed.js +32 -0
- package/dist/blessed/lib/colors.js +490 -0
- package/dist/blessed/lib/events.js +195 -0
- package/dist/blessed/lib/gpmclient.js +245 -0
- package/dist/blessed/lib/helpers.js +170 -0
- package/dist/blessed/lib/keys.js +512 -0
- package/dist/blessed/lib/program.js +4530 -0
- package/dist/blessed/lib/tput.js +3111 -0
- package/dist/blessed/lib/unicode.js +912 -0
- package/dist/blessed/lib/widget.js +60 -0
- package/dist/blessed/lib/widgets/ansiimage.js +173 -0
- package/dist/blessed/lib/widgets/bigtext.js +170 -0
- package/dist/blessed/lib/widgets/box.js +34 -0
- package/dist/blessed/lib/widgets/button.js +62 -0
- package/dist/blessed/lib/widgets/checkbox.js +95 -0
- package/dist/blessed/lib/widgets/element.js +2871 -0
- package/dist/blessed/lib/widgets/filemanager.js +223 -0
- package/dist/blessed/lib/widgets/form.js +301 -0
- package/dist/blessed/lib/widgets/image.js +71 -0
- package/dist/blessed/lib/widgets/input.js +34 -0
- package/dist/blessed/lib/widgets/layout.js +249 -0
- package/dist/blessed/lib/widgets/line.js +59 -0
- package/dist/blessed/lib/widgets/list.js +652 -0
- package/dist/blessed/lib/widgets/listbar.js +452 -0
- package/dist/blessed/lib/widgets/listtable.js +265 -0
- package/dist/blessed/lib/widgets/loading.js +88 -0
- package/dist/blessed/lib/widgets/log.js +82 -0
- package/dist/blessed/lib/widgets/message.js +145 -0
- package/dist/blessed/lib/widgets/node.js +314 -0
- package/dist/blessed/lib/widgets/overlayimage.js +794 -0
- package/dist/blessed/lib/widgets/progressbar.js +166 -0
- package/dist/blessed/lib/widgets/prompt.js +127 -0
- package/dist/blessed/lib/widgets/question.js +129 -0
- package/dist/blessed/lib/widgets/radiobutton.js +62 -0
- package/dist/blessed/lib/widgets/radioset.js +36 -0
- package/dist/blessed/lib/widgets/screen.js +2485 -0
- package/dist/blessed/lib/widgets/scrollablebox.js +415 -0
- package/dist/blessed/lib/widgets/scrollabletext.js +35 -0
- package/dist/blessed/lib/widgets/table.js +383 -0
- package/dist/blessed/lib/widgets/terminal.js +452 -0
- package/dist/blessed/lib/widgets/text.js +35 -0
- package/dist/blessed/lib/widgets/textarea.js +376 -0
- package/dist/blessed/lib/widgets/textbox.js +79 -0
- package/dist/blessed/lib/widgets/video.js +130 -0
- package/dist/blessed/usr/fonts/AUTHORS +1 -0
- package/dist/blessed/usr/fonts/LICENSE +94 -0
- package/dist/blessed/usr/fonts/README +340 -0
- package/dist/blessed/usr/fonts/ter-u14b.json +17826 -0
- package/dist/blessed/usr/fonts/ter-u14n.json +17826 -0
- 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 +243 -0
- package/dist/blessed/usr/xterm.terminfo +1977 -0
- package/dist/blessed/vendor/tng.js +1876 -0
- package/dist/blessed-contrib/LICENSE.md +21 -0
- package/dist/blessed-contrib/lib/layout/carousel.js +82 -0
- package/dist/blessed-contrib/lib/layout/grid.js +46 -0
- package/dist/blessed-contrib/lib/server-utils.js +83 -0
- package/dist/blessed-contrib/lib/utils.js +73 -0
- package/dist/blessed-contrib/lib/widget/canvas.js +52 -0
- package/dist/blessed-contrib/lib/widget/charts/bar.js +99 -0
- package/dist/blessed-contrib/lib/widget/charts/line.js +311 -0
- package/dist/blessed-contrib/lib/widget/charts/stacked-bar.js +245 -0
- package/dist/blessed-contrib/lib/widget/donut.js +183 -0
- package/dist/blessed-contrib/lib/widget/gauge-list.js +111 -0
- package/dist/blessed-contrib/lib/widget/gauge.js +127 -0
- package/dist/blessed-contrib/lib/widget/lcd.js +497 -0
- package/dist/blessed-contrib/lib/widget/log.js +32 -0
- package/dist/blessed-contrib/lib/widget/map.js +97 -0
- package/dist/blessed-contrib/lib/widget/markdown.js +68 -0
- package/dist/blessed-contrib/lib/widget/picture.js +61 -0
- package/dist/blessed-contrib/lib/widget/sparkline.js +66 -0
- package/dist/blessed-contrib/lib/widget/table.js +141 -0
- package/dist/blessed-contrib/lib/widget/tree.js +179 -0
- package/dist/blessed-contrib/node_modules/ansi-regex/index.js +6 -0
- package/dist/blessed-contrib/node_modules/ansi-regex/license +21 -0
- package/dist/blessed-contrib/node_modules/ansi-regex/package.json +64 -0
- package/dist/blessed-contrib/node_modules/ansi-regex/readme.md +39 -0
- package/dist/blessed-contrib/node_modules/ansi-styles/index.js +67 -0
- package/dist/blessed-contrib/node_modules/ansi-styles/license +21 -0
- package/dist/blessed-contrib/node_modules/ansi-styles/package.json +50 -0
- package/dist/blessed-contrib/node_modules/ansi-styles/readme.md +86 -0
- package/dist/blessed-contrib/node_modules/chalk/index.js +118 -0
- package/dist/blessed-contrib/node_modules/chalk/license +21 -0
- package/dist/blessed-contrib/node_modules/chalk/package.json +70 -0
- package/dist/blessed-contrib/node_modules/chalk/readme.md +213 -0
- package/dist/blessed-contrib/node_modules/escape-string-regexp/index.js +13 -0
- package/dist/blessed-contrib/node_modules/escape-string-regexp/license +21 -0
- package/dist/blessed-contrib/node_modules/escape-string-regexp/package.json +41 -0
- package/dist/blessed-contrib/node_modules/escape-string-regexp/readme.md +27 -0
- package/dist/blessed-contrib/node_modules/strip-ansi/index.js +8 -0
- package/dist/blessed-contrib/node_modules/strip-ansi/license +21 -0
- package/dist/blessed-contrib/node_modules/strip-ansi/package.json +57 -0
- package/dist/blessed-contrib/node_modules/strip-ansi/readme.md +33 -0
- package/dist/blessed-contrib/node_modules/supports-color/index.js +52 -0
- package/dist/blessed-contrib/node_modules/supports-color/license +21 -0
- package/dist/blessed-contrib/node_modules/supports-color/package.json +49 -0
- package/dist/blessed-contrib/node_modules/supports-color/readme.md +36 -0
- package/dist/cli.js +9 -8
- package/dist/cli.js.map +1 -1
- 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/shadow-npm-inject.js +2 -2
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/vendor.js +19 -5
- package/dist/vendor.js.map +1 -1
- package/package.json +7 -8
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* filemanager.js - file manager 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 path = require('node:path'),
|
|
12
|
+
fs = require('node:fs')
|
|
13
|
+
|
|
14
|
+
const helpers = require('../helpers')
|
|
15
|
+
|
|
16
|
+
const Node = require('./node')
|
|
17
|
+
const List = require('./list')
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* FileManager
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
function FileManager(options) {
|
|
24
|
+
const self = this
|
|
25
|
+
|
|
26
|
+
if (!(this instanceof Node)) {
|
|
27
|
+
return new FileManager(options)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
options = options || {}
|
|
31
|
+
options.parseTags = true
|
|
32
|
+
// options.label = ' {blue-fg}%path{/blue-fg} ';
|
|
33
|
+
|
|
34
|
+
List.call(this, options)
|
|
35
|
+
|
|
36
|
+
this.cwd = options.cwd || process.cwd()
|
|
37
|
+
this.file = this.cwd
|
|
38
|
+
this.value = this.cwd
|
|
39
|
+
|
|
40
|
+
if (options.label && ~options.label.indexOf('%path')) {
|
|
41
|
+
this._label.setContent(options.label.replace('%path', this.cwd))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this.on('select', function (item) {
|
|
45
|
+
const value = item.content.replace(/\{[^{}]+\}/g, '').replace(/@$/, ''),
|
|
46
|
+
file = path.resolve(self.cwd, value)
|
|
47
|
+
|
|
48
|
+
return fs.stat(file, function (err, stat) {
|
|
49
|
+
if (err) {
|
|
50
|
+
return self.emit('error', err, file)
|
|
51
|
+
}
|
|
52
|
+
self.file = file
|
|
53
|
+
self.value = file
|
|
54
|
+
if (stat.isDirectory()) {
|
|
55
|
+
self.emit('cd', file, self.cwd)
|
|
56
|
+
self.cwd = file
|
|
57
|
+
if (options.label && ~options.label.indexOf('%path')) {
|
|
58
|
+
self._label.setContent(options.label.replace('%path', file))
|
|
59
|
+
}
|
|
60
|
+
self.refresh()
|
|
61
|
+
} else {
|
|
62
|
+
self.emit('file', file)
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Object.setPrototypeOf(FileManager.prototype, List.prototype)
|
|
69
|
+
|
|
70
|
+
FileManager.prototype.type = 'file-manager'
|
|
71
|
+
|
|
72
|
+
FileManager.prototype.refresh = function (cwd, callback) {
|
|
73
|
+
if (!callback) {
|
|
74
|
+
callback = cwd
|
|
75
|
+
cwd = null
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const self = this
|
|
79
|
+
|
|
80
|
+
if (cwd) {
|
|
81
|
+
this.cwd = cwd
|
|
82
|
+
} else {
|
|
83
|
+
cwd = this.cwd
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return fs.readdir(cwd, function (err, list) {
|
|
87
|
+
if (err && err.code === 'ENOENT') {
|
|
88
|
+
self.cwd = cwd !== process.env.HOME ? process.env.HOME : '/'
|
|
89
|
+
return self.refresh(callback)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (err) {
|
|
93
|
+
if (callback) {
|
|
94
|
+
return callback(err)
|
|
95
|
+
}
|
|
96
|
+
return self.emit('error', err, cwd)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let dirs = [],
|
|
100
|
+
files = []
|
|
101
|
+
|
|
102
|
+
list.unshift('..')
|
|
103
|
+
|
|
104
|
+
list.forEach(function (name) {
|
|
105
|
+
let f = path.resolve(cwd, name),
|
|
106
|
+
stat
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
stat = fs.lstatSync(f)
|
|
110
|
+
} catch (e) {}
|
|
111
|
+
|
|
112
|
+
if ((stat && stat.isDirectory()) || name === '..') {
|
|
113
|
+
dirs.push({
|
|
114
|
+
name: name,
|
|
115
|
+
text: '{light-blue-fg}' + name + '{/light-blue-fg}/',
|
|
116
|
+
dir: true
|
|
117
|
+
})
|
|
118
|
+
} else if (stat && stat.isSymbolicLink()) {
|
|
119
|
+
files.push({
|
|
120
|
+
name: name,
|
|
121
|
+
text: '{light-cyan-fg}' + name + '{/light-cyan-fg}@',
|
|
122
|
+
dir: false
|
|
123
|
+
})
|
|
124
|
+
} else {
|
|
125
|
+
files.push({
|
|
126
|
+
name: name,
|
|
127
|
+
text: name,
|
|
128
|
+
dir: false
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
dirs = helpers.asort(dirs)
|
|
134
|
+
files = helpers.asort(files)
|
|
135
|
+
|
|
136
|
+
list = dirs.concat(files).map(function (data) {
|
|
137
|
+
return data.text
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
self.setItems(list)
|
|
141
|
+
self.select(0)
|
|
142
|
+
self.screen.render()
|
|
143
|
+
|
|
144
|
+
self.emit('refresh')
|
|
145
|
+
|
|
146
|
+
if (callback) {
|
|
147
|
+
callback()
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
FileManager.prototype.pick = function (cwd, callback) {
|
|
153
|
+
if (!callback) {
|
|
154
|
+
callback = cwd
|
|
155
|
+
cwd = null
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
let self = this,
|
|
159
|
+
focused = this.screen.focused === this,
|
|
160
|
+
hidden = this.hidden,
|
|
161
|
+
onfile,
|
|
162
|
+
oncancel
|
|
163
|
+
|
|
164
|
+
function resume() {
|
|
165
|
+
self.removeListener('file', onfile)
|
|
166
|
+
self.removeListener('cancel', oncancel)
|
|
167
|
+
if (hidden) {
|
|
168
|
+
self.hide()
|
|
169
|
+
}
|
|
170
|
+
if (!focused) {
|
|
171
|
+
self.screen.restoreFocus()
|
|
172
|
+
}
|
|
173
|
+
self.screen.render()
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
this.on(
|
|
177
|
+
'file',
|
|
178
|
+
(onfile = function (file) {
|
|
179
|
+
resume()
|
|
180
|
+
return callback(null, file)
|
|
181
|
+
})
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
this.on(
|
|
185
|
+
'cancel',
|
|
186
|
+
(oncancel = function () {
|
|
187
|
+
resume()
|
|
188
|
+
return callback()
|
|
189
|
+
})
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
this.refresh(cwd, function (err) {
|
|
193
|
+
if (err) {
|
|
194
|
+
return callback(err)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (hidden) {
|
|
198
|
+
self.show()
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (!focused) {
|
|
202
|
+
self.screen.saveFocus()
|
|
203
|
+
self.focus()
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
self.screen.render()
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
FileManager.prototype.reset = function (cwd, callback) {
|
|
211
|
+
if (!callback) {
|
|
212
|
+
callback = cwd
|
|
213
|
+
cwd = null
|
|
214
|
+
}
|
|
215
|
+
this.cwd = cwd || this.options.cwd
|
|
216
|
+
this.refresh(callback)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Expose
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
module.exports = FileManager
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* form.js - form 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
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Form
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function Form(options) {
|
|
19
|
+
const self = this
|
|
20
|
+
|
|
21
|
+
if (!(this instanceof Node)) {
|
|
22
|
+
return new Form(options)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
options = options || {}
|
|
26
|
+
|
|
27
|
+
options.ignoreKeys = true
|
|
28
|
+
Box.call(this, options)
|
|
29
|
+
|
|
30
|
+
if (options.keys) {
|
|
31
|
+
this.screen._listenKeys(this)
|
|
32
|
+
this.on('element keypress', function (el, ch, key) {
|
|
33
|
+
if (
|
|
34
|
+
(key.name === 'tab' && !key.shift) ||
|
|
35
|
+
(el.type === 'textbox' && options.autoNext && key.name === 'enter') ||
|
|
36
|
+
key.name === 'down' ||
|
|
37
|
+
(options.vi && key.name === 'j')
|
|
38
|
+
) {
|
|
39
|
+
if (el.type === 'textbox' || el.type === 'textarea') {
|
|
40
|
+
if (key.name === 'j') {
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
if (key.name === 'tab') {
|
|
44
|
+
// Workaround, since we can't stop the tab from being added.
|
|
45
|
+
el.emit('keypress', null, { name: 'backspace' })
|
|
46
|
+
}
|
|
47
|
+
el.emit('keypress', '\x1b', { name: 'escape' })
|
|
48
|
+
}
|
|
49
|
+
self.focusNext()
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (
|
|
54
|
+
(key.name === 'tab' && key.shift) ||
|
|
55
|
+
key.name === 'up' ||
|
|
56
|
+
(options.vi && key.name === 'k')
|
|
57
|
+
) {
|
|
58
|
+
if (el.type === 'textbox' || el.type === 'textarea') {
|
|
59
|
+
if (key.name === 'k') {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
el.emit('keypress', '\x1b', { name: 'escape' })
|
|
63
|
+
}
|
|
64
|
+
self.focusPrevious()
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (key.name === 'escape') {
|
|
69
|
+
self.focus()
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
Object.setPrototypeOf(Form.prototype, Box.prototype)
|
|
77
|
+
|
|
78
|
+
Form.prototype.type = 'form'
|
|
79
|
+
|
|
80
|
+
Form.prototype._refresh = function () {
|
|
81
|
+
// XXX Possibly remove this if statement and refresh on every focus.
|
|
82
|
+
// Also potentially only include *visible* focusable elements.
|
|
83
|
+
// This would remove the need to check for _selected.visible in previous()
|
|
84
|
+
// and next().
|
|
85
|
+
if (!this._children) {
|
|
86
|
+
const out = []
|
|
87
|
+
|
|
88
|
+
this.children.forEach(function fn(el) {
|
|
89
|
+
if (el.keyable) {
|
|
90
|
+
out.push(el)
|
|
91
|
+
}
|
|
92
|
+
el.children.forEach(fn)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
this._children = out
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
Form.prototype._visible = function () {
|
|
100
|
+
return !!this._children.filter(function (el) {
|
|
101
|
+
return el.visible
|
|
102
|
+
}).length
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
Form.prototype.next = function () {
|
|
106
|
+
this._refresh()
|
|
107
|
+
|
|
108
|
+
if (!this._visible()) {
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!this._selected) {
|
|
113
|
+
this._selected = this._children[0]
|
|
114
|
+
if (!this._selected.visible) {
|
|
115
|
+
return this.next()
|
|
116
|
+
}
|
|
117
|
+
if (this.screen.focused !== this._selected) {
|
|
118
|
+
return this._selected
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const i = this._children.indexOf(this._selected)
|
|
123
|
+
if (!~i || !this._children[i + 1]) {
|
|
124
|
+
this._selected = this._children[0]
|
|
125
|
+
if (!this._selected.visible) {
|
|
126
|
+
return this.next()
|
|
127
|
+
}
|
|
128
|
+
return this._selected
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
this._selected = this._children[i + 1]
|
|
132
|
+
if (!this._selected.visible) {
|
|
133
|
+
return this.next()
|
|
134
|
+
}
|
|
135
|
+
return this._selected
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
Form.prototype.previous = function () {
|
|
139
|
+
this._refresh()
|
|
140
|
+
|
|
141
|
+
if (!this._visible()) {
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!this._selected) {
|
|
146
|
+
this._selected = this._children[this._children.length - 1]
|
|
147
|
+
if (!this._selected.visible) {
|
|
148
|
+
return this.previous()
|
|
149
|
+
}
|
|
150
|
+
if (this.screen.focused !== this._selected) {
|
|
151
|
+
return this._selected
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const i = this._children.indexOf(this._selected)
|
|
156
|
+
if (!~i || !this._children[i - 1]) {
|
|
157
|
+
this._selected = this._children[this._children.length - 1]
|
|
158
|
+
if (!this._selected.visible) {
|
|
159
|
+
return this.previous()
|
|
160
|
+
}
|
|
161
|
+
return this._selected
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this._selected = this._children[i - 1]
|
|
165
|
+
if (!this._selected.visible) {
|
|
166
|
+
return this.previous()
|
|
167
|
+
}
|
|
168
|
+
return this._selected
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
Form.prototype.focusNext = function () {
|
|
172
|
+
const next = this.next()
|
|
173
|
+
if (next) {
|
|
174
|
+
next.focus()
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
Form.prototype.focusPrevious = function () {
|
|
179
|
+
const previous = this.previous()
|
|
180
|
+
if (previous) {
|
|
181
|
+
previous.focus()
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
Form.prototype.resetSelected = function () {
|
|
186
|
+
this._selected = null
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
Form.prototype.focusFirst = function () {
|
|
190
|
+
this.resetSelected()
|
|
191
|
+
this.focusNext()
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
Form.prototype.focusLast = function () {
|
|
195
|
+
this.resetSelected()
|
|
196
|
+
this.focusPrevious()
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
Form.prototype.submit = function () {
|
|
200
|
+
const out = {}
|
|
201
|
+
|
|
202
|
+
this.children.forEach(function fn(el) {
|
|
203
|
+
if (el.value != null) {
|
|
204
|
+
const name = el.name || el.type
|
|
205
|
+
if (Array.isArray(out[name])) {
|
|
206
|
+
out[name].push(el.value)
|
|
207
|
+
} else if (out[name]) {
|
|
208
|
+
out[name] = [out[name], el.value]
|
|
209
|
+
} else {
|
|
210
|
+
out[name] = el.value
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
el.children.forEach(fn)
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
this.emit('submit', out)
|
|
217
|
+
|
|
218
|
+
return (this.submission = out)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
Form.prototype.cancel = function () {
|
|
222
|
+
this.emit('cancel')
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
Form.prototype.reset = function () {
|
|
226
|
+
this.children.forEach(function fn(el) {
|
|
227
|
+
switch (el.type) {
|
|
228
|
+
case 'screen':
|
|
229
|
+
break
|
|
230
|
+
case 'box':
|
|
231
|
+
break
|
|
232
|
+
case 'text':
|
|
233
|
+
break
|
|
234
|
+
case 'line':
|
|
235
|
+
break
|
|
236
|
+
case 'scrollable-box':
|
|
237
|
+
break
|
|
238
|
+
case 'list':
|
|
239
|
+
el.select(0)
|
|
240
|
+
return
|
|
241
|
+
case 'form':
|
|
242
|
+
break
|
|
243
|
+
case 'input':
|
|
244
|
+
break
|
|
245
|
+
case 'textbox':
|
|
246
|
+
el.clearInput()
|
|
247
|
+
return
|
|
248
|
+
case 'textarea':
|
|
249
|
+
el.clearInput()
|
|
250
|
+
return
|
|
251
|
+
case 'button':
|
|
252
|
+
delete el.value
|
|
253
|
+
break
|
|
254
|
+
case 'progress-bar':
|
|
255
|
+
el.setProgress(0)
|
|
256
|
+
break
|
|
257
|
+
case 'file-manager':
|
|
258
|
+
el.refresh(el.options.cwd)
|
|
259
|
+
return
|
|
260
|
+
case 'checkbox':
|
|
261
|
+
el.uncheck()
|
|
262
|
+
return
|
|
263
|
+
case 'radio-set':
|
|
264
|
+
break
|
|
265
|
+
case 'radio-button':
|
|
266
|
+
el.uncheck()
|
|
267
|
+
return
|
|
268
|
+
case 'prompt':
|
|
269
|
+
break
|
|
270
|
+
case 'question':
|
|
271
|
+
break
|
|
272
|
+
case 'message':
|
|
273
|
+
break
|
|
274
|
+
case 'info':
|
|
275
|
+
break
|
|
276
|
+
case 'loading':
|
|
277
|
+
break
|
|
278
|
+
case 'list-bar':
|
|
279
|
+
//el.select(0);
|
|
280
|
+
break
|
|
281
|
+
case 'dir-manager':
|
|
282
|
+
el.refresh(el.options.cwd)
|
|
283
|
+
return
|
|
284
|
+
case 'terminal':
|
|
285
|
+
el.write('')
|
|
286
|
+
return
|
|
287
|
+
case 'image':
|
|
288
|
+
//el.clearImage();
|
|
289
|
+
return
|
|
290
|
+
}
|
|
291
|
+
el.children.forEach(fn)
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
this.emit('reset')
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Expose
|
|
299
|
+
*/
|
|
300
|
+
|
|
301
|
+
module.exports = Form
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* image.js - image 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
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Image
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function Image(options) {
|
|
19
|
+
if (!(this instanceof Node)) {
|
|
20
|
+
return new Image(options)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
options = options || {}
|
|
24
|
+
options.type = options.itype || options.type || 'ansi'
|
|
25
|
+
|
|
26
|
+
Box.call(this, options)
|
|
27
|
+
|
|
28
|
+
if (options.type === 'ansi' && this.type !== 'ansiimage') {
|
|
29
|
+
const ANSIImage = require('./ansiimage')
|
|
30
|
+
Object.getOwnPropertyNames(ANSIImage.prototype).forEach(function (key) {
|
|
31
|
+
if (key === 'type') {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(
|
|
35
|
+
this,
|
|
36
|
+
key,
|
|
37
|
+
Object.getOwnPropertyDescriptor(ANSIImage.prototype, key)
|
|
38
|
+
)
|
|
39
|
+
}, this)
|
|
40
|
+
ANSIImage.call(this, options)
|
|
41
|
+
return this
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (options.type === 'overlay' && this.type !== 'overlayimage') {
|
|
45
|
+
const OverlayImage = require('./overlayimage')
|
|
46
|
+
Object.getOwnPropertyNames(OverlayImage.prototype).forEach(function (key) {
|
|
47
|
+
if (key === 'type') {
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
Object.defineProperty(
|
|
51
|
+
this,
|
|
52
|
+
key,
|
|
53
|
+
Object.getOwnPropertyDescriptor(OverlayImage.prototype, key)
|
|
54
|
+
)
|
|
55
|
+
}, this)
|
|
56
|
+
OverlayImage.call(this, options)
|
|
57
|
+
return this
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
throw new Error('`type` must either be `ansi` or `overlay`.')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Object.setPrototypeOf(Image.prototype, Box.prototype)
|
|
64
|
+
|
|
65
|
+
Image.prototype.type = 'image'
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Expose
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
module.exports = Image
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* input.js - abstract input 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
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Input
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function Input(options) {
|
|
19
|
+
if (!(this instanceof Node)) {
|
|
20
|
+
return new Input(options)
|
|
21
|
+
}
|
|
22
|
+
options = options || {}
|
|
23
|
+
Box.call(this, options)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Object.setPrototypeOf(Input.prototype, Box.prototype)
|
|
27
|
+
|
|
28
|
+
Input.prototype.type = 'input'
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Expose
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
module.exports = Input
|