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

Seprate raw keystroke config for each platforms

This commit is contained in:
Nobuyoshi Nakada 2019-06-01 00:34:38 +09:00
parent 8fc552adee
commit 552c42f51f
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
4 changed files with 27 additions and 25 deletions

View file

@ -326,31 +326,7 @@ module Reline
@@line_editor.pre_input_hook = @@pre_input_hook
@@line_editor.rerender
if IS_WINDOWS
config = {
key_mapping: {
[224, 72] => :ed_prev_history, # ↑
[224, 80] => :ed_next_history, # ↓
[224, 77] => :ed_next_char, # →
[224, 75] => :ed_prev_char, # ←
[224, 83] => :key_delete, # Del
[224, 71] => :ed_move_to_beg, # Home
[224, 79] => :ed_move_to_end # End
}
}
else
config = {
key_mapping: {
[27, 91, 65] => :ed_prev_history, # ↑
[27, 91, 66] => :ed_next_history, # ↓
[27, 91, 67] => :ed_next_char, # →
[27, 91, 68] => :ed_prev_char, # ←
[27, 91, 51, 126] => :key_delete, # Del
[27, 91, 49, 126] => :ed_move_to_beg,# Home
[27, 91, 52, 126] => :ed_move_to_end # End
}
}
end
config = Reline::IOGate::RAW_KEYSTROKE_CONFIG
key_stroke = Reline::KeyStroke.new(config)
begin

View file

@ -1,4 +1,16 @@
class Reline::ANSI
RAW_KEYSTROKE_CONFIG = {
key_mapping: {
[27, 91, 65] => :ed_prev_history, # ↑
[27, 91, 66] => :ed_next_history, # ↓
[27, 91, 67] => :ed_next_char, # →
[27, 91, 68] => :ed_prev_char, # ←
[27, 91, 51, 126] => :key_delete, # Del
[27, 91, 49, 126] => :ed_move_to_beg, # Home
[27, 91, 52, 126] => :ed_move_to_end, # End
}.each_key(&:freeze).freeze,
}.freeze
@@input = STDIN
def self.input=(val)
@@input = val

View file

@ -1,6 +1,8 @@
require 'timeout'
class Reline::GeneralIO
RAW_KEYSTROKE_CONFIG = {key_mapping: {}.freeze}.freeze
@@buf = []
def self.input=(val)

View file

@ -1,6 +1,18 @@
require 'fiddle/import'
class Reline::Windows
RAW_KEYSTROKE_CONFIG = {
key_mapping: {
[224, 72] => :ed_prev_history, # ↑
[224, 80] => :ed_next_history, # ↓
[224, 77] => :ed_next_char, # →
[224, 75] => :ed_prev_char, # ←
[224, 83] => :key_delete, # Del
[224, 71] => :ed_move_to_beg, # Home
[224, 79] => :ed_move_to_end, # End
}.each_key(&:freeze).freeze,
}.freeze
class Win32API
DLL = {}
TYPEMAP = {"0" => Fiddle::TYPE_VOID, "S" => Fiddle::TYPE_VOIDP, "I" => Fiddle::TYPE_LONG}