cura 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +45 -21
  3. data/cura.gemspec +1 -1
  4. data/examples/hello_world/lib/hello_world.rb +10 -10
  5. data/examples/mruby-examples/mrbgem.rake +5 -6
  6. data/examples/todo_list/data.db +0 -0
  7. data/examples/todo_list/lib/todo_list/application.rb +24 -18
  8. data/lib/cura/adapter.rb +13 -20
  9. data/lib/cura/application.rb +47 -51
  10. data/lib/cura/attributes/has_ancestry.rb +4 -8
  11. data/lib/cura/attributes/has_application.rb +3 -7
  12. data/lib/cura/attributes/has_attributes.rb +1 -9
  13. data/lib/cura/attributes/has_children.rb +14 -20
  14. data/lib/cura/attributes/has_colors.rb +14 -18
  15. data/lib/cura/attributes/has_coordinates.rb +9 -15
  16. data/lib/cura/attributes/has_dimensions.rb +12 -18
  17. data/lib/cura/attributes/has_events.rb +10 -18
  18. data/lib/cura/attributes/has_focusability.rb +5 -11
  19. data/lib/cura/attributes/has_initialize.rb +1 -5
  20. data/lib/cura/attributes/has_offsets.rb +16 -20
  21. data/lib/cura/attributes/has_orientation.rb +12 -18
  22. data/lib/cura/attributes/has_relative_coordinates.rb +4 -8
  23. data/lib/cura/attributes/has_root.rb +18 -22
  24. data/lib/cura/attributes/has_side_attributes.rb +18 -24
  25. data/lib/cura/attributes/has_windows.rb +13 -19
  26. data/lib/cura/borders.rb +0 -4
  27. data/lib/cura/color.rb +84 -91
  28. data/lib/cura/component/base.rb +29 -33
  29. data/lib/cura/component/button.rb +10 -16
  30. data/lib/cura/component/group.rb +14 -18
  31. data/lib/cura/component/label.rb +44 -48
  32. data/lib/cura/component/listbox.rb +24 -28
  33. data/lib/cura/component/pack.rb +14 -18
  34. data/lib/cura/component/scrollbar.rb +41 -45
  35. data/lib/cura/component/textbox.rb +21 -25
  36. data/lib/cura/cursor.rb +15 -23
  37. data/lib/cura/error/base.rb +0 -3
  38. data/lib/cura/error/invalid_adapter.rb +1 -7
  39. data/lib/cura/error/invalid_application.rb +1 -7
  40. data/lib/cura/error/invalid_color.rb +1 -7
  41. data/lib/cura/error/invalid_component.rb +1 -7
  42. data/lib/cura/error/invalid_middleware.rb +1 -7
  43. data/lib/cura/event.rb +4 -8
  44. data/lib/cura/event/base.rb +17 -24
  45. data/lib/cura/event/click.rb +1 -6
  46. data/lib/cura/event/dispatcher.rb +20 -26
  47. data/lib/cura/event/focus.rb +1 -6
  48. data/lib/cura/event/handler.rb +16 -24
  49. data/lib/cura/event/key_down.rb +11 -17
  50. data/lib/cura/event/middleware/aimer/base.rb +4 -10
  51. data/lib/cura/event/middleware/aimer/dispatcher_target.rb +2 -8
  52. data/lib/cura/event/middleware/aimer/mouse_focus.rb +6 -11
  53. data/lib/cura/event/middleware/aimer/target_option.rb +4 -10
  54. data/lib/cura/event/middleware/base.rb +0 -4
  55. data/lib/cura/event/middleware/dispatch.rb +0 -4
  56. data/lib/cura/event/middleware/translator/base.rb +4 -10
  57. data/lib/cura/event/middleware/translator/mouse_click.rb +4 -8
  58. data/lib/cura/event/mouse.rb +5 -11
  59. data/lib/cura/event/mouse_button.rb +21 -27
  60. data/lib/cura/event/mouse_wheel_down.rb +1 -6
  61. data/lib/cura/event/mouse_wheel_up.rb +1 -6
  62. data/lib/cura/event/resize.rb +0 -4
  63. data/lib/cura/event/selected.rb +1 -6
  64. data/lib/cura/event/unfocus.rb +1 -6
  65. data/lib/cura/focus_controller.rb +19 -23
  66. data/lib/cura/key.rb +277 -283
  67. data/lib/cura/margins.rb +0 -4
  68. data/lib/cura/offsets.rb +14 -18
  69. data/lib/cura/padding.rb +0 -4
  70. data/lib/cura/pencil.rb +3 -7
  71. data/lib/cura/version.rb +1 -3
  72. data/lib/cura/window.rb +11 -16
  73. data/spec/cura/attributes/has_ancestry_spec.rb +39 -39
  74. data/spec/cura/attributes/has_application_spec.rb +20 -20
  75. data/spec/cura/attributes/has_attributes_spec.rb +26 -26
  76. data/spec/cura/attributes/has_children_spec.rb +54 -54
  77. data/spec/cura/attributes/has_colors_spec.rb +4 -4
  78. data/spec/cura/attributes/has_coordinates_spec.rb +4 -4
  79. data/spec/cura/attributes/has_dimensions_spec.rb +4 -4
  80. data/spec/cura/attributes/has_events_spec.rb +4 -4
  81. data/spec/cura/attributes/has_focusability_spec.rb +18 -18
  82. data/spec/cura/attributes/has_offsets_spec.rb +4 -4
  83. data/spec/cura/attributes/has_orientation_spec.rb +38 -38
  84. data/spec/cura/attributes/has_relative_coordinates_spec.rb +4 -4
  85. data/spec/cura/attributes/has_side_attributes_spec.rb +4 -4
  86. data/spec/spec_helper.rb +1 -1
  87. data/spec/support/shared_examples_for_attributes.rb +41 -41
  88. metadata +1 -1
