mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/reline] Reline::Key supports the comparison with Integer
https://github.com/ruby/reline/commit/ebc3e0f673
This commit is contained in:
parent
e68a586263
commit
bb6d45cfee
1 changed files with 15 additions and 3 deletions
|
@ -18,9 +18,21 @@ module Reline
|
||||||
|
|
||||||
Key = Struct.new('Key', :char, :combined_char, :with_meta) do
|
Key = Struct.new('Key', :char, :combined_char, :with_meta) do
|
||||||
def match?(key)
|
def match?(key)
|
||||||
(key.char.nil? or char.nil? or char == key.char) and
|
if key.instance_of?(Reline::Key)
|
||||||
(key.combined_char.nil? or combined_char.nil? or combined_char == key.combined_char) and
|
(key.char.nil? or char.nil? or char == key.char) and
|
||||||
(key.with_meta.nil? or with_meta.nil? or with_meta == key.with_meta)
|
(key.combined_char.nil? or combined_char.nil? or combined_char == key.combined_char) and
|
||||||
|
(key.with_meta.nil? or with_meta.nil? or with_meta == key.with_meta)
|
||||||
|
elsif key.is_a?(Integer)
|
||||||
|
if not combined_char.nil? and combined_char == key
|
||||||
|
true
|
||||||
|
elsif not char.nil? and char == key
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
CursorPos = Struct.new(:x, :y)
|
CursorPos = Struct.new(:x, :y)
|
||||||
|
|
Loading…
Reference in a new issue