term: add MakeRawOutput function #687
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add MakeRawOutput function that puts the terminal into raw mode for input while preserving output processing flags (OPOST/ONLCR). This allows special keys (arrows, etc.) to be captured properly while keeping standard output functions like println() and logging libraries working correctly.
Unlike MakeRaw, this preserves the terminal's output processing so that newlines (\n) are automatically converted to carriage return + newline (\r\n), making standard output functions work as expected.
This is useful for applications that need proper keyboard input handling but want to use standard logging libraries or print statements without manual \r\n handling.
Implementations:
Unix: Sets raw mode for input but keeps OPOST and ONLCR flags enabled
Windows: Same as MakeRaw (output processing is separate on Windows)
Plan 9: Same as MakeRaw (Plan 9 handles output differently)
Other platforms: Returns appropriate error message
I have read
CONTRIBUTING.md.I have created a discussion that was approved by a maintainer (for new features).