Class: Twiddler::Config
- Inherits:
-
Object
- Object
- Twiddler::Config
- Defined in:
- lib/twiddler/config.rb
Defined Under Namespace
Classes: Chord, KeyChord, KeyTable, MouseChord
Instance Attribute Summary collapse
-
#configs ⇒ Object
readonly
Returns the value of attribute configs.
-
#keyboard ⇒ Object
readonly
Returns the value of attribute keyboard.
-
#mouse ⇒ Object
readonly
Returns the value of attribute mouse.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #inspect ⇒ Object
- #keytable ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
389 390 391 392 393 |
# File 'lib/twiddler/config.rb', line 389 def initialize() @mouse = [] @keyboard = [] @configs = {} end |
Instance Attribute Details
#configs ⇒ Object (readonly)
Returns the value of attribute configs.
399 400 401 |
# File 'lib/twiddler/config.rb', line 399 def configs @configs end |
#keyboard ⇒ Object (readonly)
Returns the value of attribute keyboard.
399 400 401 |
# File 'lib/twiddler/config.rb', line 399 def keyboard @keyboard end |
#mouse ⇒ Object (readonly)
Returns the value of attribute mouse.
399 400 401 |
# File 'lib/twiddler/config.rb', line 399 def mouse @mouse end |
Class Method Details
.keytable ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/twiddler/config.rb', line 129 def self.keytable @table ||= begin table = KeyTable.new table.start_tag(:normal) table.start_tag(:letters) (("a".."z").to_a).each_with_index do |ltr, idx| table[idx+4] = ltr end (("A".."Z").to_a).each_with_index do |ltr, idx| table.mod(idx+4, "shift", ltr) end table.end_tag(:letters) table.start_tag(:numbers) (("1".."9").to_a + ["0"]).each_with_index do |num, idx| table[idx+30] = num end %w[! @ # $ % ^ & * ( )].each_with_index do |shift_num, idx| table.mod(idx+30, "shift", shift_num) end table.end_tag(:numbers) table.start_tag(:punctuation) table[45] = "-" table.mod(45, "shift", "_") table[46] = "=" table.mod(46, "shift", "+") table[47] = "[" table.mod(47, "shift", "{") table[48] = "]" table.mod(48, "shift", "}") table[49] = "\\" table.mod(49, "shift", "|") table[56] = "/" table.mod(56, "shift", "?") table[51] = ";" table.mod(51, "shift", ":") table[52] = "'" table.mod(52, "shift", "\"") table[53] = "`" table.mod(53, "shift", "~") table[54] = "," table.mod(54, "shift", "<") table[55] = "." table.mod(55, "shift", ">") table[73] = "~" table. table.start_tag(:special) table[40] = "<Rtrn>" table[41] = "<Esc>" table[42] = "<Bksp>" table[43] = "<Tab>" table[44] = "<Spc>" table[57] = "<Cplk>" table[71] = "<Scrlk>" table[74] = "<Home>" table[75] = "<PgUp>" table[76] = "<Delete>" table[77] = "<End>" table[78] = "<PgDn>" table[79] = "<Right>" table[80] = "<Left>" table[81] = "<Down>" table[82] = "<Up>" table[83] = "<Nmlk>" table.start_tag(:fkeys) ("1".."12").to_a.each_with_index do |fkey, idx| table[idx+58] = "F" + fkey end table.end_tag(:fkeys) table.start_tag(:hardware_control) table[-2] = "<<Mass Storage Mode>>" table[-3] = "<<Upgrade Mode>>" table[-4] = "<<Disable Mouse Mode>>" table[-5] = "<<Enable Mouse Mode>>" table. table end end |
Instance Method Details
#inspect ⇒ Object
401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/twiddler/config.rb', line 401 def inspect "<Twiddler::Config: \n " + "Config: #{@configs.inspect}\n " + @keyboard.map do |chord| chord.render end.join("\n ") + "\n ---\n " + @mouse.map do |chord| chord.render end.join("\n ") + "\n" + ">" end |
#keytable ⇒ Object
395 396 397 |
# File 'lib/twiddler/config.rb', line 395 def keytable self.class.keytable end |