1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.Cursor = void 0;
|
4 | const tslib_1 = require("tslib");
|
5 | const signal_exit_1 = tslib_1.__importDefault(require("signal-exit"));
|
6 | const ansi_1 = require("./ansi");
|
7 | class Cursor {
|
8 | static show() {
|
9 | if (Cursor.stream.isTTY) {
|
10 | Cursor._isVisible = true;
|
11 | Cursor.stream.write(ansi_1.EscapeCode.cursorShow());
|
12 | }
|
13 | }
|
14 | static hide() {
|
15 | if (Cursor.stream.isTTY) {
|
16 | if (!Cursor._listenerAttached) {
|
17 | (0, signal_exit_1.default)(() => {
|
18 | Cursor.show();
|
19 | });
|
20 | Cursor._listenerAttached = true;
|
21 | }
|
22 | Cursor._isVisible = false;
|
23 | Cursor.stream.write(ansi_1.EscapeCode.cursorHide());
|
24 | }
|
25 | }
|
26 | static toggle() {
|
27 | if (Cursor._isVisible) {
|
28 | Cursor.hide();
|
29 | }
|
30 | else {
|
31 | Cursor.show();
|
32 | }
|
33 | }
|
34 | }
|
35 | exports.Cursor = Cursor;
|
36 | Cursor.stream = process.stderr;
|
37 | Cursor._isVisible = true;
|
38 | Cursor._listenerAttached = false;
|