Skip to content

Commit

Permalink
Reline::Key supports the comparison with Integer
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Sep 5, 2021
1 parent 9a77fc9 commit ebc3e0f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/reline.rb
Expand Up @@ -18,9 +18,21 @@ class ConfigEncodingConversionError < StandardError; end

Key = Struct.new('Key', :char, :combined_char, :with_meta) do
def match?(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)
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)
Expand Down

0 comments on commit ebc3e0f

Please sign in to comment.