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

Support non-terminal stdin reading for GETC and IN #41

Merged
merged 2 commits into from
Sep 21, 2024

Conversation

dxrcy
Copy link
Contributor

@dxrcy dxrcy commented Sep 21, 2024

Fixes #23
Don't use console::Term to read stdin, when stdin is not a terminal. Instead read to a single-character buffer using standard library functions.
Line-buffering is not a problem when stdin is not a terminal.

Improvements that could be made:

  • Use shared console::Term and std::io::Stdin instances, instead of creating them for each GETC/IN call (stdin() creates a new handle the the global stdin mutex)
  • Extract the common behaviour of GETC and IN to a function

Copy link
Owner

@rozukke rozukke left a comment

Choose a reason for hiding this comment

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

Cheers for the fix, will get it refactored out eventually 👍

@rozukke rozukke merged commit 5c00422 into rozukke:main Sep 21, 2024
3 checks passed
@dxrcy dxrcy deleted the pipe-stdin branch September 22, 2024 00: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.

getc and in don't support piping input
2 participants