зеркало из https://github.com/github/ruby.git
Seprate raw keystroke config for each platforms
This commit is contained in:
Родитель
8fc552adee
Коммит
552c42f51f
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require 'timeout'
|
||||
|
||||
class Reline::GeneralIO
|
||||
RAW_KEYSTROKE_CONFIG = {key_mapping: {}.freeze}.freeze
|
||||
|
||||
@@buf = []
|
||||
|
||||
def self.input=(val)
|
||||
|
|
|
@ -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}
|
||||
|
|
Загрузка…
Ссылка в новой задаче