@teaui/core 1.1.4
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/Buffer.d.ts +21 -0
- package/.dist/Buffer.js +140 -0
- package/.dist/Buffer.js.map +1 -0
- package/.dist/Color.d.ts +7 -0
- package/.dist/Color.js +39 -0
- package/.dist/Color.js.map +1 -0
- package/.dist/Container.d.ts +21 -0
- package/.dist/Container.js +138 -0
- package/.dist/Container.js.map +1 -0
- package/.dist/Screen.d.ts +54 -0
- package/.dist/Screen.js +278 -0
- package/.dist/Screen.js.map +1 -0
- package/.dist/Style.d.ts +46 -0
- package/.dist/Style.js +433 -0
- package/.dist/Style.js.map +1 -0
- package/.dist/System.d.ts +13 -0
- package/.dist/System.js +26 -0
- package/.dist/System.js.map +1 -0
- package/.dist/Theme.d.ts +56 -0
- package/.dist/Theme.js +157 -0
- package/.dist/Theme.js.map +1 -0
- package/.dist/UI.d.ts +2 -0
- package/.dist/UI.js +28 -0
- package/.dist/UI.js.map +1 -0
- package/.dist/View.d.ts +99 -0
- package/.dist/View.js +374 -0
- package/.dist/View.js.map +1 -0
- package/.dist/Viewport.d.ts +89 -0
- package/.dist/Viewport.js +295 -0
- package/.dist/Viewport.js.map +1 -0
- package/.dist/ansi.d.ts +31 -0
- package/.dist/ansi.js +139 -0
- package/.dist/ansi.js.map +1 -0
- package/.dist/components/Accordion.d.ts +47 -0
- package/.dist/components/Accordion.js +294 -0
- package/.dist/components/Accordion.js.map +1 -0
- package/.dist/components/Box.d.ts +67 -0
- package/.dist/components/Box.js +211 -0
- package/.dist/components/Box.js.map +1 -0
- package/.dist/components/Button.d.ts +28 -0
- package/.dist/components/Button.js +118 -0
- package/.dist/components/Button.js.map +1 -0
- package/.dist/components/Checkbox.d.ts +31 -0
- package/.dist/components/Checkbox.js +106 -0
- package/.dist/components/Checkbox.js.map +1 -0
- package/.dist/components/Collapsible.d.ts +32 -0
- package/.dist/components/Collapsible.js +109 -0
- package/.dist/components/Collapsible.js.map +1 -0
- package/.dist/components/CollapsibleText.d.ts +21 -0
- package/.dist/components/CollapsibleText.js +113 -0
- package/.dist/components/CollapsibleText.js.map +1 -0
- package/.dist/components/Digits.d.ts +20 -0
- package/.dist/components/Digits.js +843 -0
- package/.dist/components/Digits.js.map +1 -0
- package/.dist/components/Drawer.d.ts +44 -0
- package/.dist/components/Drawer.js +473 -0
- package/.dist/components/Drawer.js.map +1 -0
- package/.dist/components/Dropdown.d.ts +61 -0
- package/.dist/components/Dropdown.js +367 -0
- package/.dist/components/Dropdown.js.map +1 -0
- package/.dist/components/Header.d.ts +25 -0
- package/.dist/components/Header.js +106 -0
- package/.dist/components/Header.js.map +1 -0
- package/.dist/components/HotKey.d.ts +14 -0
- package/.dist/components/HotKey.js +31 -0
- package/.dist/components/HotKey.js.map +1 -0
- package/.dist/components/Input.d.ts +45 -0
- package/.dist/components/Input.js +1109 -0
- package/.dist/components/Input.js.map +1 -0
- package/.dist/components/Log.d.ts +16 -0
- package/.dist/components/Log.js +122 -0
- package/.dist/components/Log.js.map +1 -0
- package/.dist/components/Progress.d.ts +21 -0
- package/.dist/components/Progress.js +200 -0
- package/.dist/components/Progress.js.map +1 -0
- package/.dist/components/Scrollable.d.ts +50 -0
- package/.dist/components/Scrollable.js +226 -0
- package/.dist/components/Scrollable.js.map +1 -0
- package/.dist/components/ScrollableList.d.ts +70 -0
- package/.dist/components/ScrollableList.js +354 -0
- package/.dist/components/ScrollableList.js.map +1 -0
- package/.dist/components/Separator.d.ts +21 -0
- package/.dist/components/Separator.js +67 -0
- package/.dist/components/Separator.js.map +1 -0
- package/.dist/components/Slider.d.ts +60 -0
- package/.dist/components/Slider.js +341 -0
- package/.dist/components/Slider.js.map +1 -0
- package/.dist/components/Space.d.ts +19 -0
- package/.dist/components/Space.js +45 -0
- package/.dist/components/Space.js.map +1 -0
- package/.dist/components/Spinner.d.ts +16 -0
- package/.dist/components/Spinner.js +48 -0
- package/.dist/components/Spinner.js.map +1 -0
- package/.dist/components/Stack.d.ts +33 -0
- package/.dist/components/Stack.js +285 -0
- package/.dist/components/Stack.js.map +1 -0
- package/.dist/components/Tabs.d.ts +52 -0
- package/.dist/components/Tabs.js +312 -0
- package/.dist/components/Tabs.js.map +1 -0
- package/.dist/components/Text.d.ts +35 -0
- package/.dist/components/Text.js +242 -0
- package/.dist/components/Text.js.map +1 -0
- package/.dist/components/ToggleGroup.d.ts +26 -0
- package/.dist/components/ToggleGroup.js +279 -0
- package/.dist/components/ToggleGroup.js.map +1 -0
- package/.dist/components/Tree.d.ts +21 -0
- package/.dist/components/Tree.js +233 -0
- package/.dist/components/Tree.js.map +1 -0
- package/.dist/components/Window.d.ts +6 -0
- package/.dist/components/Window.js +17 -0
- package/.dist/components/Window.js.map +1 -0
- package/.dist/components/fonts.d.ts +2 -0
- package/.dist/components/fonts.js +39 -0
- package/.dist/components/fonts.js.map +1 -0
- package/.dist/components/index.d.ts +27 -0
- package/.dist/components/index.js +48 -0
- package/.dist/components/index.js.map +1 -0
- package/.dist/components/types.d.ts +6 -0
- package/.dist/components/types.js +20 -0
- package/.dist/components/types.js.map +1 -0
- package/.dist/components/utility/TrackMouse.d.ts +16 -0
- package/.dist/components/utility/TrackMouse.js +53 -0
- package/.dist/components/utility/TrackMouse.js.map +1 -0
- package/.dist/components/utility/index.d.ts +1 -0
- package/.dist/components/utility/index.js +6 -0
- package/.dist/components/utility/index.js.map +1 -0
- package/.dist/events/index.d.ts +12 -0
- package/.dist/events/index.js +20 -0
- package/.dist/events/index.js.map +1 -0
- package/.dist/events/key.d.ts +15 -0
- package/.dist/events/key.js +105 -0
- package/.dist/events/key.js.map +1 -0
- package/.dist/events/mouse.d.ts +65 -0
- package/.dist/events/mouse.js +68 -0
- package/.dist/events/mouse.js.map +1 -0
- package/.dist/events/window.d.ts +6 -0
- package/.dist/events/window.js +3 -0
- package/.dist/events/window.js.map +1 -0
- package/.dist/geometry.d.ts +178 -0
- package/.dist/geometry.js +315 -0
- package/.dist/geometry.js.map +1 -0
- package/.dist/iTerm2.d.ts +20 -0
- package/.dist/iTerm2.js +60 -0
- package/.dist/iTerm2.js.map +1 -0
- package/.dist/index.d.ts +18 -0
- package/.dist/index.js +37 -0
- package/.dist/index.js.map +1 -0
- package/.dist/inspect.d.ts +2 -0
- package/.dist/inspect.js +118 -0
- package/.dist/inspect.js.map +1 -0
- package/.dist/log.d.ts +12 -0
- package/.dist/log.js +56 -0
- package/.dist/log.js.map +1 -0
- package/.dist/managers/FocusManager.d.ts +28 -0
- package/.dist/managers/FocusManager.js +143 -0
- package/.dist/managers/FocusManager.js.map +1 -0
- package/.dist/managers/ModalManager.d.ts +10 -0
- package/.dist/managers/ModalManager.js +67 -0
- package/.dist/managers/ModalManager.js.map +1 -0
- package/.dist/managers/MouseManager.d.ts +21 -0
- package/.dist/managers/MouseManager.js +313 -0
- package/.dist/managers/MouseManager.js.map +1 -0
- package/.dist/managers/TickManager.d.ts +11 -0
- package/.dist/managers/TickManager.js +63 -0
- package/.dist/managers/TickManager.js.map +1 -0
- package/.dist/sys/alias.d.ts +470 -0
- package/.dist/sys/alias.js +487 -0
- package/.dist/sys/alias.js.map +1 -0
- package/.dist/sys/colors.d.ts +10 -0
- package/.dist/sys/colors.js +285 -0
- package/.dist/sys/colors.js.map +1 -0
- package/.dist/sys/gpmclient.d.ts +11 -0
- package/.dist/sys/gpmclient.js +193 -0
- package/.dist/sys/gpmclient.js.map +1 -0
- package/.dist/sys/index.d.ts +4 -0
- package/.dist/sys/index.js +41 -0
- package/.dist/sys/index.js.map +1 -0
- package/.dist/sys/keys.d.ts +4 -0
- package/.dist/sys/keys.js +531 -0
- package/.dist/sys/keys.js.map +1 -0
- package/.dist/sys/program.d.ts +356 -0
- package/.dist/sys/program.js +3739 -0
- package/.dist/sys/program.js.map +1 -0
- package/.dist/sys/tput.d.ts +297 -0
- package/.dist/sys/tput.js +2708 -0
- package/.dist/sys/tput.js.map +1 -0
- package/.dist/sys/unicode.d.ts +11 -0
- package/.dist/sys/unicode.js +619 -0
- package/.dist/sys/unicode.js.map +1 -0
- package/.dist/sys/usr/linux +0 -0
- package/.dist/sys/usr/windows-ansi +0 -0
- package/.dist/sys/usr/xterm +0 -0
- package/.dist/sys/usr/xterm-256color +0 -0
- package/.dist/sys/usr/xterm.termcap +243 -0
- package/.dist/sys/usr/xterm.terminfo +1977 -0
- package/.dist/terminal.d.ts +7 -0
- package/.dist/terminal.js +3 -0
- package/.dist/terminal.js.map +1 -0
- package/.dist/util.d.ts +22 -0
- package/.dist/util.js +79 -0
- package/.dist/util.js.map +1 -0
- package/LICENSE +24 -0
- package/package.json +49 -0
package/.dist/Screen.js
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Screen = void 0;
|
|
4
|
+
const sys_1 = require("./sys");
|
|
5
|
+
const geometry_1 = require("./geometry");
|
|
6
|
+
const View_1 = require("./View");
|
|
7
|
+
const Viewport_1 = require("./Viewport");
|
|
8
|
+
const log_1 = require("./log");
|
|
9
|
+
const Buffer_1 = require("./Buffer");
|
|
10
|
+
const FocusManager_1 = require("./managers/FocusManager");
|
|
11
|
+
const ModalManager_1 = require("./managers/ModalManager");
|
|
12
|
+
const MouseManager_1 = require("./managers/MouseManager");
|
|
13
|
+
const TickManager_1 = require("./managers/TickManager");
|
|
14
|
+
const Window_1 = require("./components/Window");
|
|
15
|
+
const System_1 = require("./System");
|
|
16
|
+
class Screen {
|
|
17
|
+
#program;
|
|
18
|
+
#onExit;
|
|
19
|
+
rootView;
|
|
20
|
+
#buffer;
|
|
21
|
+
#focusManager = new FocusManager_1.FocusManager();
|
|
22
|
+
#modalManager = new ModalManager_1.ModalManager();
|
|
23
|
+
#mouseManager = new MouseManager_1.MouseManager();
|
|
24
|
+
#tickManager = new TickManager_1.TickManager(() => this.render());
|
|
25
|
+
static reset() {
|
|
26
|
+
const program = (0, sys_1.program)({
|
|
27
|
+
useBuffer: true,
|
|
28
|
+
tput: true,
|
|
29
|
+
});
|
|
30
|
+
program.alternateBuffer();
|
|
31
|
+
program.enableMouse();
|
|
32
|
+
program.setMouse({ sendFocus: true }, true);
|
|
33
|
+
program.clear();
|
|
34
|
+
program.disableMouse();
|
|
35
|
+
program.showCursor();
|
|
36
|
+
program.normalBuffer();
|
|
37
|
+
(0, log_1.flushLogs)();
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
static async start(viewConstructor = new Window_1.Window(), opts = { quitChar: 'c' }) {
|
|
41
|
+
const program = (0, sys_1.program)({
|
|
42
|
+
useBuffer: true,
|
|
43
|
+
tput: true,
|
|
44
|
+
});
|
|
45
|
+
program.alternateBuffer();
|
|
46
|
+
program.enableMouse();
|
|
47
|
+
program.hideCursor();
|
|
48
|
+
program.clear();
|
|
49
|
+
program.setMouse({ sendFocus: true }, true);
|
|
50
|
+
// weird quirk of blessed - bind anything to 'keypress' before
|
|
51
|
+
// attaching the screen or else I-don't-remember-what will happen.
|
|
52
|
+
const fn = function () { };
|
|
53
|
+
program.on('keypress', fn);
|
|
54
|
+
program.off('keypress', fn);
|
|
55
|
+
const rootView = viewConstructor instanceof View_1.View
|
|
56
|
+
? viewConstructor
|
|
57
|
+
: await viewConstructor(program);
|
|
58
|
+
const screen = new Screen(program, rootView);
|
|
59
|
+
screen.onExit(() => {
|
|
60
|
+
program.clear();
|
|
61
|
+
program.disableMouse();
|
|
62
|
+
program.showCursor();
|
|
63
|
+
program.normalBuffer();
|
|
64
|
+
});
|
|
65
|
+
program.on('focus', function () {
|
|
66
|
+
screen.trigger({ type: 'focus' });
|
|
67
|
+
});
|
|
68
|
+
program.on('blur', function () {
|
|
69
|
+
screen.trigger({ type: 'blur' });
|
|
70
|
+
});
|
|
71
|
+
program.on('resize', function () {
|
|
72
|
+
screen.trigger({ type: 'resize' });
|
|
73
|
+
});
|
|
74
|
+
if (opts?.quitChar) {
|
|
75
|
+
program.key(`C-${opts.quitChar}`, () => {
|
|
76
|
+
screen.exit();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
program.on('keypress', (char, key) => {
|
|
80
|
+
screen.trigger({ type: 'key', ...key });
|
|
81
|
+
});
|
|
82
|
+
program.on('mouse', function (data) {
|
|
83
|
+
let action = data.action;
|
|
84
|
+
if (action === 'focus' || action === 'blur') {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (data.button === 'unknown') {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
screen.trigger({
|
|
91
|
+
...data,
|
|
92
|
+
name: translateMouseAction(action),
|
|
93
|
+
type: 'mouse',
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
screen.start();
|
|
97
|
+
return [screen, program, rootView];
|
|
98
|
+
}
|
|
99
|
+
constructor(program, rootView) {
|
|
100
|
+
this.#program = program;
|
|
101
|
+
this.#buffer = new Buffer_1.Buffer();
|
|
102
|
+
this.rootView = rootView;
|
|
103
|
+
Object.defineProperty(this, 'program', {
|
|
104
|
+
enumerable: false,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
onExit(callback) {
|
|
108
|
+
if (this.#onExit) {
|
|
109
|
+
const prev = this.#onExit;
|
|
110
|
+
this.#onExit = () => {
|
|
111
|
+
prev();
|
|
112
|
+
callback();
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this.#onExit = callback;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
start() {
|
|
120
|
+
this.rootView.moveToScreen(this);
|
|
121
|
+
this.render();
|
|
122
|
+
}
|
|
123
|
+
exit() {
|
|
124
|
+
this.#tickManager.stop();
|
|
125
|
+
this.rootView.moveToScreen(undefined);
|
|
126
|
+
this.#onExit?.();
|
|
127
|
+
(0, log_1.flushLogs)();
|
|
128
|
+
process.exit(0);
|
|
129
|
+
}
|
|
130
|
+
trigger(event) {
|
|
131
|
+
switch (event.type) {
|
|
132
|
+
case 'resize':
|
|
133
|
+
case 'focus':
|
|
134
|
+
case 'blur':
|
|
135
|
+
break;
|
|
136
|
+
case 'key':
|
|
137
|
+
this.triggerKeyboard(event);
|
|
138
|
+
break;
|
|
139
|
+
case 'mouse': {
|
|
140
|
+
this.triggerMouse(event);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
this.render();
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Requests a modal. A modal will be created if:
|
|
148
|
+
* (a) no modal is already displayed
|
|
149
|
+
* or
|
|
150
|
+
* (b) a modal is requesting a nested modal
|
|
151
|
+
*/
|
|
152
|
+
requestModal(parent, modal, onClose, rect) {
|
|
153
|
+
return this.#modalManager.requestModal(parent, modal, onClose, rect);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @return boolean Whether the current view has focus
|
|
157
|
+
*/
|
|
158
|
+
registerFocus(view) {
|
|
159
|
+
return this.#focusManager.registerFocus(view);
|
|
160
|
+
}
|
|
161
|
+
registerHotKey(view, key) {
|
|
162
|
+
return this.#focusManager.registerHotKey(view, key);
|
|
163
|
+
}
|
|
164
|
+
requestFocus(view) {
|
|
165
|
+
return this.#focusManager.requestFocus(view);
|
|
166
|
+
}
|
|
167
|
+
nextFocus() {
|
|
168
|
+
this.#focusManager.nextFocus();
|
|
169
|
+
}
|
|
170
|
+
prevFocus() {
|
|
171
|
+
this.#focusManager.prevFocus();
|
|
172
|
+
}
|
|
173
|
+
triggerKeyboard(event) {
|
|
174
|
+
event = translateKeyEvent(event);
|
|
175
|
+
this.#focusManager.trigger(event);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* @see MouseManager.registerMouse
|
|
179
|
+
*/
|
|
180
|
+
registerMouse(view, offset, point, eventNames) {
|
|
181
|
+
this.#mouseManager.registerMouse(view, offset, point, eventNames);
|
|
182
|
+
}
|
|
183
|
+
checkMouse(view, x, y) {
|
|
184
|
+
this.#mouseManager.checkMouse(view, x, y);
|
|
185
|
+
}
|
|
186
|
+
triggerMouse(systemEvent) {
|
|
187
|
+
const system = new System_1.UnboundSystem(this.#focusManager);
|
|
188
|
+
this.#mouseManager.trigger(systemEvent, system);
|
|
189
|
+
}
|
|
190
|
+
registerTick(view) {
|
|
191
|
+
this.#tickManager.registerTick(view);
|
|
192
|
+
}
|
|
193
|
+
triggerTick(dt) { }
|
|
194
|
+
preRender(view) {
|
|
195
|
+
this.#modalManager.reset();
|
|
196
|
+
this.#tickManager.reset();
|
|
197
|
+
this.#mouseManager.reset();
|
|
198
|
+
this.#focusManager.reset(view === this.rootView);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* @return boolean Whether or not to rerender the view due to focus or mouse change
|
|
202
|
+
*/
|
|
203
|
+
commit() {
|
|
204
|
+
const system = new System_1.UnboundSystem(this.#focusManager);
|
|
205
|
+
const focusNeedsRender = this.#focusManager.commit();
|
|
206
|
+
const mouseNeedsRender = this.#mouseManager.commit(system);
|
|
207
|
+
return focusNeedsRender || mouseNeedsRender;
|
|
208
|
+
}
|
|
209
|
+
needsRender() {
|
|
210
|
+
this.#tickManager.needsRender();
|
|
211
|
+
}
|
|
212
|
+
render() {
|
|
213
|
+
const screenSize = new geometry_1.Size(this.#program.cols, this.#program.rows);
|
|
214
|
+
this.#buffer.resize(screenSize);
|
|
215
|
+
// this may be called again by renderModals, before the last modal renders
|
|
216
|
+
this.preRender(this.rootView);
|
|
217
|
+
const size = this.rootView.naturalSize(screenSize).max(screenSize);
|
|
218
|
+
const viewport = new Viewport_1.Viewport(this, this.#buffer, size);
|
|
219
|
+
this.rootView.render(viewport);
|
|
220
|
+
const rerenderView = this.#modalManager.renderModals(this, viewport);
|
|
221
|
+
const needsRerender = this.commit();
|
|
222
|
+
// one -and only one- re-render if a change is detected to focus or mouse-hover
|
|
223
|
+
if (needsRerender) {
|
|
224
|
+
rerenderView.render(viewport);
|
|
225
|
+
}
|
|
226
|
+
this.#tickManager.endRender();
|
|
227
|
+
this.#buffer.flush(this.#program);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
exports.Screen = Screen;
|
|
231
|
+
function translateMouseAction(action) {
|
|
232
|
+
switch (action) {
|
|
233
|
+
case 'mousemove':
|
|
234
|
+
return 'mouse.move.in';
|
|
235
|
+
case 'mousedown':
|
|
236
|
+
return `mouse.button.down`;
|
|
237
|
+
case 'mouseup':
|
|
238
|
+
return `mouse.button.up`;
|
|
239
|
+
case 'wheeldown':
|
|
240
|
+
return 'mouse.wheel.down';
|
|
241
|
+
case 'wheelup':
|
|
242
|
+
return 'mouse.wheel.up';
|
|
243
|
+
case 'wheelleft':
|
|
244
|
+
return 'mouse.wheel.left';
|
|
245
|
+
case 'wheelright':
|
|
246
|
+
return 'mouse.wheel.right';
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* These are mostly due to my own terminal keybindings; would be better to have
|
|
251
|
+
* these configured in some .rc file.
|
|
252
|
+
*/
|
|
253
|
+
function translateKeyEvent(event) {
|
|
254
|
+
if (event.full === 'M-b') {
|
|
255
|
+
return {
|
|
256
|
+
type: 'key',
|
|
257
|
+
full: 'M-left',
|
|
258
|
+
name: 'left',
|
|
259
|
+
ctrl: false,
|
|
260
|
+
meta: true,
|
|
261
|
+
shift: false,
|
|
262
|
+
char: '1;9D',
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
if (event.full === 'M-f') {
|
|
266
|
+
return {
|
|
267
|
+
type: 'key',
|
|
268
|
+
full: 'M-right',
|
|
269
|
+
name: 'right',
|
|
270
|
+
ctrl: false,
|
|
271
|
+
meta: true,
|
|
272
|
+
shift: false,
|
|
273
|
+
char: '1;9C',
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
return event;
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=Screen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Screen.js","sourceRoot":"","sources":["../lib/Screen.ts"],"names":[],"mappings":";;;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I,EAAE,OAAO;YACb,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,MAAM;SACb,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/.dist/Style.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Color } from './Color';
|
|
2
|
+
type Nullable<T> = {
|
|
3
|
+
[K in keyof T]?: null | undefined | T[K];
|
|
4
|
+
};
|
|
5
|
+
export declare class Style {
|
|
6
|
+
bold?: boolean;
|
|
7
|
+
dim?: boolean;
|
|
8
|
+
italic?: boolean;
|
|
9
|
+
strikeout?: boolean;
|
|
10
|
+
underline?: boolean;
|
|
11
|
+
inverse?: boolean;
|
|
12
|
+
blink?: boolean;
|
|
13
|
+
invisible?: boolean;
|
|
14
|
+
foreground?: Color;
|
|
15
|
+
background?: Color;
|
|
16
|
+
static NONE: Style;
|
|
17
|
+
static underlined: Style;
|
|
18
|
+
static bold: Style;
|
|
19
|
+
constructor({ bold, dim, italic, strikeout, underline, inverse, blink, invisible, foreground, background, }?: {
|
|
20
|
+
underline?: boolean;
|
|
21
|
+
inverse?: boolean;
|
|
22
|
+
bold?: boolean;
|
|
23
|
+
dim?: boolean;
|
|
24
|
+
italic?: boolean;
|
|
25
|
+
strikeout?: boolean;
|
|
26
|
+
blink?: boolean;
|
|
27
|
+
invisible?: boolean;
|
|
28
|
+
foreground?: Color;
|
|
29
|
+
background?: Color;
|
|
30
|
+
});
|
|
31
|
+
invert(): Style;
|
|
32
|
+
merge(style?: Nullable<Style>): Style;
|
|
33
|
+
isEqual(style: Style): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* @return a more easily debuggable object
|
|
36
|
+
*/
|
|
37
|
+
toDebug(): any;
|
|
38
|
+
static fromSGR(ansi: string, prevStyle: Style): Style;
|
|
39
|
+
/**
|
|
40
|
+
* @param prevStyle Used by the buffer to reset foreground/background colors and attrs
|
|
41
|
+
* @param text If provided, the text will be "wrapped" in the new codes, and
|
|
42
|
+
* `prevStyle` will be restored.
|
|
43
|
+
*/
|
|
44
|
+
toSGR(prevStyle: Style, text?: string): string;
|
|
45
|
+
}
|
|
46
|
+
export {};
|