Class: Xkbcommon::Keymap::Parser
- Inherits:
-
Object
- Object
- Xkbcommon::Keymap::Parser
- Defined in:
- lib/xkbcommon/keymap/parser.rb
Instance Attribute Summary collapse
-
#keymap ⇒ Object
readonly
Returns the value of attribute keymap.
Instance Method Summary collapse
- #characters ⇒ Object
-
#initialize(keymap) ⇒ Parser
constructor
A new instance of Parser.
- #keys ⇒ Object
- #modifiers ⇒ Object
- #symbols ⇒ Object
Constructor Details
#initialize(keymap) ⇒ Parser
Returns a new instance of Parser.
4 5 6 |
# File 'lib/xkbcommon/keymap/parser.rb', line 4 def initialize(keymap) @keymap = keymap end |
Instance Attribute Details
#keymap ⇒ Object (readonly)
Returns the value of attribute keymap.
8 9 10 |
# File 'lib/xkbcommon/keymap/parser.rb', line 8 def keymap @keymap end |
Instance Method Details
#characters ⇒ Object
45 46 47 48 |
# File 'lib/xkbcommon/keymap/parser.rb', line 45 def characters symbols # will be parsed while parsing symbols @characters end |
#keys ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/xkbcommon/keymap/parser.rb', line 10 def keys @keys ||= begin min_code = Libxkbcommon.xkb_keymap_min_keycode(@keymap.to_native) max_code = Libxkbcommon.xkb_keymap_max_keycode(@keymap.to_native) keycode_range = min_code..max_code codes = keycode_range.select do |code| # Todo: This does not seem to filter out keys that do not exist on the keyboard? 0 < Libxkbcommon.xkb_keymap_num_layouts_for_key(@keymap.to_native, code) end codes.map{ |code| Key.new(self, code) } end end |
#modifiers ⇒ Object
24 25 26 27 |
# File 'lib/xkbcommon/keymap/parser.rb', line 24 def modifiers symbols # will be parsed while parsing symbols @modifiers end |
#symbols ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/xkbcommon/keymap/parser.rb', line 29 def symbols @symbols ||= begin symbols = parse_symbols # first parse round will give us all modifier keys, so we can parse # what keys active which modifiers next @modifiers = parse_modifiers(symbols) all_combinations(@modifiers).each do |modifiers| symbols = parse_symbols(symbols, modifiers) end symbols end end |