From 4794c5df03806229b92c5681cfb86da8bf00d5a0 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 20 May 2009 09:10:21 +0000 Subject: =?UTF-8?q?=E2=80=A2=C2=A0added=20=E2=8C=98+=20and=20=E2=8C=98-=20?= =?UTF-8?q?for=20increasing/decreasing=20the=20font=20size=20by=201=20in?= =?UTF-8?q?=20the=20Custom=20Query=20Editor=20quickly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CMTextView.h | 4 +++- Source/CMTextView.m | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) (limited to 'Source') diff --git a/Source/CMTextView.h b/Source/CMTextView.h index e5eee68c..37731784 100644 --- a/Source/CMTextView.h +++ b/Source/CMTextView.h @@ -74,6 +74,8 @@ - (void) autoHelp; - (void) doSyntaxHighlighting; - (void) insertFileContentOfFile:(NSString *)aPath; -- (unsigned int)characterIndexOfPoint:(NSPoint)aPoint; +- (unsigned int) characterIndexOfPoint:(NSPoint)aPoint; +- (void) makeTextSizeLarger; +- (void) makeTextSizeSmaller; @end diff --git a/Source/CMTextView.m b/Source/CMTextView.m index ad66a874..7489fe1c 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -304,6 +304,7 @@ YY_BUFFER_STATE yy_scan_string (const char *); NSString *charactersIgnMod = [theEvent charactersIgnoringModifiers]; unichar insertedCharacter = [characters characterAtIndex:0]; long curFlags = ([theEvent modifierFlags] & allFlags); + int keyCode = [theEvent keyCode]; // Note: switch(insertedCharacter) {} does not work instead use charactersIgnoringModifiers if([charactersIgnMod isEqualToString:@"c"]) // ^C copy as RTF @@ -319,6 +320,18 @@ YY_BUFFER_STATE yy_scan_string (const char *); [self showMySQLHelpForCurrentWord:self]; return; } + if(curFlags & NSCommandKeyMask) { + if([charactersIgnMod isEqualToString:@"+"]) // increase text size by 1; ⌘+ and numpad + + { + [self makeTextSizeLarger]; + return; + } + if([charactersIgnMod isEqualToString:@"-"]) // decrease text size by 1; ⌘- and numpad - + { + [self makeTextSizeSmaller]; + return; + } + } // Only process for character autopairing if autopairing is enabled and a single character is being added. if ([prefs boolForKey:@"CustomQueryAutopair"] && characters && [characters length] == 1) { @@ -720,6 +733,24 @@ YY_BUFFER_STATE yy_scan_string (const char *); return [compl autorelease]; } +/* + * Increase the textView's font size by 1 + */ +- (void)makeTextSizeLarger +{ + NSFont *aFont = [self font]; + [self setFont:[[NSFontManager sharedFontManager] convertFont:aFont toSize:[aFont pointSize]+1]]; +} + +/* + * Decrease the textView's font size by 1 but not smaller than 4pt + */ +- (void)makeTextSizeSmaller +{ + NSFont *aFont = [self font]; + int newSize = ([aFont pointSize]-1 < 4) ? [aFont pointSize] : [aFont pointSize]-1; + [self setFont:[[NSFontManager sharedFontManager] convertFont:aFont toSize:newSize]]; +} /* * Hook to invoke the auto-uppercasing of SQL keywords after pasting -- cgit v1.2.3