Skip to content

Conversation

@robin-samuel
Copy link

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).

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
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.

1 participant