@socketsecurity/cli-with-sentry 0.14.67 → 0.14.69
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/lib/alias.js +521 -0
- package/dist/blessed/lib/blessed.js +34 -0
- package/dist/blessed/lib/colors.js +492 -0
- package/dist/blessed/lib/events.js +197 -0
- package/dist/blessed/lib/gpmclient.js +247 -0
- package/dist/blessed/lib/helpers.js +172 -0
- package/dist/blessed/lib/keys.js +514 -0
- package/dist/blessed/lib/program.js +4532 -0
- package/dist/blessed/lib/tput.js +3113 -0
- package/dist/blessed/lib/unicode.js +914 -0
- package/dist/blessed/lib/widget.js +62 -0
- package/dist/blessed/lib/widgets/ansiimage.js +175 -0
- package/dist/blessed/lib/widgets/bigtext.js +172 -0
- package/dist/blessed/lib/widgets/box.js +36 -0
- package/dist/blessed/lib/widgets/button.js +64 -0
- package/dist/blessed/lib/widgets/checkbox.js +97 -0
- package/dist/blessed/lib/widgets/element.js +2873 -0
- package/dist/blessed/lib/widgets/filemanager.js +225 -0
- package/dist/blessed/lib/widgets/form.js +303 -0
- package/dist/blessed/lib/widgets/image.js +73 -0
- package/dist/blessed/lib/widgets/input.js +36 -0
- package/dist/blessed/lib/widgets/layout.js +251 -0
- package/dist/blessed/lib/widgets/line.js +61 -0
- package/dist/blessed/lib/widgets/list.js +654 -0
- package/dist/blessed/lib/widgets/listbar.js +454 -0
- package/dist/blessed/lib/widgets/listtable.js +267 -0
- package/dist/blessed/lib/widgets/loading.js +90 -0
- package/dist/blessed/lib/widgets/log.js +84 -0
- package/dist/blessed/lib/widgets/message.js +147 -0
- package/dist/blessed/lib/widgets/node.js +316 -0
- package/dist/blessed/lib/widgets/overlayimage.js +796 -0
- package/dist/blessed/lib/widgets/progressbar.js +168 -0
- package/dist/blessed/lib/widgets/prompt.js +129 -0
- package/dist/blessed/lib/widgets/question.js +131 -0
- package/dist/blessed/lib/widgets/radiobutton.js +64 -0
- package/dist/blessed/lib/widgets/radioset.js +38 -0
- package/dist/blessed/lib/widgets/screen.js +2489 -0
- package/dist/blessed/lib/widgets/scrollablebox.js +417 -0
- package/dist/blessed/lib/widgets/scrollabletext.js +37 -0
- package/dist/blessed/lib/widgets/table.js +385 -0
- package/dist/blessed/lib/widgets/terminal.js +454 -0
- package/dist/blessed/lib/widgets/text.js +37 -0
- package/dist/blessed/lib/widgets/textarea.js +378 -0
- package/dist/blessed/lib/widgets/textbox.js +81 -0
- package/dist/blessed/lib/widgets/video.js +132 -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 +1878 -0
- package/dist/constants.d.ts +271 -207
- package/dist/constants.js +271 -227
- package/dist/constants.js.map +1 -1
- package/dist/instrument-with-sentry.d.ts +1 -1
- package/dist/instrument-with-sentry.js +27 -24
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/module-sync/artifact.d.ts +60 -26
- package/dist/module-sync/cli.d.ts +1 -1
- package/dist/module-sync/cli.js +6803 -4726
- package/dist/module-sync/cli.js.map +1 -1
- package/dist/module-sync/cmd.d.ts +4 -4
- package/dist/module-sync/config.d.ts +42 -17
- package/dist/module-sync/edge.d.ts +73 -60
- package/dist/module-sync/errors.d.ts +26 -11
- package/dist/module-sync/index.d.ts +31 -20
- package/dist/module-sync/node.d.ts +118 -83
- package/dist/module-sync/override-set.d.ts +39 -33
- package/dist/module-sync/package-environment.d.ts +83 -52
- package/dist/module-sync/path-resolve.d.ts +14 -9
- package/dist/module-sync/sdk.d.ts +9 -5
- package/dist/module-sync/shadow-bin.d.ts +5 -2
- package/dist/module-sync/shadow-bin.js +82 -66
- package/dist/module-sync/shadow-bin.js.map +1 -1
- package/dist/module-sync/shadow-npm-inject.d.ts +1 -1
- package/dist/module-sync/shadow-npm-inject.js +1231 -986
- package/dist/module-sync/shadow-npm-inject.js.map +1 -1
- package/dist/module-sync/shadow-npm-paths.d.ts +28 -14
- package/dist/module-sync/shadow-npm-paths.js +300 -208
- package/dist/module-sync/shadow-npm-paths.js.map +1 -1
- package/dist/module-sync/socket-package-alert.d.ts +95 -39
- package/dist/module-sync/types.d.ts +75 -47
- package/dist/module-sync/vendor.js +15055 -0
- package/dist/module-sync/vendor.js.map +1 -0
- package/dist/require/cli.d.ts +1 -1
- package/dist/require/cli.js +6802 -4724
- package/dist/require/cli.js.map +1 -1
- package/dist/require/vendor.js +2 -9145
- package/package.json +48 -38
- package/dist/require/vendor.js.map +0 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* widget.js - high-level interface for blessed
|
|
5
|
+
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
|
|
6
|
+
* https://github.com/chjj/blessed
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const widget = exports
|
|
10
|
+
|
|
11
|
+
widget.classes = [
|
|
12
|
+
'Node',
|
|
13
|
+
'Screen',
|
|
14
|
+
'Element',
|
|
15
|
+
'Box',
|
|
16
|
+
'Text',
|
|
17
|
+
'Line',
|
|
18
|
+
'ScrollableBox',
|
|
19
|
+
'ScrollableText',
|
|
20
|
+
'BigText',
|
|
21
|
+
'List',
|
|
22
|
+
'Form',
|
|
23
|
+
'Input',
|
|
24
|
+
'Textarea',
|
|
25
|
+
'Textbox',
|
|
26
|
+
'Button',
|
|
27
|
+
'ProgressBar',
|
|
28
|
+
'FileManager',
|
|
29
|
+
'Checkbox',
|
|
30
|
+
'RadioSet',
|
|
31
|
+
'RadioButton',
|
|
32
|
+
'Prompt',
|
|
33
|
+
'Question',
|
|
34
|
+
'Message',
|
|
35
|
+
'Loading',
|
|
36
|
+
'Listbar',
|
|
37
|
+
'Log',
|
|
38
|
+
'Table',
|
|
39
|
+
'ListTable',
|
|
40
|
+
'Terminal',
|
|
41
|
+
'Image',
|
|
42
|
+
'ANSIImage',
|
|
43
|
+
'OverlayImage',
|
|
44
|
+
'Video',
|
|
45
|
+
'Layout'
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
widget.classes.forEach(function (name) {
|
|
49
|
+
const file = name.toLowerCase()
|
|
50
|
+
widget[name] = widget[file] = require('./widgets/' + file)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
widget.aliases = {
|
|
54
|
+
ListBar: 'Listbar',
|
|
55
|
+
PNG: 'ANSIImage'
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
Object.keys(widget.aliases).forEach(function (key) {
|
|
59
|
+
const name = widget.aliases[key]
|
|
60
|
+
widget[key] = widget[name]
|
|
61
|
+
widget[key.toLowerCase()] = widget[name]
|
|
62
|
+
})
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ansiimage.js - render PNGS/GIFS as ANSI
|
|
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 cp = require('node:child_process')
|
|
14
|
+
|
|
15
|
+
const colors = require('../colors')
|
|
16
|
+
|
|
17
|
+
const Node = require('./node')
|
|
18
|
+
const Box = require('./box')
|
|
19
|
+
|
|
20
|
+
const tng = require('../../vendor/tng')
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* ANSIImage
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
function ANSIImage(options) {
|
|
27
|
+
const self = this
|
|
28
|
+
|
|
29
|
+
if (!(this instanceof Node)) {
|
|
30
|
+
return new ANSIImage(options)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
options = options || {}
|
|
34
|
+
options.shrink = true
|
|
35
|
+
|
|
36
|
+
Box.call(this, options)
|
|
37
|
+
|
|
38
|
+
this.scale = this.options.scale || 1.0
|
|
39
|
+
this.options.animate = this.options.animate !== false
|
|
40
|
+
this._noFill = true
|
|
41
|
+
|
|
42
|
+
if (this.options.file) {
|
|
43
|
+
this.setImage(this.options.file)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.screen.on('prerender', function () {
|
|
47
|
+
const lpos = self.lpos
|
|
48
|
+
if (!lpos) {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
// prevent image from blending with itself if there are alpha channels
|
|
52
|
+
self.screen.clearRegion(lpos.xi, lpos.xl, lpos.yi, lpos.yl)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
this.on('destroy', function () {
|
|
56
|
+
self.stop()
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
Object.setPrototypeOf(ANSIImage.prototype, Box.prototype)
|
|
61
|
+
|
|
62
|
+
ANSIImage.prototype.type = 'ansiimage'
|
|
63
|
+
|
|
64
|
+
ANSIImage.curl = function (url) {
|
|
65
|
+
try {
|
|
66
|
+
return cp.execFileSync('curl', ['-s', '-A', '', url], {
|
|
67
|
+
stdio: ['ignore', 'pipe', 'ignore']
|
|
68
|
+
})
|
|
69
|
+
} catch (e) {}
|
|
70
|
+
try {
|
|
71
|
+
return cp.execFileSync('wget', ['-U', '', '-O', '-', url], {
|
|
72
|
+
stdio: ['ignore', 'pipe', 'ignore']
|
|
73
|
+
})
|
|
74
|
+
} catch (e) {}
|
|
75
|
+
throw new Error('curl or wget failed.')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
ANSIImage.prototype.setImage = function (file) {
|
|
79
|
+
this.file = typeof file === 'string' ? file : null
|
|
80
|
+
|
|
81
|
+
if (/^https?:/.test(file)) {
|
|
82
|
+
file = ANSIImage.curl(file)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let width = this.position.width
|
|
86
|
+
let height = this.position.height
|
|
87
|
+
|
|
88
|
+
if (width != null) {
|
|
89
|
+
width = this.width
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (height != null) {
|
|
93
|
+
height = this.height
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
this.setContent('')
|
|
98
|
+
|
|
99
|
+
this.img = tng(file, {
|
|
100
|
+
colors: colors,
|
|
101
|
+
width: width,
|
|
102
|
+
height: height,
|
|
103
|
+
scale: this.scale,
|
|
104
|
+
ascii: this.options.ascii,
|
|
105
|
+
speed: this.options.speed,
|
|
106
|
+
filename: this.file
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
if (width == null || height == null) {
|
|
110
|
+
this.width = this.img.cellmap[0].length
|
|
111
|
+
this.height = this.img.cellmap.length
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (this.img.frames && this.options.animate) {
|
|
115
|
+
this.play()
|
|
116
|
+
} else {
|
|
117
|
+
this.cellmap = this.img.cellmap
|
|
118
|
+
}
|
|
119
|
+
} catch (e) {
|
|
120
|
+
this.setContent('Image Error: ' + e.message)
|
|
121
|
+
this.img = null
|
|
122
|
+
this.cellmap = null
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
ANSIImage.prototype.play = function () {
|
|
127
|
+
const self = this
|
|
128
|
+
if (!this.img) {
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
return this.img.play(function (bmp, cellmap) {
|
|
132
|
+
self.cellmap = cellmap
|
|
133
|
+
self.screen.render()
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
ANSIImage.prototype.pause = function () {
|
|
138
|
+
if (!this.img) {
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
return this.img.pause()
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
ANSIImage.prototype.stop = function () {
|
|
145
|
+
if (!this.img) {
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
return this.img.stop()
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
ANSIImage.prototype.clearImage = function () {
|
|
152
|
+
this.stop()
|
|
153
|
+
this.setContent('')
|
|
154
|
+
this.img = null
|
|
155
|
+
this.cellmap = null
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
ANSIImage.prototype.render = function () {
|
|
159
|
+
const coords = this._render()
|
|
160
|
+
if (!coords) {
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (this.img && this.cellmap) {
|
|
165
|
+
this.img.renderElement(this.cellmap, this)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return coords
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Expose
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
module.exports = ANSIImage
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* bigtext.js - bigtext 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 fs = require('node:fs')
|
|
14
|
+
|
|
15
|
+
const Node = require('./node')
|
|
16
|
+
const Box = require('./box')
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* BigText
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function BigText(options) {
|
|
23
|
+
if (!(this instanceof Node)) {
|
|
24
|
+
return new BigText(options)
|
|
25
|
+
}
|
|
26
|
+
options = options || {}
|
|
27
|
+
options.font = options.font || __dirname + '/../../usr/fonts/ter-u14n.json'
|
|
28
|
+
options.fontBold =
|
|
29
|
+
options.font || __dirname + '/../../usr/fonts/ter-u14b.json'
|
|
30
|
+
this.fch = options.fch
|
|
31
|
+
this.ratio = {}
|
|
32
|
+
this.font = this.loadFont(options.font)
|
|
33
|
+
this.fontBold = this.loadFont(options.font)
|
|
34
|
+
Box.call(this, options)
|
|
35
|
+
if (this.style.bold) {
|
|
36
|
+
this.font = this.fontBold
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Object.setPrototypeOf(BigText.prototype, Box.prototype)
|
|
41
|
+
|
|
42
|
+
BigText.prototype.type = 'bigtext'
|
|
43
|
+
|
|
44
|
+
BigText.prototype.loadFont = function (filename) {
|
|
45
|
+
let self = this,
|
|
46
|
+
data,
|
|
47
|
+
font
|
|
48
|
+
|
|
49
|
+
data = JSON.parse(fs.readFileSync(filename, 'utf8'))
|
|
50
|
+
|
|
51
|
+
this.ratio.width = data.width
|
|
52
|
+
this.ratio.height = data.height
|
|
53
|
+
|
|
54
|
+
function convertLetter(ch, lines) {
|
|
55
|
+
let line, i
|
|
56
|
+
|
|
57
|
+
while (lines.length > self.ratio.height) {
|
|
58
|
+
lines.shift()
|
|
59
|
+
lines.pop()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
lines = lines.map(function (line) {
|
|
63
|
+
let chs = line.split('')
|
|
64
|
+
chs = chs.map(function (ch) {
|
|
65
|
+
return ch === ' ' ? 0 : 1
|
|
66
|
+
})
|
|
67
|
+
while (chs.length < self.ratio.width) {
|
|
68
|
+
chs.push(0)
|
|
69
|
+
}
|
|
70
|
+
return chs
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
while (lines.length < self.ratio.height) {
|
|
74
|
+
line = []
|
|
75
|
+
for (i = 0; i < self.ratio.width; i++) {
|
|
76
|
+
line.push(0)
|
|
77
|
+
}
|
|
78
|
+
lines.push(line)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return lines
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
font = Object.keys(data.glyphs).reduce(function (out, ch) {
|
|
85
|
+
const lines = data.glyphs[ch].map
|
|
86
|
+
out[ch] = convertLetter(ch, lines)
|
|
87
|
+
return out
|
|
88
|
+
}, {})
|
|
89
|
+
|
|
90
|
+
delete font[' ']
|
|
91
|
+
|
|
92
|
+
return font
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
BigText.prototype.setContent = function (content) {
|
|
96
|
+
this.content = ''
|
|
97
|
+
this.text = content || ''
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
BigText.prototype.render = function () {
|
|
101
|
+
if (this.position.width == null || this._shrinkWidth) {
|
|
102
|
+
// if (this.width - this.iwidth < this.ratio.width * this.text.length + 1) {
|
|
103
|
+
this.position.width = this.ratio.width * this.text.length + 1
|
|
104
|
+
this._shrinkWidth = true
|
|
105
|
+
// }
|
|
106
|
+
}
|
|
107
|
+
if (this.position.height == null || this._shrinkHeight) {
|
|
108
|
+
// if (this.height - this.iheight < this.ratio.height + 0) {
|
|
109
|
+
this.position.height = this.ratio.height + 0
|
|
110
|
+
this._shrinkHeight = true
|
|
111
|
+
// }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const coords = this._render()
|
|
115
|
+
if (!coords) {
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const lines = this.screen.lines,
|
|
120
|
+
left = coords.xi + this.ileft,
|
|
121
|
+
top = coords.yi + this.itop,
|
|
122
|
+
right = coords.xl - this.iright,
|
|
123
|
+
bottom = coords.yl - this.ibottom
|
|
124
|
+
|
|
125
|
+
const dattr = this.sattr(this.style),
|
|
126
|
+
bg = dattr & 0x1ff,
|
|
127
|
+
fg = (dattr >> 9) & 0x1ff,
|
|
128
|
+
flags = (dattr >> 18) & 0x1ff,
|
|
129
|
+
attr = (flags << 18) | (bg << 9) | fg
|
|
130
|
+
|
|
131
|
+
for (let x = left, i = 0; x < right; x += this.ratio.width, i++) {
|
|
132
|
+
const ch = this.text[i]
|
|
133
|
+
if (!ch) {
|
|
134
|
+
break
|
|
135
|
+
}
|
|
136
|
+
const map = this.font[ch]
|
|
137
|
+
if (!map) {
|
|
138
|
+
continue
|
|
139
|
+
}
|
|
140
|
+
for (let y = top; y < Math.min(bottom, top + this.ratio.height); y++) {
|
|
141
|
+
if (!lines[y]) {
|
|
142
|
+
continue
|
|
143
|
+
}
|
|
144
|
+
const mline = map[y - top]
|
|
145
|
+
if (!mline) {
|
|
146
|
+
continue
|
|
147
|
+
}
|
|
148
|
+
for (let mx = 0; mx < this.ratio.width; mx++) {
|
|
149
|
+
const mcell = mline[mx]
|
|
150
|
+
if (mcell == null) {
|
|
151
|
+
break
|
|
152
|
+
}
|
|
153
|
+
if (this.fch && this.fch !== ' ') {
|
|
154
|
+
lines[y][x + mx][0] = dattr
|
|
155
|
+
lines[y][x + mx][1] = mcell === 1 ? this.fch : this.ch
|
|
156
|
+
} else {
|
|
157
|
+
lines[y][x + mx][0] = mcell === 1 ? attr : dattr
|
|
158
|
+
lines[y][x + mx][1] = mcell === 1 ? ' ' : this.ch
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
lines[y].dirty = true
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return coords
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Expose
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
module.exports = BigText
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* box.js - box 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 Element = require('./element')
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Box
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function Box(options) {
|
|
21
|
+
if (!(this instanceof Node)) {
|
|
22
|
+
return new Box(options)
|
|
23
|
+
}
|
|
24
|
+
options = options || {}
|
|
25
|
+
Element.call(this, options)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Object.setPrototypeOf(Box.prototype, Element.prototype)
|
|
29
|
+
|
|
30
|
+
Box.prototype.type = 'box'
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Expose
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
module.exports = Box
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* button.js - button 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 Input = require('./input')
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Button
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function Button(options) {
|
|
21
|
+
const self = this
|
|
22
|
+
|
|
23
|
+
if (!(this instanceof Node)) {
|
|
24
|
+
return new Button(options)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
options = options || {}
|
|
28
|
+
|
|
29
|
+
if (options.autoFocus == null) {
|
|
30
|
+
options.autoFocus = false
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Input.call(this, options)
|
|
34
|
+
|
|
35
|
+
this.on('keypress', function (ch, key) {
|
|
36
|
+
if (key.name === 'enter' || key.name === 'space') {
|
|
37
|
+
return self.press()
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
if (this.options.mouse) {
|
|
42
|
+
this.on('click', function () {
|
|
43
|
+
return self.press()
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Object.setPrototypeOf(Button.prototype, Input.prototype)
|
|
49
|
+
|
|
50
|
+
Button.prototype.type = 'button'
|
|
51
|
+
|
|
52
|
+
Button.prototype.press = function () {
|
|
53
|
+
this.focus()
|
|
54
|
+
this.value = true
|
|
55
|
+
const result = this.emit('press')
|
|
56
|
+
delete this.value
|
|
57
|
+
return result
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Expose
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
module.exports = Button
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* checkbox.js - checkbox 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 Input = require('./input')
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Checkbox
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function Checkbox(options) {
|
|
21
|
+
const self = this
|
|
22
|
+
|
|
23
|
+
if (!(this instanceof Node)) {
|
|
24
|
+
return new Checkbox(options)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
options = options || {}
|
|
28
|
+
|
|
29
|
+
Input.call(this, options)
|
|
30
|
+
|
|
31
|
+
this.text = options.content || options.text || ''
|
|
32
|
+
this.checked = this.value = options.checked || false
|
|
33
|
+
|
|
34
|
+
this.on('keypress', function (ch, key) {
|
|
35
|
+
if (key.name === 'enter' || key.name === 'space') {
|
|
36
|
+
self.toggle()
|
|
37
|
+
self.screen.render()
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
if (options.mouse) {
|
|
42
|
+
this.on('click', function () {
|
|
43
|
+
self.toggle()
|
|
44
|
+
self.screen.render()
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.on('focus', function () {
|
|
49
|
+
const lpos = self.lpos
|
|
50
|
+
if (!lpos) {
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
self.screen.program.lsaveCursor('checkbox')
|
|
54
|
+
self.screen.program.cup(lpos.yi, lpos.xi + 1)
|
|
55
|
+
self.screen.program.showCursor()
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
this.on('blur', function () {
|
|
59
|
+
self.screen.program.lrestoreCursor('checkbox', true)
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Object.setPrototypeOf(Checkbox.prototype, Input.prototype)
|
|
64
|
+
|
|
65
|
+
Checkbox.prototype.type = 'checkbox'
|
|
66
|
+
|
|
67
|
+
Checkbox.prototype.render = function () {
|
|
68
|
+
this.clearPos(true)
|
|
69
|
+
this.setContent('[' + (this.checked ? 'x' : ' ') + '] ' + this.text, true)
|
|
70
|
+
return this._render()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
Checkbox.prototype.check = function () {
|
|
74
|
+
if (this.checked) {
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
this.checked = this.value = true
|
|
78
|
+
this.emit('check')
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
Checkbox.prototype.uncheck = function () {
|
|
82
|
+
if (!this.checked) {
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
this.checked = this.value = false
|
|
86
|
+
this.emit('uncheck')
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
Checkbox.prototype.toggle = function () {
|
|
90
|
+
return this.checked ? this.uncheck() : this.check()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Expose
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
module.exports = Checkbox
|