diff options
author | aycabta <aycabta@gmail.com> | 2019-05-28 04:39:29 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-05-28 04:39:29 +0900 |
commit | f6b62d8fe77a474935ef3dee6bb20ca3cc4da602 (patch) | |
tree | ceca9679fb4210381d8959a01e6def097a2ed37c /lib/reline/windows.rb | |
parent | 8b135cc8752abf89f2c11fb8760febb756348577 (diff) | |
download | ruby-f6b62d8fe77a474935ef3dee6bb20ca3cc4da602.tar.gz |
Use Shift+Enter as Meta+Enter on Windows
Diffstat (limited to 'lib/reline/windows.rb')
-rw-r--r-- | lib/reline/windows.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb index da4f744b18..36bd8dcc45 100644 --- a/lib/reline/windows.rb +++ b/lib/reline/windows.rb @@ -40,6 +40,7 @@ class Reline::Windows end VK_MENU = 0x12 + VK_SHIFT = 0x10 STD_OUTPUT_HANDLE = -11 @@getwch = Win32API.new('msvcrt', '_getwch', [], 'I') @@kbhit = Win32API.new('msvcrt', '_kbhit', [], 'I') @@ -75,7 +76,12 @@ class Reline::Windows end input = getwch alt = (@@GetKeyState.call(VK_MENU) & 0x80) != 0 - if input.size > 1 + shift_enter = (@@GetKeyState.call(VK_SHIFT) & 0x80) != 0 and input.first == 0x0D + if shift_enter + # It's treated as Meta+Enter on Windows + @@buf.concat(["\e".ord]) + @@buf.concat(input) + elsif input.size > 1 @@buf.concat(input) else # single byte case input[0] |