1
0
Fork 0
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:
aycabta 2021-09-05 23:29:18 +09:00 committed by git
parent e68a586263
commit bb6d45cfee

View file

@ -18,9 +18,21 @@ module Reline
Key = Struct.new('Key', :char, :combined_char, :with_meta) do
def match?(key)
if key.instance_of?(Reline::Key)
(key.char.nil? or char.nil? or char == key.char) and
(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
CursorPos = Struct.new(:x, :y)