Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for left/right arrows to move terminal line cursor #37

Merged
merged 6 commits into from
May 2, 2023

Conversation

jerwolff
Copy link
Contributor

@jerwolff jerwolff commented May 1, 2023

This PR is in relation to issue #36

  • Changes the Cursor to its own span element.
  • Cursor's position set to relative, and left property is being controlled by the position of the cursor inside the hidden terminal input element.
  • Works with any font size or font family

src/index.tsx Show resolved Hide resolved
src/style.css Outdated Show resolved Hide resolved
src/style.css Outdated Show resolved Hide resolved
@jonmbake jonmbake merged commit abe7b89 into jonmbake:master May 2, 2023
3 checks passed
<div ref={ scrollIntoViewRef }></div>
</div>
<input className="terminal-hidden-input" placeholder="Terminal Hidden Input" value={ currentLineInput } autoFocus={ onInput != null } onChange={ updateCurrentLineInput } onKeyDown={ handleInputKeyDown }/>
<input id="hidden" className="terminal-hidden-input" placeholder="Terminal Hidden Input" value={ currentLineInput } autoFocus={ onInput != null } onChange={ updateCurrentLineInput } onKeyDown={ handleInputKeyDown }/>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check this, but there have been a bug introduced here when multiple terminals are rendered by using an id attr. @jerwolff I think we may want to use a ref to look this el up, instead of using id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah that's a good point, I should be using a ref. I can work on that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may be able to avoid using both a ref and id, and instead use event.currentTarget in #handleInputKeyDown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants