Skip to content

Raw terminal mode for keyboard channel#91

Merged
associate-1 merged 1 commit intomainfrom
feat/raw-terminal-keyboard-90
Feb 24, 2026
Merged

Raw terminal mode for keyboard channel#91
associate-1 merged 1 commit intomainfrom
feat/raw-terminal-keyboard-90

Conversation

@associate-1
Copy link
Member

Summary

  • Use golang.org/x/term to switch stdin to raw mode in the generated entry harness, so keyboard input is available character-by-character without waiting for Enter (Support character-by-character keyboard channel semantics #90)
  • Fall back to buffered bufio.NewReader when stdin is piped (non-terminal)
  • Handle Ctrl+C (byte 3) in raw mode to restore terminal and exit cleanly
  • Insert CR before LF in screen/error output writers when in raw mode (raw mode disables OPOST)
  • Restore terminal state on SIGINT/SIGTERM via signal handler

Test plan

  • Unit test verifies generated code contains term.MakeRaw, term.IsTerminal, term.Restore, and new imports
  • E2E test transpiles an echoing program, pipes "hello Z" to stdin, verifies output matches "hello "
  • All existing tests pass (go test ./codegen ./lexer ./parser ./preproc ./modgen)
  • Course module still transpiles and passes go vet
  • Manual test with echoing.occ — characters echo immediately on keypress

Closes #90

🤖 Generated with Claude Code

Use golang.org/x/term to switch stdin to raw mode in the generated entry
harness so characters are available immediately as typed, without waiting
for Enter. Falls back to buffered bufio.NewReader when stdin is not a
terminal (piped input). Handles Ctrl+C in raw mode, LF→CRLF in output
writers, and restores terminal state on signals.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@associate-1 associate-1 merged commit 6272c72 into main Feb 24, 2026
1 check passed
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.

Support character-by-character keyboard channel semantics

2 participants