From 52b6a2b07abf9dbcf375431188fcd09aec44b60e Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 2 Feb 2010 10:25:54 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20key-shortcut=20=E2=8C=98=3D=20to=20?= =?UTF-8?q?make=20the=20textview=20size=20larger=20=E2=80=A2=20=E2=8C=98-,?= =?UTF-8?q?=20=E2=8C=98+,=20=E2=8C=98=3D=20changes=20the=20font=20size=20t?= =?UTF-8?q?emporarily=20(Mac=20app=20conform)=20=E2=80=A2=20added=20key-sh?= =?UTF-8?q?ortcut=20=E2=8C=980=20to=20reset=20the=20font=20to=20pref=20def?= =?UTF-8?q?ault=20=E2=80=A2=20fixed=20search=20field=20background=20for=20?= =?UTF-8?q?Tables=20List=20=E2=80=A2=20fixed=20NSUInteger=20for=20completi?= =?UTF-8?q?on=20parsing;=20interrupt=20completion=20if=20parsed=20string?= =?UTF-8?q?=20length=20is=20larger=20than=20100000=20since=20it=20doesn't?= =?UTF-8?q?=20make=20sense=20and=20leads=20to=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/DBView.xib | 139 ++++++++++++++---------------------- Source/CMTextView.m | 53 ++++++++++++-- Source/CustomQuery.m | 20 ------ 3 files changed, 100 insertions(+), 112 deletions(-) diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index 534a09a3..a4e8d47f 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -18,13 +18,13 @@ YES 740 740 - 1.2.1 + 1.2.5 YES - + YES @@ -100,7 +100,7 @@ 290 - {{5, 1}, {204, 19}} + {{5, 2}, {204, 19}} YES @@ -192,7 +192,7 @@ 4362 - {213, 38} + {218, 38} YES @@ -203,7 +203,7 @@ YES - 210 + 215 40 1000 @@ -252,13 +252,8 @@ 3 2 - 6 - System - _sourceListBackgroundColor - - 1 - MC44MzkyMTU2OTU5IDAuODY2NjY2Njc0NiAwLjg5ODAzOTIyMTgAA - + 2 + MC44NzQ1MDk4MTE0IDAuODkwMTk2MDg1IDAuOTE3NjQ3MDYzNwA 6 @@ -281,12 +276,12 @@ 1 - {{1, 1}, {213, 38}} + {{1, 1}, {218, 38}} - 4 + 2 @@ -308,7 +303,7 @@ 0.57142859697341919 - {{0, -13}, {215, 40}} + {{-1, -13}, {220.212, 40}} 2 @@ -1694,6 +1689,7 @@ NO NO NO + NO 0.0 0.0 @@ -3808,7 +3804,7 @@ status - + 256 YES @@ -3835,6 +3831,29 @@ 2322 + + YES + + YES + Apple HTML pasteboard type + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple PNG pasteboard type + Apple URL pasteboard type + CorePasteboardFlavorType 0x6D6F6F76 + NSColor pasteboard type + NSFilenamesPboardType + NSStringPboardType + NeXT Encapsulated PostScript v1.2 pasteboard type + NeXT RTFD pasteboard type + NeXT Rich Text Format v1.0 pasteboard type + NeXT TIFF v4.0 pasteboard type + NeXT font pasteboard type + NeXT ruler pasteboard type + WebURLsWithTitlesPboardType + public.url + + {542, 14} @@ -3894,7 +3913,7 @@ 6 - {1085, 1e+07} + {1097, 1e+07} {223, 0} @@ -4032,7 +4051,7 @@ 6 - {1085, 1e+07} + {1097, 1e+07} {223, 0} @@ -4451,6 +4470,7 @@ {{10, 7}, {706, 544}} + Status @@ -4846,7 +4866,7 @@ triggers - + 256 YES @@ -5279,21 +5299,20 @@ {{10, 7}, {706, 544}} - Triggers - + 134217731 YES YES YES - + @@ -13211,26 +13230,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 5531 - - - font: values.CustomQueryEditorFont - - - - - - font: values.CustomQueryEditorFont - font - values.CustomQueryEditorFont - - NSValueTransformerName - NSUnarchiveFromData - - 2 - - - 5533 - autohelpMenuItem @@ -13591,26 +13590,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 5860 - - - font: values.CustomQueryEditorFont - - - - - - font: values.CustomQueryEditorFont - font - values.CustomQueryEditorFont - - NSValueTransformerName - NSUnarchiveFromData - - 2 - - - 5864 - selectTableColumn: @@ -14788,26 +14767,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 6587 - - - font: values.CustomQueryEditorFont - - - - - - font: values.CustomQueryEditorFont - font - values.CustomQueryEditorFont - - NSValueTransformerName - NSUnarchiveFromData - - 2 - - - 6593 - createTableSyntaxTextView @@ -22776,7 +22735,8 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 669.IBPluginDependency 669.ImportedFromIB2 6690.IBPluginDependency - 6691.IBPluginDependency + 6692.IBPluginDependency + 6693.IBPluginDependency 6694.IBPluginDependency 6695.IBPluginDependency 6696.IBAttributePlaceholdersKey @@ -22820,8 +22780,12 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 672.IBPluginDependency 672.ImportedFromIB2 6720.IBPluginDependency + 6727.IBPluginDependency + 6728.IBPluginDependency + 6729.IBPluginDependency 673.IBPluginDependency 673.ImportedFromIB2 + 6730.IBPluginDependency 6735.IBEditorWindowLastContentRect 6735.IBPluginDependency 6736.IBPluginDependency @@ -23697,10 +23661,10 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{799, 846}, {944, 550}} + {{239, 357}, {944, 550}} com.apple.InterfaceBuilder.CocoaPlugin - {{799, 846}, {944, 550}} + {{239, 357}, {944, 550}} {{62, 352}, {845, 504}} @@ -24660,6 +24624,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin ToolTip @@ -24723,7 +24688,11 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{539, 190}, {158, 23}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin 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]; diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index d977d7de..75bbb894 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -1278,19 +1278,11 @@ // Set up the interface - [textView setAllowsDocumentBackgroundColorChange:YES]; - [customQueryView setVerticalMotionCanBeginDrag:NO]; - [textView setContinuousSpellCheckingEnabled:NO]; [autoindentMenuItem setState:([prefs boolForKey:SPCustomQueryAutoIndent]?NSOnState:NSOffState)]; - [textView setAutoindent:[prefs boolForKey:SPCustomQueryAutoIndent]]; - [textView setAutoindentIgnoresEnter:YES]; [autopairMenuItem setState:([prefs boolForKey:SPCustomQueryAutoPairCharacters]?NSOnState:NSOffState)]; - [textView setAutopair:[prefs boolForKey:SPCustomQueryAutoPairCharacters]]; [autohelpMenuItem setState:([prefs boolForKey:SPCustomQueryUpdateAutoHelp]?NSOnState:NSOffState)]; - [textView setAutohelp:[prefs boolForKey:SPCustomQueryUpdateAutoHelp]]; [autouppercaseKeywordsMenuItem setState:([prefs boolForKey:SPCustomQueryAutoUppercaseKeywords]?NSOnState:NSOffState)]; - [textView setAutouppercaseKeywords:[prefs boolForKey:SPCustomQueryAutoUppercaseKeywords]]; if ( [[SPQueryController sharedQueryController] historyForFileURL:[tableDocumentInstance fileURL]] ) { @@ -2107,18 +2099,6 @@ } } -/* - * Save the custom query editor font if it is changed. - */ -- (void)textViewDidChangeTypingAttributes:(NSNotification *)aNotification -{ - // Only save the font if prefs have been loaded, ensuring the saved font has been applied once. - // And check for [textView font] != nil which occurs while awaking from nib. - if (prefs && [textView font] != nil) - [prefs setObject:[NSArchiver archivedDataWithRootObject:[textView font]] forKey:SPCustomQueryEditorFont]; - -} - #pragma mark - #pragma mark TextField delegate methods -- cgit v1.2.3