diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-02-02 10:25:54 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-02-02 10:25:54 +0000 |
commit | 52b6a2b07abf9dbcf375431188fcd09aec44b60e (patch) | |
tree | 90b308b3281e4c470ba22bc449abd982e986fb50 /Source/CMTextView.m | |
parent | 71d01e1417607aebc4254b32258c91b09078672f (diff) | |
download | sequelpro-52b6a2b07abf9dbcf375431188fcd09aec44b60e.tar.gz sequelpro-52b6a2b07abf9dbcf375431188fcd09aec44b60e.tar.bz2 sequelpro-52b6a2b07abf9dbcf375431188fcd09aec44b60e.zip |
• added key-shortcut ⌘= to make the textview size larger
• ⌘-, ⌘+, ⌘= changes the font size temporarily (Mac app conform)
• added key-shortcut ⌘0 to reset the font to pref default
• fixed search field background for Tables List
• fixed NSUInteger for completion parsing; interrupt completion if parsed string length is larger than 100000 since it doesn't make sense and leads to warnings
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r-- | Source/CMTextView.m | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m index 97fceb37..2601a314 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -106,6 +106,10 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) - (void) awakeFromNib { + + prefs = [[NSUserDefaults standardUserDefaults] retain]; + [self setFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]]]; + // Set self as delegate for the textView's textStorage to enable syntax highlighting, [[self textStorage] setDelegate:self]; @@ -125,6 +129,13 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [scrollView setHasHorizontalRuler:NO]; [scrollView setHasVerticalRuler:YES]; [scrollView setRulersVisible:YES]; + [self setAllowsDocumentBackgroundColorChange:YES]; + [self setContinuousSpellCheckingEnabled:NO]; + [self setAutoindent:[prefs boolForKey:SPCustomQueryAutoIndent]]; + [self setAutoindentIgnoresEnter:YES]; + [self setAutopair:[prefs boolForKey:SPCustomQueryAutoPairCharacters]]; + [self setAutohelp:[prefs boolForKey:SPCustomQueryUpdateAutoHelp]]; + [self setAutouppercaseKeywords:[prefs boolForKey:SPCustomQueryAutoUppercaseKeywords]]; // Re-define 64 tab stops for a better editing NSFont *tvFont = [self font]; @@ -168,8 +179,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) NSNotificationCenter *aNotificationCenter = [NSNotificationCenter defaultCenter]; [aNotificationCenter addObserver:self selector:@selector(boundsDidChangeNotification:) name:@"NSViewBoundsDidChangeNotification" object:[scrollView contentView]]; - prefs = [[NSUserDefaults standardUserDefaults] retain]; - [self setQueryHiliteColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorHighlightQueryColor]]]; [self setQueryEditorBackgroundColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorBackgroundColor]]]; [self setCommentColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorCommentColor]]]; @@ -184,6 +193,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [self setShouldHiliteQuery:[prefs boolForKey:SPCustomQueryHighlightCurrentQuery]]; // Register observers for the when editor background colors preference changes + [prefs addObserver:self forKeyPath:SPCustomQueryEditorFont options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:self forKeyPath:SPCustomQueryEditorBackgroundColor options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:self forKeyPath:SPCustomQueryEditorHighlightQueryColor options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:self forKeyPath:SPCustomQueryHighlightCurrentQuery options:NSKeyValueObservingOptionNew context:NULL]; @@ -211,6 +221,9 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) if ([keyPath isEqualToString:SPCustomQueryEditorBackgroundColor]) { [self setQueryEditorBackgroundColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; [self setNeedsDisplay:YES]; + } else if ([keyPath isEqualToString:SPCustomQueryEditorFont]) { + [self setFont:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; + [self setNeedsDisplay:YES]; } else if ([keyPath isEqualToString:SPCustomQueryEditorHighlightQueryColor]) { [self setQueryHiliteColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; [self setNeedsDisplay:YES]; @@ -510,6 +523,10 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) NSString* prefix = @""; NSString *currentDb = nil; + // Break for long stuff + if(completionRange.length>100000) return; + + NSString* allow; // additional chars which not close the popup if(isDictMode) allow= @"_"; @@ -549,9 +566,9 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) NSCharacterSet *whiteSpaceCharSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; NSUInteger start = caretPos; NSInteger backticksCounter = (caretIsInsideBackticks) ? 1 : 0; - NSUInteger pointCounter = 0; - NSUInteger firstPoint = 0; - NSUInteger secondPoint = 0; + NSInteger pointCounter = 0; + NSInteger firstPoint = 0; + NSInteger secondPoint = 0; BOOL rightBacktick = NO; BOOL leftBacktick = NO; BOOL doParsing = YES; @@ -592,9 +609,13 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } dbBrowseMode = (pointCounter || backticksCounter); - + if(dbBrowseMode) { parseRange = NSMakeRange(start, caretPos-start); + + // Break for long stuff + if(parseRange.length>100000) return; + NSString *parsedString = [[self string] substringWithRange:parseRange]; // Check if parsed string is wrapped by `` @@ -1449,7 +1470,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) return; } if(curFlags & NSCommandKeyMask) { - if([charactersIgnMod isEqualToString:@"+"]) // increase text size by 1; ⌘+ and numpad + + if([charactersIgnMod isEqualToString:@"+"] || [charactersIgnMod isEqualToString:@"="]) // increase text size by 1; ⌘+, ⌘=, and ⌘ numpad + { [self makeTextSizeLarger]; return; @@ -1459,6 +1480,10 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [self makeTextSizeSmaller]; return; } + if([charactersIgnMod isEqualToString:@"0"]) { // reset font to default + [self setFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]]]; + return; + } } // Only process for character autopairing if autopairing is enabled and a single character is being added. @@ -3452,6 +3477,20 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) NSLog(@"%@ ‘%@’.", NSLocalizedString(@"Couldn't read the file content of", @"Couldn't read the file content of"), aPath); } +- (void)changeFont:(id)sender +{ + if (prefs && [self font] != nil) { + [prefs setObject:[NSArchiver archivedDataWithRootObject:[self font]] forKey:SPCustomQueryEditorFont]; + NSFont *nf = [[NSFontPanel sharedFontPanel] panelConvertFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]]]; + BOOL oldEditable = [self isEditable]; + [self setEditable:YES]; + [self setFont:nf]; + [self setEditable:oldEditable]; + [self setNeedsDisplay:YES]; + [prefs setObject:[NSArchiver archivedDataWithRootObject:nf] forKey:SPCustomQueryEditorFont]; + } +} + - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; |