-
Notifications
You must be signed in to change notification settings - Fork 11
/
SwipeShiftCaret.x
590 lines (527 loc) · 22 KB
/
SwipeShiftCaret.x
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
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
#import <rootless.h>
#import <DLog.h>
#import <Firmware.h>
#import <UIKit/UIKit.h>
#import <UIKit/UIGestureRecognizerSubclass.h>
#define PREF_PATH ROOT_PATH_NS(@"/var/mobile/Library/Preferences/jp.r-plus.SwipeShiftCaret.plist")
// interfaces {{{
@interface WKContentView
- (NSString *)selectedText;
- (void)_moveRight:(BOOL)extend withHistory:(id)history;
- (void)_moveLeft:(BOOL)extend withHistory:(id)history;
- (void)selectWordBackward;
- (void)executeEditCommandWithCallback:(NSString *)commandName;
@end
@interface UIWebDocumentView : UIView <UITextInput>
- (BOOL)isEditing;
- (void)beginSelectionChange;
- (void)endSelectionChange;
@end
@interface UIView (Private) <UITextInput>
- (UIWebDocumentView *)webView;
- (NSRange)selectedRange;
- (NSRange)selectionRange;
- (void)setSelectedRange:(NSRange)range;
- (void)setSelectionRange:(NSRange)range;
- (void)scrollSelectionToVisible:(BOOL)arg1;
- (CGRect)rectForSelection:(NSRange)range;
- (CGRect)textRectForBounds:(CGRect)rect;
- (id)content;
@property(copy) NSString *text;
@end
@protocol UITextInputPrivate <UITextInput, UITextInputTokenizer>
@end
@interface TIKeyboardState : NSObject
@property(copy, nonatomic) NSString *searchStringForMarkedText;
@property(copy, nonatomic) NSString *inputForMarkedText;
@end
@interface UIKeyboardImpl : NSObject
+ (id)sharedInstance;
- (BOOL)callLayoutIsShiftKeyBeingHeld;
- (BOOL)caretVisible;
@property (readonly, assign, nonatomic) UIResponder <UITextInputPrivate> *privateInputDelegate;
@property (readonly, assign, nonatomic) UIResponder <UITextInput> *inputDelegate;
- (id)searchStringForMarkedText;
- (BOOL)hasEditableMarkedText;
- (BOOL)hasMarkedText;
- (void)generateCandidates;
// iOS 7+
- (id)markedText;
- (void)setMarkedText:(id)arg1 selectedRange:(NSRange)arg2 inputString:(id)arg3 searchString:(id)arg4;
@end
@interface UIFieldEditor : NSObject
+ (id)sharedFieldEditor;
- (void)revealSelection; // iOS ~9
- (void)scrollSelectionToVisible:(BOOL)arg1; // iOS 4+
@end
@interface UIKBKey : NSObject
@property(copy, nonatomic) NSString *displayString;
@end
@interface UIKeyboardLayoutStar : NSObject
- (UIKBKey *)keyHitTest:(CGPoint)arg;
- (NSString *)displayString;
@end
@interface UITextMagnifierRanged
@property (retain) UIView *target;
+ (id)sharedRangedMagnifier;
@end
// }}}
// global variables {{{
static UIView *tv;
static UIWebDocumentView *webView;
static BOOL panGestureEnabled;
static BOOL fasterByVelocityIsEnabled;
static BOOL verticalScrollLockIsEnabled;
static BOOL verticalScrollLockAndMoveIsEnabled;
static BOOL isSelectionMode = NO;
static BOOL hasStarted = NO;
static BOOL isPreventSwipeLoupe;
// }}}
// GestureRecognizers {{{
@interface SCSwipeGestureRecognizer : UISwipeGestureRecognizer
@end
@implementation SCSwipeGestureRecognizer
- (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)gesture
{
if ([gesture isMemberOfClass:[SCSwipeGestureRecognizer class]])
return YES;
return NO;
}
// NOTE: This method didnot call for UISwipeGestureRecognizer if UIDragRecognizer is dragable since iOS 7+.
- (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)gesture
{
// Prevent duplicated myself
if ([gesture isMemberOfClass:[SCSwipeGestureRecognizer class]])
return YES;
// Don't prevent SwipeNav
if ([gesture isMemberOfClass:%c(SNSwipeGestureRecognizer)])
return NO;
return NO;
}
@end
@interface SCPanGestureRecognizer : UIPanGestureRecognizer
@end
@implementation SCPanGestureRecognizer
- (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)gesture
{
if ([gesture isMemberOfClass:[SCPanGestureRecognizer class]])
return YES;
return NO;
}
- (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)gesture
{
DLog(@"%@", gesture);
// Prevent duplicated myself
if ([gesture isMemberOfClass:[SCPanGestureRecognizer class]])
return YES;
// Don't prevent SwipeNav
if ([gesture isMemberOfClass:%c(SNSwipeGestureRecognizer)])
return NO;
// v.scroll lock option
if (hasStarted && [gesture isKindOfClass:[UIPanGestureRecognizer class]])
if (verticalScrollLockIsEnabled || verticalScrollLockAndMoveIsEnabled)
return YES;
// UIDragRecognizer action @selector(loupeGesture:) since iOS 7+
// But caret shift performance is too bad even if prevent this gestureRecognizer.
/* if (isPreventSwipeLoupe && [gesture isKindOfClass:%c(UIDragRecognizer)])*/
/* return YES;*/
return NO;
}
@end
// }}}
// functions {{{
static void InstallSwipeGestureRecognizer()
{
// if this uninstall pan gesture is nothing, should implement 'if (panGestureEnabled) return;' code
// top of ShiftCaret function.
if ([tv isKindOfClass:[UIView class]]) {
for (UIGestureRecognizer *gesture in [tv gestureRecognizers])
if ([gesture isMemberOfClass:[SCPanGestureRecognizer class]])
[tv removeGestureRecognizer:gesture];
SCSwipeGestureRecognizer *rightSwipeShiftCaret = [[SCSwipeGestureRecognizer alloc] initWithTarget:tv action:@selector(rightSwipeShiftCaret:)];
rightSwipeShiftCaret.direction = UISwipeGestureRecognizerDirectionRight;
[tv addGestureRecognizer:rightSwipeShiftCaret];
[rightSwipeShiftCaret release];
SCSwipeGestureRecognizer *leftSwipeShiftCaret = [[SCSwipeGestureRecognizer alloc] initWithTarget:tv action:@selector(leftSwipeShiftCaret:)];
leftSwipeShiftCaret.direction = UISwipeGestureRecognizerDirectionLeft;
[tv addGestureRecognizer:leftSwipeShiftCaret];
[leftSwipeShiftCaret release];
}
}
static void InstallPanGestureRecognizer()
{
if ([tv isKindOfClass:[UIView class]]) {
SCPanGestureRecognizer *pan = [[SCPanGestureRecognizer alloc] initWithTarget:tv action:@selector(SCPanGestureDidPan:)];
pan.cancelsTouchesInView = NO;
[tv addGestureRecognizer:pan];
[pan release];
}
}
static void UpdateCaretAndCandidateIfNecessary(UITextRange *range)
{
UITextRange *markedTextRange = nil;
if ([webView respondsToSelector:@selector(markedTextRange)])
markedTextRange = webView.markedTextRange;
// return target(firstresponder) view if showing magnifier view to zoom IME converting strings.
if (markedTextRange && [[%c(UITextMagnifierRanged) sharedRangedMagnifier] target])
return;
UIKeyboardImpl *keyboardImpl = [%c(UIKeyboardImpl) sharedInstance];
// if nou supported update markedtext, only update caret position.
if (!markedTextRange || isSelectionMode || kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_7_0) {
webView.selectedTextRange = range;
return;
}
TIKeyboardState *m_keyboardState = (TIKeyboardState *)[keyboardImpl valueForKey:@"m_keyboardState"];
// markedText edge over check.
NSComparisonResult result;
result = [webView comparePosition:range.start toPosition:markedTextRange.start];
if (result == NSOrderedAscending)
range = [webView textRangeFromPosition:markedTextRange.start toPosition:markedTextRange.start];
result = [webView comparePosition:range.end toPosition:markedTextRange.end];
if (result == NSOrderedDescending)
range = [webView textRangeFromPosition:markedTextRange.end toPosition:markedTextRange.end];
UITextPosition *beginning = webView.beginningOfDocument;
NSUInteger offsetToTargetPosition = [webView offsetFromPosition:beginning toPosition:range.start];
NSUInteger offsetToMarkedTextPosition = [webView offsetFromPosition:beginning toPosition:markedTextRange.start];
[keyboardImpl setMarkedText:[keyboardImpl markedText]
selectedRange:NSMakeRange(offsetToTargetPosition-offsetToMarkedTextPosition, 0)
inputString:[m_keyboardState inputForMarkedText]
searchString:[keyboardImpl searchStringForMarkedText]];
[keyboardImpl generateCandidates];
}
static void ShiftCaretToLeft(BOOL isLeftSwipe)
{
if ([webView isKindOfClass:%c(WKContentView)]) {
// iOS 8+ WebKit.framework base view.
if (isLeftSwipe)
[(WKContentView *)webView _moveLeft:NO withHistory:nil];
else
[(WKContentView *)webView _moveRight:NO withHistory:nil];
} else if ([webView respondsToSelector:@selector(positionFromPosition:inDirection:offset:)]) {
UITextPosition *position = nil;
position = isLeftSwipe ? [webView positionFromPosition:webView.selectedTextRange.start inDirection:UITextLayoutDirectionLeft offset:1]
: [webView positionFromPosition:webView.selectedTextRange.end inDirection:UITextLayoutDirectionRight offset:1];
// failsafe for over edge position crash.
if (!position)
return;
UITextRange *range = [webView textRangeFromPosition:position toPosition:position];
[webView beginSelectionChange];
UpdateCaretAndCandidateIfNecessary(range);
[webView endSelectionChange];
}
// reveal for UITextField iOS ~9.
UIFieldEditor *editor = [%c(UIFieldEditor) sharedFieldEditor];
if ([editor respondsToSelector:@selector(revealSelection)]) {
[editor revealSelection];
} else {
[editor scrollSelectionToVisible:YES];
}
// reveal for UITextView, UITextContentView and UIWebDocumentView.
if ([tv respondsToSelector:@selector(scrollSelectionToVisible:)])
[tv scrollSelectionToVisible:YES];
}
static void PopupMenuFromRect(CGRect rect)
{
UIMenuController *mc = [UIMenuController sharedMenuController];
if (@available(iOS 13.0, *)) {
[mc showMenuFromView:tv rect:rect];
} else {
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
[mc setTargetRect:rect inView:tv];
[mc setMenuVisible:YES animated:YES];
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
}
}
// }}}
// Hooks {{{
%hook UIKeyboardLayoutStar
static BOOL IsForSelectionModeString(NSString * string)
{
return ([string isEqualToString:@"あいう"] ||
[string isEqualToString:@"ABC"] ||
[string isEqualToString:@"☆123"] ||
[string isEqualToString:@"123"]
);
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
%orig;
UITouch *touch = [touches anyObject];
UIKBKey *kb = [self keyHitTest:[touch locationInView:touch.view]];
NSString *kbString = [kb displayString];
if ([webView respondsToSelector:@selector(markedTextRange)]) {
isSelectionMode = (!webView.markedTextRange && IsForSelectionModeString(kbString));
} else {
isSelectionMode = IsForSelectionModeString(kbString);
}
}
- (void)touchesCancelled:(id)arg1 withEvent:(id)arg2
{
%orig;
isSelectionMode = NO;
}
- (void)touchesEnded:(id)arg1 withEvent:(id)arg2
{
%orig;
isSelectionMode = NO;
}
%end
%group iOS_ge_70_lt_90
%hook UIDragRecognizer
- (BOOL)canBeginDrag
{
return isPreventSwipeLoupe ? NO : %orig;
}
%end
%end
%hook UIView
- (BOOL)becomeFirstResponder
{
BOOL tmp = %orig;
if (tmp && ([self respondsToSelector:@selector(setSelectedTextRange:)] ||
[self respondsToSelector:@selector(setSelectedRange:)] ||
[self respondsToSelector:@selector(setSelectionRange:)])) {
if ([self isKindOfClass:%c(UIWebDocumentView)]) {
tv = webView = (UIWebDocumentView *)self;
} else {
tv = self;
// iOS 7: webView method no longer supported, its returning nil.
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0)
webView = (UIWebDocumentView *)tv;
else if ([self respondsToSelector:@selector(webView)])
webView = [tv webView];
}
DLog(@"firstResponder class = %@", NSStringFromClass([self class]));
DLog(@"tv = %@, webView = %@", tv, webView);
if (panGestureEnabled)
InstallPanGestureRecognizer();
else
InstallSwipeGestureRecognizer();
DLog(@"gestureRecognizers = %@", [self gestureRecognizers]);
}
return tmp;
}
- (BOOL)resignFirstResponder
{
if (tv == self) {
tv = nil;
webView = nil;
}
return %orig;
}
%new
- (void)leftSwipeShiftCaret:(UISwipeGestureRecognizer *)gesture
{
ShiftCaretToLeft(YES);
}
%new
- (void)rightSwipeShiftCaret:(UISwipeGestureRecognizer *)gesture
{
ShiftCaretToLeft(NO);
}
// based code is SwipeSelection.
%new
- (void)SCPanGestureDidPan:(UIPanGestureRecognizer *)gesture
{
if (!panGestureEnabled)
return;
static BOOL isLeftPanning = YES;
static BOOL beginningRangeIsEmpty;
static UITextPosition *beginningStartPosition;
static UITextPosition *beginningEndPosition;
static int numberOfTouches = 0;
static CGPoint previousVelocityPoint;
static int previousXOffset = 0;
static int previousYOffset = 0;
int touchesCount = [gesture numberOfTouches];
if (touchesCount > numberOfTouches)
numberOfTouches = touchesCount;
UIKeyboardImpl *keyboardImpl = [%c(UIKeyboardImpl) sharedInstance];
// fix for un-editable UIWebDocumentView.
// NOTE: -(BOOL)isEditing method of UIWebDocumentView always return NO, it's not useful.
if (![keyboardImpl caretVisible])
return;
if ([keyboardImpl respondsToSelector:@selector(callLayoutIsShiftKeyBeingHeld)] && !isSelectionMode)
isSelectionMode = [keyboardImpl callLayoutIsShiftKeyBeingHeld];
if (gesture.state == UIGestureRecognizerStateEnded || gesture.state == UIGestureRecognizerStateCancelled) { // {{{
// cleanup
numberOfTouches = 0;
previousVelocityPoint = CGPointMake(0,0);
isLeftPanning = YES;
gesture.cancelsTouchesInView = NO;
if (beginningStartPosition)
[beginningStartPosition release];
beginningStartPosition = nil;
if (beginningEndPosition)
[beginningEndPosition release];
beginningEndPosition = nil;
previousXOffset = 0;
previousYOffset = 0;
// reveal for UITextView, UITextContentView and UIWebDocumentView.
if ([tv respondsToSelector:@selector(scrollSelectionToVisible:)] && hasStarted)
[tv scrollSelectionToVisible:YES];
hasStarted = NO;
// auto pop-up menu.
if ([webView respondsToSelector:@selector(selectedTextRange)]) {
UITextRange *range = webView.selectedTextRange;
if (range && !range.isEmpty)
PopupMenuFromRect([webView firstRectForRange:range]);
}
// fix text deletion issue during Korean syllable composing
[webView endSelectionChange];
} // }}}
else if (gesture.state == UIGestureRecognizerStateBegan) { // {{{
beginningStartPosition = [webView.selectedTextRange.start retain];
beginningEndPosition = [webView.selectedTextRange.end retain];
beginningRangeIsEmpty = [webView comparePosition:beginningStartPosition toPosition:beginningEndPosition] == NSOrderedSame;
// fix text deletion issue during Korean syllable composing
[webView beginSelectionChange];
} // }}}
else if (gesture.state == UIGestureRecognizerStateChanged) { // {{{
CGPoint offset = [gesture translationInView:tv];
if (!hasStarted && fabs(offset.x) < 16.0)
return;
if (!hasStarted && fabs(offset.x) < fabs(offset.y)) {
gesture.state = UIGestureRecognizerStateEnded;
return;
}
if (!hasStarted)
isLeftPanning = offset.x < 0 ? YES : NO;
gesture.cancelsTouchesInView = YES;
hasStarted = YES;
if (fasterByVelocityIsEnabled) {
CGPoint velo = [gesture velocityInView:tv];
if (fabs(previousVelocityPoint.x) < 1000.0 && fabs(velo.x) / 1000.0 != 0)
numberOfTouches += (fabs(velo.x) / 1000.0);
previousVelocityPoint = velo;
}
int scale = 16 / numberOfTouches ? : 1;
int xPointsChanged = offset.x / scale;
int yPointsChanged = offset.y / scale;
if ([webView isKindOfClass:%c(WKContentView)]) {
// WebKit based view.
// Horizontal Move.
if (xPointsChanged == previousXOffset) {
// do nothing.
} else if (xPointsChanged > previousXOffset) {
// isRightSwipe:
for(; xPointsChanged > previousXOffset; previousXOffset++) {
[(WKContentView *)webView executeEditCommandWithCallback:isSelectionMode ? @"moveRightAndModifySelection" : @"moveRight"];
}
} else {
// isLeftSwipe:
for(; xPointsChanged < previousXOffset; previousXOffset--) {
[(WKContentView *)webView executeEditCommandWithCallback:isSelectionMode ? @"moveLeftAndModifySelection" : @"moveLeft"];
}
}
// Vertical Move.
if (verticalScrollLockAndMoveIsEnabled) {
if (yPointsChanged == previousYOffset) {
// do nothing.
} else if (yPointsChanged > previousYOffset) {
// isDownSwipe:
for(; yPointsChanged > previousYOffset; previousYOffset++) {
[(WKContentView *)webView executeEditCommandWithCallback:isSelectionMode ? @"moveDownAndModifySelection" : @"moveDown"];
}
} else {
// isUpSwipe:
for(; yPointsChanged < previousYOffset; previousYOffset--) {
[(WKContentView *)webView executeEditCommandWithCallback:isSelectionMode ? @"moveUpAndModifySelection" : @"moveUp"];
}
}
}
// No need manually reveal, automatically reveal via framework.
} else if ([webView respondsToSelector:@selector(positionFromPosition:inDirection:offset:)]) {
// UIKit based view.
UITextPosition *position = nil;
// Horizontal Move.
if (beginningRangeIsEmpty) {
position = [webView positionFromPosition:beginningStartPosition
inDirection:xPointsChanged < 0 ? UITextLayoutDirectionLeft : UITextLayoutDirectionRight
offset:abs(xPointsChanged)];
} else {
position = [webView positionFromPosition:isLeftPanning ? beginningStartPosition : beginningEndPosition
inDirection:xPointsChanged < 0 ? UITextLayoutDirectionLeft : UITextLayoutDirectionRight
offset:abs(xPointsChanged)];
}
// Vertical Move.
if (verticalScrollLockAndMoveIsEnabled) {
position = [webView positionFromPosition:position
inDirection:yPointsChanged < 0 ? UITextLayoutDirectionUp : UITextLayoutDirectionDown
offset:abs(yPointsChanged)];
}
// over edge correction.
if (!position) {
position = xPointsChanged < 0 ? webView.beginningOfDocument : webView.endOfDocument;
}
// ShiftCaret
UITextRange *range;
if (!isSelectionMode) {
range = [webView textRangeFromPosition:position toPosition:position];
} else {
if (beginningRangeIsEmpty)
range = [webView textRangeFromPosition:beginningStartPosition toPosition:position];
else
range = [webView textRangeFromPosition:isLeftPanning ? beginningEndPosition : beginningStartPosition toPosition:position];
}
UpdateCaretAndCandidateIfNecessary(range);
// reveal for UITextField.
UIFieldEditor *editor = [%c(UIFieldEditor) sharedFieldEditor];
if ([editor respondsToSelector:@selector(revealSelection)]) {
// iOS ~9
[editor revealSelection];
} else {
[editor scrollSelectionToVisible:YES];
}
}
} // }}}
}
%end
// }}}
static void LoadSettings()
{
NSDictionary *dict;
if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_8_0) {
dict = [NSDictionary dictionaryWithContentsOfFile:PREF_PATH];
} else {
CFStringRef appID = CFSTR("jp.r-plus.SwipeShiftCaret");
CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
if (keyList) {
dict = [(NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost) autorelease];
CFRelease(keyList);
} else {
dict = [NSDictionary dictionaryWithContentsOfFile:PREF_PATH];
}
}
id panGesturePref = [dict objectForKey:@"PanGestureEnabled"];
panGestureEnabled = panGesturePref ? [panGesturePref boolValue] : YES;
id velocityPref = [dict objectForKey:@"VelocityEnabled"];
fasterByVelocityIsEnabled = velocityPref ? [velocityPref boolValue] : NO;
id verticalScrollLockPref = [dict objectForKey:@"LockVerticalScrollEnabled"];
verticalScrollLockIsEnabled = verticalScrollLockPref ? [verticalScrollLockPref boolValue] : NO;
id verticalScrollLockAndMovePref = [dict objectForKey:@"VLockAndMoveEnabled"];
verticalScrollLockAndMoveIsEnabled = verticalScrollLockAndMovePref ? [verticalScrollLockAndMovePref boolValue] : NO;
id preventSwipeLoupePref = [dict objectForKey:@"PreventSwipeLoupe"];
isPreventSwipeLoupe = preventSwipeLoupePref ? [preventSwipeLoupePref boolValue] : YES;
if (tv) {
if (panGestureEnabled)
InstallPanGestureRecognizer();
else
InstallSwipeGestureRecognizer();
}
}
static void PostNotification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
LoadSettings();
}
%ctor
{
@autoreleasepool {
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, PostNotification, CFSTR("jp.r-plus.swipeshiftcaret.settingschanged"), NULL, CFNotificationSuspensionBehaviorCoalesce);
LoadSettings();
%init;
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0 && kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_9_0)
%init(iOS_ge_70_lt_90);
}
}
/* vim: set fdm=marker : */