cura 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -21
- data/cura.gemspec +1 -1
- data/examples/hello_world/lib/hello_world.rb +10 -10
- data/examples/mruby-examples/mrbgem.rake +5 -6
- data/examples/todo_list/data.db +0 -0
- data/examples/todo_list/lib/todo_list/application.rb +24 -18
- data/lib/cura/adapter.rb +13 -20
- data/lib/cura/application.rb +47 -51
- data/lib/cura/attributes/has_ancestry.rb +4 -8
- data/lib/cura/attributes/has_application.rb +3 -7
- data/lib/cura/attributes/has_attributes.rb +1 -9
- data/lib/cura/attributes/has_children.rb +14 -20
- data/lib/cura/attributes/has_colors.rb +14 -18
- data/lib/cura/attributes/has_coordinates.rb +9 -15
- data/lib/cura/attributes/has_dimensions.rb +12 -18
- data/lib/cura/attributes/has_events.rb +10 -18
- data/lib/cura/attributes/has_focusability.rb +5 -11
- data/lib/cura/attributes/has_initialize.rb +1 -5
- data/lib/cura/attributes/has_offsets.rb +16 -20
- data/lib/cura/attributes/has_orientation.rb +12 -18
- data/lib/cura/attributes/has_relative_coordinates.rb +4 -8
- data/lib/cura/attributes/has_root.rb +18 -22
- data/lib/cura/attributes/has_side_attributes.rb +18 -24
- data/lib/cura/attributes/has_windows.rb +13 -19
- data/lib/cura/borders.rb +0 -4
- data/lib/cura/color.rb +84 -91
- data/lib/cura/component/base.rb +29 -33
- data/lib/cura/component/button.rb +10 -16
- data/lib/cura/component/group.rb +14 -18
- data/lib/cura/component/label.rb +44 -48
- data/lib/cura/component/listbox.rb +24 -28
- data/lib/cura/component/pack.rb +14 -18
- data/lib/cura/component/scrollbar.rb +41 -45
- data/lib/cura/component/textbox.rb +21 -25
- data/lib/cura/cursor.rb +15 -23
- data/lib/cura/error/base.rb +0 -3
- data/lib/cura/error/invalid_adapter.rb +1 -7
- data/lib/cura/error/invalid_application.rb +1 -7
- data/lib/cura/error/invalid_color.rb +1 -7
- data/lib/cura/error/invalid_component.rb +1 -7
- data/lib/cura/error/invalid_middleware.rb +1 -7
- data/lib/cura/event.rb +4 -8
- data/lib/cura/event/base.rb +17 -24
- data/lib/cura/event/click.rb +1 -6
- data/lib/cura/event/dispatcher.rb +20 -26
- data/lib/cura/event/focus.rb +1 -6
- data/lib/cura/event/handler.rb +16 -24
- data/lib/cura/event/key_down.rb +11 -17
- data/lib/cura/event/middleware/aimer/base.rb +4 -10
- data/lib/cura/event/middleware/aimer/dispatcher_target.rb +2 -8
- data/lib/cura/event/middleware/aimer/mouse_focus.rb +6 -11
- data/lib/cura/event/middleware/aimer/target_option.rb +4 -10
- data/lib/cura/event/middleware/base.rb +0 -4
- data/lib/cura/event/middleware/dispatch.rb +0 -4
- data/lib/cura/event/middleware/translator/base.rb +4 -10
- data/lib/cura/event/middleware/translator/mouse_click.rb +4 -8
- data/lib/cura/event/mouse.rb +5 -11
- data/lib/cura/event/mouse_button.rb +21 -27
- data/lib/cura/event/mouse_wheel_down.rb +1 -6
- data/lib/cura/event/mouse_wheel_up.rb +1 -6
- data/lib/cura/event/resize.rb +0 -4
- data/lib/cura/event/selected.rb +1 -6
- data/lib/cura/event/unfocus.rb +1 -6
- data/lib/cura/focus_controller.rb +19 -23
- data/lib/cura/key.rb +277 -283
- data/lib/cura/margins.rb +0 -4
- data/lib/cura/offsets.rb +14 -18
- data/lib/cura/padding.rb +0 -4
- data/lib/cura/pencil.rb +3 -7
- data/lib/cura/version.rb +1 -3
- data/lib/cura/window.rb +11 -16
- data/spec/cura/attributes/has_ancestry_spec.rb +39 -39
- data/spec/cura/attributes/has_application_spec.rb +20 -20
- data/spec/cura/attributes/has_attributes_spec.rb +26 -26
- data/spec/cura/attributes/has_children_spec.rb +54 -54
- data/spec/cura/attributes/has_colors_spec.rb +4 -4
- data/spec/cura/attributes/has_coordinates_spec.rb +4 -4
- data/spec/cura/attributes/has_dimensions_spec.rb +4 -4
- data/spec/cura/attributes/has_events_spec.rb +4 -4
- data/spec/cura/attributes/has_focusability_spec.rb +18 -18
- data/spec/cura/attributes/has_offsets_spec.rb +4 -4
- data/spec/cura/attributes/has_orientation_spec.rb +38 -38
- data/spec/cura/attributes/has_relative_coordinates_spec.rb +4 -4
- data/spec/cura/attributes/has_side_attributes_spec.rb +4 -4
- data/spec/spec_helper.rb +1 -1
- data/spec/support/shared_examples_for_attributes.rb +41 -41
- metadata +1 -1
data/lib/cura/key.rb
CHANGED
@@ -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
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
72
|
-
:
|
73
|
-
:
|
74
|
-
:
|
75
|
-
:
|
76
|
-
:
|
77
|
-
:
|
78
|
-
:
|
79
|
-
:
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
88
|
-
:
|
89
|
-
:
|
90
|
-
:
|
91
|
-
:
|
92
|
-
:
|
93
|
-
:
|
94
|
-
:
|
95
|
-
:
|
96
|
-
:
|
97
|
-
:
|
98
|
-
:
|
99
|
-
:
|
100
|
-
:
|
101
|
-
:
|
102
|
-
:
|
103
|
-
:
|
104
|
-
:
|
105
|
-
:
|
106
|
-
:
|
107
|
-
:
|
108
|
-
:
|
109
|
-
:
|
110
|
-
:
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:
|
114
|
-
:
|
115
|
-
:
|
116
|
-
:
|
117
|
-
:
|
118
|
-
:
|
119
|
-
:
|
120
|
-
:
|
121
|
-
:
|
122
|
-
:
|
123
|
-
:
|
124
|
-
:
|
125
|
-
:
|
126
|
-
:
|
127
|
-
:
|
128
|
-
:
|
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
|
-
|
214
|
-
:
|
215
|
-
:
|
216
|
-
:
|
217
|
-
:
|
218
|
-
:
|
219
|
-
:
|
220
|
-
:
|
221
|
-
:
|
222
|
-
:
|
223
|
-
:
|
224
|
-
:
|
225
|
-
:
|
226
|
-
:
|
227
|
-
:
|
228
|
-
:
|
229
|
-
:
|
230
|
-
:
|
231
|
-
:
|
232
|
-
:
|
233
|
-
:
|
234
|
-
:
|
235
|
-
:
|
236
|
-
:
|
237
|
-
:
|
238
|
-
:
|
239
|
-
:
|
240
|
-
:
|
241
|
-
:
|
242
|
-
:
|
243
|
-
:
|
244
|
-
:
|
245
|
-
:
|
246
|
-
:
|
247
|
-
:
|
248
|
-
:
|
249
|
-
:
|
250
|
-
:
|
251
|
-
:
|
252
|
-
:
|
253
|
-
:
|
254
|
-
:
|
255
|
-
:
|
256
|
-
:
|
257
|
-
:
|
258
|
-
:
|
259
|
-
:
|
260
|
-
:
|
261
|
-
:
|
262
|
-
:
|
263
|
-
:
|
264
|
-
:
|
265
|
-
:
|
266
|
-
:
|
267
|
-
:
|
268
|
-
:
|
269
|
-
:
|
270
|
-
:
|
271
|
-
:
|
272
|
-
:
|
273
|
-
:
|
274
|
-
:
|
275
|
-
:
|
276
|
-
:
|
277
|
-
:
|
278
|
-
:
|
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
|