|
| 1 | +// |
| 2 | +// GitXTextView.m |
| 3 | +// GitX |
| 4 | +// |
| 5 | +// Created by NanoTech on 2016-12-14. |
| 6 | +// |
| 7 | + |
| 8 | +#import "GitXTextView.h" |
| 9 | + |
| 10 | +static NSString *AutomaticDashSubstitutionEnabledKey = @"GitXTextViewAutomaticDashSubstitutionEnabled"; |
| 11 | +static NSString *AutomaticDataDetectionEnabledKey = @"GitXTextViewAutomaticDataDetectionEnabled"; |
| 12 | +static NSString *AutomaticLinkDetectionEnabledKey = @"GitXTextViewAutomaticLinkDetectionEnabled"; |
| 13 | +static NSString *AutomaticQuoteSubstitutionEnabled = @"GitXTextViewAutomaticQuoteSubstitutionEnabled"; |
| 14 | +static NSString *AutomaticSpellingCorrectionEnabledKey = @"GitXTextViewAutomaticSpellingCorrectionEnabled"; |
| 15 | +static NSString *AutomaticTextReplacementEnabledKey = @"GitXTextViewAutomaticTextReplacementEnabled"; |
| 16 | +static NSString *SmartInsertDeleteEnabledKey = @"GitXTextViewSmartInsertDeleteEnabled"; // "Smart Copy/Paste" |
| 17 | + |
| 18 | +@implementation GitXTextView |
| 19 | + |
| 20 | ++ (void)initialize |
| 21 | +{ |
| 22 | + if (self != [GitXTextView class]) return; |
| 23 | + |
| 24 | + // Matches the commit message text view properties in PBGitCommitView.xib |
| 25 | + [[NSUserDefaults standardUserDefaults] registerDefaults:@{ |
| 26 | + AutomaticDashSubstitutionEnabledKey : @(NO), |
| 27 | + AutomaticDataDetectionEnabledKey : @(NO), |
| 28 | + AutomaticLinkDetectionEnabledKey : @(YES), |
| 29 | + AutomaticQuoteSubstitutionEnabled : @(NO), |
| 30 | + AutomaticSpellingCorrectionEnabledKey : @(NO), |
| 31 | + AutomaticTextReplacementEnabledKey : @(NO), |
| 32 | + SmartInsertDeleteEnabledKey : @(YES), |
| 33 | + }]; |
| 34 | +} |
| 35 | + |
| 36 | +- (void)awakeFromNib |
| 37 | +{ |
| 38 | + [super awakeFromNib]; |
| 39 | + |
| 40 | + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; |
| 41 | + super.automaticDashSubstitutionEnabled = [defaults boolForKey:AutomaticDashSubstitutionEnabledKey]; |
| 42 | + super.automaticDataDetectionEnabled = [defaults boolForKey:AutomaticDataDetectionEnabledKey]; |
| 43 | + super.automaticLinkDetectionEnabled = [defaults boolForKey:AutomaticLinkDetectionEnabledKey]; |
| 44 | + super.automaticQuoteSubstitutionEnabled = [defaults boolForKey:AutomaticQuoteSubstitutionEnabled]; |
| 45 | + super.automaticSpellingCorrectionEnabled = [defaults boolForKey:AutomaticSpellingCorrectionEnabledKey]; |
| 46 | + super.automaticTextReplacementEnabled = [defaults boolForKey:AutomaticTextReplacementEnabledKey]; |
| 47 | + super.smartInsertDeleteEnabled = [defaults boolForKey:SmartInsertDeleteEnabledKey]; |
| 48 | +} |
| 49 | + |
| 50 | +- (void)setAutomaticDashSubstitutionEnabled:(BOOL)enabled |
| 51 | +{ |
| 52 | + [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:AutomaticDashSubstitutionEnabledKey]; |
| 53 | + [super setAutomaticDashSubstitutionEnabled:enabled]; |
| 54 | +} |
| 55 | + |
| 56 | +- (void)setAutomaticDataDetectionEnabled:(BOOL)enabled |
| 57 | +{ |
| 58 | + [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:AutomaticDataDetectionEnabledKey]; |
| 59 | + [super setAutomaticDataDetectionEnabled:enabled]; |
| 60 | +} |
| 61 | + |
| 62 | +- (void)setAutomaticLinkDetectionEnabled:(BOOL)enabled |
| 63 | +{ |
| 64 | + [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:AutomaticLinkDetectionEnabledKey]; |
| 65 | + [super setAutomaticLinkDetectionEnabled:enabled]; |
| 66 | +} |
| 67 | + |
| 68 | +- (void)setAutomaticQuoteSubstitutionEnabled:(BOOL)enabled |
| 69 | +{ |
| 70 | + [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:AutomaticQuoteSubstitutionEnabled]; |
| 71 | + [super setAutomaticQuoteSubstitutionEnabled:enabled]; |
| 72 | +} |
| 73 | + |
| 74 | +- (void)setAutomaticSpellingCorrectionEnabled:(BOOL)enabled |
| 75 | +{ |
| 76 | + [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:AutomaticSpellingCorrectionEnabledKey]; |
| 77 | + [super setAutomaticSpellingCorrectionEnabled:enabled]; |
| 78 | +} |
| 79 | + |
| 80 | +- (void)setAutomaticTextReplacementEnabled:(BOOL)enabled |
| 81 | +{ |
| 82 | + [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:AutomaticTextReplacementEnabledKey]; |
| 83 | + [super setAutomaticTextReplacementEnabled:enabled]; |
| 84 | +} |
| 85 | + |
| 86 | +- (void)setSmartInsertDeleteEnabled:(BOOL)enabled |
| 87 | +{ |
| 88 | + [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:SmartInsertDeleteEnabledKey]; |
| 89 | + [super setSmartInsertDeleteEnabled:enabled]; |
| 90 | +} |
| 91 | + |
| 92 | +@end |
0 commit comments