summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-09-05 23:29:18 +0900
committergit <svn-admin@ruby-lang.org>2021-09-06 05:23:01 +0900
commitbb6d45cfeecc8e16ec22e89ab40fb6b56177da7f (patch)
tree039f6855b0f55aa9523e44d7ffa538e4f83f4d31
parente68a5862630590caf79ac0576ba6d15135709d58 (diff)
[ruby/reline] Reline::Key supports the comparison with Integer
https://github.com/ruby/reline/commit/ebc3e0f673
-rw-r--r--lib/reline.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/reline.rb b/lib/reline.rb
index 735a5afad8..4b06d07b4d 100644
--- a/lib/reline.rb
+++ b/lib/reline.rb
@@ -18,9 +18,21 @@ module Reline
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)