Class: Twiddler::Lint::MissingStrokes

Inherits:
Rule
  • Object
show all
Defined in:
lib/twiddler/lint.rb

Instance Method Summary collapse

Methods inherited from Rule

#initialize, register, registered

Constructor Details

This class inherits a constructor from Twiddler::Lint::Rule

Instance Method Details

#checkObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/twiddler/lint.rb', line 36

def check()
  all_strokes = []
  @config.keytable.each do |key|
    all_strokes << [key.code, ""]
    all_strokes << [key.code, "shift"] if key.has_mod?("shift")
  end

  @config.keyboard.each do |chord|
    next unless chord.single?
    all_strokes.delete(@config.keytable.normalized(chord[0]))
  end

  if all_strokes.empty?
    return "Missing: all normal keystrokes accounted for"
  else
    return "Config lacks strokes: #{all_strokes.map{|str| @config.keytable[*str]}.inspect}"
  end
end