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

Allow virtual term input in raw mode #335

Merged
merged 1 commit into from
Dec 28, 2023

Conversation

Vap0r1ze
Copy link
Contributor

This PR adds support for virtual terminal input (e.g: \x1b[B for DownArrow) when reading from stdin in raw mode.
It does this by moving from crossterm to a (smaller) crate specifically for cross-platform tty raw mode. It works almost exactly like crossterm, but also uses the virtual terminal mode flag.

This also fixes a small bug with the uiua watch-runner where raw mode does not get disabled after the program exits, because disable_raw_mode() only worked after enable_raw_mode() was called at least once, which the main process never does, only the child process (even though they share the same stdio).

Motivation: I wanted to be handle arrow keys so I could make Tetris :^)

@Vap0r1ze
Copy link
Contributor Author

One possibly weird behaviour about the current state of this PR is that raw mode causes Ctrl+C to be passed down to the uiua program rather than being caught by the main process. Let me know if this is desired or if I should change this in some way because it can be annoying

@kaikalii
Copy link
Member

This is the current behavior, so I think it's fine.

@kaikalii
Copy link
Member

Thanks!

@kaikalii kaikalii merged commit 31d2638 into uiua-lang:main Dec 28, 2023
1 check passed
@Vap0r1ze Vap0r1ze deleted the feat/virt-input branch December 28, 2023 19:24
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