forked from CocoaBob/xee
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CSKeyboardShortcuts.h
216 lines (139 loc) · 5.4 KB
/
CSKeyboardShortcuts.h
1
2
3
4
5
6
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
#import <Cocoa/Cocoa.h>
#import "KFTypeSelectTableView.h"
#define CSCmd NSCommandKeyMask
#define CSAlt NSAlternateKeyMask
#define CSCtrl NSControlKeyMask
#define CSShift NSShiftKeyMask
@class CSKeyStroke,CSAction;
@interface CSKeyboardShortcuts:NSObject
{
NSArray *actions;
}
+(NSArray *)parseMenu:(NSMenu *)menu;
+(NSArray *)parseMenu:(NSMenu *)menu namespace:(NSMutableSet *)namespace;
+(CSKeyboardShortcuts *)defaultShortcuts;
+(void)installWindowClass;
-(id)init;
-(void)dealloc;
-(NSArray *)actions;
-(void)addActions:(NSArray *)actions;
-(void)addActionsFromMenu:(NSMenu *)mainmenu;
-(void)addShortcuts:(NSDictionary *)shortcuts;
-(void)resetToDefaults;
-(BOOL)handleKeyEvent:(NSEvent *)event;
-(CSAction *)actionForEvent:(NSEvent *)event;
-(CSAction *)actionForEvent:(NSEvent *)event ignoringModifiers:(int)ignoredmods;
-(CSKeyStroke *)findKeyStrokeForEvent:(NSEvent *)event index:(int *)index;
@end
@interface CSAction:NSObject
{
NSString *title,*identifier;
SEL sel;
id target;
NSMenuItem *item;
NSImage *fullimage;
int spacing;
NSMutableArray *shortcuts,*defshortcuts;
}
+(CSAction *)actionWithTitle:(NSString *)acttitle selector:(SEL)selector;
+(CSAction *)actionWithTitle:(NSString *)acttitle identifier:(NSString *)ident selector:(SEL)selector;
+(CSAction *)actionWithTitle:(NSString *)acttitle identifier:(NSString *)ident selector:(SEL)selector defaultShortcut:(CSKeyStroke *)defshortcut;
+(CSAction *)actionWithTitle:(NSString *)acttitle identifier:(NSString *)ident;
+(CSAction *)actionFromMenuItem:(NSMenuItem *)item namespace:(NSMutableSet *)namespace;
-(id)initWithTitle:(NSString *)acttitle identifier:(NSString *)ident selector:(SEL)selector target:(id)acttarget defaultShortcut:(CSKeyStroke *)defshortcut;
-(id)initWithMenuItem:(NSMenuItem *)menuitem namespace:(NSMutableSet *)namespace;
-(void)dealloc;
-(NSString *)title;
-(NSString *)identifier;
-(SEL)selector;
-(BOOL)isMenuItem;
-(void)setDefaultShortcuts:(NSArray *)shortcutarray;
-(void)addDefaultShortcut:(CSKeyStroke *)shortcut;
-(void)addDefaultShortcuts:(NSArray *)shortcutarray;
-(void)setShortcuts:(NSArray *)shortcutarray;
-(NSArray *)shortcuts;
-(void)resetToDefaults;
-(void)loadCustomizations;
-(void)updateMenuItem;
-(BOOL)perform:(NSEvent *)event;
-(NSImage *)shortcutsImage;
-(void)clearImage;
-(NSSize)imageSizeWithDropSize:(NSSize)dropsize;
-(void)drawAtPoint:(NSPoint)point selected:(CSKeyStroke *)selected dropBefore:(CSKeyStroke *)dropbefore dropSize:(NSSize)dropsize;
-(CSKeyStroke *)findKeyAtPoint:(NSPoint)point offset:(NSPoint)offset;
-(NSPoint)findLocationOfKey:(CSKeyStroke *)searchkey offset:(NSPoint)offset;
-(CSKeyStroke *)findKeyAfterDropPoint:(NSPoint)point offset:(NSPoint)offset;
-(NSString *)description;
-(NSComparisonResult)compare:(CSAction *)other;
@end
@interface CSKeyStroke:NSObject
{
NSString *chr;
unsigned int mod;
NSImage *img;
}
+(CSKeyStroke *)keyForCharacter:(NSString *)character modifiers:(unsigned int)modifiers;
+(CSKeyStroke *)keyForCharCode:(unichar)character modifiers:(unsigned int)modifiers;
+(CSKeyStroke *)keyFromMenuItem:(NSMenuItem *)item;
+(CSKeyStroke *)keyFromEvent:(NSEvent *)event;
+(CSKeyStroke *)keyFromDictionary:(NSDictionary *)dict;
+(NSArray *)keysFromDictionaries:(NSArray *)dicts;
+(NSArray *)dictionariesFromKeys:(NSArray *)keys;
-(id)initWithCharacter:(NSString *)character modifiers:(unsigned int)modifiers;
-(void)dealloc;
-(NSString *)character;
-(unsigned int)modifiers;
-(NSDictionary *)dictionary;
-(NSImage *)image;
-(BOOL)matchesEvent:(NSEvent *)event ignoringModifiers:(int)ignoredmods;
-(NSString *)description;
-(NSString *)descriptionOfModifiers;
-(NSString *)descriptionOfCharacter;
@end
@interface CSKeyboardList:KFTypeSelectTableView
{
CSKeyStroke *selected;
CSAction *dropaction;
CSKeyStroke *dropbefore;
NSSize dropsize;
IBOutlet CSKeyboardShortcuts *keyboardShortcuts;
IBOutlet NSTextField *infoTextField;
IBOutlet NSControl *addButton;
IBOutlet NSControl *removeButton;
IBOutlet NSControl *resetButton;
}
-(id)initWithCoder:(NSCoder *)decoder;
-(void)dealloc;
-(void)awakeFromNib;
-(id)tableView:(NSTableView *)table objectValueForTableColumn:(NSTableColumn *)column row:(int)row;
-(int)numberOfRowsInTableView:(NSTableView *)table;
-(void)tableViewSelectionDidChange:(NSNotification *)notification;
-(void)mouseDown:(NSEvent *)event;
-(unsigned int)draggingSourceOperationMaskForLocal:(BOOL)local;
-(void)draggedImage:(NSImage *)image endedAt:(NSPoint)point operation:(NSDragOperation)operation;
-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
-(NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender;
-(void)draggingExited:(id <NSDraggingInfo>)sender;
-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
-(CSAction *)getActionForLocation:(NSPoint)point hasFrame:(NSRect *)frame;
-(void)updateButtons;
-(void)setKeyboardShortcuts:(CSKeyboardShortcuts *)shortcuts;
-(CSKeyboardShortcuts *)keybardShortcuts;
-(CSAction *)getSelectedAction;
-(IBAction)addShortcut:(id)sender;
-(IBAction)removeShortcut:(id)sender;
-(IBAction)resetToDefaults:(id)sender;
-(IBAction)resetAll:(id)sender;
@end
@interface CSKeyListenerWindow:NSWindow
{
}
+(void)install;
-(BOOL)performKeyEquivalent:(NSEvent *)event;
@end
@interface NSEvent (CSKeyboardShortcutsAdditions)
+(NSString *)remapCharacters:(NSString *)characters;
-(NSString *)charactersIgnoringAllModifiers;
-(NSString *)remappedCharacters;
-(NSString *)remappedCharactersIgnoringAllModifiers;
@end