@ohos-ports/pm2 0.0.0-stage → 7.1.2-beta.0
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/CHANGELOG.md +2607 -0
- package/CONTRIBUTING.md +124 -0
- package/GNU-AGPL-3.0.txt +665 -0
- package/LICENSE +1 -0
- package/README.md +255 -2
- package/SECURITY.md +41 -0
- package/bin/pm2 +3 -0
- package/bin/pm2-dev +3 -0
- package/bin/pm2-docker +3 -0
- package/bin/pm2-runtime +3 -0
- package/bin/pm2.ps1 +3 -0
- package/constants.js +113 -0
- package/index.js +12 -0
- package/lib/API/Configuration.js +212 -0
- package/lib/API/Containerizer.js +335 -0
- package/lib/API/Dashboard.js +726 -0
- package/lib/API/Deploy.js +117 -0
- package/lib/API/Extra.js +798 -0
- package/lib/API/ExtraMgmt/Docker.js +30 -0
- package/lib/API/Log.js +388 -0
- package/lib/API/LogManagement.js +351 -0
- package/lib/API/Modules/LOCAL.js +122 -0
- package/lib/API/Modules/Modularizer.js +148 -0
- package/lib/API/Modules/NPM.js +443 -0
- package/lib/API/Modules/TAR.js +368 -0
- package/lib/API/Modules/flagExt.js +46 -0
- package/lib/API/Modules/index.js +120 -0
- package/lib/API/Monit.js +247 -0
- package/lib/API/Serve.js +497 -0
- package/lib/API/Startup.js +630 -0
- package/lib/API/UX/helpers.js +213 -0
- package/lib/API/UX/index.js +9 -0
- package/lib/API/UX/pm2-describe.js +197 -0
- package/lib/API/UX/pm2-ls-minimal.js +31 -0
- package/lib/API/UX/pm2-ls.js +581 -0
- package/lib/API/Version.js +383 -0
- package/lib/API/interpreter.json +12 -0
- package/lib/API/pm2-plus/PM2IO.js +381 -0
- package/lib/API/pm2-plus/auth-strategies/CliAuth.js +306 -0
- package/lib/API/pm2-plus/auth-strategies/WebAuth.js +195 -0
- package/lib/API/pm2-plus/helpers.js +97 -0
- package/lib/API/pm2-plus/link.js +126 -0
- package/lib/API/pm2-plus/pres/motd +16 -0
- package/lib/API/pm2-plus/pres/motd.update +26 -0
- package/lib/API/pm2-plus/pres/welcome +28 -0
- package/lib/API/pm2-plus/process-selector.js +52 -0
- package/lib/API/schema.json +375 -0
- package/lib/API.js +1980 -0
- package/lib/Client.js +793 -0
- package/lib/Common.js +949 -0
- package/lib/Configuration.js +309 -0
- package/lib/Daemon.js +468 -0
- package/lib/Event.js +37 -0
- package/lib/God/ActionMethods.js +955 -0
- package/lib/God/ClusterMode.js +192 -0
- package/lib/God/ForkMode.js +205 -0
- package/lib/God/Methods.js +292 -0
- package/lib/God/Reload.js +300 -0
- package/lib/God/StdioLogger.js +239 -0
- package/lib/God.js +653 -0
- package/lib/HttpInterface.js +75 -0
- package/lib/OtelManager.js +74 -0
- package/lib/ProcessContainer.js +321 -0
- package/lib/ProcessContainerBun.js +355 -0
- package/lib/ProcessContainerFork.js +42 -0
- package/lib/ProcessContainerForkBun.js +31 -0
- package/lib/ProcessUtils.js +74 -0
- package/lib/TreeKill.js +111 -0
- package/lib/Utility.js +304 -0
- package/lib/VersionCheck.js +46 -0
- package/lib/Watcher.js +117 -0
- package/lib/Worker.js +200 -0
- package/lib/binaries/CLI.js +1092 -0
- package/lib/binaries/DevCLI.js +183 -0
- package/lib/binaries/Runtime.js +101 -0
- package/lib/binaries/Runtime4Docker.js +192 -0
- package/lib/completion.js +229 -0
- package/lib/completion.sh +40 -0
- package/lib/motd +36 -0
- package/lib/templates/Dockerfiles/Dockerfile-nodejs.tpl +8 -0
- package/lib/templates/ecosystem-es.tpl +24 -0
- package/lib/templates/ecosystem-simple-es.tpl +8 -0
- package/lib/templates/ecosystem-simple.tpl +6 -0
- package/lib/templates/ecosystem.tpl +22 -0
- package/lib/templates/init-scripts/launchd.tpl +35 -0
- package/lib/templates/init-scripts/openrc.tpl +52 -0
- package/lib/templates/init-scripts/pm2-init-amazon.sh +86 -0
- package/lib/templates/init-scripts/rcd-openbsd.tpl +41 -0
- package/lib/templates/init-scripts/rcd.tpl +44 -0
- package/lib/templates/init-scripts/smf.tpl +43 -0
- package/lib/templates/init-scripts/systemd-online.tpl +22 -0
- package/lib/templates/init-scripts/systemd.tpl +22 -0
- package/lib/templates/init-scripts/upstart.tpl +103 -0
- package/lib/templates/logrotate.d/pm2 +10 -0
- package/lib/templates/sample-apps/http-server/README.md +14 -0
- package/lib/templates/sample-apps/http-server/api.js +9 -0
- package/lib/templates/sample-apps/http-server/ecosystem.config.js +14 -0
- package/lib/templates/sample-apps/http-server/package.json +11 -0
- package/lib/templates/sample-apps/pm2-plus-metrics-actions/README.md +45 -0
- package/lib/templates/sample-apps/pm2-plus-metrics-actions/custom-metrics.js +66 -0
- package/lib/templates/sample-apps/pm2-plus-metrics-actions/ecosystem.config.js +12 -0
- package/lib/templates/sample-apps/pm2-plus-metrics-actions/package.json +11 -0
- package/lib/templates/sample-apps/python-app/README.md +4 -0
- package/lib/templates/sample-apps/python-app/echo.py +7 -0
- package/lib/templates/sample-apps/python-app/ecosystem.config.js +12 -0
- package/lib/templates/sample-apps/python-app/package.json +11 -0
- package/lib/tools/Config.js +251 -0
- package/lib/tools/SysMetrics.js +375 -0
- package/lib/tools/copydirSync.js +101 -0
- package/lib/tools/deleteFolderRecursive.js +19 -0
- package/lib/tools/find-package-json.js +74 -0
- package/lib/tools/fmt.js +72 -0
- package/lib/tools/interpreter.js +88 -0
- package/lib/tools/isbinaryfile.js +94 -0
- package/lib/tools/json5.js +752 -0
- package/lib/tools/multimeter/bar.js +111 -0
- package/lib/tools/multimeter/charm/encode.js +18 -0
- package/lib/tools/multimeter/charm/index.js +305 -0
- package/lib/tools/multimeter/index.js +76 -0
- package/lib/tools/open.js +56 -0
- package/lib/tools/passwd.js +58 -0
- package/lib/tools/pm2-config-keys.js +165 -0
- package/lib/tools/prompt.js +76 -0
- package/lib/tools/serviceStop.js +149 -0
- package/lib/tools/sexec.js +55 -0
- package/lib/tools/treeify.js +113 -0
- package/lib/tools/typestrip.js +55 -0
- package/lib/tools/which.js +120 -0
- package/lib/tools/xdg-open +861 -0
- package/modules/blessed/LICENSE +20 -0
- package/modules/blessed/README.md +34 -0
- package/modules/blessed/index.js +1 -0
- package/modules/blessed/lib/alias.js +526 -0
- package/modules/blessed/lib/blessed.js +32 -0
- package/modules/blessed/lib/colors.js +530 -0
- package/modules/blessed/lib/events.js +189 -0
- package/modules/blessed/lib/gpmclient.js +221 -0
- package/modules/blessed/lib/helpers.js +165 -0
- package/modules/blessed/lib/keys.js +339 -0
- package/modules/blessed/lib/program.js +4297 -0
- package/modules/blessed/lib/tput.js +3022 -0
- package/modules/blessed/lib/unicode.js +885 -0
- package/modules/blessed/lib/widget.js +32 -0
- package/modules/blessed/lib/widgets/box.js +34 -0
- package/modules/blessed/lib/widgets/element.js +2570 -0
- package/modules/blessed/lib/widgets/list.js +599 -0
- package/modules/blessed/lib/widgets/log.js +83 -0
- package/modules/blessed/lib/widgets/node.js +282 -0
- package/modules/blessed/lib/widgets/screen.js +2298 -0
- package/modules/blessed/lib/widgets/scrollablebox.js +389 -0
- package/modules/blessed/lib/widgets/scrollabletext.js +35 -0
- package/modules/blessed/lib/widgets/text.js +35 -0
- package/modules/blessed/usr/linux +0 -0
- package/modules/blessed/usr/windows-ansi +0 -0
- package/modules/blessed/usr/xterm +0 -0
- package/modules/blessed/usr/xterm-256color +0 -0
- package/modules/blessed/usr/xterm.termcap +243 -0
- package/modules/chokidar/LICENSE +21 -0
- package/modules/chokidar/VENDORED.md +76 -0
- package/modules/chokidar/index.js +979 -0
- package/modules/chokidar/lib/brace-expand.js +180 -0
- package/modules/chokidar/lib/constants.js +66 -0
- package/modules/chokidar/lib/fsevents-handler.js +526 -0
- package/modules/chokidar/lib/nodefs-handler.js +654 -0
- package/modules/fclone.js +49 -0
- package/modules/pm2-axon/index.js +2 -0
- package/modules/pm2-axon/lib/configurable/History.md +5 -0
- package/modules/pm2-axon/lib/configurable/Makefile +7 -0
- package/modules/pm2-axon/lib/configurable/Readme.md +57 -0
- package/modules/pm2-axon/lib/configurable/index.js +2 -0
- package/modules/pm2-axon/lib/configurable/lib/configurable.js +47 -0
- package/modules/pm2-axon/lib/configurable/package.json +68 -0
- package/modules/pm2-axon/lib/index.js +44 -0
- package/modules/pm2-axon/lib/plugins/queue.js +71 -0
- package/modules/pm2-axon/lib/plugins/round-robin.js +55 -0
- package/modules/pm2-axon/lib/sockets/pub-emitter.js +26 -0
- package/modules/pm2-axon/lib/sockets/pub.js +77 -0
- package/modules/pm2-axon/lib/sockets/pull.js +37 -0
- package/modules/pm2-axon/lib/sockets/push.js +32 -0
- package/modules/pm2-axon/lib/sockets/rep.js +73 -0
- package/modules/pm2-axon/lib/sockets/req.js +101 -0
- package/modules/pm2-axon/lib/sockets/sock.js +430 -0
- package/modules/pm2-axon/lib/sockets/sub-emitter.js +92 -0
- package/modules/pm2-axon/lib/sockets/sub.js +147 -0
- package/modules/pm2-axon/lib/utils.js +19 -0
- package/modules/pm2-axon-rpc/index.js +3 -0
- package/modules/pm2-axon-rpc/lib/client.js +63 -0
- package/modules/pm2-axon-rpc/lib/server.js +139 -0
- package/modules/pm2-io-agent/LICENSE +661 -0
- package/modules/pm2-io-agent/README.md +62 -0
- package/modules/pm2-io-agent/config.js +30 -0
- package/modules/pm2-io-agent/constants.js +118 -0
- package/modules/pm2-io-agent/index.js +2 -0
- package/modules/pm2-io-agent/src/InteractorClient.js +513 -0
- package/modules/pm2-io-agent/src/InteractorDaemon.js +455 -0
- package/modules/pm2-io-agent/src/PM2Client.js +112 -0
- package/modules/pm2-io-agent/src/PM2Interface.js +180 -0
- package/modules/pm2-io-agent/src/TransporterInterface.js +173 -0
- package/modules/pm2-io-agent/src/Utility.js +392 -0
- package/modules/pm2-io-agent/src/WatchDog.js +70 -0
- package/modules/pm2-io-agent/src/push/DataRetriever.js +77 -0
- package/modules/pm2-io-agent/src/push/PushInteractor.js +206 -0
- package/modules/pm2-io-agent/src/push/TransactionAggregator.js +670 -0
- package/modules/pm2-io-agent/src/reverse/ReverseInteractor.js +128 -0
- package/modules/pm2-io-agent/src/transporters/Transporter.js +129 -0
- package/modules/pm2-io-agent/src/transporters/WebsocketTransport.js +202 -0
- package/modules/pm2-io-agent/src/utils/BinaryHeap.js +135 -0
- package/modules/pm2-io-agent/src/utils/EDS.js +111 -0
- package/modules/pm2-io-agent/src/utils/probes/Histogram.js +204 -0
- package/modules/pm2-io-agent/src/utils/units.js +10 -0
- package/modules/pm2-io-bpm/configuration.js +141 -0
- package/modules/pm2-io-bpm/constants.js +10 -0
- package/modules/pm2-io-bpm/featureManager.js +110 -0
- package/modules/pm2-io-bpm/features/dependencies.js +48 -0
- package/modules/pm2-io-bpm/features/events.js +50 -0
- package/modules/pm2-io-bpm/features/metrics.js +102 -0
- package/modules/pm2-io-bpm/features/notify.js +238 -0
- package/modules/pm2-io-bpm/features/profiling.js +70 -0
- package/modules/pm2-io-bpm/features/tracing.js +174 -0
- package/modules/pm2-io-bpm/index.js +11 -0
- package/modules/pm2-io-bpm/metrics/eventLoopMetrics.js +136 -0
- package/modules/pm2-io-bpm/metrics/httpMetrics.js +175 -0
- package/modules/pm2-io-bpm/metrics/network.js +132 -0
- package/modules/pm2-io-bpm/metrics/runtime.js +161 -0
- package/modules/pm2-io-bpm/metrics/v8.js +104 -0
- package/modules/pm2-io-bpm/otel/constants.js +7 -0
- package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/platform/index.js +17 -0
- package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/platform/node/index.js +17 -0
- package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/platform/node/util.js +51 -0
- package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/transform.js +137 -0
- package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/types.js +24 -0
- package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/utils.js +23 -0
- package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/zipkin.js +149 -0
- package/modules/pm2-io-bpm/pmx.js +380 -0
- package/modules/pm2-io-bpm/profilers/addonProfiler.js +193 -0
- package/modules/pm2-io-bpm/profilers/inspectorProfiler.js +302 -0
- package/modules/pm2-io-bpm/serviceManager.js +21 -0
- package/modules/pm2-io-bpm/services/actions.js +159 -0
- package/modules/pm2-io-bpm/services/inspector.js +43 -0
- package/modules/pm2-io-bpm/services/metrics.js +186 -0
- package/modules/pm2-io-bpm/services/runtimeStats.js +54 -0
- package/modules/pm2-io-bpm/services/transport.js +11 -0
- package/modules/pm2-io-bpm/transports/IPCTransport.js +115 -0
- package/modules/pm2-io-bpm/utils/BinaryHeap.js +134 -0
- package/modules/pm2-io-bpm/utils/EDS.js +113 -0
- package/modules/pm2-io-bpm/utils/EWMA.js +32 -0
- package/modules/pm2-io-bpm/utils/autocast.js +61 -0
- package/modules/pm2-io-bpm/utils/metrics/counter.js +33 -0
- package/modules/pm2-io-bpm/utils/metrics/gauge.js +23 -0
- package/modules/pm2-io-bpm/utils/metrics/histogram.js +192 -0
- package/modules/pm2-io-bpm/utils/metrics/meter.js +46 -0
- package/modules/pm2-io-bpm/utils/miscellaneous.js +19 -0
- package/modules/pm2-io-bpm/utils/module.js +67 -0
- package/modules/pm2-io-bpm/utils/shimmer.js +19 -0
- package/modules/pm2-io-bpm/utils/stackParser.js +160 -0
- package/modules/pm2-io-bpm/utils/transactionAggregator.js +429 -0
- package/modules/pm2-io-bpm/utils/units.js +16 -0
- package/modules/vizion/LICENSE +13 -0
- package/modules/vizion/README.md +133 -0
- package/modules/vizion/index.js +1 -0
- package/modules/vizion/lib/git/git.js +247 -0
- package/modules/vizion/lib/vizion.js +52 -0
- package/package.json +170 -4
- package/paths.js +121 -0
- package/pm2 +11 -0
- package/types/index.d.ts +732 -0
- package/types/tsconfig.json +14 -0
|
@@ -0,0 +1,389 @@
|
|
|
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
|
+
var Node = require('./node');
|
|
12
|
+
var Box = require('./box');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* ScrollableBox
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function ScrollableBox(options) {
|
|
19
|
+
var 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
|
+
var x = data.x - self.aleft;
|
|
79
|
+
var 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
|
+
var perc = (y - self.itop) / (self.height - self.iheight);
|
|
85
|
+
self.setScrollPerc(perc * 100 | 0);
|
|
86
|
+
self.screen.render();
|
|
87
|
+
var smd, smu;
|
|
88
|
+
self._scrollingBar = true;
|
|
89
|
+
self.onScreenEvent('mousedown', smd = function(data) {
|
|
90
|
+
var y = data.y - self.atop;
|
|
91
|
+
var perc = y / self.height;
|
|
92
|
+
self.setScrollPerc(perc * 100 | 0);
|
|
93
|
+
self.screen.render();
|
|
94
|
+
});
|
|
95
|
+
// If mouseup occurs out of the window, no mouseup event fires, and
|
|
96
|
+
// scrollbar will drag again on mousedown until another mouseup
|
|
97
|
+
// occurs.
|
|
98
|
+
self.onScreenEvent('mouseup', smu = function() {
|
|
99
|
+
self._scrollingBar = false;
|
|
100
|
+
self.removeScreenEvent('mousedown', smd);
|
|
101
|
+
self.removeScreenEvent('mouseup', smu);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (options.mouse) {
|
|
109
|
+
this.on('wheeldown', function() {
|
|
110
|
+
self.scroll(self.height / 2 | 0 || 1);
|
|
111
|
+
self.screen.render();
|
|
112
|
+
});
|
|
113
|
+
this.on('wheelup', function() {
|
|
114
|
+
self.scroll(-(self.height / 2 | 0) || -1);
|
|
115
|
+
self.screen.render();
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (options.keys && !options.ignoreKeys) {
|
|
120
|
+
this.on('keypress', function(ch, key) {
|
|
121
|
+
if (key.name === 'up' || (options.vi && key.name === 'k')) {
|
|
122
|
+
self.scroll(-1);
|
|
123
|
+
self.screen.render();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (key.name === 'down' || (options.vi && key.name === 'j')) {
|
|
127
|
+
self.scroll(1);
|
|
128
|
+
self.screen.render();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (options.vi && key.name === 'u' && key.ctrl) {
|
|
132
|
+
self.scroll(-(self.height / 2 | 0) || -1);
|
|
133
|
+
self.screen.render();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (options.vi && key.name === 'd' && key.ctrl) {
|
|
137
|
+
self.scroll(self.height / 2 | 0 || 1);
|
|
138
|
+
self.screen.render();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (options.vi && key.name === 'b' && key.ctrl) {
|
|
142
|
+
self.scroll(-self.height || -1);
|
|
143
|
+
self.screen.render();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (options.vi && key.name === 'f' && key.ctrl) {
|
|
147
|
+
self.scroll(self.height || 1);
|
|
148
|
+
self.screen.render();
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (options.vi && key.name === 'g' && !key.shift) {
|
|
152
|
+
self.scrollTo(0);
|
|
153
|
+
self.screen.render();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (options.vi && key.name === 'g' && key.shift) {
|
|
157
|
+
self.scrollTo(self.getScrollHeight());
|
|
158
|
+
self.screen.render();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this.on('parsed content', function() {
|
|
165
|
+
self._recalculateIndex();
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
self._recalculateIndex();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
ScrollableBox.prototype.__proto__ = Box.prototype;
|
|
172
|
+
|
|
173
|
+
ScrollableBox.prototype.type = 'scrollable-box';
|
|
174
|
+
|
|
175
|
+
// XXX Potentially use this in place of scrollable checks elsewhere.
|
|
176
|
+
ScrollableBox.prototype.__defineGetter__('reallyScrollable', function() {
|
|
177
|
+
if (this.shrink) return this.scrollable;
|
|
178
|
+
return this.getScrollHeight() > this.height;
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
ScrollableBox.prototype._scrollBottom = function() {
|
|
182
|
+
if (!this.scrollable) return 0;
|
|
183
|
+
|
|
184
|
+
// We could just calculate the children, but we can
|
|
185
|
+
// optimize for lists by just returning the items.length.
|
|
186
|
+
if (this._isList) {
|
|
187
|
+
return this.items ? this.items.length : 0;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (this.lpos && this.lpos._scrollBottom) {
|
|
191
|
+
return this.lpos._scrollBottom;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var bottom = this.children.reduce(function(current, el) {
|
|
195
|
+
// el.height alone does not calculate the shrunken height, we need to use
|
|
196
|
+
// getCoords. A shrunken box inside a scrollable element will not grow any
|
|
197
|
+
// larger than the scrollable element's context regardless of how much
|
|
198
|
+
// content is in the shrunken box, unless we do this (call getCoords
|
|
199
|
+
// without the scrollable calculation):
|
|
200
|
+
// See: $ node test/widget-shrink-fail-2.js
|
|
201
|
+
if (!el.detached) {
|
|
202
|
+
var lpos = el._getCoords(false, true);
|
|
203
|
+
if (lpos) {
|
|
204
|
+
return Math.max(current, el.rtop + (lpos.yl - lpos.yi));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return Math.max(current, el.rtop + el.height);
|
|
208
|
+
}, 0);
|
|
209
|
+
|
|
210
|
+
// XXX Use this? Makes .getScrollHeight() useless!
|
|
211
|
+
// if (bottom < this._clines.length) bottom = this._clines.length;
|
|
212
|
+
|
|
213
|
+
if (this.lpos) this.lpos._scrollBottom = bottom;
|
|
214
|
+
|
|
215
|
+
return bottom;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
ScrollableBox.prototype.setScroll =
|
|
219
|
+
ScrollableBox.prototype.scrollTo = function(offset, always) {
|
|
220
|
+
// XXX
|
|
221
|
+
// At first, this appeared to account for the first new calculation of childBase:
|
|
222
|
+
this.scroll(0);
|
|
223
|
+
return this.scroll(offset - (this.childBase + this.childOffset), always);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
ScrollableBox.prototype.getScroll = function() {
|
|
227
|
+
return this.childBase + this.childOffset;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
ScrollableBox.prototype.scroll = function(offset, always) {
|
|
231
|
+
if (!this.scrollable) return;
|
|
232
|
+
|
|
233
|
+
if (this.detached) return;
|
|
234
|
+
|
|
235
|
+
// Handle scrolling.
|
|
236
|
+
var visible = this.height - this.iheight
|
|
237
|
+
, base = this.childBase
|
|
238
|
+
, d
|
|
239
|
+
, p
|
|
240
|
+
, t
|
|
241
|
+
, b
|
|
242
|
+
, max
|
|
243
|
+
, emax;
|
|
244
|
+
|
|
245
|
+
if (this.alwaysScroll || always) {
|
|
246
|
+
// Semi-workaround
|
|
247
|
+
this.childOffset = offset > 0
|
|
248
|
+
? visible - 1 + offset
|
|
249
|
+
: offset;
|
|
250
|
+
} else {
|
|
251
|
+
this.childOffset += offset;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (this.childOffset > visible - 1) {
|
|
255
|
+
d = this.childOffset - (visible - 1);
|
|
256
|
+
this.childOffset -= d;
|
|
257
|
+
this.childBase += d;
|
|
258
|
+
} else if (this.childOffset < 0) {
|
|
259
|
+
d = this.childOffset;
|
|
260
|
+
this.childOffset += -d;
|
|
261
|
+
this.childBase += d;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (this.childBase < 0) {
|
|
265
|
+
this.childBase = 0;
|
|
266
|
+
} else if (this.childBase > this.baseLimit) {
|
|
267
|
+
this.childBase = this.baseLimit;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Find max "bottom" value for
|
|
271
|
+
// content and descendant elements.
|
|
272
|
+
// Scroll the content if necessary.
|
|
273
|
+
if (this.childBase === base) {
|
|
274
|
+
return this.emit('scroll');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// When scrolling text, we want to be able to handle SGR codes as well as line
|
|
278
|
+
// feeds. This allows us to take preformatted text output from other programs
|
|
279
|
+
// and put it in a scrollable text box.
|
|
280
|
+
this.parseContent();
|
|
281
|
+
|
|
282
|
+
// XXX
|
|
283
|
+
// max = this.getScrollHeight() - (this.height - this.iheight);
|
|
284
|
+
|
|
285
|
+
max = this._clines.length - (this.height - this.iheight);
|
|
286
|
+
if (max < 0) max = 0;
|
|
287
|
+
emax = this._scrollBottom() - (this.height - this.iheight);
|
|
288
|
+
if (emax < 0) emax = 0;
|
|
289
|
+
|
|
290
|
+
this.childBase = Math.min(this.childBase, Math.max(emax, max));
|
|
291
|
+
|
|
292
|
+
if (this.childBase < 0) {
|
|
293
|
+
this.childBase = 0;
|
|
294
|
+
} else if (this.childBase > this.baseLimit) {
|
|
295
|
+
this.childBase = this.baseLimit;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Optimize scrolling with CSR + IL/DL.
|
|
299
|
+
p = this.lpos;
|
|
300
|
+
// Only really need _getCoords() if we want
|
|
301
|
+
// to allow nestable scrolling elements...
|
|
302
|
+
// or if we **really** want shrinkable
|
|
303
|
+
// scrolling elements.
|
|
304
|
+
// p = this._getCoords();
|
|
305
|
+
if (p && this.childBase !== base && this.screen.cleanSides(this)) {
|
|
306
|
+
t = p.yi + this.itop;
|
|
307
|
+
b = p.yl - this.ibottom - 1;
|
|
308
|
+
d = this.childBase - base;
|
|
309
|
+
|
|
310
|
+
if (d > 0 && d < visible) {
|
|
311
|
+
// scrolled down
|
|
312
|
+
this.screen.deleteLine(d, t, t, b);
|
|
313
|
+
} else if (d < 0 && -d < visible) {
|
|
314
|
+
// scrolled up
|
|
315
|
+
d = -d;
|
|
316
|
+
this.screen.insertLine(d, t, t, b);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return this.emit('scroll');
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
ScrollableBox.prototype._recalculateIndex = function() {
|
|
324
|
+
var max, emax;
|
|
325
|
+
|
|
326
|
+
if (this.detached || !this.scrollable) {
|
|
327
|
+
return 0;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// XXX
|
|
331
|
+
// max = this.getScrollHeight() - (this.height - this.iheight);
|
|
332
|
+
|
|
333
|
+
max = this._clines.length - (this.height - this.iheight);
|
|
334
|
+
if (max < 0) max = 0;
|
|
335
|
+
emax = this._scrollBottom() - (this.height - this.iheight);
|
|
336
|
+
if (emax < 0) emax = 0;
|
|
337
|
+
|
|
338
|
+
this.childBase = Math.min(this.childBase, Math.max(emax, max));
|
|
339
|
+
|
|
340
|
+
if (this.childBase < 0) {
|
|
341
|
+
this.childBase = 0;
|
|
342
|
+
} else if (this.childBase > this.baseLimit) {
|
|
343
|
+
this.childBase = this.baseLimit;
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
ScrollableBox.prototype.resetScroll = function() {
|
|
348
|
+
if (!this.scrollable) return;
|
|
349
|
+
this.childOffset = 0;
|
|
350
|
+
this.childBase = 0;
|
|
351
|
+
return this.emit('scroll');
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
ScrollableBox.prototype.getScrollHeight = function() {
|
|
355
|
+
return Math.max(this._clines.length, this._scrollBottom());
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
ScrollableBox.prototype.getScrollPerc = function(s) {
|
|
359
|
+
var pos = this.lpos || this._getCoords();
|
|
360
|
+
if (!pos) return s ? -1 : 0;
|
|
361
|
+
|
|
362
|
+
var height = (pos.yl - pos.yi) - this.iheight
|
|
363
|
+
, i = this.getScrollHeight()
|
|
364
|
+
, p;
|
|
365
|
+
|
|
366
|
+
if (height < i) {
|
|
367
|
+
if (this.alwaysScroll) {
|
|
368
|
+
p = this.childBase / (i - height);
|
|
369
|
+
} else {
|
|
370
|
+
p = (this.childBase + this.childOffset) / (i - 1);
|
|
371
|
+
}
|
|
372
|
+
return p * 100;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return s ? -1 : 0;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
ScrollableBox.prototype.setScrollPerc = function(i) {
|
|
379
|
+
// XXX
|
|
380
|
+
// var m = this.getScrollHeight();
|
|
381
|
+
var m = Math.max(this._clines.length, this._scrollBottom());
|
|
382
|
+
return this.scrollTo((i / 100) * m | 0);
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Expose
|
|
387
|
+
*/
|
|
388
|
+
|
|
389
|
+
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
|
+
var Node = require('./node');
|
|
12
|
+
var 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
|
+
ScrollableText.prototype.__proto__ = ScrollableBox.prototype;
|
|
28
|
+
|
|
29
|
+
ScrollableText.prototype.type = 'scrollable-text';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Expose
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
module.exports = ScrollableText;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* text.js - 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
|
+
var Node = require('./node');
|
|
12
|
+
var Element = require('./element');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Text
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function Text(options) {
|
|
19
|
+
if (!(this instanceof Node)) {
|
|
20
|
+
return new Text(options);
|
|
21
|
+
}
|
|
22
|
+
options = options || {};
|
|
23
|
+
options.shrink = true;
|
|
24
|
+
Element.call(this, options);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Text.prototype.__proto__ = Element.prototype;
|
|
28
|
+
|
|
29
|
+
Text.prototype.type = 'text';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Expose
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
module.exports = Text;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|