AXElements 0.6.0beta2 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +1 -2
- data/README.markdown +152 -88
- data/Rakefile +8 -103
- data/docs/Debugging.markdown +9 -2
- data/docs/KeyboardEvents.markdown +114 -49
- data/docs/Setting.markdown +1 -0
- data/docs/images/next_version.png +0 -0
- data/ext/accessibility/key_coder/extconf.rb +22 -0
- data/ext/accessibility/key_coder/key_coder.c +113 -0
- data/lib/AXElements.rb +2 -0
- data/lib/accessibility/core.rb +897 -0
- data/lib/accessibility/debug.rb +168 -0
- data/lib/accessibility/dsl.rb +697 -0
- data/lib/accessibility/enumerators.rb +104 -0
- data/lib/accessibility/errors.rb +32 -0
- data/lib/accessibility/factory.rb +153 -0
- data/lib/accessibility/graph.rb +150 -0
- data/lib/{ax_elements/inspector.rb → accessibility/pp_inspector.rb} +39 -28
- data/lib/accessibility/qualifier.rb +158 -0
- data/lib/accessibility/string.rb +494 -0
- data/lib/accessibility/translator.rb +178 -0
- data/lib/accessibility/version.rb +7 -0
- data/lib/accessibility.rb +79 -0
- data/lib/ax/application.rb +234 -0
- data/lib/{ax_elements/elements → ax}/button.rb +2 -0
- data/lib/ax/element.rb +518 -0
- data/lib/{ax_elements/elements → ax}/radio_button.rb +2 -0
- data/lib/ax/row.rb +37 -0
- data/lib/{ax_elements/elements → ax}/static_text.rb +2 -0
- data/lib/ax/systemwide.rb +86 -0
- data/lib/ax_elements/awesome_print.rb +25 -0
- data/lib/ax_elements/exception_workaround.rb +8 -0
- data/lib/ax_elements/nsarray_compat.rb +64 -0
- data/lib/ax_elements/vendor/inflection_data.rb +65 -0
- data/lib/ax_elements/vendor/inflections.rb +172 -0
- data/lib/ax_elements/vendor/inflector.rb +306 -0
- data/lib/ax_elements.rb +14 -25
- data/lib/minitest/ax_elements.rb +112 -12
- data/lib/mouse.rb +72 -46
- data/lib/rspec/expectations/ax_elements.rb +133 -6
- data/rakelib/doc.rake +13 -0
- data/rakelib/ext.rake +61 -0
- data/rakelib/gem.rake +28 -0
- data/rakelib/test.rake +53 -0
- data/test/helper.rb +11 -97
- data/test/integration/accessibility/test_core.rb +18 -0
- data/test/integration/accessibility/test_debug.rb +44 -0
- data/test/integration/accessibility/test_dsl.rb +225 -0
- data/test/integration/accessibility/test_enumerators.rb +122 -0
- data/test/integration/accessibility/test_errors.rb +38 -0
- data/test/integration/accessibility/test_notifications.rb +22 -0
- data/test/integration/accessibility/test_qualifier.rb +148 -0
- data/test/integration/ax/test_application.rb +56 -0
- data/test/integration/ax/test_element.rb +46 -0
- data/test/integration/ax/test_row.rb +23 -0
- data/test/integration/ax_elements/test_nsarray_compat.rb +43 -0
- data/test/integration/minitest/test_ax_elements.rb +98 -0
- data/test/integration/rspec/expectations/test_ax_elements.rb +58 -0
- data/test/integration/test_mouse.rb +35 -0
- data/test/sanity/accessibility/test_core.rb +553 -0
- data/test/sanity/accessibility/test_debug.rb +63 -0
- data/test/sanity/accessibility/test_dsl.rb +75 -0
- data/test/sanity/accessibility/test_errors.rb +10 -0
- data/test/sanity/accessibility/test_factory.rb +88 -0
- data/test/sanity/accessibility/test_pp_inspector.rb +110 -0
- data/test/sanity/accessibility/test_qualifier.rb +13 -0
- data/test/sanity/accessibility/test_string.rb +238 -0
- data/test/sanity/accessibility/test_translator.rb +145 -0
- data/test/sanity/ax/test_application.rb +90 -0
- data/test/sanity/ax/test_element.rb +80 -0
- data/test/sanity/ax/test_systemwide.rb +66 -0
- data/test/sanity/ax_elements/test_nsarray_compat.rb +16 -0
- data/test/sanity/ax_elements/test_nsobject_inspect.rb +11 -0
- data/test/sanity/minitest/test_ax_elements.rb +15 -0
- data/test/sanity/rspec/expectations/test_ax_elements.rb +12 -0
- data/test/sanity/test_ax_elements.rb +10 -0
- data/test/sanity/test_mouse.rb +19 -0
- metadata +111 -93
- data/LICENSE.txt +0 -25
- data/ext/key_coder/extconf.rb +0 -6
- data/ext/key_coder/key_coder.m +0 -77
- data/lib/ax_elements/accessibility/enumerators.rb +0 -104
- data/lib/ax_elements/accessibility/graph.rb +0 -118
- data/lib/ax_elements/accessibility/language.rb +0 -347
- data/lib/ax_elements/accessibility/qualifier.rb +0 -73
- data/lib/ax_elements/accessibility.rb +0 -166
- data/lib/ax_elements/core.rb +0 -541
- data/lib/ax_elements/element.rb +0 -593
- data/lib/ax_elements/elements/application.rb +0 -88
- data/lib/ax_elements/elements/row.rb +0 -30
- data/lib/ax_elements/elements/systemwide.rb +0 -46
- data/lib/ax_elements/macruby_extensions.rb +0 -255
- data/lib/ax_elements/notification.rb +0 -37
- data/lib/ax_elements/version.rb +0 -9
- data/test/elements/test_application.rb +0 -72
- data/test/elements/test_row.rb +0 -27
- data/test/elements/test_systemwide.rb +0 -38
- data/test/test_accessibility.rb +0 -127
- data/test/test_blankness.rb +0 -26
- data/test/test_core.rb +0 -448
- data/test/test_element.rb +0 -939
- data/test/test_enumerators.rb +0 -81
- data/test/test_inspector.rb +0 -130
- data/test/test_language.rb +0 -157
- data/test/test_macruby_extensions.rb +0 -303
- data/test/test_mouse.rb +0 -5
- data/test/test_search_semantics.rb +0 -143
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* key_coder.c
|
|
3
|
+
* KeyCoder
|
|
4
|
+
*
|
|
5
|
+
* Created by Mark Rada on 11-07-27.
|
|
6
|
+
* Copyright 2011 Marketcircle Incorporated. All rights reserved.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
#import <Cocoa/Cocoa.h>
|
|
11
|
+
#import <Carbon/Carbon.h>
|
|
12
|
+
#import <ApplicationServices/ApplicationServices.h>
|
|
13
|
+
|
|
14
|
+
#include "ruby.h"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* Generate the mapping of characters to key codes for keys that can be
|
|
19
|
+
* remapped based on keyboard layout. Changing the keyboard layout at
|
|
20
|
+
* runtime will cause the returned hash to be different.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* KeyCoder.dynamic_mapping => { "a" => 0, "b" => 24, ... }
|
|
25
|
+
*
|
|
26
|
+
* @return [Hash{String=>Number}]
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
static VALUE
|
|
30
|
+
keycoder_dynamic_mapping()
|
|
31
|
+
{
|
|
32
|
+
|
|
33
|
+
VALUE map = rb_hash_new();
|
|
34
|
+
|
|
35
|
+
#ifdef NOT_MACRUBY
|
|
36
|
+
@autoreleasepool {
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
TISInputSourceRef keyboard = TISCopyCurrentKeyboardLayoutInputSource();
|
|
40
|
+
CFDataRef layout_data = (CFDataRef)TISGetInputSourceProperty(keyboard, kTISPropertyUnicodeKeyLayoutData);
|
|
41
|
+
const UCKeyboardLayout* layout = (const UCKeyboardLayout*)CFDataGetBytePtr(layout_data);
|
|
42
|
+
|
|
43
|
+
void (^key_coder)(int) = ^(int key_code) {
|
|
44
|
+
UniChar string[255];
|
|
45
|
+
UniCharCount string_length = 0;
|
|
46
|
+
UInt32 dead_key_state = 0;
|
|
47
|
+
UCKeyTranslate(
|
|
48
|
+
layout,key_code,
|
|
49
|
+
kUCKeyActionDown,
|
|
50
|
+
0,
|
|
51
|
+
LMGetKbdType(), // kb type
|
|
52
|
+
0, // OptionBits keyTranslateOptions,
|
|
53
|
+
&dead_key_state,
|
|
54
|
+
255,
|
|
55
|
+
&string_length,
|
|
56
|
+
string
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
NSString* nsstring = [NSString stringWithCharacters:string length:string_length];
|
|
60
|
+
rb_hash_aset(map, rb_str_new_cstr([nsstring UTF8String]), INT2FIX(key_code));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// skip 65-92 since they are hard coded and do not change
|
|
64
|
+
for (int key_code = 0; key_code < 65; key_code++)
|
|
65
|
+
key_coder(key_code);
|
|
66
|
+
for (int key_code = 93; key_code < 127; key_code++)
|
|
67
|
+
key_coder(key_code);
|
|
68
|
+
|
|
69
|
+
#ifdef NOT_MACRUBY
|
|
70
|
+
CFRelease(keyboard);
|
|
71
|
+
}; // Close the autorelease pool
|
|
72
|
+
#else
|
|
73
|
+
CFMakeCollectable(keyboard);
|
|
74
|
+
#endif
|
|
75
|
+
|
|
76
|
+
return map;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
* Post the given event to the system and return `true`. This method
|
|
82
|
+
* will also add a small (9000 microsecond) delay after posting to
|
|
83
|
+
* ensure that keyboard actions do not go too fast.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
*
|
|
87
|
+
* KeyCoder.post_event [0, true] -> true
|
|
88
|
+
*
|
|
89
|
+
* @param [Array(Number, Boolean)]
|
|
90
|
+
* @return [true]
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
static VALUE
|
|
94
|
+
keycoder_post_event(VALUE self, VALUE event)
|
|
95
|
+
{
|
|
96
|
+
VALUE code = rb_ary_entry(event, 0);
|
|
97
|
+
VALUE state = rb_ary_entry(event, 1);
|
|
98
|
+
|
|
99
|
+
CGEventRef event_ref = CGEventCreateKeyboardEvent(NULL, FIX2LONG(code), state);
|
|
100
|
+
CGEventPost(kCGHIDEventTap, event_ref);
|
|
101
|
+
|
|
102
|
+
usleep(9000);
|
|
103
|
+
return Qtrue;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
void
|
|
108
|
+
Init_key_coder()
|
|
109
|
+
{
|
|
110
|
+
VALUE cKeyCoder = rb_define_class("KeyCoder", rb_cObject);
|
|
111
|
+
rb_define_singleton_method(cKeyCoder, "dynamic_mapping", keycoder_dynamic_mapping, 0);
|
|
112
|
+
rb_define_singleton_method(cKeyCoder, "post_event", keycoder_post_event, 1);
|
|
113
|
+
}
|
data/lib/AXElements.rb
CHANGED