@@ -1,285 +1,282 @@
1
1
  module Cura
2
-
3
2
  # Helpers for dealing with keyboard keys.
4
3
  module Key
5
-
6
4
  NAMES = { # Name => Character
7
- :ac_back => nil,
8
- :ac_bookmarks => nil,
9
- :ac_forward => nil,
10
- :ac_home => nil,
11
- :ac_refresh => nil,
12
- :ac_search => nil,
13
- :ac_stop => nil,
14
- :again => nil,
15
- :alterase => nil,
16
- :ampersand => "&",
17
- :apostrophe => nil,
18
- :application => nil,
19
- :asterisk => "*",
20
- :at => "@",
21
- :audio_mute => nil,
22
- :audio_next => nil,
23
- :audio_play => nil,
24
- :audio_prev => nil,
25
- :audio_previous => nil,
26
- :audio_stop => nil,
27
- :backquote => "`",
28
- :backslash => '\\',
29
- :backspace => nil,
30
- :binary => nil,
31
- :brightness_down => nil,
32
- :brightness_up => nil,
33
- :calculator => nil,
34
- :cancel => nil,
35
- :capslock => nil,
36
- :caret => "^",
37
- :clear => nil,
38
- :clear_again => nil,
39
- :clear_entry => nil,
40
- :colon => ":",
41
- :comma => ",",
42
- :computer => nil,
43
- :copy => nil,
44
- :crsel => nil, # TODO: Clear selection?
45
- :currency_subunit => nil,
46
- :currency_unit => nil,
47
- :cut => nil,
48
- :decimal => nil, # See: hexadecimal
49
- :decimal_separator => nil,
50
- :delete => nil,
51
- :display_switch => nil,
52
- :divide => "%",
53
- :dollar => "$", # TODO: i18n?
54
- :double_ampersand => nil,
55
- :double_quote => '"',
56
- :double_vertical_bar => nil,
57
- :down => nil,
58
- :eject => nil,
59
- :end => nil,
60
- :enter => nil,
61
- :equals => "=",
62
- :equalsas400 => nil,
63
- :escape => nil,
64
- :exclamation => "!",
65
- :execute => nil,
66
- :exsel => nil,
67
- :f1 => nil,
68
- :f10 => nil,
69
- :f11 => nil,
70
- :f12 => nil,
71
- :f13 => nil,
72
- :f14 => nil,
73
- :f15 => nil,
74
- :f16 => nil,
75
- :f17 => nil,
76
- :f18 => nil,
77
- :f19 => nil,
78
- :f2 => nil,
79
- :f20 => nil,
80
- :f21 => nil,
81
- :f22 => nil,
82
- :f23 => nil,
83
- :f24 => nil,
84
- :f3 => nil,
85
- :f4 => nil,
86
- :f5 => nil,
87
- :f6 => nil,
88
- :f7 => nil,
89
- :f8 => nil,
90
- :f9 => nil,
91
- :find => nil,
92
- :grave => nil,
93
- :greater => ">",
94
- :hash => "#",
95
- :help => nil,
96
- :hexadecimal => nil,
97
- :home => nil,
98
- :insert => nil,
99
- :international_1 => nil,
100
- :international_2 => nil,
101
- :international_3 => nil,
102
- :international_4 => nil,
103
- :international_5 => nil,
104
- :international_6 => nil,
105
- :international_7 => nil,
106
- :international_8 => nil,
107
- :international_9 => nil,
108
- :kbdillum_down => nil,
109
- :kbdillum_toggle => nil,
110
- :kbdillum_up => nil,
111
- :language_1 => nil,
112
- :language_2 => nil,
113
- :language_3 => nil,
114
- :language_4 => nil,
115
- :language_5 => nil,
116
- :language_6 => nil,
117
- :language_7 => nil,
118
- :language_8 => nil,
119
- :language_9 => nil,
120
- :left => nil,
121
- :left_alt => nil,
122
- :left_brace => "{",
123
- :left_bracket => "[",
124
- :left_control => nil,
125
- :left_ctrl => nil,
126
- :left_gui => nil,
127
- :left_parenthesis => "(",
128
- :left_race => nil,
129
- :left_shift => nil,
130
- :less => "<",
131
- :a => "a",
132
- :b => "b",
133
- :c => "c",
134
- :d => "d",
135
- :e => "e",
136
- :f => "f",
137
- :g => "g",
138
- :h => "h",
139
- :i => "i",
140
- :j => "j",
141
- :k => "k",
142
- :l => "l",
143
- :m => "m",
144
- :n => "n",
145
- :o => "o",
146
- :p => "p",
147
- :q => "q",
148
- :r => "r",
149
- :s => "s",
150
- :t => "t",
151
- :u => "u",
152
- :v => "v",
153
- :w => "w",
154
- :x => "x",
155
- :y => "y",
156
- :z => "z",
157
- :A => "A",
158
- :B => "B",
159
- :C => "C",
160
- :D => "D",
161
- :E => "E",
162
- :F => "F",
163
- :G => "G",
164
- :H => "H",
165
- :I => "I",
166
- :J => "J",
167
- :K => "K",
168
- :L => "L",
169
- :M => "M",
170
- :N => "N",
171
- :O => "O",
172
- :P => "P",
173
- :Q => "Q",
174
- :R => "R",
175
- :S => "S",
176
- :T => "T",
177
- :U => "U",
178
- :V => "V",
179
- :W => "W",
180
- :X => "X",
181
- :Y => "Y",
182
- :Z => "Z",
183
- :locking_capslock => nil,
184
- :locking_numlock => nil,
185
- :locking_scrolllock => nil,
186
- :mail => nil,
187
- :media_select => nil,
188
- :mem_add => nil,
189
- :mem_clear => nil,
190
- :mem_divide => nil,
191
- :mem_multiply => nil,
192
- :mem_recall => nil,
193
- :mem_store => nil,
194
- :mem_subtract => nil,
195
- :menu => nil,
196
- :minus => "-",
197
- :mode => nil,
198
- :multiply => "*",
199
- :mute => nil,
200
- :non_us_backslash => nil,
201
- :non_us_hash => nil,
202
- :"0" => "0",
203
- :"00" => "00",
204
- :"000" => "000",
205
- :"1" => "1",
206
- :"2" => "2",
207
- :"3" => "3",
208
- :"4" => "4",
209
- :"5" => "5",
210
- :"6" => "6",
211
- :"7" => "7",
212
- :"8" => "8",
213
- :"9" => "9",
214
- :numlock_clear => nil,
215
- :numpad_0 => "0",
216
- :numpad_1 => "1",
217
- :numpad_2 => "2",
218
- :numpad_3 => "3",
219
- :numpad_4 => "4",
220
- :numpad_5 => "5",
221
- :numpad_6 => "6",
222
- :numpad_7 => "7",
223
- :numpad_8 => "8",
224
- :numpad_9 => "9",
225
- :numpad_equals => "=",
226
- :numpad_slash => "/",
227
- :numpad_asterisk => "*",
228
- :numpad_minus => "-",
229
- :numpad_plus => "+",
230
- :numpad_enter => nil,
231
- :numpad_period => ".",
232
- :octal => nil,
233
- :oper => nil,
234
- :out => nil,
235
- :page_down => nil,
236
- :page_up => nil,
237
- :paste => nil,
238
- :pause => nil,
239
- :percent => "%",
240
- :period => ".",
241
- :plus => "+",
242
- :plus_minus => nil,
243
- :power => nil,
244
- :print_screen => nil,
245
- :prior => nil,
246
- :question => "?",
247
- :quote => '\'',
248
- :return => nil,
249
- :right => nil,
250
- :right_alt => nil,
251
- :right_brace => "}",
252
- :right_bracket => "]",
253
- :right_control => nil,
254
- :right_ctrl => nil,
255
- :right_gui => nil,
256
- :right_parenthesis => ")",
257
- :right_shift => nil,
258
- :scrolllock => nil,
259
- :select => nil,
260
- :semicolon => ";",
261
- :separator => nil,
262
- :slash => "/",
263
- :sleep => nil,
264
- :space => nil,
265
- :stop => nil,
266
- :sysreq => nil,
267
- :tab => nil,
268
- :thousands_separator => nil,
269
- :tilde => "~",
270
- :underscore => "_",
271
- :undo => nil,
272
- :unknown => nil,
273
- :up => nil,
274
- :vertical_bar => "|",
275
- :volume_down => nil,
276
- :volume_up => nil,
277
- :www => nil,
278
- :xor => nil
5
+ ac_back: nil,
6
+ ac_bookmarks: nil,
7
+ ac_forward: nil,
8
+ ac_home: nil,
9
+ ac_refresh: nil,
10
+ ac_search: nil,
11
+ ac_stop: nil,
12
+ again: nil,
13
+ alterase: nil,
14
+ ampersand: "&",
15
+ apostrophe: nil,
16
+ application: nil,
17
+ asterisk: "*",
18
+ at: "@",
19
+ audio_mute: nil,
20
+ audio_next: nil,
21
+ audio_play: nil,
22
+ audio_prev: nil,
23
+ audio_previous: nil,
24
+ audio_stop: nil,
25
+ backquote: "`",
26
+ backslash: '\\',
27
+ backspace: nil,
28
+ binary: nil,
29
+ brightness_down: nil,
30
+ brightness_up: nil,
31
+ calculator: nil,
32
+ cancel: nil,
33
+ capslock: nil,
34
+ caret: "^",
35
+ clear: nil,
36
+ clear_again: nil,
37
+ clear_entry: nil,
38
+ colon: ":",
39
+ comma: ",",
40
+ computer: nil,
41
+ copy: nil,
42
+ crsel: nil, # TODO: Clear selection?
43
+ currency_subunit: nil,
44
+ currency_unit: nil,
45
+ cut: nil,
46
+ decimal: nil, # See: hexadecimal
47
+ decimal_separator: nil,
48
+ delete: nil,
49
+ display_switch: nil,
50
+ divide: "%",
51
+ dollar: "$", # TODO: i18n?
52
+ double_ampersand: nil,
53
+ double_quote: '"',
54
+ double_vertical_bar: nil,
55
+ down: nil,
56
+ eject: nil,
57
+ end: nil,
58
+ enter: nil,
59
+ equals: "=",
60
+ equalsas400: nil,
61
+ escape: nil,
62
+ exclamation: "!",
63
+ execute: nil,
64
+ exsel: nil,
65
+ f1: nil,
66
+ f10: nil,
67
+ f11: nil,
68
+ f12: nil,
69
+ f13: nil,
70
+ f14: nil,
71
+ f15: nil,
72
+ f16: nil,
73
+ f17: nil,
74
+ f18: nil,
75
+ f19: nil,
76
+ f2: nil,
77
+ f20: nil,
78
+ f21: nil,
79
+ f22: nil,
80
+ f23: nil,
81
+ f24: nil,
82
+ f3: nil,
83
+ f4: nil,
84
+ f5: nil,
85
+ f6: nil,
86
+ f7: nil,
87
+ f8: nil,
88
+ f9: nil,
89
+ find: nil,
90
+ grave: nil,
91
+ greater: ">",
92
+ hash: "#",
93
+ help: nil,
94
+ hexadecimal: nil,
95
+ home: nil,
96
+ insert: nil,
97
+ international_1: nil,
98
+ international_2: nil,
99
+ international_3: nil,
100
+ international_4: nil,
101
+ international_5: nil,
102
+ international_6: nil,
103
+ international_7: nil,
104
+ international_8: nil,
105
+ international_9: nil,
106
+ kbdillum_down: nil,
107
+ kbdillum_toggle: nil,
108
+ kbdillum_up: nil,
109
+ language_1: nil,
110
+ language_2: nil,
111
+ language_3: nil,
112
+ language_4: nil,
113
+ language_5: nil,
114
+ language_6: nil,
115
+ language_7: nil,
116
+ language_8: nil,
117
+ language_9: nil,
118
+ left: nil,
119
+ left_alt: nil,
120
+ left_brace: "{",
121
+ left_bracket: "[",
122
+ left_control: nil,
123
+ left_ctrl: nil,
124
+ left_gui: nil,
125
+ left_parenthesis: "(",
126
+ left_race: nil,
127
+ left_shift: nil,
128
+ less: "<",
129
+ a: "a",
130
+ b: "b",
131
+ c: "c",
132
+ d: "d",
133
+ e: "e",
134
+ f: "f",
135
+ g: "g",
136
+ h: "h",
137
+ i: "i",
138
+ j: "j",
139
+ k: "k",
140
+ l: "l",
141
+ m: "m",
142
+ n: "n",
143
+ o: "o",
144
+ p: "p",
145
+ q: "q",
146
+ r: "r",
147
+ s: "s",
148
+ t: "t",
149
+ u: "u",
150
+ v: "v",
151
+ w: "w",
152
+ x: "x",
153
+ y: "y",
154
+ z: "z",
155
+ A: "A",
156
+ B: "B",
157
+ C: "C",
158
+ D: "D",
159
+ E: "E",
160
+ F: "F",
161
+ G: "G",
162
+ H: "H",
163
+ I: "I",
164
+ J: "J",
165
+ K: "K",
166
+ L: "L",
167
+ M: "M",
168
+ N: "N",
169
+ O: "O",
170
+ P: "P",
171
+ Q: "Q",
172
+ R: "R",
173
+ S: "S",
174
+ T: "T",
175
+ U: "U",
176
+ V: "V",
177
+ W: "W",
178
+ X: "X",
179
+ Y: "Y",
180
+ Z: "Z",
181
+ locking_capslock: nil,
182
+ locking_numlock: nil,
183
+ locking_scrolllock: nil,
184
+ mail: nil,
185
+ media_select: nil,
186
+ mem_add: nil,
187
+ mem_clear: nil,
188
+ mem_divide: nil,
189
+ mem_multiply: nil,
190
+ mem_recall: nil,
191
+ mem_store: nil,
192
+ mem_subtract: nil,
193
+ menu: nil,
194
+ minus: "-",
195
+ mode: nil,
196
+ multiply: "*",
197
+ mute: nil,
198
+ non_us_backslash: nil,
199
+ non_us_hash: nil,
200
+ "0": "0",
201
+ "00": "00",
202
+ "000": "000",
203
+ "1": "1",
204
+ "2": "2",
205
+ "3": "3",
206
+ "4": "4",
207
+ "5": "5",
208
+ "6": "6",
209
+ "7": "7",
210
+ "8": "8",
211
+ "9": "9",
212
+ numlock_clear: nil,
213
+ numpad_0: "0",
214
+ numpad_1: "1",
215
+ numpad_2: "2",
216
+ numpad_3: "3",
217
+ numpad_4: "4",
218
+ numpad_5: "5",
219
+ numpad_6: "6",
220
+ numpad_7: "7",
221
+ numpad_8: "8",
222
+ numpad_9: "9",
223
+ numpad_equals: "=",
224
+ numpad_slash: "/",
225
+ numpad_asterisk: "*",
226
+ numpad_minus: "-",
227
+ numpad_plus: "+",
228
+ numpad_enter: nil,
229
+ numpad_period: ".",
230
+ octal: nil,
231
+ oper: nil,
232
+ out: nil,
233
+ page_down: nil,
234
+ page_up: nil,
235
+ paste: nil,
236
+ pause: nil,
237
+ percent: "%",
238
+ period: ".",
239
+ plus: "+",
240
+ plus_minus: nil,
241
+ power: nil,
242
+ print_screen: nil,
243
+ prior: nil,
244
+ question: "?",
245
+ quote: '\'',
246
+ return: nil,
247
+ right: nil,
248
+ right_alt: nil,
249
+ right_brace: "}",
250
+ right_bracket: "]",
251
+ right_control: nil,
252
+ right_ctrl: nil,
253
+ right_gui: nil,
254
+ right_parenthesis: ")",
255
+ right_shift: nil,
256
+ scrolllock: nil,
257
+ select: nil,
258
+ semicolon: ";",
259
+ separator: nil,
260
+ slash: "/",
261
+ sleep: nil,
262
+ space: nil,
263
+ stop: nil,
264
+ sysreq: nil,
265
+ tab: nil,
266
+ thousands_separator: nil,
267
+ tilde: "~",
268
+ underscore: "_",
269
+ undo: nil,
270
+ unknown: nil,
271
+ up: nil,
272
+ vertical_bar: "|",
273
+ volume_down: nil,
274
+ volume_up: nil,
275
+ www: nil,
276
+ xor: nil
279
277
  }
280
-
278
+
281
279
  class << self
282
-
283
280
  # Check if the given name is valid.
284
281
  #
285
282
  # @param [#to_sym] value
@@ -287,7 +284,7 @@ module Cura
287
284
  def valid_name?(value)
288
285
  NAMES.key?(value.to_sym)
289
286
  end
290
-
287
+
291
288
  # Check if the given name is printable.
292
289
  #
293
290
  # @param [#to_sym] value
@@ -295,19 +292,16 @@ module Cura
295
292
  def name_is_printable?(value)
296
293
  !NAMES[value.to_sym].nil?
297
294
  end
298
-
295
+
299
296
  def name_from_character(value)
300
297
  value = value.to_s[0]
301
-
298
+
302
299
  NAMES.key(value)
303
300
  end
304
-
301
+
305
302
  def character_from_name(value)
306
303
  NAMES[value.to_sym]
307
304
  end
308
-
309
305
  end
310
-
311
306
  end
312
-
313
307
  end