Skip to content

aiorepl: Fix Enter key handling in raw terminal mode #1016

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andrewleech
Copy link
Contributor

Summary

Fix aiorepl to properly handle the Enter key when stdin is in raw terminal mode by accepting both CR (0x0D) and LF (0x0A) for command execution.

Problem

When using aiorepl with MicroPython ports that put stdin in raw mode (such as the updated unix port using pyexec), the Enter key sends CR (0x0D) instead of LF (0x0A). The original aiorepl only handled LF, requiring users to use Ctrl+Enter instead of Enter to execute commands.

Solution

  • Handle both CR (0x0D) and LF (0x0A) for command execution
  • Improve handling of various newline sequences (CRLF, double-LF, double-CR) to prevent double-execution
  • Preserve original behavior in paste mode

Test plan

  • Verify Enter key now executes commands in raw terminal mode
  • Verify CRLF sequences don't cause double-execution
  • Verify paste mode still works correctly
  • Test with unix MicroPython port using new pyexec REPL

🤖 Generated with Claude Code

Handle both CR (0x0D) and LF (0x0A) for command execution to ensure
compatibility with raw terminal mode where Enter sends CR instead of LF.

This fixes the issue where aiorepl required Ctrl+Enter instead of
just Enter to execute commands when used with MicroPython ports that
put stdin in raw mode (such as the updated unix port using pyexec).

Also improves handling of various newline sequences (CRLF, double-LF,
double-CR) to prevent double-execution of commands.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Andrew Leech <[email protected]>
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.

2 participants