vadimdemedes / goodness-squad

4 stars 0 forks source link

Add support for a fake cursor #7

Open vadimdemedes opened 3 years ago

vadimdemedes commented 3 years ago

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 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: