@socketsecurity/cli-with-sentry 0.14.137 → 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/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,415 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scrollablebox.js - scrollable box 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
|
+
* ScrollableBox
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function ScrollableBox(options) {
|
|
19
|
+
const self = this
|
|
20
|
+
|
|
21
|
+
if (!(this instanceof Node)) {
|
|
22
|
+
return new ScrollableBox(options)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
options = options || {}
|
|
26
|
+
|
|
27
|
+
Box.call(this, options)
|
|
28
|
+
|
|
29
|
+
if (options.scrollable === false) {
|
|
30
|
+
return this
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
this.scrollable = true
|
|
34
|
+
this.childOffset = 0
|
|
35
|
+
this.childBase = 0
|
|
36
|
+
this.baseLimit = options.baseLimit || Infinity
|
|
37
|
+
this.alwaysScroll = options.alwaysScroll
|
|
38
|
+
|
|
39
|
+
this.scrollbar = options.scrollbar
|
|
40
|
+
if (this.scrollbar) {
|
|
41
|
+
this.scrollbar.ch = this.scrollbar.ch || ' '
|
|
42
|
+
this.style.scrollbar = this.style.scrollbar || this.scrollbar.style
|
|
43
|
+
if (!this.style.scrollbar) {
|
|
44
|
+
this.style.scrollbar = {}
|
|
45
|
+
this.style.scrollbar.fg = this.scrollbar.fg
|
|
46
|
+
this.style.scrollbar.bg = this.scrollbar.bg
|
|
47
|
+
this.style.scrollbar.bold = this.scrollbar.bold
|
|
48
|
+
this.style.scrollbar.underline = this.scrollbar.underline
|
|
49
|
+
this.style.scrollbar.inverse = this.scrollbar.inverse
|
|
50
|
+
this.style.scrollbar.invisible = this.scrollbar.invisible
|
|
51
|
+
}
|
|
52
|
+
//this.scrollbar.style = this.style.scrollbar;
|
|
53
|
+
if (this.track || this.scrollbar.track) {
|
|
54
|
+
this.track = this.scrollbar.track || this.track
|
|
55
|
+
this.style.track = this.style.scrollbar.track || this.style.track
|
|
56
|
+
this.track.ch = this.track.ch || ' '
|
|
57
|
+
this.style.track = this.style.track || this.track.style
|
|
58
|
+
if (!this.style.track) {
|
|
59
|
+
this.style.track = {}
|
|
60
|
+
this.style.track.fg = this.track.fg
|
|
61
|
+
this.style.track.bg = this.track.bg
|
|
62
|
+
this.style.track.bold = this.track.bold
|
|
63
|
+
this.style.track.underline = this.track.underline
|
|
64
|
+
this.style.track.inverse = this.track.inverse
|
|
65
|
+
this.style.track.invisible = this.track.invisible
|
|
66
|
+
}
|
|
67
|
+
this.track.style = this.style.track
|
|
68
|
+
}
|
|
69
|
+
// Allow controlling of the scrollbar via the mouse:
|
|
70
|
+
if (options.mouse) {
|
|
71
|
+
this.on('mousedown', function (data) {
|
|
72
|
+
if (self._scrollingBar) {
|
|
73
|
+
// Do not allow dragging on the scrollbar:
|
|
74
|
+
delete self.screen._dragging
|
|
75
|
+
delete self._drag
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
const x = data.x - self.aleft
|
|
79
|
+
const y = data.y - self.atop
|
|
80
|
+
if (x === self.width - self.iright - 1) {
|
|
81
|
+
// Do not allow dragging on the scrollbar:
|
|
82
|
+
delete self.screen._dragging
|
|
83
|
+
delete self._drag
|
|
84
|
+
const perc = (y - self.itop) / (self.height - self.iheight)
|
|
85
|
+
self.setScrollPerc((perc * 100) | 0)
|
|
86
|
+
self.screen.render()
|
|
87
|
+
let smd, smu
|
|
88
|
+
self._scrollingBar = true
|
|
89
|
+
self.onScreenEvent(
|
|
90
|
+
'mousedown',
|
|
91
|
+
(smd = function (data) {
|
|
92
|
+
const y = data.y - self.atop
|
|
93
|
+
const perc = y / self.height
|
|
94
|
+
self.setScrollPerc((perc * 100) | 0)
|
|
95
|
+
self.screen.render()
|
|
96
|
+
})
|
|
97
|
+
)
|
|
98
|
+
// If mouseup occurs out of the window, no mouseup event fires, and
|
|
99
|
+
// scrollbar will drag again on mousedown until another mouseup
|
|
100
|
+
// occurs.
|
|
101
|
+
self.onScreenEvent(
|
|
102
|
+
'mouseup',
|
|
103
|
+
(smu = function () {
|
|
104
|
+
self._scrollingBar = false
|
|
105
|
+
self.removeScreenEvent('mousedown', smd)
|
|
106
|
+
self.removeScreenEvent('mouseup', smu)
|
|
107
|
+
})
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (options.mouse) {
|
|
115
|
+
this.on('wheeldown', function () {
|
|
116
|
+
self.scroll((self.height / 2) | 0 || 1)
|
|
117
|
+
self.screen.render()
|
|
118
|
+
})
|
|
119
|
+
this.on('wheelup', function () {
|
|
120
|
+
self.scroll(-((self.height / 2) | 0) || -1)
|
|
121
|
+
self.screen.render()
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (options.keys && !options.ignoreKeys) {
|
|
126
|
+
this.on('keypress', function (ch, key) {
|
|
127
|
+
if (key.name === 'up' || (options.vi && key.name === 'k')) {
|
|
128
|
+
self.scroll(-1)
|
|
129
|
+
self.screen.render()
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
if (key.name === 'down' || (options.vi && key.name === 'j')) {
|
|
133
|
+
self.scroll(1)
|
|
134
|
+
self.screen.render()
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
if (options.vi && key.name === 'u' && key.ctrl) {
|
|
138
|
+
self.scroll(-((self.height / 2) | 0) || -1)
|
|
139
|
+
self.screen.render()
|
|
140
|
+
return
|
|
141
|
+
}
|
|
142
|
+
if (options.vi && key.name === 'd' && key.ctrl) {
|
|
143
|
+
self.scroll((self.height / 2) | 0 || 1)
|
|
144
|
+
self.screen.render()
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
if (options.vi && key.name === 'b' && key.ctrl) {
|
|
148
|
+
self.scroll(-self.height || -1)
|
|
149
|
+
self.screen.render()
|
|
150
|
+
return
|
|
151
|
+
}
|
|
152
|
+
if (options.vi && key.name === 'f' && key.ctrl) {
|
|
153
|
+
self.scroll(self.height || 1)
|
|
154
|
+
self.screen.render()
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
if (options.vi && key.name === 'g' && !key.shift) {
|
|
158
|
+
self.scrollTo(0)
|
|
159
|
+
self.screen.render()
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
if (options.vi && key.name === 'g' && key.shift) {
|
|
163
|
+
self.scrollTo(self.getScrollHeight())
|
|
164
|
+
self.screen.render()
|
|
165
|
+
return
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
this.on('parsed content', function () {
|
|
171
|
+
self._recalculateIndex()
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
self._recalculateIndex()
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
Object.setPrototypeOf(ScrollableBox.prototype, Box.prototype)
|
|
178
|
+
|
|
179
|
+
ScrollableBox.prototype.type = 'scrollable-box'
|
|
180
|
+
|
|
181
|
+
// XXX Potentially use this in place of scrollable checks elsewhere.
|
|
182
|
+
ScrollableBox.prototype.__defineGetter__('reallyScrollable', function () {
|
|
183
|
+
if (this.shrink) {
|
|
184
|
+
return this.scrollable
|
|
185
|
+
}
|
|
186
|
+
return this.getScrollHeight() > this.height
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
ScrollableBox.prototype._scrollBottom = function () {
|
|
190
|
+
if (!this.scrollable) {
|
|
191
|
+
return 0
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// We could just calculate the children, but we can
|
|
195
|
+
// optimize for lists by just returning the items.length.
|
|
196
|
+
if (this._isList) {
|
|
197
|
+
return this.items ? this.items.length : 0
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (this.lpos && this.lpos._scrollBottom) {
|
|
201
|
+
return this.lpos._scrollBottom
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const bottom = this.children.reduce(function (current, el) {
|
|
205
|
+
// el.height alone does not calculate the shrunken height, we need to use
|
|
206
|
+
// getCoords. A shrunken box inside a scrollable element will not grow any
|
|
207
|
+
// larger than the scrollable element's context regardless of how much
|
|
208
|
+
// content is in the shrunken box, unless we do this (call getCoords
|
|
209
|
+
// without the scrollable calculation):
|
|
210
|
+
// See: $ node test/widget-shrink-fail-2.js
|
|
211
|
+
if (!el.detached) {
|
|
212
|
+
const lpos = el._getCoords(false, true)
|
|
213
|
+
if (lpos) {
|
|
214
|
+
return Math.max(current, el.rtop + (lpos.yl - lpos.yi))
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return Math.max(current, el.rtop + el.height)
|
|
218
|
+
}, 0)
|
|
219
|
+
|
|
220
|
+
// XXX Use this? Makes .getScrollHeight() useless!
|
|
221
|
+
// if (bottom < this._clines.length) bottom = this._clines.length;
|
|
222
|
+
|
|
223
|
+
if (this.lpos) {
|
|
224
|
+
this.lpos._scrollBottom = bottom
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return bottom
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
ScrollableBox.prototype.setScroll = ScrollableBox.prototype.scrollTo =
|
|
231
|
+
function (offset, always) {
|
|
232
|
+
// XXX
|
|
233
|
+
// At first, this appeared to account for the first new calculation of childBase:
|
|
234
|
+
this.scroll(0)
|
|
235
|
+
return this.scroll(offset - (this.childBase + this.childOffset), always)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
ScrollableBox.prototype.getScroll = function () {
|
|
239
|
+
return this.childBase + this.childOffset
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
ScrollableBox.prototype.scroll = function (offset, always) {
|
|
243
|
+
if (!this.scrollable) {
|
|
244
|
+
return
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (this.detached) {
|
|
248
|
+
return
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Handle scrolling.
|
|
252
|
+
let visible = this.height - this.iheight,
|
|
253
|
+
base = this.childBase,
|
|
254
|
+
d,
|
|
255
|
+
p,
|
|
256
|
+
t,
|
|
257
|
+
b,
|
|
258
|
+
max,
|
|
259
|
+
emax
|
|
260
|
+
|
|
261
|
+
if (this.alwaysScroll || always) {
|
|
262
|
+
// Semi-workaround
|
|
263
|
+
this.childOffset = offset > 0 ? visible - 1 + offset : offset
|
|
264
|
+
} else {
|
|
265
|
+
this.childOffset += offset
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (this.childOffset > visible - 1) {
|
|
269
|
+
d = this.childOffset - (visible - 1)
|
|
270
|
+
this.childOffset -= d
|
|
271
|
+
this.childBase += d
|
|
272
|
+
} else if (this.childOffset < 0) {
|
|
273
|
+
d = this.childOffset
|
|
274
|
+
this.childOffset += -d
|
|
275
|
+
this.childBase += d
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (this.childBase < 0) {
|
|
279
|
+
this.childBase = 0
|
|
280
|
+
} else if (this.childBase > this.baseLimit) {
|
|
281
|
+
this.childBase = this.baseLimit
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Find max "bottom" value for
|
|
285
|
+
// content and descendant elements.
|
|
286
|
+
// Scroll the content if necessary.
|
|
287
|
+
if (this.childBase === base) {
|
|
288
|
+
return this.emit('scroll')
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// When scrolling text, we want to be able to handle SGR codes as well as line
|
|
292
|
+
// feeds. This allows us to take preformatted text output from other programs
|
|
293
|
+
// and put it in a scrollable text box.
|
|
294
|
+
this.parseContent()
|
|
295
|
+
|
|
296
|
+
// XXX
|
|
297
|
+
// max = this.getScrollHeight() - (this.height - this.iheight);
|
|
298
|
+
|
|
299
|
+
max = this._clines.length - (this.height - this.iheight)
|
|
300
|
+
if (max < 0) {
|
|
301
|
+
max = 0
|
|
302
|
+
}
|
|
303
|
+
emax = this._scrollBottom() - (this.height - this.iheight)
|
|
304
|
+
if (emax < 0) {
|
|
305
|
+
emax = 0
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
this.childBase = Math.min(this.childBase, Math.max(emax, max))
|
|
309
|
+
|
|
310
|
+
if (this.childBase < 0) {
|
|
311
|
+
this.childBase = 0
|
|
312
|
+
} else if (this.childBase > this.baseLimit) {
|
|
313
|
+
this.childBase = this.baseLimit
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Optimize scrolling with CSR + IL/DL.
|
|
317
|
+
p = this.lpos
|
|
318
|
+
// Only really need _getCoords() if we want
|
|
319
|
+
// to allow nestable scrolling elements...
|
|
320
|
+
// or if we **really** want shrinkable
|
|
321
|
+
// scrolling elements.
|
|
322
|
+
// p = this._getCoords();
|
|
323
|
+
if (p && this.childBase !== base && this.screen.cleanSides(this)) {
|
|
324
|
+
t = p.yi + this.itop
|
|
325
|
+
b = p.yl - this.ibottom - 1
|
|
326
|
+
d = this.childBase - base
|
|
327
|
+
|
|
328
|
+
if (d > 0 && d < visible) {
|
|
329
|
+
// scrolled down
|
|
330
|
+
this.screen.deleteLine(d, t, t, b)
|
|
331
|
+
} else if (d < 0 && -d < visible) {
|
|
332
|
+
// scrolled up
|
|
333
|
+
d = -d
|
|
334
|
+
this.screen.insertLine(d, t, t, b)
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return this.emit('scroll')
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
ScrollableBox.prototype._recalculateIndex = function () {
|
|
342
|
+
let max, emax
|
|
343
|
+
|
|
344
|
+
if (this.detached || !this.scrollable) {
|
|
345
|
+
return 0
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// XXX
|
|
349
|
+
// max = this.getScrollHeight() - (this.height - this.iheight);
|
|
350
|
+
|
|
351
|
+
max = this._clines.length - (this.height - this.iheight)
|
|
352
|
+
if (max < 0) {
|
|
353
|
+
max = 0
|
|
354
|
+
}
|
|
355
|
+
emax = this._scrollBottom() - (this.height - this.iheight)
|
|
356
|
+
if (emax < 0) {
|
|
357
|
+
emax = 0
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
this.childBase = Math.min(this.childBase, Math.max(emax, max))
|
|
361
|
+
|
|
362
|
+
if (this.childBase < 0) {
|
|
363
|
+
this.childBase = 0
|
|
364
|
+
} else if (this.childBase > this.baseLimit) {
|
|
365
|
+
this.childBase = this.baseLimit
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
ScrollableBox.prototype.resetScroll = function () {
|
|
370
|
+
if (!this.scrollable) {
|
|
371
|
+
return
|
|
372
|
+
}
|
|
373
|
+
this.childOffset = 0
|
|
374
|
+
this.childBase = 0
|
|
375
|
+
return this.emit('scroll')
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
ScrollableBox.prototype.getScrollHeight = function () {
|
|
379
|
+
return Math.max(this._clines.length, this._scrollBottom())
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
ScrollableBox.prototype.getScrollPerc = function (s) {
|
|
383
|
+
const pos = this.lpos || this._getCoords()
|
|
384
|
+
if (!pos) {
|
|
385
|
+
return s ? -1 : 0
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
let height = pos.yl - pos.yi - this.iheight,
|
|
389
|
+
i = this.getScrollHeight(),
|
|
390
|
+
p
|
|
391
|
+
|
|
392
|
+
if (height < i) {
|
|
393
|
+
if (this.alwaysScroll) {
|
|
394
|
+
p = this.childBase / (i - height)
|
|
395
|
+
} else {
|
|
396
|
+
p = (this.childBase + this.childOffset) / (i - 1)
|
|
397
|
+
}
|
|
398
|
+
return p * 100
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
return s ? -1 : 0
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
ScrollableBox.prototype.setScrollPerc = function (i) {
|
|
405
|
+
// XXX
|
|
406
|
+
// var m = this.getScrollHeight();
|
|
407
|
+
const m = Math.max(this._clines.length, this._scrollBottom())
|
|
408
|
+
return this.scrollTo(((i / 100) * m) | 0)
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Expose
|
|
413
|
+
*/
|
|
414
|
+
|
|
415
|
+
module.exports = ScrollableBox
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scrollabletext.js - scrollable text 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 ScrollableBox = require('./scrollablebox')
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* ScrollableText
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function ScrollableText(options) {
|
|
19
|
+
if (!(this instanceof Node)) {
|
|
20
|
+
return new ScrollableText(options)
|
|
21
|
+
}
|
|
22
|
+
options = options || {}
|
|
23
|
+
options.alwaysScroll = true
|
|
24
|
+
ScrollableBox.call(this, options)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Object.setPrototypeOf(ScrollableText.prototype, ScrollableBox.prototype)
|
|
28
|
+
|
|
29
|
+
ScrollableText.prototype.type = 'scrollable-text'
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Expose
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
module.exports = ScrollableText
|