forked from coral/blessed-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
489 lines (349 loc) · 17.4 KB
/
index.d.ts
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
import * as Blessed from 'blessed'
export = BlessedContrib
declare namespace BlessedContrib {
export type Optionals<T, K extends keyof T> = {
[P in keyof K]?: T[P]
}
export type Picker<T, K extends keyof T> = {
[P in K]: T[P];
};
export module Widgets {
import IHasOptions = Blessed.Widgets.IHasOptions;
import BoxOptions = Blessed.Widgets.BoxOptions;
import ListOptions = Blessed.Widgets.ListOptions;
import Types = Blessed.Widgets.Types;
import ListElementStyle = Blessed.Widgets.ListElementStyle;
import BoxElement = Blessed.Widgets.BoxElement;
import ListElement = Blessed.Widgets.ListElement;
export interface GridOptions {
top?: Types.TTopLeft;
left?: Types.TTopLeft;
right?: Types.TPosition;
bottom?: Types.TPosition;
rows?: number
cols?: number
screen: BlessedWidgets.Screen
border?: Border
hideBorder?: boolean
}
export interface Border extends Blessed.Widgets.Border {
fg?: string | number
bg?: string | number
}
export type WidgetOptions =
BoxOptions
| BarOptions
| StackedBarOptions
| CanvasOptions
| TreeOptions
| TableOptions
| PictureOptions
| MarkdownOptions
| MapOptions
| SparklineOptions
| LogOptions
| LcdOptions
| GaugeOptions
| GaugeListOptions
| DonutOptions
export type WidgetElements = BoxElement
| BarElement
| LineElement
| StackedBarElement
| CanvasElement
| TreeElement
| TableElement
| PictureElement
| MarkdownElement
| MapElement
| SparklineElement
| LogElement
| LcdElement
| GaugeElement
| GaugeListElement
| DonutElement
export class GridElement extends BoxElement implements IHasOptions<GridOptions> {
constructor(opts: GridOptions);
set<T extends (options?: TreeOptions) => S, S extends TreeElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: TreeOptions): TreeElement
set<T extends (options?: TableOptions) => S, S extends TableElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: TableOptions): TableElement
set<T extends (options?: PictureOptions) => S, S extends PictureElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: PictureOptions): PictureElement
set<T extends (options?: MarkdownOptions) => S, S extends MarkdownElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: MarkdownOptions): MarkdownElement
set<T extends (options?: MapOptions) => S, S extends MapElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: MapOptions): MapElement
set<T extends (options?: LogOptions) => S, S extends LogElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: LogOptions): LogElement
set<T extends (options?: LcdOptions) => S, S extends LcdElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: LcdOptions): LcdElement
set<T extends (options?: GaugeOptions) => S, S extends GaugeElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: GaugeOptions): GaugeElement
set<T extends (options?: GaugeListOptions) => S, S extends GaugeListElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: GaugeListOptions): GaugeListElement
set<T extends (options?: DonutOptions) => S, S extends DonutElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: DonutOptions): DonutElement
set<T extends (options?: BarOptions) => S, S extends BarElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: BarOptions): BarElement
set<T extends (options?: LineOptions) => S, S extends LineElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: LineOptions): LineElement
set<T extends (options?: StackedBarOptions) => S, S extends StackedBarElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: StackedBarOptions): StackedBarElement
set<T extends (options?: CanvasOptions) => S, S extends CanvasElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: CanvasOptions): CanvasElement
// set<T extends (options?: WidgetOptions) => S, S extends WidgetElements>(row: number, col: number, rowSpan: number, colSpan: number, obj: T, opt: WidgetOptions): WidgetElements
set<T, S>(...args:any[]): any
// set<K extends keyof Factories>(row: number, col: number, rowSpan: number, colSpan: number,
// obj: T, opts?: P<T> ): P<T>
// set<A =BarOptions, T=BarElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof bar
// set<A =Line, T=LineElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof line
// set<A =StackedBar, T=StackedBarElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof stackedBar
// set<A =Canvas, T=CanvasElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof canvas
// set<A =Tree, T=TreeElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof tree
// set<A =Table, T=TableElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof table
// set<A =Picture, T=PictureElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof picture
// set<A =Markdown, T=MarkdownElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof markdown
// set<A =Map, T=MapElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof map
// set<A =Log, T=LogElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof log
// set<A =Lcd, T=LcdElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof lcd
// set<A =Gauge, T=GaugeElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof gauge
// set<A =GaugeList, T=GaugeListElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof gaugeList
// set<A =Donut, T=DonutElement>(row: number, col: number, rowSpan: number, colSpan: number, obj: A, opts?: O): T //typeof donut
options: GridOptions;
}
export interface BarData {
titles?: string[],
data?: number[]
}
export interface BarOptions extends CanvasOptions<BarData> {
barWidth?: number
barSpacing?: number
xOffset?: number
maxHeight?: number
showText?: boolean
}
export class BarElement extends CanvasElement<BarData> implements IHasOptions<BarOptions> {
constructor(opts: BarOptions);
setData(data: BarData)
options: BarOptions;
}
export interface LineData {
title?: string
x?: string[]
y?: number[]
style?: Picker<LineOptions, 'style'>
}
export interface LineOptions extends CanvasOptions<LineData[]> {
showNthLabel?: boolean
style?: {
line?: string
text?: string
baseline?: string
}
xLabelPadding?: number
xPadding?: number
numYLabels?: number
legend?: { width: number }
wholeNumbersOnly?: boolean
minY?: number
maxY?: number
label?: string
}
export class LineElement extends CanvasElement<LineData[]> implements IHasOptions<LineOptions> {
constructor(opts: LineOptions);
options: LineOptions;
}
export interface StackedBarData {
barCategory?: string[]
stackedCategory?: string[]
data?: Array<number[]>
}
export interface StackedBarOptions extends CanvasOptions<StackedBarData[]> {
barWidth?: number
barSpacing?: number
xOffset?: number
maxValue?: number
barBgColor?: string
showLegend?: boolean
legend?: any
showText?: boolean
}
export class StackedBarElement extends CanvasElement<StackedBarData> implements IHasOptions<StackedBarOptions> {
constructor(opts: StackedBarOptions)
options: StackedBarOptions;
addLegend(bars: any, x: number)
}
export interface CanvasOptions<D extends any=any> extends BoxOptions {
canvasSize?: {
width?: number,
height?: number
}
data?: D
}
export class CanvasElement<D extends any=any> extends BoxElement implements IHasOptions<CanvasOptions> {
constructor(opts: CanvasOptions<D>)
options: CanvasOptions<D>;
calcSize()
setData(data: D)
}
export interface DonutData {
percent?: string,
label?: string,
color?: string
}
export interface DonutOptions extends CanvasOptions<DonutData[]> {
stroke?: string
fill?: string
label?: string
radius?: number
arcWidth?: number
spacing?: number
remainColor?: string
yPadding?: number
}
export class DonutElement extends CanvasElement<DonutData[]> implements IHasOptions<DonutOptions> {
constructor(opts: DonutOptions)
options: DonutOptions;
}
export interface GaugeListOptions extends CanvasOptions {
}
export class GaugeListElement extends CanvasElement implements IHasOptions<GaugeListOptions> {
constructor(opts: GaugeListOptions)
options: GaugeListOptions;
}
export interface GaugeOptions extends CanvasOptions {
percent: number[]
stroke?: string
fill?: string
label?: string
stack?: any
showLabel?: boolean
}
export class GaugeElement extends CanvasElement implements IHasOptions<GaugeOptions> {
constructor(opts: GaugeOptions)
options: GaugeOptions;
setPercent(number: number)
setStack(stack: Array<{ percent: number, stroke: string }>)
setData(percent: number[])
setData(percent: number)
}
export interface LcdOptions extends CanvasOptions {
segmentWidth?: number// how wide are the segments in % so 50% = 0.5
segmentInterval?: number// spacing between the segments in % so 50% = 0.550% = 0.5
strokeWidth?: number// spacing between the segments in % so 50% = 0.5
elements?: number// how many elements in the display. or how many characters can be displayed.
display?: number// what should be displayed before first call to setDisplay
elementSpacing?: number// spacing between each element
elementPadding?: number// how far away from the edges to put the elements
color?: 'white' // color for the segments
label?: 'Storage Remaining'
}
export class LcdElement extends CanvasElement implements IHasOptions<LcdOptions> {
constructor(opts: LcdOptions)
options: LcdOptions;
increaseWidth()
decreaseWidth()
increaseInterval()
decreaseInterval()
increaseStroke()
decreaseStroke()
setOptions(options: any)
setDisplay(display)
}
export interface LogOptions extends ListOptions<ListElementStyle> {
border: Border
bufferLength?: number
logLines?: string[]
interactive?: boolean
}
export class LogElement extends ListElement implements IHasOptions<LogOptions> {
constructor(opts: LogOptions);
options: LogOptions;
log(str: string)
emit(str:any)
}
export interface MapOptions extends CanvasOptions {
}
export class MapElement extends CanvasElement implements IHasOptions<MapOptions> {
constructor(opts: MapOptions)
options: MapOptions;
}
export interface SparklineOptions extends CanvasOptions<string[]> {
}
export class SparklineElement extends CanvasElement<string[]> implements IHasOptions<SparklineOptions> {
constructor(opts: CanvasOptions);
options: SparklineOptions;
setData(...str: any[])
}
export interface MarkdownOptions extends CanvasOptions {
}
export class MarkdownElement extends CanvasElement implements IHasOptions<MarkdownOptions> {
constructor(opts: MarkdownOptions)
options: MarkdownOptions;
}
export interface PictureOptions extends CanvasOptions {
}
export class PictureElement extends CanvasElement implements IHasOptions<PictureOptions> {
constructor(opts: PictureOptions)
options: PictureOptions;
}
export interface TableData {
headers?: string[]
data?: Array<string[]>
}
export interface TableOptions extends CanvasOptions<TableData> {
bold?: boolean
columnSpacing?: number
columnWidth?: number[]
rows?: ListOptions
selectedFg?: string
selectedBg?: string
fg?: string
bg?: string
interactive?: string
}
export class TableElement extends CanvasElement<TableData> implements IHasOptions<TableOptions> {
constructor(opts: TableOptions);
options: TableOptions;
}
export interface TreeOptions extends BoxOptions {
data?: any
extended?: boolean
keys?: string[]
template?: {
extend?: string
retract?: string
lines?: boolean
}
}
export class TreeElement extends BoxElement implements IHasOptions<TreeOptions> {
constructor(opts: TreeOptions)
rows: BlessedWidgets.ListElement
nodeLines?: string[]
lineNbr?: number
data?: any
options: TreeOptions;
}
}
export module widget {
export class Grid extends Widgets.GridElement {}
export class Bar extends Widgets.BarElement {}
export class Line extends Widgets.LineElement {}
export class StackedBar extends Widgets.StackedBarElement {}
export class Canvas extends Widgets.CanvasElement {}
export class Tree extends Widgets.TreeElement {}
export class Table extends Widgets.TableElement {}
export class Picture extends Widgets.PictureElement {}
export class Markdown extends Widgets.MarkdownElement {}
export class Map extends Widgets.MapElement {}
export class Log extends Widgets.LogElement {}
export class Lcd extends Widgets.LcdElement {}
export class Gauge extends Widgets.GaugeElement {}
export class GaugeList extends Widgets.GaugeListElement {}
export class Donut extends Widgets.DonutElement {}
export class Sparkline extends Widgets.SparklineElement {}
}
export class grid extends Widgets.GridElement {}
export function line(options?: Widgets.LineOptions): Widgets.LineElement
export function bar(options?: Widgets.BarOptions): Widgets.BarElement
export function stackedBar(options?: Widgets.StackedBarOptions): Widgets.StackedBarElement
export function canvas(options?: Widgets.CanvasOptions): Widgets.CanvasElement
export function tree(options?: Widgets.TreeOptions): Widgets.TreeElement
export function table(options?: Widgets.TableOptions): Widgets.TableElement
export function picture(options?: Widgets.PictureOptions): Widgets.PictureElement
export function markdown(options?: Widgets.MarkdownOptions): Widgets.MarkdownElement
export function sparkline(options?: Widgets.SparklineOptions): Widgets.SparklineElement
export function map(options?: Widgets.MapOptions): Widgets.MapElement
export function log(options?: Widgets.LogOptions): Widgets.LogElement
export function lcd(options?: Widgets.LcdOptions): Widgets.LcdElement
export function gauge(options?: Widgets.GaugeOptions): Widgets.GaugeElement
export function gaugeList(options?: Widgets.GaugeListOptions): Widgets.GaugeListElement
export function donut(options?: Widgets.DonutOptions): Widgets.DonutElement
}