You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Arrow key inputs are ignored on ENABLE_VIRTUAL_TERMINAL_INPUT enabled windows console #914
Symptoms similar to those described in #903 also occur in mswin/mingw.
ENABLE_VIRTUAL_TERMINAL_INPUT is normally disabled, but it may be enabled by other processes sharing the console, and it is possible that it is not reset due to a crash or other issue.
irb(main):001> Reline::IOGate.class=>Reline::Windowsirb(main):002* defset_vt_input(f)irb(main):003* Reline::IOGate.instance_execdoirb(main):004* m="\0"*4;@GetConsoleMode.call(@hConsoleInputHandle,m);irb(main):005* mode=m.unpack1("L")irb(main):006* puts"old mode: #{mode.to_s(16)}"irb(main):007* new_mode=(mode & ~0x200) | (f ? 0x200 : 0)irb(main):008* @SetConsoleMode.call(@hConsoleInputHandle,new_mode)irb(main):009* puts"new mode: #{new_mode.to_s(16)}"irb(main):010* endirb(main):011> end=>:set_vt_inputirb(main):012> set_vt_input(true)oldmode: 1f7newmode: 3f7=> nilirb(main):013> # => cursor movement using the arrow keys is disabledirb(main):014> set_vt_input(false)oldmode: 3f7newmode: 1f7=> nilirb(main):015> # => cursor movement using the arrow keys is enabled
Under the hood
Reline::Windows converts input key events to the output of getwch() rather than VT sequences (presumably to preserve the specifications from the early stages of development).
When ENABLE_VIRTUAL_TERMINAL_INPUT is enabled, Reline receives input that can be represented as VT sequences as characters rather than events, so no conversion to getwch() code takes place.
Since Reline::Windows bases its key bindings on getwch() codes, it cannot recognize input in the form of VT sequences.
Options for a Solution
Add key bindings for VT sequences to Reline::Windows
Stop using the getwch() code and have Reline::Windows convert key events to VT sequences
Although option 2 introduces more changes, since WSL coexists in Windows environments, this approach is preferable because it allows for the use of a common configuration.
Activity