forked from coral/blessed-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (40 loc) · 1.22 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module.exports = function (blessed) {
this.grid = require('./lib/layout/grid')
this.carousel = require('./lib/layout/carousel')
var widgets = [
'map',
'canvas',
'gauge',
'gauge-list',
'lcd',
'donut',
'log',
'picture',
'reverselog',
'sparkline',
'table',
'tree',
'markdown',
];
for (const widget of widgets) {
var name = snakeToVar(widget);
this[name] = (new (require(`./lib/widget/${widget}.js`))(blessed)).exports;
}
var widgetsCharts = [
'bar',
'stacked-bar',
'line',
];
for (const widget of widgetsCharts) {
var name = snakeToVar(widget);
this[name] = (new (require(`./lib/widget/charts/${widget}.js`))(blessed)).exports;
}
var serverUtils = new (require('./lib/server-utils'))(blessed);
this.OutputBuffer = serverUtils.OutputBuffer
this.InputBuffer = serverUtils.InputBuffer
this.createScreen = serverUtils.createScreen
this.serverError = serverUtils.serverError
}
function snakeToVar(str) {
return str.split('-').map((part, i) => (i > 0) ? `${part.charAt(0).toUpperCase()}${part.slice(1)}` : part).join('');
}