Accept modifier in `key' run control keyword
This commit is contained in:
parent
231e72df42
commit
6c7b01c9aa
@ -8,6 +8,14 @@ Feature: `key' run control keyword
|
|||||||
When I press the alt+f keys
|
When I press the alt+f keys
|
||||||
Then the output must contain "trigger f key code"
|
Then the output must contain "trigger f key code"
|
||||||
|
|
||||||
|
Scenario: defines code to run when given keys are pressed
|
||||||
|
Given uhwm is running with this run control file:
|
||||||
|
"""
|
||||||
|
key(:f, :shift) { puts 'trigger f key code' }
|
||||||
|
"""
|
||||||
|
When I press the alt+shift+f keys
|
||||||
|
Then the output must contain "trigger f key code"
|
||||||
|
|
||||||
Scenario: translates common key names to their X equivalent
|
Scenario: translates common key names to their X equivalent
|
||||||
Given uhwm is running with this run control file:
|
Given uhwm is running with this run control file:
|
||||||
"""
|
"""
|
||||||
|
@ -28,8 +28,8 @@ module Uh
|
|||||||
@env.modifier = mod
|
@env.modifier = mod
|
||||||
end
|
end
|
||||||
|
|
||||||
def key keysym, &block
|
def key *keysyms, &block
|
||||||
@env.keybinds[translate_keysym keysym] = block
|
@env.keybinds[translate_keysym *keysyms] = block
|
||||||
end
|
end
|
||||||
|
|
||||||
def worker type, **options
|
def worker type, **options
|
||||||
@ -39,7 +39,8 @@ module Uh
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def translate_keysym keysym
|
def translate_keysym keysym, modifier = nil
|
||||||
|
return [translate_keysym(keysym)[0].to_sym, modifier] if modifier
|
||||||
translate_key = keysym.to_s.downcase.to_sym
|
translate_key = keysym.to_s.downcase.to_sym
|
||||||
translated_keysym = KEYSYM_TRANSLATIONS.key?(translate_key) ?
|
translated_keysym = KEYSYM_TRANSLATIONS.key?(translate_key) ?
|
||||||
KEYSYM_TRANSLATIONS[translate_key] :
|
KEYSYM_TRANSLATIONS[translate_key] :
|
||||||
|
@ -65,6 +65,11 @@ module Uh
|
|||||||
expect(env.keybinds.keys).to include :f
|
expect(env.keybinds.keys).to include :f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'registers a combined keys binding in the env' do
|
||||||
|
rc.key :f, :shift, &code
|
||||||
|
expect(env.keybinds.keys).to include %i[f shift]
|
||||||
|
end
|
||||||
|
|
||||||
it 'registers given block with the key binding' do
|
it 'registers given block with the key binding' do
|
||||||
rc.key :f, &code
|
rc.key :f, &code
|
||||||
expect(env.keybinds[:f].call).to eq :keybind_code
|
expect(env.keybinds[:f].call).to eq :keybind_code
|
||||||
|
Loading…
x
Reference in New Issue
Block a user