From 5052718afb789f21654e094f2d065baf6bb6ac81 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sat, 6 Mar 2010 12:36:37 +0000 Subject: =?UTF-8?q?=E2=80=A2=20CSV=20Import=20Field=20Mapper=20-=20fixed?= =?UTF-8?q?=20some=20issues=20for=20displaying=20the=20default=20values=20?= =?UTF-8?q?for=20auto=5Fincrement=20and=20time=5Fstamp=20=E2=80=A2=20added?= =?UTF-8?q?=20possibility=20to=20change=20the=20tab=20stop=20width=20in=20?= =?UTF-8?q?each=20CMTextView=20via=20Preference=20setting=20in=20Editor=20?= =?UTF-8?q?window?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/Preferences.xib | 265 ++++++++++++++++++++++++++++--- Resources/PreferenceDefaults.plist | 2 + Source/CMTextView.h | 1 + Source/CMTextView.m | 81 ++++++---- Source/SPConstants.h | 1 + Source/SPConstants.m | 1 + Source/SPFieldMapperController.m | 17 +- 7 files changed, 304 insertions(+), 64 deletions(-) diff --git a/Interfaces/English.lproj/Preferences.xib b/Interfaces/English.lproj/Preferences.xib index b9f04f4f..04efb9eb 100644 --- a/Interfaces/English.lproj/Preferences.xib +++ b/Interfaces/English.lproj/Preferences.xib @@ -13,6 +13,7 @@ YES + YES @@ -58,7 +59,7 @@ {3.40282e+38, 3.40282e+38} - + 268 YES @@ -67,7 +68,6 @@ 268 {{151, 121}, {254, 26}} - YES -2076049856 @@ -405,7 +405,6 @@ 268 {{152, 214}, {209, 18}} - YES 67239424 @@ -433,7 +432,6 @@ 268 {{40, 242}, {108, 17}} - YES 68288064 @@ -466,7 +464,6 @@ 268 {{151, 236}, {254, 26}} - YES -2076049856 @@ -499,7 +496,6 @@ 268 {{33, 85}, {116, 17}} - YES 68288064 @@ -516,7 +512,6 @@ 268 {{33, 127}, {116, 17}} - YES 68288064 @@ -533,7 +528,6 @@ 268 {{152, 84}, {166, 18}} - YES 67239424 @@ -556,7 +550,6 @@ 268 {{152, 62}, {181, 18}} - YES 67239424 @@ -579,7 +572,6 @@ 12 {{154, 156}, {326, 5}} - {0, 0} 67239424 @@ -610,7 +602,6 @@ 12 {{154, 108}, {326, 5}} - {0, 0} 67239424 @@ -633,7 +624,6 @@ 12 {{154, 53}, {326, 5}} - {0, 0} 67239424 @@ -656,7 +646,6 @@ 268 {{42, 23}, {106, 17}} - YES 68288064 @@ -673,7 +662,6 @@ 268 {{153, 20}, {38, 22}} - YES -1804468671 @@ -750,7 +738,6 @@ 268 {{197, 23}, {162, 17}} - YES 68288064 @@ -767,7 +754,6 @@ 268 {{151, 169}, {254, 26}} - YES -2076049856 @@ -881,7 +867,6 @@ 268 {{61, 175}, {88, 17}} - YES 68288064 @@ -898,7 +883,6 @@ 12 {{154, 204}, {326, 5}} - {0, 0} 67239424 @@ -918,8 +902,6 @@ {500, 280} - - NSView @@ -3097,10 +3079,116 @@ AQAAAAA NSView - + 268 YES + + + 268 + {{363, 55}, {23, 19}} + + YES + + -1804468671 + 71435264 + + + + YES + + YES + allowsFloats + formatterBehavior + lenient + locale + maximum + minimum + negativeInfinitySymbol + nilSymbol + numberStyle + positiveInfinitySymbol + + + YES + + + + + + + -∞ + + + +∞ + + + #,##0.### + #,##0.### + + + + + + + + NaN + + + + + + 3 + YES + YES + YES + + . + , + YES + NO + YES + + + YES + + + + + + + 268 + {{256, 57}, {104, 17}} + + YES + + 68288064 + 272630784 + Tab Stop Width: + + + + + + + + + 268 + {{393, 53}, {15, 22}} + + YES + + 68025888 + 131072 + + + 1 + 1 + 20 + 1 + YES + + 268 @@ -3802,9 +3890,14 @@ AQAAAAA {500, 395} + NSView + + YES + CustomQueryEditorTabStopWidth + YES @@ -5899,6 +5992,54 @@ AQAAAAA 1494 + + + takeIntegerValueFrom: + + + + 1509 + + + + value: values.CustomQueryEditorTabStopWidth + + + + + + value: values.CustomQueryEditorTabStopWidth + value + values.CustomQueryEditorTabStopWidth + 2 + + + 1511 + + + + takeIntegerValueFrom: + + + + 1512 + + + + value: values.CustomQueryEditorTabStopWidth + + + + + + value: values.CustomQueryEditorTabStopWidth + value + values.CustomQueryEditorTabStopWidth + 2 + + + 1516 + @@ -6914,6 +7055,9 @@ AQAAAAA + + + Editor @@ -8383,6 +8527,57 @@ AQAAAAA + + 1497 + + + YES + + + + + + 1498 + + + + + 1499 + + + YES + + + + + + 1500 + + + + + 1505 + + + YES + + + + + + 1506 + + + YES + + + + + + 1507 + + + @@ -8592,6 +8787,15 @@ AQAAAAA 1489.IBPluginDependency 1490.IBPluginDependency 1492.IBPluginDependency + 1497.IBPluginDependency + 1498.IBPluginDependency + 1499.IBPluginDependency + 1500.IBPluginDependency + 1505.IBPluginDependency + 1506.IBPluginDependency + 1507.IBNumberFormatterBehaviorMetadataKey + 1507.IBNumberFormatterLocalizesFormatMetadataKey + 1507.IBPluginDependency 17.IBEditorWindowLastContentRect 17.IBPluginDependency 17.IBUserGuides @@ -9063,6 +9267,15 @@ AQAAAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + com.apple.InterfaceBuilder.CocoaPlugin {{571, 222}, {500, 280}} com.apple.InterfaceBuilder.CocoaPlugin @@ -9243,7 +9456,7 @@ AQAAAAA com.apple.InterfaceBuilder.CocoaPlugin - {{751, 254}, {499, 316}} + {{122, 254}, {499, 316}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -9385,7 +9598,7 @@ AQAAAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{545, 361}, {500, 395}} + {{121, 361}, {500, 395}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -9446,7 +9659,7 @@ AQAAAAA - 1494 + 1516 @@ -9662,7 +9875,6 @@ AQAAAAA displayAutoUpdatePreferences: displayEditorPreferences: displayFavoritePreferences: - displayGeneralPreferences: displayNetworkPreferences: displayNotificationPreferences: displayTablePreferences: @@ -9693,7 +9905,6 @@ AQAAAAA id id id - id @@ -9723,6 +9934,7 @@ AQAAAAA sshPasswordField sshSQLPasswordField standardPasswordField + tabWidthInputField tableCell tablesView @@ -9752,6 +9964,7 @@ AQAAAAA NSSecureTextField NSSecureTextField id + id NSView diff --git a/Resources/PreferenceDefaults.plist b/Resources/PreferenceDefaults.plist index 18b71f09..52abb689 100644 --- a/Resources/PreferenceDefaults.plist +++ b/Resources/PreferenceDefaults.plist @@ -84,6 +84,8 @@ CustomQueryUpdateAutoHelp + CustomQueryEditorTabStopWidth + 4 CustomQueryAutoHelpDelay 1 lastSqlFileEncoding diff --git a/Source/CMTextView.h b/Source/CMTextView.h index c278c2c3..53afe0df 100644 --- a/Source/CMTextView.h +++ b/Source/CMTextView.h @@ -121,6 +121,7 @@ static inline id NSMutableAttributedStringAttributeAtIndex (NSMutableAttributedS - (BOOL) autouppercaseKeywords; - (void) setAutohelp:(BOOL)enableAutohelp; - (BOOL) autohelp; +- (void) setTabStops; - (void) selectLineNumber:(NSUInteger)lineNumber ignoreLeadingNewLines:(BOOL)ignLeadingNewLines; - (NSUInteger) getLineNumberForCharacterIndex:(NSUInteger)anIndex; - (void) autoHelp; diff --git a/Source/CMTextView.m b/Source/CMTextView.m index d6a1e9d7..3a95a6b5 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -140,40 +140,9 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [self setAutohelp:[prefs boolForKey:SPCustomQueryUpdateAutoHelp]]; [self setAutouppercaseKeywords:[prefs boolForKey:SPCustomQueryAutoUppercaseKeywords]]; - // Re-define 64 tab stops for a better editing - NSFont *tvFont = [self font]; - float firstColumnInch = 0.5, otherColumnInch = 0.5, pntPerInch = 72.0; - NSInteger i; - NSTextTab *aTab; - NSMutableArray *myArrayOfTabs; - NSMutableParagraphStyle *paragraphStyle; - myArrayOfTabs = [NSMutableArray arrayWithCapacity:64]; - aTab = [[NSTextTab alloc] initWithType:NSLeftTabStopType location:firstColumnInch*pntPerInch]; - [myArrayOfTabs addObject:aTab]; - [aTab release]; - for(i=1; i<64; i++) { - aTab = [[NSTextTab alloc] initWithType:NSLeftTabStopType location:(firstColumnInch*pntPerInch) + ((float)i * otherColumnInch * pntPerInch)]; - [myArrayOfTabs addObject:aTab]; - [aTab release]; - } - paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; - [paragraphStyle setTabStops:myArrayOfTabs]; - // Soft wrapped lines are indented slightly - [paragraphStyle setHeadIndent:4.0]; - - NSMutableDictionary *textAttributes = [[[NSMutableDictionary alloc] initWithCapacity:1] autorelease]; - [textAttributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName]; + // Re-define tab stops for a better editing + [self setTabStops]; - NSRange range = NSMakeRange(0, [[self textStorage] length]); - if ([self shouldChangeTextInRange:range replacementString:nil]) { - [[self textStorage] setAttributes:textAttributes range: range]; - [self didChangeText]; - } - [self setTypingAttributes:textAttributes]; - [self setDefaultParagraphStyle:paragraphStyle]; - [paragraphStyle release]; - [self setFont:tvFont]; - // disabled to get the current text range in textView safer [[self layoutManager] setBackgroundLayoutEnabled:NO]; @@ -207,6 +176,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [prefs addObserver:self forKeyPath:SPCustomQueryEditorNumericColor options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:self forKeyPath:SPCustomQueryEditorVariableColor options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:self forKeyPath:SPCustomQueryEditorTextColor options:NSKeyValueObservingOptionNew context:NULL]; + [prefs addObserver:self forKeyPath:SPCustomQueryEditorTabStopWidth options:NSKeyValueObservingOptionNew context:NULL]; } @@ -262,6 +232,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [self setTextColor:[self otherTextColor]]; if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; + } else if ([keyPath isEqualToString:SPCustomQueryEditorTabStopWidth]) { + [self setTabStops]; } } @@ -3117,6 +3089,49 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } +- (void) setTabStops +{ + NSFont *tvFont = [self font]; + NSInteger i; + NSTextTab *aTab; + NSMutableArray *myArrayOfTabs; + NSMutableParagraphStyle *paragraphStyle; + + NSInteger tabStopWidth = [prefs integerForKey:SPCustomQueryEditorTabStopWidth]; + if(tabStopWidth < 1) tabStopWidth = 1; + + float tabWidth = NSSizeToCGSize([[NSString stringWithString:@" "] sizeWithAttributes:[NSDictionary dictionaryWithObject:tvFont forKey:NSFontAttributeName]]).width; + tabWidth = (float)tabStopWidth * tabWidth; + + NSInteger numberOfTabs = 256/tabStopWidth; + myArrayOfTabs = [NSMutableArray arrayWithCapacity:numberOfTabs]; + aTab = [[NSTextTab alloc] initWithType:NSLeftTabStopType location:tabWidth]; + [myArrayOfTabs addObject:aTab]; + [aTab release]; + for(i=1; i