aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-04-30 10:18:03 +0000
committerBibiko <bibiko@eva.mpg.de>2009-04-30 10:18:03 +0000
commit40dc576b30ec1da22ae58c1daaae86a6d1020b2c (patch)
tree8affef0bc1daa659abb3a1c3c6205171e88a931d
parentdc29496e335f047cbee8a1c58371ad1827d0467d (diff)
downloadsequelpro-40dc576b30ec1da22ae58c1daaae86a6d1020b2c.tar.gz
sequelpro-40dc576b30ec1da22ae58c1daaae86a6d1020b2c.tar.bz2
sequelpro-40dc576b30ec1da22ae58c1daaae86a6d1020b2c.zip
• MySQL Help
- updated autoHelp, now it recognizes cursor movement via mouse • if the chunk in CQ's textview is too large remove all attributes • some minor code cosmetics
-rw-r--r--Source/CMTextView.h2
-rw-r--r--Source/CMTextView.m38
-rw-r--r--Source/CustomQuery.h2
-rw-r--r--Source/CustomQuery.m2
4 files changed, 31 insertions, 13 deletions
diff --git a/Source/CMTextView.h b/Source/CMTextView.h
index 67a553b6..88b7a995 100644
--- a/Source/CMTextView.h
+++ b/Source/CMTextView.h
@@ -35,6 +35,8 @@
NSString *lookupInDocumentationTitle;
+ BOOL sqlStringIsTooLarge;
+
IBOutlet NSScrollView *scrollView;
}
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 89262a4b..272efc07 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -40,10 +40,10 @@ YY_BUFFER_STATE yy_scan_string (const char *);
#define kAPlinked @"Linked" // attribute for a via auto-pair inserted char
#define kAPval @"linked"
#define kWQquoted @"Quoted" // set via lex to indicate a quoted string
-#define kWquoted @"isQuoted"
-#define kWQval @"aValue"
#define kSQLkeyword @"SQLkw" // attribute for found SQL keywords
#define kQuote @"Quote"
+#define kValue @"dummy"
+
#define MYSQL_DOC_SEARCH_URL @"http://dev.mysql.com/doc/refman/%@/en/%@.html"
@@ -241,7 +241,7 @@ YY_BUFFER_STATE yy_scan_string (const char *);
*/
- (void) keyDown:(NSEvent *)theEvent
{
-
+
if(autohelpEnabled) // cancel autoHelp request
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(autoHelp)
@@ -412,6 +412,19 @@ YY_BUFFER_STATE yy_scan_string (const char *);
}
+- (void)mouseDown:(NSEvent *)theEvent
+{
+
+ if(autohelpEnabled) // cancel autoHelp request
+ [NSObject cancelPreviousPerformRequestsWithTarget:self
+ selector:@selector(autoHelp)
+ object:nil];
+
+ [super mouseDown:theEvent];
+ if(autohelpEnabled)
+ [self performSelector:@selector(autoHelp) withObject:nil afterDelay:1];
+
+}
- (void) deleteBackward:(id)sender
{
@@ -604,7 +617,7 @@ YY_BUFFER_STATE yy_scan_string (const char *);
// Check if the caret is inside quotes "" or ''; if so
// return the normal word suggestion due to the spelling's settings
- if([[self textStorage] attribute:kQuote atIndex:charRange.location effectiveRange:nil])
+ if(!sqlStringIsTooLarge && [[self textStorage] attribute:kQuote atIndex:charRange.location effectiveRange:nil])
return [[NSSpellChecker sharedSpellChecker] completionsForPartialWordRange:NSMakeRange(0,charRange.length) inString:[[self string] substringWithRange:charRange] language:nil inSpellDocumentWithTag:0];
NSCharacterSet *separators = [NSCharacterSet characterSetWithCharactersInString:@" \t\r\n,()\"'`-!;=+|?:~"];
@@ -1742,7 +1755,7 @@ SYNTAX HIGHLIGHTING!
long cursorPosition = [self selectedRange].location;
if (cursorPosition >= [[self string] length]) cursorPosition--;
- if(cursorPosition > -1 && (![[[self textStorage] attribute:kQuote atIndex:cursorPosition effectiveRange:nil] isEqualToString:kWquoted]||[[self textStorage] attribute:kSQLkeyword atIndex:cursorPosition effectiveRange:nil]))
+ if(cursorPosition > -1 && (![[self textStorage] attribute:kQuote atIndex:cursorPosition effectiveRange:nil]||[[self textStorage] attribute:kSQLkeyword atIndex:cursorPosition effectiveRange:nil]))
[[[[self window] delegate] valueForKeyPath:@"customQueryInstance"] performSelector:@selector(showHelpForCurrentWord:) withObject:self afterDelay:0.1];
}
@@ -1779,11 +1792,14 @@ SYNTAX HIGHLIGHTING!
textRange = NSMakeRange(0, [textStore length]);
+ //first remove the old colors and kQuote
+ [textStore removeAttribute:NSForegroundColorAttributeName range:textRange];
+ [textStore removeAttribute:kQuote range:textRange];
+
//don't color texts longer than about 20KB. would be too slow
- if (textRange.length > 20000) return;
+ sqlStringIsTooLarge = (textRange.length > 20000);
+ if(sqlStringIsTooLarge) return;
- //first remove the old colors
- [textStore removeAttribute:NSForegroundColorAttributeName range:textRange];
//initialise flex
yyuoffset = 0; yyuleng = 0;
@@ -1856,7 +1872,7 @@ SYNTAX HIGHLIGHTING!
// to disable auto-pairing if caret is inside of any token found by lex.
// For discussion: maybe change it later (only for quotes not keywords?)
[textStore addAttribute: kWQquoted
- value: kWQval
+ value: kValue
range: tokenRange ];
@@ -1864,13 +1880,13 @@ SYNTAX HIGHLIGHTING!
// Performing it one token later allows words which start as reserved keywords to be entered.
if(token == SPT_RESERVED_WORD)
[textStore addAttribute: kSQLkeyword
- value: kWQval
+ value: kValue
range: tokenRange ];
// Add an attribute to be used to distinguish quotes from keywords etc.
// used e.g. in completion suggestions
if(token == SPT_DOUBLE_QUOTED_TEXT || token == SPT_SINGLE_QUOTED_TEXT || SPT_BACKTICK_QUOTED_TEXT)
[textStore addAttribute: kQuote
- value: kWquoted
+ value: kValue
range: tokenRange ];
}
diff --git a/Source/CustomQuery.h b/Source/CustomQuery.h
index 8973804c..34c1ebff 100644
--- a/Source/CustomQuery.h
+++ b/Source/CustomQuery.h
@@ -60,7 +60,7 @@
IBOutlet NSMenuItem *autouppercaseKeywordsMenuItem;
IBOutlet NSWindow *helpWebViewWindow;
- IBOutlet id helpWebView;
+ IBOutlet WebView *helpWebView;
IBOutlet NSSearchField *helpSearchField;
IBOutlet NSSearchFieldCell *helpSearchFieldCell;
IBOutlet NSSegmentedControl *helpNavigator;
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 4af056b1..a7741792 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -1811,7 +1811,7 @@ traps enter key and
}
}
- // Add two menu items for a selection
+ // Add two menu items for a selection if no link is given
if(webViewMenuItems
&& [[element objectForKey:@"WebElementIsSelected"] boolValue]
&& ![[element objectForKey:@"WebElementLinkIsLive"] boolValue])