aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/DBView.xib73
-rw-r--r--Source/CMTextView.h3
-rw-r--r--Source/CMTextView.m87
-rw-r--r--Source/CustomQuery.h1
-rw-r--r--Source/CustomQuery.m11
-rw-r--r--Source/MainController.m1
6 files changed, 131 insertions, 45 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib
index bd19a6d1..fea37f75 100644
--- a/Interfaces/English.lproj/DBView.xib
+++ b/Interfaces/English.lproj/DBView.xib
@@ -8,7 +8,6 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="673"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -45,7 +44,7 @@
<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
<string key="NSWindowContentMinSize">{780, 480}</string>
<object class="NSView" key="NSWindowView" id="579726586">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -175,7 +174,6 @@
</object>
<string key="NSFrame">{{1, 1}, {194, 393}}</string>
<reference key="NSSuperview" ref="233472824"/>
- <reference key="NSNextKeyView" ref="251040077"/>
<reference key="NSDocView" ref="251040077"/>
<object class="NSColor" key="NSBGColor" id="1024678221">
<int key="NSColorSpace">6</int>
@@ -207,7 +205,6 @@
</object>
<string key="NSFrameSize">{196, 395}</string>
<reference key="NSSuperview" ref="355288374"/>
- <reference key="NSNextKeyView" ref="73685676"/>
<int key="NSsFlags">530</int>
<reference key="NSVScroller" ref="693168867"/>
<reference key="NSHScroller" ref="656188692"/>
@@ -292,7 +289,6 @@
</object>
<string key="NSFrame">{{1, 1}, {194, 123}}</string>
<reference key="NSSuperview" ref="298226231"/>
- <reference key="NSNextKeyView" ref="347093764"/>
<reference key="NSDocView" ref="347093764"/>
<reference key="NSBGColor" ref="1024678221"/>
<int key="NScvFlags">4</int>
@@ -319,7 +315,6 @@
</object>
<string key="NSFrame">{{0, 404}, {196, 125}}</string>
<reference key="NSSuperview" ref="355288374"/>
- <reference key="NSNextKeyView" ref="685057119"/>
<int key="NSsFlags">530</int>
<reference key="NSVScroller" ref="245346414"/>
<reference key="NSHScroller" ref="353686052"/>
@@ -709,7 +704,7 @@
<object class="_NSCornerView" key="NSCornerView" id="868771861">
<reference key="NSNextResponder" ref="22340145"/>
<int key="NSvFlags">-2147483392</int>
- <string key="NSFrame">{{611, 0}, {16, 17}}</string>
+ <string key="NSFrame">{{-26, 0}, {16, 17}}</string>
<reference key="NSSuperview" ref="22340145"/>
</object>
<object class="NSMutableArray" key="NSTableColumns">
@@ -1243,7 +1238,6 @@
</object>
<string key="NSFrame">{{1, 17}, {625, 289}}</string>
<reference key="NSSuperview" ref="22340145"/>
- <reference key="NSNextKeyView" ref="715508012"/>
<reference key="NSDocView" ref="715508012"/>
<reference key="NSBGColor" ref="1024678221"/>
<int key="NScvFlags">4</int>
@@ -1276,7 +1270,6 @@
</object>
<string key="NSFrame">{{1, 0}, {625, 17}}</string>
<reference key="NSSuperview" ref="22340145"/>
- <reference key="NSNextKeyView" ref="926883367"/>
<reference key="NSDocView" ref="926883367"/>
<reference key="NSBGColor" ref="1024678221"/>
<int key="NScvFlags">4</int>
@@ -1285,7 +1278,6 @@
</object>
<string key="NSFrame">{{-1, 22}, {627, 307}}</string>
<reference key="NSSuperview" ref="220777809"/>
- <reference key="NSNextKeyView" ref="16936123"/>
<int key="NSsFlags">562</int>
<reference key="NSVScroller" ref="943144555"/>
<reference key="NSHScroller" ref="456666876"/>
@@ -1719,7 +1711,6 @@
</object>
<string key="NSFrame">{{1, 17}, {625, 141}}</string>
<reference key="NSSuperview" ref="376224367"/>
- <reference key="NSNextKeyView" ref="584834515"/>
<reference key="NSDocView" ref="584834515"/>
<reference key="NSBGColor" ref="1024678221"/>
<int key="NScvFlags">4</int>
@@ -1752,7 +1743,6 @@
</object>
<string key="NSFrame">{{1, 0}, {625, 17}}</string>
<reference key="NSSuperview" ref="376224367"/>
- <reference key="NSNextKeyView" ref="459548655"/>
<reference key="NSDocView" ref="459548655"/>
<reference key="NSBGColor" ref="1024678221"/>
<int key="NScvFlags">4</int>
@@ -1761,7 +1751,6 @@
</object>
<string key="NSFrame">{{-1, 22}, {627, 159}}</string>
<reference key="NSSuperview" ref="1063281455"/>
- <reference key="NSNextKeyView" ref="794929378"/>
<int key="NSsFlags">562</int>
<reference key="NSVScroller" ref="1019209947"/>
<reference key="NSHScroller" ref="328951385"/>
@@ -2786,7 +2775,7 @@
<object class="NSPopUpButton" id="86760255">
<reference key="NSNextResponder" ref="345834048"/>
<int key="NSvFlags">268</int>
- <string key="NSFrame">{{162, 246}, {106, 22}}</string>
+ <string key="NSFrame">{{166, 246}, {108, 22}}</string>
<reference key="NSSuperview" ref="345834048"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="830957297">
@@ -2837,7 +2826,7 @@
<object class="NSPopUpButton" id="872178320">
<reference key="NSNextResponder" ref="345834048"/>
<int key="NSvFlags">264</int>
- <string key="NSFrame">{{38, 246}, {114, 22}}</string>
+ <string key="NSFrame">{{38, 246}, {118, 22}}</string>
<reference key="NSSuperview" ref="345834048"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="416049103">
@@ -2931,7 +2920,10 @@
<reference key="NSControlView" ref="363916571"/>
<int key="NSButtonFlags">-2042609409</int>
<int key="NSButtonFlags2">35</int>
- <reference key="NSNormalImage" ref="646982536"/>
+ <object class="NSCustomResource" key="NSNormalImage">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">button_action</string>
+ </object>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">400</int>
@@ -3110,9 +3102,19 @@
<int key="NSTag">10</int>
<reference key="NSTarget" ref="984501775"/>
</object>
+ <object class="NSMenuItem" id="81663257">
+ <reference key="NSMenu" ref="60735230"/>
+ <string key="NSTitle">Auto-uppercase Keywords</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="594889092"/>
+ <reference key="NSMixedImage" ref="515625830"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="984501775"/>
+ </object>
</object>
</object>
- <int key="NSSelectedIndex">12</int>
+ <int key="NSSelectedIndex">14</int>
<bool key="NSPullDown">YES</bool>
<int key="NSPreferredEdge">1</int>
<bool key="NSUsesItemFromMenu">YES</bool>
@@ -3657,7 +3659,6 @@
</object>
</object>
<string key="NSFrameSize">{863, 550}</string>
- <reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMinSize">{780, 502}</string>
@@ -11936,6 +11937,22 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
<int key="connectionID">5316</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">autouppercaseKeywordsMenuItem</string>
+ <reference key="source" ref="601471102"/>
+ <reference key="destination" ref="81663257"/>
+ </object>
+ <int key="connectionID">5318</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">gearMenuItemSelected:</string>
+ <reference key="source" ref="601471102"/>
+ <reference key="destination" ref="81663257"/>
+ </object>
+ <int key="connectionID">5319</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -15761,9 +15778,9 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<reference ref="363916571"/>
<reference ref="811536132"/>
<reference ref="1009499029"/>
- <reference ref="86760255"/>
<reference ref="696609643"/>
<reference ref="872178320"/>
+ <reference ref="86760255"/>
</object>
<reference key="parent" ref="894339536"/>
</object>
@@ -16783,6 +16800,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<reference ref="309123434"/>
<reference ref="820189134"/>
<reference ref="620583791"/>
+ <reference ref="81663257"/>
</object>
<reference key="parent" ref="984501775"/>
</object>
@@ -16884,6 +16902,11 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<reference key="object" ref="42997882"/>
<reference key="parent" ref="324870933"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">5317</int>
+ <reference key="object" ref="81663257"/>
+ <reference key="parent" ref="60735230"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -17915,6 +17938,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string>5299.IBPluginDependency</string>
<string>5300.IBPluginDependency</string>
<string>5301.IBPluginDependency</string>
+ <string>5317.IBPluginDependency</string>
<string>557.IBPluginDependency</string>
<string>557.ImportedFromIB2</string>
<string>565.IBEditorWindowLastContentRect</string>
@@ -19243,8 +19267,8 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{428, 361}, {863, 550}}</string>
- <string>{{428, 361}, {863, 550}}</string>
+ <string>{{92, 306}, {863, 550}}</string>
+ <string>{{92, 306}, {863, 550}}</string>
<reference ref="9"/>
<reference ref="9"/>
<string>{{62, 352}, {845, 504}}</string>
@@ -19426,7 +19450,8 @@ aGUgYWN0aXZlIHNlbGVjdGlvbiAo4oyl4oyYUik</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{619, 520}, {236, 220}}</string>
+ <string>{{283, 448}, {236, 237}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -19715,7 +19740,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">5316</int>
+ <int key="maxID">5319</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -19815,6 +19840,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
<string>affectedRowsText</string>
<string>autoindentMenuItem</string>
<string>autopairMenuItem</string>
+ <string>autouppercaseKeywordsMenuItem</string>
<string>clearHistoryMenuItem</string>
<string>completionListMenuItem</string>
<string>copyQueryFavoriteButton</string>
@@ -19842,6 +19868,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
<string>NSMenuItem</string>
<string>NSMenuItem</string>
<string>NSMenuItem</string>
+ <string>NSMenuItem</string>
<string>id</string>
<string>CMCopyTable</string>
<string>id</string>
diff --git a/Source/CMTextView.h b/Source/CMTextView.h
index 4dadb33d..cec4c67b 100644
--- a/Source/CMTextView.h
+++ b/Source/CMTextView.h
@@ -27,6 +27,7 @@
BOOL autoindentEnabled;
BOOL autopairEnabled;
BOOL autoindentIgnoresEnter;
+ BOOL autouppercaseKeywordsEnabled;
}
- (BOOL) isNextCharMarkedBy:(id)attribute;
@@ -42,5 +43,7 @@
- (BOOL) autoindentIgnoresEnter;
- (void) setAutopair:(BOOL)enableAutopair;
- (BOOL) autopair;
+- (void) setAutouppercaseKeywords:(BOOL)enableAutouppercaseKeywords;
+- (BOOL) autouppercaseKeywords;
@end
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 67d2b39b..7685728d 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -34,10 +34,11 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
void yy_switch_to_buffer(YY_BUFFER_STATE);
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 kWQval @"quoted"
+#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 kWQval @"quoted"
+#define kSQLkeyword @"SQLkw" // attribute for found SQL keywords
@implementation CMTextView
@@ -488,6 +489,20 @@ YY_BUFFER_STATE yy_scan_string (const char *);
/*
+ * Hook to invoke the auto-uppercasing of SQL keywords after pasting
+ */
+- (void)paste:(id)sender
+{
+ // Insert the content of the pasteboard
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+ [self insertText:[pb stringForType:NSStringPboardType]];
+
+ // Invoke the auto-uppercasing of SQL keywords via an additional trigger
+ [self insertText:@""];
+}
+
+
+/*
List of keywords for autocompletion. If you add a keyword here,
it should also be added to the flex file SPEditorTokens.l
*/
@@ -817,15 +832,38 @@ it should also be added to the flex file SPEditorTokens.l
return autopairEnabled;
}
+/*
+ * Set whether SQL keywords should be automatically uppercased.
+ */
+- (void)setAutouppercaseKeywords:(BOOL)enableAutouppercaseKeywords
+{
+ autouppercaseKeywordsEnabled = enableAutouppercaseKeywords;
+}
+
+/*
+ * Retrieve whether SQL keywords should be automaticallyuppercased.
+ */
+- (BOOL)autouppercaseKeywords
+{
+ return autouppercaseKeywordsEnabled;
+}
+
+
/*******************
SYNTAX HIGHLIGHTING!
*******************/
- (void)awakeFromNib
/*
-sets self as delegate for the textView's textStorage to enable syntax highlighting
-*/
+ * Sets self as delegate for the textView's textStorage to enable syntax highlighting,
+ * and set defaults for general usage
+ */
{
[[self textStorage] setDelegate:self];
+
+ autoindentEnabled = YES;
+ autopairEnabled = YES;
+ autoindentIgnoresEnter = NO;
+ autouppercaseKeywordsEnabled = YES;
}
- (void)textStorageDidProcessEditing:(NSNotification *)notification
@@ -896,31 +934,36 @@ sets self as delegate for the textView's textStorage to enable syntax highlighti
// otherwise a bug in the lex code could cause the the TextView to crash
tokenRange = NSIntersectionRange(tokenRange, textRange);
if (!tokenRange.length) continue;
-
+
+ // Is the current token is marked as SQL keyword, uppercase it if required.
+ if (autouppercaseKeywordsEnabled &&
+ [[self textStorage] attribute:kSQLkeyword atIndex:tokenRange.location effectiveRange:nil])
+ {
+ // Note: Register it for undo doesn't work ?=> unreliable single char undo
+ // Replace it
+ [self replaceCharactersInRange:tokenRange withString:[[[self string] substringWithRange:tokenRange] uppercaseString]];
+ }
+
[textStore addAttribute: NSForegroundColorAttributeName
value: tokenColor
range: tokenRange ];
- // this attr is used in the auto-pairing (keyDown:)
- // to disable auto-pairing if caret is inside of any token found by lex
- // maybe change it later (only for quotes) => discussion
+
+ // Add an attribute to be used in the auto-pairing (keyDown:)
+ // 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
range: tokenRange ];
+
+ // Mark each SQL keyword for auto-uppercasing and do it for the next textStorageDidProcessEditing: event.
+ // 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
+ range: tokenRange ];
}
}
-- (id) init
-{
- if (self = [super init]) {
- autoindentEnabled = YES;
- autopairEnabled = YES;
- autoindentIgnoresEnter = NO;
- }
-
- return self;
-}
-
-
@end
diff --git a/Source/CustomQuery.h b/Source/CustomQuery.h
index 9b75c906..5d314316 100644
--- a/Source/CustomQuery.h
+++ b/Source/CustomQuery.h
@@ -53,6 +53,7 @@
IBOutlet NSMenuItem *completionListMenuItem;
IBOutlet NSMenuItem *autoindentMenuItem;
IBOutlet NSMenuItem *autopairMenuItem;
+ IBOutlet NSMenuItem *autouppercaseKeywordsMenuItem;
NSArray *queryResult;
NSUserDefaults *prefs;
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 3d6c18d0..6b89f6a4 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -201,6 +201,15 @@ closes the sheet
[autopairMenuItem setState:enableAutopair?NSOnState:NSOffState];
[textView setAutopair:enableAutopair];
}
+
+ // "Auto-uppercase keywords" toggle
+ if (sender == autouppercaseKeywordsMenuItem) {
+ BOOL enableAutouppercaseKeywords = ([autouppercaseKeywordsMenuItem state] == NSOffState);
+ [prefs setBool:enableAutouppercaseKeywords forKey:@"CustomQueryAutouppercaseKeywords"];
+ [prefs synchronize];
+ [autouppercaseKeywordsMenuItem setState:enableAutouppercaseKeywords?NSOnState:NSOffState];
+ [textView setAutouppercaseKeywords:enableAutouppercaseKeywords];
+ }
}
@@ -603,6 +612,8 @@ sets the connection (received from TableDocument) and makes things that have to
[textView setAutoindentIgnoresEnter:YES];
[autopairMenuItem setState:([prefs boolForKey:@"CustomQueryAutopair"]?NSOnState:NSOffState)];
[textView setAutopair:[prefs boolForKey:@"CustomQueryAutopair"]];
+ [autouppercaseKeywordsMenuItem setState:([prefs boolForKey:@"CustomQueryAutouppercaseKeywords"]?NSOnState:NSOffState)];
+ [textView setAutouppercaseKeywords:[prefs boolForKey:@"CustomQueryAutouppercaseKeywords"]];
[queryFavoritesView registerForDraggedTypes:[NSArray arrayWithObjects:@"SequelProPasteboard", nil]];
while ( (column = [enumerator nextObject]) )
{
diff --git a/Source/MainController.m b/Source/MainController.m
index 4e21c4d5..f68c69e3 100644
--- a/Source/MainController.m
+++ b/Source/MainController.m
@@ -673,6 +673,7 @@ checks for updates and opens download page in default browser
[NSNumber numberWithInt:0], @"lastUsedVersion",
[NSNumber numberWithBool:YES], @"CustomQueryAutopair",
[NSNumber numberWithBool:YES], @"CustomQueryAutoindent",
+ [NSNumber numberWithBool:NO], @"CustomQueryAutouppercaseKeywords",
nil]];
// For versions prior to r336, where column widths have been saved, walk through them and remove