Ink hides terminal cursor to ensure it doesn't break the output. However, cursor is still useful in components like ink-text-input, so that component actually fakes the cursor and replicates normal cursor behavior (moving cursor left or right, pasting text from clipboard, inserting characters at different positions, etc).
This issue involves extracting cursor functionality out of ink-text-input into useCursor React hook inside Ink. I think the API could look like:
const value = 'Some text';
// `valueWithCursor` has the same text as `value`, but with cursor faked inside that string
const valueWithCursor = useCursor(value);
You'd also need to handle such use cases as:
[ ] Mask value for sensitive data, like passwords
[ ] Ignore user input in case other component is focused by exposing an option to disable useCursor's behavior
See https://github.com/vadimdemedes/ink/issues/251.
Ink hides terminal cursor to ensure it doesn't break the output. However, cursor is still useful in components like ink-text-input, so that component actually fakes the cursor and replicates normal cursor behavior (moving cursor left or right, pasting text from clipboard, inserting characters at different positions, etc).
This issue involves extracting cursor functionality out of
ink-text-input
intouseCursor
React hook inside Ink. I think the API could look like:You'd also need to handle such use cases as:
useCursor
's behavior