Skip to content

Commit 46599eb

Browse files
author
test2
committed
feat: show cursor when stdin is true
1 parent cb5cb8c commit 46599eb

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

package-lock.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"ajv": "^8.12.0",
1616
"ajv-formats": "^3.0.1",
1717
"chalk": "^5.3.0",
18+
"cli-cursor": "^4.0.0",
1819
"cli-spinners": "^3.4.0",
1920
"cors": "^2.8.5",
2021
"debug": "^4.3.4",

src/ui/reporters/default-reporter.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { FormProps, FormReturnValue } from '@codifycli/ink-form';
22
import { CommandRequestData } from '@codifycli/schemas';
3+
import cliCursor from 'cli-cursor';
34
import { render } from 'ink';
45
import { EventEmitter } from 'node:events';
56
import React from 'react';
@@ -141,12 +142,16 @@ export class DefaultReporter implements Reporter {
141142
this.inkPauseRendering?.();
142143
this.inkSuspendStdin?.();
143144
process.stdin.setRawMode(true);
145+
// Ink hides the terminal cursor on its first render and only restores it on unmount,
146+
// so without this the cursor stays hidden while we're waiting on stdin from the user.
147+
cliCursor.show(process.stdout);
144148
}
145149

146150
async disableRawMode(): Promise<void> {
147151
this.rawOutput = false;
148152
this.inkResumeStdin?.();
149153
process.stdin.setRawMode(true);
154+
cliCursor.hide(process.stdout);
150155

151156
// Wait for the terminal to settle before Ink resumes writing to stdout.
152157
await sleep(200);

0 commit comments

Comments
 (0)