@socketsecurity/cli-with-sentry 0.14.137 → 0.14.139
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/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/package.json +4 -4
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const Node = require('../../../blessed/lib/widgets/node'),
|
|
3
|
+
Canvas = require('./canvas')
|
|
4
|
+
|
|
5
|
+
function LCD(options) {
|
|
6
|
+
if (!(this instanceof Node)) {
|
|
7
|
+
return new LCD(options)
|
|
8
|
+
}
|
|
9
|
+
const self = this
|
|
10
|
+
|
|
11
|
+
options = options || {}
|
|
12
|
+
self.options = options
|
|
13
|
+
|
|
14
|
+
//these options need to be modified epending on the resulting positioning/size
|
|
15
|
+
self.options.segmentWidth = options.segmentWidth || 0.06 // how wide are the segments in % so 50% = 0.5
|
|
16
|
+
self.options.segmentInterval = options.segmentInterval || 0.11 // spacing between the segments in % so 50% = 0.5
|
|
17
|
+
self.options.strokeWidth = options.strokeWidth || 0.11 // spacing between the segments in % so 50% = 0.5
|
|
18
|
+
|
|
19
|
+
//default display settings
|
|
20
|
+
self.options.elements = options.elements || 3 // how many elements in the display. or how many characters can be displayed.
|
|
21
|
+
self.options.display = options.display || 321 // what should be displayed before anything is set
|
|
22
|
+
self.options.elementSpacing = options.spacing || 4 // spacing between each element
|
|
23
|
+
self.options.elementPadding = options.padding || 2 // how far away from the edges to put the elements
|
|
24
|
+
|
|
25
|
+
//coloring
|
|
26
|
+
self.options.color = options.color || 'white'
|
|
27
|
+
|
|
28
|
+
Canvas.call(this, options)
|
|
29
|
+
|
|
30
|
+
this.segment16 = null
|
|
31
|
+
|
|
32
|
+
this.on('attach', function () {
|
|
33
|
+
const display = self.options.display || 1234
|
|
34
|
+
if (!this.segment16) {
|
|
35
|
+
this.segment16 = new SixteenSegment(
|
|
36
|
+
this.options.elements,
|
|
37
|
+
this.ctx,
|
|
38
|
+
this.canvasSize.width,
|
|
39
|
+
this.canvasSize.height,
|
|
40
|
+
0,
|
|
41
|
+
0,
|
|
42
|
+
this.options
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.setDisplay(display)
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
LCD.prototype = Object.create(Canvas.prototype)
|
|
51
|
+
|
|
52
|
+
LCD.prototype.calcSize = function () {
|
|
53
|
+
this.canvasSize = { width: this.width * 2 - 8, height: this.height * 4 - 12 }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
LCD.prototype.type = 'lcd'
|
|
57
|
+
LCD.prototype.increaseWidth = function () {
|
|
58
|
+
if (this.segment16) {
|
|
59
|
+
this.segment16.SegmentWidth += 0.01
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
LCD.prototype.decreaseWidth = function () {
|
|
63
|
+
if (this.segment16) {
|
|
64
|
+
this.segment16.SegmentWidth -= 0.01
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
LCD.prototype.increaseInterval = function () {
|
|
68
|
+
if (this.segment16) {
|
|
69
|
+
this.segment16.SegmentInterval += 0.01
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
LCD.prototype.decreaseInterval = function () {
|
|
73
|
+
if (this.segment16) {
|
|
74
|
+
this.segment16.SegmentInterval -= 0.01
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
LCD.prototype.increaseStroke = function () {
|
|
78
|
+
if (this.segment16) {
|
|
79
|
+
this.segment16.StrokeWidth += 0.05
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
LCD.prototype.decreaseStroke = function () {
|
|
83
|
+
if (this.segment16) {
|
|
84
|
+
this.segment16.StrokeWidth -= 0.05
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
LCD.prototype.setOptions = function (options) {
|
|
88
|
+
if (this.segment16) {
|
|
89
|
+
this.segment16.setOptions(options)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
LCD.prototype.setData = function (data) {
|
|
94
|
+
this.setDisplay(data.toString())
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
LCD.prototype.getOptionsPrototype = function () {
|
|
98
|
+
return {
|
|
99
|
+
label: 'LCD Test',
|
|
100
|
+
segmentWidth: 0.06,
|
|
101
|
+
segmentInterval: 0.11,
|
|
102
|
+
strokeWidth: 0.1,
|
|
103
|
+
elements: 5,
|
|
104
|
+
display: 3210,
|
|
105
|
+
elementSpacing: 4,
|
|
106
|
+
elementPadding: 2
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
LCD.prototype.setDisplay = function (display) {
|
|
111
|
+
if (!this.ctx) {
|
|
112
|
+
throw 'error: canvas context does not exist. setData() for line charts must be called after the chart has been added to the screen via screen.append()'
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.ctx.clearRect(0, 0, this.canvasSize.width, this.canvasSize.height)
|
|
116
|
+
|
|
117
|
+
this.segment16.DisplayText(display)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function ElementArray(count) {
|
|
121
|
+
this.SetCount = SetCount
|
|
122
|
+
this.SetText = SetText
|
|
123
|
+
this.SetElementValue = SetElementValue
|
|
124
|
+
this.NullMask = 0x10
|
|
125
|
+
this.Elements = []
|
|
126
|
+
this.SetCount(count || 0)
|
|
127
|
+
|
|
128
|
+
function SetCount(count) {
|
|
129
|
+
const c = parseInt(count, 10)
|
|
130
|
+
if (isNaN(c)) {
|
|
131
|
+
throw 'Invalid element count: ' + count
|
|
132
|
+
}
|
|
133
|
+
this.Elements = [c]
|
|
134
|
+
for (let i = 0; i < c; i++) {
|
|
135
|
+
this.Elements[i] = 0
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function SetText(value, charMaps) {
|
|
140
|
+
// Get the string of the value passed in
|
|
141
|
+
if (value === null) {
|
|
142
|
+
value = ''
|
|
143
|
+
}
|
|
144
|
+
value = value.toString()
|
|
145
|
+
|
|
146
|
+
// Clear the elements
|
|
147
|
+
for (let i = 0; i < this.Elements.length; i++) {
|
|
148
|
+
this.SetElementValue(i, 0)
|
|
149
|
+
}
|
|
150
|
+
if (value.length === 0) {
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
// Set the bitmask to dispay the proper character for each element
|
|
154
|
+
for (let e = 0; e < this.Elements.length && e < value.length; e++) {
|
|
155
|
+
const c = value[e]
|
|
156
|
+
let mask = charMaps[c]
|
|
157
|
+
// Use blank of there is no bitmask for this character
|
|
158
|
+
if (mask === null || mask === undefined) {
|
|
159
|
+
mask = this.NullMask
|
|
160
|
+
}
|
|
161
|
+
this.SetElementValue(e, mask)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function SetElementValue(i, value) {
|
|
165
|
+
if (i >= 0 && i < this.Elements.length) {
|
|
166
|
+
this.Elements[i] = parseInt(value, 10)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
//thx to https://github.com/Enderer/sixteensegment!!!
|
|
172
|
+
//although it needed HEAVY rework since it was already somewhat busted ;-(
|
|
173
|
+
function SixteenSegment(count, canvas, width, height, x, y, options) {
|
|
174
|
+
this.ElementArray = new ElementArray(count)
|
|
175
|
+
|
|
176
|
+
this.SegmentWidth = options.segmentWidth //(this.ElementWidth * 0.0015) * 5 //0.1; // Width of segments (% of Element Width)
|
|
177
|
+
this.SegmentInterval = options.segmentInterval //(this.ElementWidth * 0.0015) * 10 // 0.20; // Spacing between segments (% of Element Width)
|
|
178
|
+
this.BevelWidth = 0.01 // Size of corner bevel (% of Element Width)
|
|
179
|
+
this.SideBevelEnabled = true // Should the sides be beveled
|
|
180
|
+
this.StrokeLight = options.color // Color of an on segment outline
|
|
181
|
+
|
|
182
|
+
this.StrokeWidth = options.strokeWidth // Width of segment outline
|
|
183
|
+
this.Padding = options.elementPadding // Padding around the display
|
|
184
|
+
this.Spacing = options.elementSpacing // Spacing between elements
|
|
185
|
+
|
|
186
|
+
this.ElementWidth = (width - this.Spacing * count) / count
|
|
187
|
+
this.ElementHeight = height - this.Padding * 2
|
|
188
|
+
|
|
189
|
+
// console.error("w %s h %s", this.ElementWidth, this.ElementHeight);
|
|
190
|
+
|
|
191
|
+
this.FillLight = 'red' // Color of an on segment
|
|
192
|
+
this.FillDark = 'cyan' // Color of an off segment
|
|
193
|
+
this.StrokeDark = 'black' // Color of an off segment outline
|
|
194
|
+
|
|
195
|
+
this.X = 0
|
|
196
|
+
this.Y = 0
|
|
197
|
+
|
|
198
|
+
this.ElementCount = count
|
|
199
|
+
|
|
200
|
+
this.CalcElementDimensions = CalcElementDimensions
|
|
201
|
+
this.FlipVertical = FlipVertical
|
|
202
|
+
this.FlipHorizontal = FlipHorizontal
|
|
203
|
+
this.CalcPoints = CalcPoints
|
|
204
|
+
this.DisplayText = DisplayText
|
|
205
|
+
this.Draw = Draw
|
|
206
|
+
this.setOptions = setOptions
|
|
207
|
+
|
|
208
|
+
this.Width = width || canvas.width
|
|
209
|
+
this.Height = height || canvas.height
|
|
210
|
+
|
|
211
|
+
this.Canvas = canvas
|
|
212
|
+
this.CalcPoints()
|
|
213
|
+
this.ElementArray.SetCount(count)
|
|
214
|
+
|
|
215
|
+
function setOptions(options) {
|
|
216
|
+
if (options.elements) {
|
|
217
|
+
this.ElementArray.SetCount(options.elements)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
this.SegmentWidth = options.segmentWidth || this.SegmentWidth
|
|
221
|
+
this.SegmentInterval = options.segmentInterval || this.SegmentInterval
|
|
222
|
+
this.BevelWidth = 0.01
|
|
223
|
+
this.SideBevelEnabled = true
|
|
224
|
+
this.StrokeLight = options.color || this.StrokeLight
|
|
225
|
+
|
|
226
|
+
this.StrokeWidth = options.strokeWidth || this.StrokeWidth
|
|
227
|
+
this.Padding = options.elementPadding || this.Padding
|
|
228
|
+
this.Spacing = options.elementSpacing || this.Spacing
|
|
229
|
+
|
|
230
|
+
this.ElementWidth = (width - this.Spacing * count) / count
|
|
231
|
+
this.ElementHeight = height - this.Padding * 2
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function DisplayText(value) {
|
|
235
|
+
// Recalculate points in case any settings changed
|
|
236
|
+
// console.error("si: %s, sw: %s", this.SegmentInterval, this.SegmentWidth);
|
|
237
|
+
// console.error("st: %s", this.StrokeWidth);
|
|
238
|
+
// Set the display patterns and draw the canvas
|
|
239
|
+
this.ElementArray.SetText(value, CharacterMasks)
|
|
240
|
+
this.CalcPoints()
|
|
241
|
+
this.Draw(this.Canvas, this.ElementArray.Elements)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function CalcElementDimensions() {
|
|
245
|
+
const n = this.ElementCount
|
|
246
|
+
let h = this.ElementHeight
|
|
247
|
+
h -= this.Padding * 2
|
|
248
|
+
|
|
249
|
+
let w = this.Width
|
|
250
|
+
w -= this.Spacing * (n - 1)
|
|
251
|
+
w -= this.Padding * 2
|
|
252
|
+
w /= n
|
|
253
|
+
const output = { Width: w, Height: h }
|
|
254
|
+
// console.error(output);
|
|
255
|
+
return output
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function FlipVertical(points, height) {
|
|
259
|
+
const flipped = []
|
|
260
|
+
for (let i = 0; i < points.length; i++) {
|
|
261
|
+
flipped[i] = {}
|
|
262
|
+
flipped[i].x = points[i].x
|
|
263
|
+
flipped[i].y = height - points[i].y
|
|
264
|
+
}
|
|
265
|
+
return flipped
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function FlipHorizontal(points, width) {
|
|
269
|
+
const flipped = []
|
|
270
|
+
for (let i = 0; i < points.length; i++) {
|
|
271
|
+
flipped[i] = {}
|
|
272
|
+
flipped[i].x = width - points[i].x
|
|
273
|
+
flipped[i].y = points[i].y
|
|
274
|
+
}
|
|
275
|
+
return flipped
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function Draw(context, elements) {
|
|
279
|
+
// Get the context and clear the area
|
|
280
|
+
context.clearRect(this.X, this.Y, this.Width, this.Height)
|
|
281
|
+
context.save()
|
|
282
|
+
|
|
283
|
+
// Calculate the width and spacing of each element
|
|
284
|
+
const elementWidth = this.CalcElementDimensions().Width
|
|
285
|
+
// console.error("width: %s", elementWidth);
|
|
286
|
+
// Offset to adjust for starting point and padding
|
|
287
|
+
context.translate(this.X, this.Y)
|
|
288
|
+
context.translate(this.Padding, this.Padding)
|
|
289
|
+
|
|
290
|
+
// Draw each segment of each element
|
|
291
|
+
for (let i = 0; i < elements.length; i++) {
|
|
292
|
+
const element = elements[i]
|
|
293
|
+
for (let s = 0; s < this.Points.length; s++) {
|
|
294
|
+
// Pick the on or off color based on the bitmask
|
|
295
|
+
const color = element & (1 << s) ? this.FillLight : this.FillDark
|
|
296
|
+
const stroke = element & (1 << s) ? this.StrokeLight : this.StrokeDark
|
|
297
|
+
if (stroke == this.StrokeDark) {
|
|
298
|
+
continue
|
|
299
|
+
}
|
|
300
|
+
// console.error("c: %s, s: %s", color, stroke);
|
|
301
|
+
context.lineWidth = this.StrokeWidth
|
|
302
|
+
context.strokeStyle = stroke
|
|
303
|
+
context.fillStyle = color
|
|
304
|
+
context.moveTo(0, 0)
|
|
305
|
+
context.beginPath()
|
|
306
|
+
context.moveTo(this.Points[s][0].x, this.Points[s][0].y)
|
|
307
|
+
// Create the segment path
|
|
308
|
+
let maxX = 0
|
|
309
|
+
for (let p = 1; p < this.Points[s].length; p++) {
|
|
310
|
+
if (this.Points[s][p].x > maxX) {
|
|
311
|
+
maxX = this.Points[s][p].x
|
|
312
|
+
}
|
|
313
|
+
context.lineTo(
|
|
314
|
+
Math.round(this.Points[s][p].x),
|
|
315
|
+
Math.round(this.Points[s][p].y)
|
|
316
|
+
)
|
|
317
|
+
}
|
|
318
|
+
context.closePath()
|
|
319
|
+
context.fill()
|
|
320
|
+
context.stroke()
|
|
321
|
+
if (this.StrokeWidth > 0) {
|
|
322
|
+
context.stroke()
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
context.translate(elementWidth + this.Spacing, 0)
|
|
326
|
+
}
|
|
327
|
+
context.restore()
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function CalcPoints() {
|
|
331
|
+
const w = this.ElementWidth,
|
|
332
|
+
h = this.ElementHeight,
|
|
333
|
+
sw = this.SegmentWidth * w,
|
|
334
|
+
si = this.SegmentInterval * w,
|
|
335
|
+
bw = this.BevelWidth * sw,
|
|
336
|
+
ib = this.SideBevelEnabled ? 1 : 0,
|
|
337
|
+
sf = sw * 0.8,
|
|
338
|
+
slope = h / w,
|
|
339
|
+
sqrt2 = Math.SQRT2,
|
|
340
|
+
sqrt3 = Math.sqrt(3)
|
|
341
|
+
|
|
342
|
+
// Base position of points w/out bevel and interval
|
|
343
|
+
const w0 = w / 2 - sw / 2,
|
|
344
|
+
h0 = 0,
|
|
345
|
+
w1 = w / 2,
|
|
346
|
+
h1 = sw / 2,
|
|
347
|
+
w2 = w / 2 + sw / 2,
|
|
348
|
+
h2 = sw,
|
|
349
|
+
w3 = w - sw,
|
|
350
|
+
h3 = h / 2 - sw / 2,
|
|
351
|
+
w4 = w - sw / 2,
|
|
352
|
+
h4 = h / 2,
|
|
353
|
+
w5 = w,
|
|
354
|
+
h5 = h / 2 + sw / 2
|
|
355
|
+
|
|
356
|
+
// Order of segments stored in Points[][]
|
|
357
|
+
const A1 = 0,
|
|
358
|
+
A2 = 1,
|
|
359
|
+
B = 2,
|
|
360
|
+
C = 3,
|
|
361
|
+
D1 = 4,
|
|
362
|
+
D2 = 5,
|
|
363
|
+
E = 6,
|
|
364
|
+
F = 7,
|
|
365
|
+
G1 = 8,
|
|
366
|
+
G2 = 9,
|
|
367
|
+
H = 10,
|
|
368
|
+
I = 11,
|
|
369
|
+
J = 12,
|
|
370
|
+
K = 13,
|
|
371
|
+
L = 14,
|
|
372
|
+
M = 15
|
|
373
|
+
|
|
374
|
+
// Create the points array for all segments
|
|
375
|
+
const points = []
|
|
376
|
+
points[A1] = [
|
|
377
|
+
{ x: bw * 2 + si / sqrt2, y: h0 },
|
|
378
|
+
{ x: w1 - si / 2 - (sw / 2) * ib, y: h0 },
|
|
379
|
+
{ x: w1 - si / 2, y: h1 },
|
|
380
|
+
{ x: w0 - si / 2, y: h2 },
|
|
381
|
+
{ x: sw + si / sqrt2, y: h2 },
|
|
382
|
+
{ x: bw + si / sqrt2, y: h0 + bw }
|
|
383
|
+
]
|
|
384
|
+
points[G2] = [
|
|
385
|
+
{ x: w2 + si / sqrt2, y: h3 },
|
|
386
|
+
{ x: w3 - (si / 2) * sqrt3, y: h3 },
|
|
387
|
+
{ x: w4 - (si / 2) * sqrt3, y: h4 },
|
|
388
|
+
{ x: w3 - (si / 2) * sqrt3, y: h5 },
|
|
389
|
+
{ x: w2 + si / sqrt2, y: h5 },
|
|
390
|
+
{ x: w1 + si / sqrt2, y: h4 }
|
|
391
|
+
]
|
|
392
|
+
points[B] = [
|
|
393
|
+
{ x: w5, y: h0 + bw * 2 + si / sqrt2 },
|
|
394
|
+
{ x: w5, y: h4 - si / 2 - (sw / 2) * ib },
|
|
395
|
+
{ x: w4, y: h4 - si / 2 },
|
|
396
|
+
{ x: w3, y: h3 - si / 2 },
|
|
397
|
+
{ x: w3, y: h2 + si / sqrt2 },
|
|
398
|
+
{ x: w5 - bw, y: h0 + bw + si / sqrt2 }
|
|
399
|
+
]
|
|
400
|
+
points[I] = [
|
|
401
|
+
{ x: w2, y: h2 + (si / 2) * sqrt3 },
|
|
402
|
+
{ x: w2, y: h3 - si / sqrt2 },
|
|
403
|
+
{ x: w1, y: h4 - si / sqrt2 },
|
|
404
|
+
{ x: w0, y: h3 - si / sqrt2 },
|
|
405
|
+
{ x: w0, y: h2 + (si / 2) * sqrt3 },
|
|
406
|
+
{ x: w1, y: h1 + (si / 2) * sqrt3 }
|
|
407
|
+
]
|
|
408
|
+
points[H] = [
|
|
409
|
+
{ x: (sw + sf) / slope + si, y: h2 + si },
|
|
410
|
+
{ x: w0 - si, y: w0 * slope - sf - si },
|
|
411
|
+
{ x: w0 - si, y: h3 - si },
|
|
412
|
+
{ x: (h3 - sf) / slope - si, y: h3 - si },
|
|
413
|
+
{ x: sw + si, y: h2 * slope + sf + si },
|
|
414
|
+
{ x: sw + si, y: h2 + si }
|
|
415
|
+
]
|
|
416
|
+
points[A2] = this.FlipHorizontal(points[A1], w) // A2
|
|
417
|
+
points[C] = this.FlipVertical(points[2], h) // C
|
|
418
|
+
points[D1] = this.FlipVertical(points[0], h) // D1
|
|
419
|
+
points[D2] = this.FlipHorizontal(points[4], w) // D2
|
|
420
|
+
points[E] = this.FlipHorizontal(points[3], w) // E
|
|
421
|
+
points[F] = this.FlipHorizontal(points[2], w) // F
|
|
422
|
+
points[G1] = this.FlipHorizontal(points[9], w) // G1
|
|
423
|
+
points[J] = this.FlipHorizontal(points[10], w) // J
|
|
424
|
+
points[K] = this.FlipVertical(points[12], h) // K
|
|
425
|
+
points[L] = this.FlipVertical(points[11], h) // L
|
|
426
|
+
points[M] = this.FlipVertical(points[10], h) // M
|
|
427
|
+
this.Points = points
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
const CharacterMasks = (function () {
|
|
431
|
+
// Segment Bitmasks for individual segments.
|
|
432
|
+
// Binary Or them together to create bitmasks
|
|
433
|
+
// a1|a2|b|c|d1|d2|e|f|g1|g2|h|i|j|k|l|m
|
|
434
|
+
const a1 = 1 << 0,
|
|
435
|
+
a2 = 1 << 1,
|
|
436
|
+
b = 1 << 2,
|
|
437
|
+
c = 1 << 3,
|
|
438
|
+
d1 = 1 << 4,
|
|
439
|
+
d2 = 1 << 5,
|
|
440
|
+
e = 1 << 6,
|
|
441
|
+
f = 1 << 7,
|
|
442
|
+
g1 = 1 << 8,
|
|
443
|
+
g2 = 1 << 9,
|
|
444
|
+
h = 1 << 10,
|
|
445
|
+
i = 1 << 11,
|
|
446
|
+
j = 1 << 12,
|
|
447
|
+
k = 1 << 13,
|
|
448
|
+
l = 1 << 14,
|
|
449
|
+
m = 1 << 15
|
|
450
|
+
// Character map associates characters with a bit pattern
|
|
451
|
+
return {
|
|
452
|
+
' ': 0,
|
|
453
|
+
'': 0,
|
|
454
|
+
0: a1 | a2 | b | c | d1 | d2 | e | f | j | m,
|
|
455
|
+
1: b | c | j,
|
|
456
|
+
2: a1 | a2 | b | d1 | d2 | e | g1 | g2,
|
|
457
|
+
3: a1 | a2 | b | c | d1 | d2 | g2,
|
|
458
|
+
4: b | c | f | g1 | g2,
|
|
459
|
+
5: a1 | a2 | c | d1 | d2 | f | g1 | g2,
|
|
460
|
+
6: a1 | a2 | c | d1 | d2 | e | f | g1 | g2,
|
|
461
|
+
7: a1 | a2 | b | c,
|
|
462
|
+
8: a1 | a2 | b | c | d1 | d2 | e | f | g1 | g2,
|
|
463
|
+
9: a1 | a2 | b | c | f | g1 | g2,
|
|
464
|
+
A: e | f | a1 | a2 | b | c | g1 | g2,
|
|
465
|
+
B: a1 | a2 | b | c | d1 | d2 | g2 | i | l,
|
|
466
|
+
C: a1 | a2 | f | e | d1 | d2,
|
|
467
|
+
D: a1 | a2 | b | c | d1 | d2 | i | l,
|
|
468
|
+
E: a1 | a2 | f | e | d1 | d2 | g1 | g2,
|
|
469
|
+
F: a1 | a2 | e | f | g1,
|
|
470
|
+
G: a1 | a2 | c | d1 | d2 | e | f | g2,
|
|
471
|
+
H: b | c | e | f | g1 | g2,
|
|
472
|
+
I: a1 | a2 | d1 | d2 | i | l,
|
|
473
|
+
J: b | c | d1 | d2 | e,
|
|
474
|
+
K: e | f | g1 | j | k,
|
|
475
|
+
L: d1 | d2 | e | f,
|
|
476
|
+
M: b | c | e | f | h | j,
|
|
477
|
+
N: b | c | e | f | h | k,
|
|
478
|
+
O: a1 | a2 | b | c | d1 | d2 | e | f,
|
|
479
|
+
P: a1 | a2 | b | e | f | g1 | g2,
|
|
480
|
+
Q: a1 | a2 | b | c | d1 | d2 | e | f | k,
|
|
481
|
+
R: a1 | a2 | b | e | f | g1 | g2 | k,
|
|
482
|
+
S: a1 | a2 | c | d1 | d2 | f | g1 | g2,
|
|
483
|
+
T: a1 | a2 | i | l,
|
|
484
|
+
U: b | c | d1 | d2 | e | f,
|
|
485
|
+
V: e | f | j | m,
|
|
486
|
+
W: b | c | e | f | k | m,
|
|
487
|
+
X: h | j | k | m,
|
|
488
|
+
Y: b | f | g1 | g2 | l,
|
|
489
|
+
Z: a1 | a2 | d1 | d2 | j | m,
|
|
490
|
+
'-': g1 | g2,
|
|
491
|
+
'?': a1 | a2 | b | g2 | l,
|
|
492
|
+
'+': g1 | g2 | i | l,
|
|
493
|
+
'*': g1 | g2 | h | i | j | k | l | m
|
|
494
|
+
}
|
|
495
|
+
})()
|
|
496
|
+
|
|
497
|
+
module.exports = LCD
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const List = require('../../../blessed/lib/widgets/list'),
|
|
3
|
+
Node = require('../../../blessed/lib/widgets/node')
|
|
4
|
+
|
|
5
|
+
function Log(options) {
|
|
6
|
+
if (!(this instanceof Node)) {
|
|
7
|
+
return new Log(options)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
options = options || {}
|
|
11
|
+
options.bufferLength = options.bufferLength || 30
|
|
12
|
+
this.options = options
|
|
13
|
+
List.call(this, options)
|
|
14
|
+
|
|
15
|
+
this.logLines = []
|
|
16
|
+
this.interactive = false
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Log.prototype = Object.create(List.prototype)
|
|
20
|
+
|
|
21
|
+
Log.prototype.log = function (str) {
|
|
22
|
+
this.logLines.push(str)
|
|
23
|
+
if (this.logLines.length > this.options.bufferLength) {
|
|
24
|
+
this.logLines.shift()
|
|
25
|
+
}
|
|
26
|
+
this.setItems(this.logLines)
|
|
27
|
+
this.scrollTo(this.logLines.length)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Log.prototype.type = 'log'
|
|
31
|
+
|
|
32
|
+
module.exports = Log
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const InnerMap = require('map-canvas'),
|
|
3
|
+
Node = require('../../../blessed/lib/widgets/node'),
|
|
4
|
+
Canvas = require('./canvas')
|
|
5
|
+
|
|
6
|
+
function Map(options) {
|
|
7
|
+
const self = this
|
|
8
|
+
|
|
9
|
+
if (!(this instanceof Node)) {
|
|
10
|
+
return new Map(options)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
Canvas.call(this, options)
|
|
14
|
+
|
|
15
|
+
this.on('attach', function () {
|
|
16
|
+
options.style = options.style || {}
|
|
17
|
+
|
|
18
|
+
const opts = {
|
|
19
|
+
excludeAntartica:
|
|
20
|
+
options.excludeAntarctica === undefined
|
|
21
|
+
? true
|
|
22
|
+
: options.excludeAntarctica,
|
|
23
|
+
disableBackground:
|
|
24
|
+
options.disableBackground === undefined
|
|
25
|
+
? true
|
|
26
|
+
: options.disableBackground,
|
|
27
|
+
disableMapBackground:
|
|
28
|
+
options.disableMapBackground === undefined
|
|
29
|
+
? true
|
|
30
|
+
: options.disableMapBackground,
|
|
31
|
+
disableGraticule:
|
|
32
|
+
options.disableGraticule === undefined
|
|
33
|
+
? true
|
|
34
|
+
: options.disableGraticule,
|
|
35
|
+
disableFill:
|
|
36
|
+
options.disableFill === undefined ? true : options.disableFill,
|
|
37
|
+
width: self.ctx._canvas.width,
|
|
38
|
+
height: self.ctx._canvas.height,
|
|
39
|
+
shapeColor: options.style.shapeColor || 'green'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
opts.startLon = options.startLon || undefined
|
|
43
|
+
opts.endLon = options.endLon || undefined
|
|
44
|
+
opts.startLat = options.startLat || undefined
|
|
45
|
+
opts.endLat = options.endLat || undefined
|
|
46
|
+
opts.region = options.region || undefined
|
|
47
|
+
opts.labelSpace = options.labelSpace || 5
|
|
48
|
+
|
|
49
|
+
this.ctx.strokeStyle = options.style.stroke || 'green'
|
|
50
|
+
this.ctx.fillStyle = options.style.fill || 'green'
|
|
51
|
+
|
|
52
|
+
self.innerMap = new InnerMap(opts, this._canvas)
|
|
53
|
+
self.innerMap.draw()
|
|
54
|
+
|
|
55
|
+
if (self.options.markers) {
|
|
56
|
+
for (const m in self.options.markers) {
|
|
57
|
+
self.addMarker(self.options.markers[m])
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Map.prototype = Object.create(Canvas.prototype)
|
|
64
|
+
|
|
65
|
+
Map.prototype.calcSize = function () {
|
|
66
|
+
this.canvasSize = { width: this.width * 2 - 12, height: this.height * 4 }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Map.prototype.type = 'map'
|
|
70
|
+
|
|
71
|
+
Map.prototype.addMarker = function (options) {
|
|
72
|
+
if (!this.innerMap) {
|
|
73
|
+
throw 'error: canvas context does not exist. addMarker() for maps must be called after the map has been added to the screen via screen.append()'
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.innerMap.addMarker(options)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
Map.prototype.getOptionsPrototype = function () {
|
|
80
|
+
return {
|
|
81
|
+
startLon: 10,
|
|
82
|
+
endLon: 10,
|
|
83
|
+
startLat: 10,
|
|
84
|
+
endLat: 10,
|
|
85
|
+
region: 'us',
|
|
86
|
+
markers: [
|
|
87
|
+
{ lon: '-79.0000', lat: '37.5000', color: 'red', char: 'X' },
|
|
88
|
+
{ lon: '79.0000', lat: '37.5000', color: 'blue', char: 'O' }
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
Map.prototype.clearMarkers = function () {
|
|
94
|
+
this.innerMap.draw()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
module.exports = Map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const Box = require('../../../blessed/lib/widgets/box'),
|
|
3
|
+
marked = require('marked'),
|
|
4
|
+
TerminalRenderer = require('marked-terminal'),
|
|
5
|
+
chalk = require('chalk')
|
|
6
|
+
|
|
7
|
+
function Markdown(options) {
|
|
8
|
+
if (!(this instanceof Box)) {
|
|
9
|
+
return new Markdown(options)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
options = options || {}
|
|
13
|
+
|
|
14
|
+
const markdownOptions = {
|
|
15
|
+
style: options.markdownStyle
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
this.evalStyles(markdownOptions)
|
|
19
|
+
|
|
20
|
+
this.setOptions(markdownOptions.style)
|
|
21
|
+
|
|
22
|
+
this.options = options
|
|
23
|
+
Box.call(this, options)
|
|
24
|
+
|
|
25
|
+
if (options.markdown) {
|
|
26
|
+
this.setMarkdown(options.markdown)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Markdown.prototype = Object.create(Box.prototype)
|
|
31
|
+
|
|
32
|
+
Markdown.prototype.setMarkdown = function (str) {
|
|
33
|
+
this.setContent(marked.parse(str))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Markdown.prototype.setOptions = function (style) {
|
|
37
|
+
marked.setOptions({
|
|
38
|
+
renderer: new TerminalRenderer(style)
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Markdown.prototype.evalStyles = function (options) {
|
|
43
|
+
if (!options.style) {
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
for (const st in options.style) {
|
|
47
|
+
if (typeof options.style[st] != 'string') {
|
|
48
|
+
continue
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const tokens = options.style[st].split('.')
|
|
52
|
+
options.style[st] = chalk
|
|
53
|
+
for (let j = 1; j < tokens.length; j++) {
|
|
54
|
+
options.style[st] = options.style[st][tokens[j]]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Markdown.prototype.getOptionsPrototype = function () {
|
|
60
|
+
return {
|
|
61
|
+
markdown: 'string',
|
|
62
|
+
markdownStyle: 'object'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
Markdown.prototype.type = 'markdown'
|
|
67
|
+
|
|
68
|
+
module.exports = Markdown
|