1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Support forced enter insertion by Ctrl+Enter on Windows

This commit is contained in:
aycabta 2019-10-24 00:12:52 +09:00
parent 659f7c0aeb
commit 7bc787fa06

View file

@ -62,6 +62,7 @@ class Reline::Windows
end end
VK_MENU = 0x12 VK_MENU = 0x12
VK_CONTROL = 0x11
VK_SHIFT = 0x10 VK_SHIFT = 0x10
STD_INPUT_HANDLE = -10 STD_INPUT_HANDLE = -10
STD_OUTPUT_HANDLE = -11 STD_OUTPUT_HANDLE = -11
@ -124,8 +125,10 @@ class Reline::Windows
end end
input = getwch input = getwch
alt = (@@GetKeyState.call(VK_MENU) & 0x80) != 0 alt = (@@GetKeyState.call(VK_MENU) & 0x80) != 0
shift_enter = !input.instance_of?(Array) && (@@GetKeyState.call(VK_SHIFT) & 0x80) != 0 && input == 0x0D control = (@@GetKeyState.call(VK_CONTROL) & 0x80) != 0
if shift_enter shift = (@@GetKeyState.call(VK_SHIFT) & 0x80) != 0
force_enter = !input.instance_of?(Array) && (control or shift) && input == 0x0D
if force_enter
# It's treated as Meta+Enter on Windows # It's treated as Meta+Enter on Windows
@@output_buf.push("\e".ord) @@output_buf.push("\e".ord)
@@output_buf.push(input) @@output_buf.push(input)