Skip to content

Commit

Permalink
Use Shift+Enter as Meta+Enter on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed May 27, 2019
1 parent 8b135cc commit f6b62d8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/reline/windows.rb
Expand Up @@ -40,6 +40,7 @@ def call(*args)
end

VK_MENU = 0x12
VK_SHIFT = 0x10
STD_OUTPUT_HANDLE = -11
@@getwch = Win32API.new('msvcrt', '_getwch', [], 'I')
@@kbhit = Win32API.new('msvcrt', '_kbhit', [], 'I')
Expand Down Expand Up @@ -75,7 +76,12 @@ def self.getc
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]
Expand Down

0 comments on commit f6b62d8

Please sign in to comment.