Skip to content

Windows improve notty stdin support to resolve issue 3264#3272

Open
abmclin wants to merge 4 commits into
mthom:masterfrom
abmclin:windows_improve_notty_stdin_support
Open

Windows improve notty stdin support to resolve issue 3264#3272
abmclin wants to merge 4 commits into
mthom:masterfrom
abmclin:windows_improve_notty_stdin_support

Conversation

@abmclin
Copy link
Copy Markdown
Contributor

@abmclin abmclin commented Mar 30, 2026

This PR fixes #3264

I opened another PR to fix a different issue: #3271 may you please apply that PR before merging this one? (PR 3271 has been merged now) Although both issues are unrelated, they affect scryer-prolog subprocess I/O behavior on Windows.

Basically, it adds a fallback mode for the case when scryer-prolog is running on Windows and attached to a non-tty stdin. After trying a few approaches which ultimately did not work, I adopted the simplest one: reading one byte at a time from stdin and converting to a character if it is a valid ASCII codepoint and wrapping it as a KeyEvent to return to the caller, preserving the get_key's interface.

The fallback mode provides limited support in the sense that it doesn't capture Crtl-C or Return key presses because of the vagaries of non-tty IPC on Windows and it cannot provide any guarantees other than delivering characters that are ASCII codable. It performs no decoding of multi-byte Unicode code points. It works well and fixes the hanging problem when prompting user input for continuing solution enumeration.

Fortunately, the lack of multibyte Unicode characters is not an issue because get_key is only used to implement the simple user interaction interface which solely is made out of characters from the ASCII subset of UTF8.

Out of the following available key characters to interact with scryer-prolog enumeration:

SPACE, "n" or ";": next solution, if any
RETURN or ".": stop enumeration
"a": enumerate all solutions
"f": enumerate the next 5 solutions
"h": display this help message
"w": write terms without depth limit
"p": print terms with depth limit

The only one that doesn't work is the RETURN key due to how it's treated by Windows OS but I think this is a perfectly acceptable compromise since . is still available as an alternative.

I tested on Windows and Linux, and I ran tests on both, I don't see any regressions on either platform.

I did notice that on Windows, tests covering file operations all failed but I think that's just due to Windows idiosyncrasies and not related to this PR's changes.

I want to note that there are no test cases covering this PR's issue. I tried adding some but weren't successful to complexities of Windows IPC. All of my testing has been manual.

@abmclin abmclin force-pushed the windows_improve_notty_stdin_support branch from a3f9e8c to 305f33c Compare April 11, 2026 02:07
@abmclin
Copy link
Copy Markdown
Contributor Author

abmclin commented Apr 11, 2026

I rebased the branch onto master and reformatted to meet style requirements..

Copy link
Copy Markdown
Contributor

@Skgland Skgland left a comment

Choose a reason for hiding this comment

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

A few note, assuming it works (on mobile so can't easily test it), this looks good otherwise.

Comment thread src/read/user_interaction.rs Outdated
Comment thread src/read/fallback_mode.rs
abmclin added 2 commits April 12, 2026 08:42
Explain why no multibyte UTF-8 encoding support
Disable `bytes()` clippy warning about performance penalty due to unbuffered bytes
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.

Scryer hangs when waiting to be prompted for additional solutions if stdin is unsupported terminal type on Windows

2 participants