aboutsummaryrefslogtreecommitdiff
path: root/node_modules/cli-cursor/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/cli-cursor/index.js')
-rw-r--r--node_modules/cli-cursor/index.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/node_modules/cli-cursor/index.js b/node_modules/cli-cursor/index.js
new file mode 100644
index 0000000..8435813
--- /dev/null
+++ b/node_modules/cli-cursor/index.js
@@ -0,0 +1,39 @@
+import process from 'node:process';
+import restoreCursor from 'restore-cursor';
+
+let isHidden = false;
+
+const cliCursor = {};
+
+cliCursor.show = (writableStream = process.stderr) => {
+ if (!writableStream.isTTY) {
+ return;
+ }
+
+ isHidden = false;
+ writableStream.write('\u001B[?25h');
+};
+
+cliCursor.hide = (writableStream = process.stderr) => {
+ if (!writableStream.isTTY) {
+ return;
+ }
+
+ restoreCursor();
+ isHidden = true;
+ writableStream.write('\u001B[?25l');
+};
+
+cliCursor.toggle = (force, writableStream) => {
+ if (force !== undefined) {
+ isHidden = force;
+ }
+
+ if (isHidden) {
+ cliCursor.show(writableStream);
+ } else {
+ cliCursor.hide(writableStream);
+ }
+};
+
+export default cliCursor;