aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/BundleEditor.xib35
-rw-r--r--Source/SPAppController.m4
-rw-r--r--Source/SPBundleEditorController.h11
-rw-r--r--Source/SPBundleEditorController.m106
-rw-r--r--Source/SPEditSheetTextView.m14
5 files changed, 140 insertions, 30 deletions
diff --git a/Interfaces/English.lproj/BundleEditor.xib b/Interfaces/English.lproj/BundleEditor.xib
index ba16ec40..67caca4a 100644
--- a/Interfaces/English.lproj/BundleEditor.xib
+++ b/Interfaces/English.lproj/BundleEditor.xib
@@ -23,7 +23,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="686"/>
+ <integer value="820"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -212,7 +212,6 @@
</object>
</object>
</object>
- <int key="NSSelectedIndex">3</int>
<bool key="NSPullDown">YES</bool>
<int key="NSPreferredEdge">1</int>
<bool key="NSUsesItemFromMenu">YES</bool>
@@ -1351,22 +1350,6 @@
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
- <string key="label">delegate</string>
- <reference key="source" ref="965862131"/>
- <reference key="destination" ref="1001"/>
- </object>
- <int key="connectionID">846</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">commandTextView</string>
- <reference key="source" ref="1001"/>
- <reference key="destination" ref="965862131"/>
- </object>
- <int key="connectionID">847</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
<string key="label">outputPopupButton</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="570587248"/>
@@ -1761,6 +1744,14 @@
</object>
<int key="connectionID">921</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">commandTextView</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="965862131"/>
+ </object>
+ <int key="connectionID">925</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -2493,6 +2484,7 @@
<string>820.IBPluginDependency</string>
<string>821.IBPluginDependency</string>
<string>822.IBPluginDependency</string>
+ <string>823.CustomClassName</string>
<string>823.IBPluginDependency</string>
<string>825.IBPluginDependency</string>
<string>859.IBAttributePlaceholdersKey</string>
@@ -2728,6 +2720,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>SPEditSheetTextView</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
@@ -2766,7 +2759,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">923</int>
+ <int key="maxID">925</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -3025,7 +3018,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSTextField</string>
<string>NSArrayController</string>
- <string>NSTextView</string>
+ <string>id</string>
<string>NSTableView</string>
<string>NSButton</string>
<string>NSButton</string>
@@ -3078,7 +3071,7 @@
</object>
<object class="IBToOneOutletInfo">
<string key="name">commandTextView</string>
- <string key="candidateClassName">NSTextView</string>
+ <string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">commandsTableView</string>
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index 2003a9e6..d5a3cef2 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -459,7 +459,7 @@
NSString *newPath = [NSString stringWithFormat:@"%@/%@", themePath, [filename lastPathComponent]];
if(![fm fileExistsAtPath:newPath isDirectory:nil]) {
- if(![fm copyItemAtPath:filename toPath:newPath error:nil]) {
+ if(![fm moveItemAtPath:filename toPath:newPath error:nil]) {
NSBeep();
return;
}
@@ -492,7 +492,7 @@
NSString *newPath = [NSString stringWithFormat:@"%@/%@", bundlePath, [filename lastPathComponent]];
if(![fm fileExistsAtPath:newPath isDirectory:nil]) {
- if(![fm copyItemAtPath:filename toPath:newPath error:nil]) {
+ if(![fm moveItemAtPath:filename toPath:newPath error:nil]) {
NSBeep();
return;
}
diff --git a/Source/SPBundleEditorController.h b/Source/SPBundleEditorController.h
index 90ed03f1..5ab3a534 100644
--- a/Source/SPBundleEditorController.h
+++ b/Source/SPBundleEditorController.h
@@ -24,12 +24,13 @@
#import <Cocoa/Cocoa.h>
#import <ShortcutRecorder/ShortcutRecorder.h>
+#import "SPEditSheetTextView.h"
@class SRRecorderControl;
@interface SPBundleEditorController : NSWindowController {
- IBOutlet NSTextView* commandTextView;
+ IBOutlet id commandTextView;
IBOutlet NSTableView* commandsTableView;
IBOutlet NSTextField* nameTextField;
IBOutlet NSTextField* tootlipTextField;
@@ -74,6 +75,11 @@
NSArray *inputFallbackEditorScopeArray;
NSArray *inputFallbackInputFieldScopeArray;
+ BOOL doGroupDueToChars;
+ BOOL allowUndo;
+ BOOL wasCutPaste;
+ BOOL selectionChanged;
+ NSUndoManager *esUndoManager;
}
@@ -91,4 +97,7 @@
- (BOOL)saveBundle:(NSDictionary*)bundle atPath:(NSString*)aPath;
+- (void)setWasCutPaste;
+- (void)setDoGroupDueToChars;
+
@end
diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m
index 574836e2..71b2f7ab 100644
--- a/Source/SPBundleEditorController.m
+++ b/Source/SPBundleEditorController.m
@@ -85,6 +85,8 @@
- (void)awakeFromNib
{
+ [commandTextView setDelegate:self];
+
// Init all needed menus
inputEditorScopePopUpMenu = [[NSMenu alloc] initWithTitle:@""];
inputInputFieldScopePopUpMenu = [[NSMenu alloc] initWithTitle:@""];
@@ -205,6 +207,11 @@
[keyEquivalentField setCanCaptureGlobalHotKeys:YES];
+ if([[NSUserDefaults standardUserDefaults] dataForKey:@"BundleEditorFont"]) {
+ NSFont *nf = [NSUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] dataForKey:@"BundleEditorFont"]];
+ [commandTextView setFont:nf];
+ }
+
}
#pragma mark -
@@ -453,7 +460,12 @@
{
// Suppress parsing if window is already opened
- if([[self window] isVisible]) return;
+ if([[self window] isVisible]) {
+ [super showWindow:sender];
+ return;
+ }
+
+
// Order out window
[super showWindow:sender];
@@ -513,6 +525,7 @@
}
[commandBundleArrayController setContent:commandBundleArray];
+ [commandBundleArrayController rearrangeObjects];
[commandsTableView reloadData];
}
@@ -592,18 +605,24 @@
// Build scope key
NSMutableString *scopes = [NSMutableString string];
- if([bundle objectForKey:SPBundleScopeQueryEditor]) {
+ if([bundle objectForKey:SPBundleScopeQueryEditor] && [[bundle objectForKey:SPBundleScopeQueryEditor] intValue]) {
if([scopes length]) [scopes appendString:@" "];
[scopes appendString:SPBundleScopeQueryEditor];
}
- if([bundle objectForKey:SPBundleScopeInputField]) {
+ if([bundle objectForKey:SPBundleScopeInputField] && [[bundle objectForKey:SPBundleScopeInputField] intValue]) {
if([scopes length]) [scopes appendString:@" "];
[scopes appendString:SPBundleScopeInputField];
}
- if([bundle objectForKey:SPBundleScopeDataTable]) {
+ if([bundle objectForKey:SPBundleScopeDataTable] && [[bundle objectForKey:SPBundleScopeInputField] intValue]) {
if([scopes length]) [scopes appendString:@" "];
[scopes appendString:SPBundleScopeDataTable];
}
+ if(![scopes length]) {
+ // For safety reasons
+ [scopes setString:[NSString stringWithFormat:@"%@ %@ %@", SPBundleScopeQueryEditor, SPBundleScopeInputField, SPBundleScopeDataTable]];
+ [saveDict setObject:SPBundleInputSourceNone forKey:SPBundleFileInputSourceKey];
+ [saveDict setObject:SPBundleOutputActionNone forKey:SPBundleFileOutputActionKey];
+ }
[saveDict setObject:scopes forKey:SPBundleFileScopeKey];
// Remove unnecessary keys
@@ -961,6 +980,84 @@
}
+#pragma mark -
+#pragma mark NSTextView delegates
+
+/**
+ * Traps any editing in editTextView to allow undo grouping only if the text buffer was really changed.
+ * Inform the run loop delayed for larger undo groups.
+ */
+- (void)textDidChange:(NSNotification *)aNotification
+{
+
+ if([aNotification object] != commandTextView) return;
+
+ [NSObject cancelPreviousPerformRequestsWithTarget:self
+ selector:@selector(setAllowedUndo)
+ object:nil];
+
+ // If conditions match create an undo group
+ NSInteger cycleCounter;
+ if( ( wasCutPaste || allowUndo || doGroupDueToChars ) && ![esUndoManager isUndoing] && ![esUndoManager isRedoing] ) {
+ allowUndo = NO;
+ wasCutPaste = NO;
+ doGroupDueToChars = NO;
+ selectionChanged = NO;
+
+ cycleCounter = 0;
+ while([esUndoManager groupingLevel] > 0) {
+ [esUndoManager endUndoGrouping];
+ cycleCounter++;
+ }
+ while([esUndoManager groupingLevel] < cycleCounter)
+ [esUndoManager beginUndoGrouping];
+
+ cycleCounter = 0;
+ }
+
+ [self performSelector:@selector(setAllowedUndo) withObject:nil afterDelay:0.09];
+
+}
+
+
+#pragma mark -
+#pragma mark UndoManager methods
+
+/**
+ * Establish and return an UndoManager for editTextView
+ */
+- (NSUndoManager*)undoManagerForTextView:(NSTextView*)aTextView
+{
+ if (!esUndoManager)
+ esUndoManager = [[NSUndoManager alloc] init];
+
+ return esUndoManager;
+}
+
+/**
+ * Set variable if something in editTextView was cutted or pasted for creating better undo grouping.
+ */
+- (void)setWasCutPaste
+{
+ wasCutPaste = YES;
+}
+
+/**
+ * Will be invoke delayed for creating better undo grouping according to type speed (see [self textDidChange:]).
+ */
+- (void)setAllowedUndo
+{
+ allowUndo = YES;
+}
+
+/**
+ * Will be set if according to characters typed in editTextView for creating better undo grouping.
+ */
+- (void)setDoGroupDueToChars
+{
+ doGroupDueToChars = YES;
+}
+
@end
#pragma mark -
@@ -1055,5 +1152,6 @@
}
+
@end
diff --git a/Source/SPEditSheetTextView.m b/Source/SPEditSheetTextView.m
index 7ac5185f..bd0c5a88 100644
--- a/Source/SPEditSheetTextView.m
+++ b/Source/SPEditSheetTextView.m
@@ -53,14 +53,16 @@
- (IBAction)paste:(id)sender
{
// Try to create an undo group
- [[self delegate] setWasCutPaste];
+ if([[self delegate] respondsToSelector:@selector(setWasCutPaste)])
+ [[self delegate] setWasCutPaste];
[super paste:sender];
}
- (IBAction)cut:(id)sender
{
// Try to create an undo group
- [[self delegate] setWasCutPaste];
+ if([[self delegate] respondsToSelector:@selector(setWasCutPaste)])
+ [[self delegate] setWasCutPaste];
[super cut:sender];
}
@@ -126,6 +128,12 @@
[[self delegate] setDoGroupDueToChars];
}
+
+ if([[[[self delegate] class] description] isEqualToString:@"SPBundleEditorController"]) {
+ [super keyDown: theEvent];
+ return;
+ }
+
// Check for assign key equivalents inside user-defined bundle commands
NSDictionary *keyEquivalents = [[NSApp delegate] bundleKeyEquivalentsForScope:SPBundleScopeInputField];
if([keyEquivalents count]) {
@@ -332,6 +340,8 @@
{
if([[[[self delegate] class] description] isEqualToString:@"SPFieldEditorController"])
[[NSUserDefaults standardUserDefaults] setObject:[NSArchiver archivedDataWithRootObject:[self font]] forKey:@"FieldEditorSheetFont"];
+ else if([[[[self delegate] class] description] isEqualToString:@"SPBundleEditorController"])
+ [[NSUserDefaults standardUserDefaults] setObject:[NSArchiver archivedDataWithRootObject:[self font]] forKey:@"BundleEditorFont"];
}
// Action receiver for a font change in the font panel