ruby/lib/reline/key_actor/composite.rb
tomoya ishida 91d4a7ae0c [ruby/reline] Improve key binding match/matching check
(https://github.com/ruby/reline/pull/709)

* Improve key binding match/matching check

* Rename key_actors to default_key_bindings

* Make key_stroke.expand always return a value

* Update add_default_key_binding to use a add_default_key_binding_by_keymap internally

Co-authored-by: Stan Lo <stan001212@gmail.com>

---------

353ec236e2

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-06-03 13:15:05 +00:00

17 lines
324 B
Ruby

class Reline::KeyActor::Composite
def initialize(key_actors)
@key_actors = key_actors
end
def matching?(key)
@key_actors.any? { |key_actor| key_actor.matching?(key) }
end
def get(key)
@key_actors.each do |key_actor|
func = key_actor.get(key)
return func if func
end
nil
end
end