Class: Twiddler::Config::KeyChord
- Inherits:
-
Chord
- Object
- Chord
- Twiddler::Config::KeyChord
show all
- Defined in:
- lib/twiddler/config.rb
Constant Summary
collapse
- ModKeys =
%w{RGui RAlt RSft RCtl LGui LAlt LSft LCtl}
Instance Attribute Summary collapse
Attributes inherited from Chord
#mods, #rows
Instance Method Summary
collapse
Methods inherited from Chord
#extract_key, #keydata=, #render, #render_keys
Constructor Details
Returns a new instance of KeyChord.
277
278
279
280
|
# File 'lib/twiddler/config.rb', line 277
def initialize
super
@keystrokes = []
end
|
Instance Attribute Details
#keystrokes ⇒ Object
Returns the value of attribute keystrokes.
282
283
284
|
# File 'lib/twiddler/config.rb', line 282
def keystrokes
@keystrokes
end
|
Instance Method Details
#[](idx) ⇒ Object
284
285
286
|
# File 'lib/twiddler/config.rb', line 284
def [](idx)
@keystrokes[idx]
end
|
#add_keystroke(mod_bits, idx) ⇒ Object
292
293
294
295
|
# File 'lib/twiddler/config.rb', line 292
def add_keystroke(mod_bits, idx)
mods = ModKeys.zip(mod_bits.split('')).delete_if{|mod,bit| bit != "1"}.map{|mod,bit| mod}
@keystrokes << [idx, mods]
end
|
#keytable ⇒ Object
297
298
299
|
# File 'lib/twiddler/config.rb', line 297
def keytable
Config.keytable
end
|
#render_action ⇒ Object
301
302
303
304
305
306
307
308
|
# File 'lib/twiddler/config.rb', line 301
def render_action
output = []
(@keystrokes || []).each do |code, mods|
output << keytable[code, mods]
end
return output.join()
end
|
#single? ⇒ Boolean
288
289
290
|
# File 'lib/twiddler/config.rb', line 288
def single?
@keystrokes.length == 1
end
|