Use Reline::ANSI when ruby is built with the msys/cygwin runtime#910
Open
tompng wants to merge 1 commit into
Open
Use Reline::ANSI when ruby is built with the msys/cygwin runtime#910tompng wants to merge 1 commit into
tompng wants to merge 1 commit into
Conversation
A cygwin-built ruby (e.g. MSYS2's ruby package) routes all I/O through the Cygwin tty layer, which presents an ANSI terminal regardless of what stdin is attached to: a Cygwin pty pipe (mintty) or a Windows console (Windows Terminal, conhost). In console mode, Cygwin enables ENABLE_VIRTUAL_TERMINAL_INPUT, so arrow keys arrive as ESC [ A character events instead of VK_UP key events. Reline::Windows reads the console handle directly via ReadConsoleInputW, bypassing the tty layer, and has no CSI key bindings, so arrow keys were ignored. cygwin/msys were originally not in this branch: until 1cfa522 the condition was `RUBY_PLATFORM =~ /mswin|mingw/`. That commit switched to the generic "is Windows" host_os regex to support JRuby (whose RUBY_PLATFORM is always "java"); including cygwin/msys was incidental, not motivated by any case where a cygwin ruby needed the console API. JRuby on Windows reports host_os "mswin32" and is unaffected. Fixes ruby#903 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A cygwin-built ruby (e.g. MSYS2's ruby package) routes all I/O through the Cygwin tty layer, which presents an ANSI terminal regardless of what stdin is attached to: a Cygwin pty pipe (mintty) or a Windows console (Windows Terminal, conhost). In console mode, Cygwin enables ENABLE_VIRTUAL_TERMINAL_INPUT, so arrow keys arrive as ESC [ A character events instead of VK_UP key events. Reline::Windows reads the console handle directly via ReadConsoleInputW, bypassing the tty layer, and has no CSI key bindings, so arrow keys were ignored.
cygwin/msys were originally not in this branch: until 1cfa522 the condition was
RUBY_PLATFORM =~ /mswin|mingw/. That commit switched to the generic "is Windows" host_os regex to support JRuby (whose RUBY_PLATFORM is always "java"); including cygwin/msys was incidental, not motivated by any case where a cygwin ruby needed the console API. JRuby on Windows reports host_os "mswin32" and is unaffected.Fixes #903