Commits

David Keegan committed 099724c

adding open in terminal

Comments (0)

Files changed (9)

English.lproj/Repo.xib

 							<string>B3D7AD46-B9E4-47B2-BA06-00D19C26908D</string>
 							<string>BB5C4395-94C4-4CD3-8D92-FE301B9CB201</string>
 							<string>BF7A5816-64B8-443B-9F80-F6DE6F6C87E6</string>
+							<string>C38A20A2-4F31-4A99-A8E1-CFCF7586E73D</string>
 							<string>C9CBFCAD-9F31-4BA8-9148-F992516001A5</string>
 							<string>E2026D47-C238-4257-BA61-F589D364EDE4</string>
 							<string>ECFD747A-2BC0-4956-9F53-52479BCB8D79</string>
 								<bool key="NSToolbarIsUserRemovable">YES</bool>
 								<int key="NSToolbarItemVisibilityPriority">0</int>
 							</object>
+							<object class="NSToolbarItem" id="186433179">
+								<object class="NSMutableString" key="NSToolbarItemIdentifier">
+									<characters key="NS.bytes">C38A20A2-4F31-4A99-A8E1-CFCF7586E73D</characters>
+								</object>
+								<string key="NSToolbarItemLabel">Terminal</string>
+								<string key="NSToolbarItemPaletteLabel">Open In Terminal</string>
+								<string type="base64-UTF8" key="NSToolbarItemToolTip">T3BlbnMgYSBGaW5kZXIgd2luZG93IG9uIHRoZSByZXBvc2l0b3J5J3Mgcm9vdCBkaXJlY3RvcnkuA</string>
+								<nil key="NSToolbarItemView"/>
+								<object class="NSCustomResource" key="NSToolbarItemImage">
+									<string key="NSClassName">NSImage</string>
+									<string key="NSResourceName">toolbar_terminal</string>
+								</object>
+								<nil key="NSToolbarItemTarget"/>
+								<nil key="NSToolbarItemAction"/>
+								<string key="NSToolbarItemMinSize">{0, 0}</string>
+								<string key="NSToolbarItemMaxSize">{0, 0}</string>
+								<bool key="NSToolbarItemEnabled">YES</bool>
+								<bool key="NSToolbarItemAutovalidates">YES</bool>
+								<int key="NSToolbarItemTag">-1</int>
+								<bool key="NSToolbarIsUserRemovable">YES</bool>
+								<int key="NSToolbarItemVisibilityPriority">0</int>
+							</object>
 							<object class="NSToolbarItem" id="215728893">
 								<object class="NSMutableString" key="NSToolbarItemIdentifier">
 									<characters key="NS.bytes">C9CBFCAD-9F31-4BA8-9148-F992516001A5</characters>
 							</object>
 						</object>
 					</object>
-					<object class="NSArray" key="NSToolbarIBAllowedItems">
+					<object class="NSMutableArray" key="NSToolbarIBAllowedItems">
 						<bool key="EncodedWithXMLCoder">YES</bool>
 						<reference ref="523879486"/>
 						<reference ref="880123533"/>
 						<reference ref="438772105"/>
 						<reference ref="971586408"/>
 						<reference ref="402557902"/>
+						<reference ref="186433179"/>
 						<reference ref="1024028341"/>
 						<reference ref="364466592"/>
 						<reference ref="1030581395"/>
 					</object>
 					<int key="connectionID">300316</int>
 				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">openInTerminal:</string>
+						<reference key="source" ref="798535885"/>
+						<reference key="destination" ref="186433179"/>
+					</object>
+					<int key="connectionID">300321</int>
+				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
 							<reference ref="364466592"/>
 							<reference ref="1030581395"/>
 							<reference ref="674981191"/>
+							<reference ref="186433179"/>
 						</object>
 						<reference key="parent" ref="927202284"/>
 					</object>
 						<reference key="object" ref="674981191"/>
 						<reference key="parent" ref="46956025"/>
 					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300320</int>
+						<reference key="object" ref="186433179"/>
+						<reference key="parent" ref="46956025"/>
+					</object>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="flattenedProperties">
 					<string>300317.IBPluginDependency</string>
 					<string>300318.IBPluginDependency</string>
 					<string>300319.IBPluginDependency</string>
+					<string>300320.IBPluginDependency</string>
 					<string>6.IBPluginDependency</string>
 					<string>6.ImportedFromIB2</string>
 					<string>8.IBPluginDependency</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<string>{{257, 305}, {586, 488}}</string>
-					<string>{{257, 305}, {586, 488}}</string>
+					<string>{{138, 205}, {586, 488}}</string>
+					<string>{{138, 205}, {586, 488}}</string>
 					<reference ref="9"/>
 					<string>{{166, 135}, {586, 488}}</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>
-					<string>{{242, 793}, {616, 0}}</string>
+					<string>{{123, 693}, {616, 0}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>{{151, 623}, {616, 0}}</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>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 				</object>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">300319</int>
+			<int key="maxID">300321</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
 							<string>discardChanges:</string>
 							<string>endCommitSheet:</string>
 							<string>infoChooserChanged:</string>
+							<string>openInTerminal:</string>
 							<string>openSelectedFile:</string>
 							<string>pushPullRevisions:</string>
 							<string>refreshStatus:</string>
 							<string>id</string>
 							<string>id</string>
 							<string>id</string>
+							<string>id</string>
 						</object>
 					</object>
 					<object class="NSMutableDictionary" key="outlets">

Murky.xcodeproj/project.pbxproj

 		73864C171012B9DA00EF650A /* status_ignored.png in Resources */ = {isa = PBXBuildFile; fileRef = 73864C141012B9DA00EF650A /* status_ignored.png */; };
 		73864C181012B9DA00EF650A /* status_needs_update.png in Resources */ = {isa = PBXBuildFile; fileRef = 73864C151012B9DA00EF650A /* status_needs_update.png */; };
 		73864C3D1012BB0D00EF650A /* status_deleted.png in Resources */ = {isa = PBXBuildFile; fileRef = 73864C3C1012BB0D00EF650A /* status_deleted.png */; };
+		73CA81FA10135B360081F0D8 /* toolbar_terminal.png in Resources */ = {isa = PBXBuildFile; fileRef = 73CA81F910135B360081F0D8 /* toolbar_terminal.png */; };
+		73CA82D710135FC10081F0D8 /* ScriptingBridge.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 73CA82D610135FC10081F0D8 /* ScriptingBridge.framework */; };
 		8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
 		D095A4110FBC0FD800512681 /* toolbar_discard.png in Resources */ = {isa = PBXBuildFile; fileRef = D095A40F0FBC0FD800512681 /* toolbar_discard.png */; };
 		D095A4120FBC0FD800512681 /* toolbar_refresh.png in Resources */ = {isa = PBXBuildFile; fileRef = D095A4100FBC0FD800512681 /* toolbar_refresh.png */; };
 		73864C141012B9DA00EF650A /* status_ignored.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = status_ignored.png; sourceTree = "<group>"; };
 		73864C151012B9DA00EF650A /* status_needs_update.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = status_needs_update.png; sourceTree = "<group>"; };
 		73864C3C1012BB0D00EF650A /* status_deleted.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = status_deleted.png; sourceTree = "<group>"; };
+		73CA81F910135B360081F0D8 /* toolbar_terminal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = toolbar_terminal.png; sourceTree = "<group>"; };
+		73CA824710135EC90081F0D8 /* Terminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Terminal.h; sourceTree = "<group>"; };
+		73CA82D610135FC10081F0D8 /* ScriptingBridge.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScriptingBridge.framework; path = /System/Library/Frameworks/ScriptingBridge.framework; sourceTree = "<absolute>"; };
 		8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		8D1107320486CEB800E47090 /* Murky.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Murky.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		D095A40F0FBC0FD800512681 /* toolbar_discard.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = toolbar_discard.png; path = Resources/Icons/toolbar_discard.png; sourceTree = SOURCE_ROOT; };
 			files = (
 				8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
 				277D16B90C989715001D8600 /* libicucore.dylib in Frameworks */,
+				73CA82D710135FC10081F0D8 /* ScriptingBridge.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 		1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				73CA82D610135FC10081F0D8 /* ScriptingBridge.framework */,
 				277D16B80C989715001D8600 /* libicucore.dylib */,
 				29B97324FDCFA39411CA2CEA /* AppKit.framework */,
 				29B97325FDCFA39411CA2CEA /* Foundation.framework */,
 				27D124F50C8F501B0075446A /* URLFormatter.m */,
 				277C51C00C56709800E60690 /* ImageAndTextCell.h */,
 				277C51C10C56709800E60690 /* ImageAndTextCell.m */,
+				73CA824710135EC90081F0D8 /* Terminal.h */,
 			);
 			name = Support;
 			path = Source;
 				7364973910107F2100B717B2 /* toolbar_reveal.png */,
 				D095A5160FBC376E00512681 /* status_null.png */,
 				D095A5110FBC363100512681 /* status_removed.png */,
+				73CA81F910135B360081F0D8 /* toolbar_terminal.png */,
 				D095A50D0FBC329500512681 /* status_nottracked.png */,
 				D095A5080FBC318400512681 /* status_modified.png */,
 				D095A4DE0FBC2BC000512681 /* status_added.png */,
 				73864C171012B9DA00EF650A /* status_ignored.png in Resources */,
 				73864C181012B9DA00EF650A /* status_needs_update.png in Resources */,
 				73864C3D1012BB0D00EF650A /* status_deleted.png in Resources */,
+				73CA81FA10135B360081F0D8 /* toolbar_terminal.png in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				COPY_PHASE_STRIP = NO;
+				FRAMEWORK_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)\"",
+				);
 				INFOPLIST_FILE = Resources/Info.plist;
 				INSTALL_PATH = "$(HOME)/Applications";
 				PRODUCT_NAME = Murky;
 		C01FCF4C08A954540054247B /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				FRAMEWORK_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)\"",
+				);
 				INFOPLIST_FILE = Resources/Info.plist;
 				INSTALL_PATH = "$(HOME)/Applications";
 				PRODUCT_NAME = Murky;

Resources/Icons/toolbar.drawit/Data

Binary file modified.

Resources/Icons/toolbar.drawit/QuickLook/Preview.jpg

Old
Old image
New
New image

Resources/Icons/toolbar.drawit/QuickLook/Thumbnail.jpg

Old
Old image
New
New image

Resources/Icons/toolbar_terminal.png

Added
New image

Source/RepoController.h

 //
 
 #import <Cocoa/Cocoa.h>
+#import <ScriptingBridge/ScriptingBridge.h>
+
 @class HgRepository, HgFile, HgRevision, HgTempDir, HgOperation;
 
 
 @interface RepoController (Actions)
 
 - (IBAction) revealInFinder: (id) sender;
+- (IBAction) openInTerminal: (id) sender;
 - (IBAction) refreshStatus: (id)sender;
 - (IBAction) toggleShowsOnlyUncleanFiles: (id)sender;
 - (IBAction) chooseRevisionFromPopUp: (id)sender;

Source/RepoController_Actions.m

 #import "HgTempDir.h"
 #import "HgConfigFile.h"
 #import "URLFormatter.h"
-
+#import "Terminal.h"
 
 #define kPrefRevertWithoutBackup @"RevertWithoutBackup"
 
     [ws openURL:fileURL];   //use openURL instead of selectFile to support PathFinder. WD-rpw May 1, 2009
 }
 
+- (IBAction) openInTerminal: (id) sender
+{
+    NSURL* fileURL = [NSURL fileURLWithPath: self.repository.absolutePath];
+
+    // Terminal
+    // Code from John Daniel - ShellHere
+    TerminalApplication * terminal = [SBApplication applicationWithBundleIdentifier: @"com.apple.Terminal"];
+    
+    // Create a "cd" command.
+    NSString * command = [NSString stringWithFormat: @"cd %@; clear", [[fileURL path] stringByStandardizingPath]];
+    [terminal doScript: command in: nil];
+    
+    // Wait for "a while" for the script to run and get a new window.
+    // I wish there was a better way to do this.
+    [NSThread sleepForTimeInterval: 0.1];
+    
+    // Activate the Terminal. Hopefully, the new window is already open and
+    // is will be brought to the front.
+    [terminal activate];
+}
+
 - (IBAction) refreshStatus: (id)sender
 {
     NSError *error =nil;

Source/Terminal.h

+/*
+ * Terminal.h
+ */
+
+#import <AppKit/AppKit.h>
+#import <ScriptingBridge/ScriptingBridge.h>
+
+
+@class TerminalApplication, TerminalWindow, TerminalSettingsSet, TerminalTab;
+
+typedef enum {
+	TerminalSaveOptionsYes = 'yes ' /* Save the file. */,
+	TerminalSaveOptionsNo = 'no  ' /* Do not save the file. */,
+	TerminalSaveOptionsAsk = 'ask ' /* Ask the user whether or not to save the file. */
+} TerminalSaveOptions;
+
+typedef enum {
+	TerminalPrintingErrorHandlingStandard = 'lwst' /* Standard PostScript error handling */,
+	TerminalPrintingErrorHandlingDetailed = 'lwdt' /* print a detailed report of PostScript errors */
+} TerminalPrintingErrorHandling;
+
+
+
+/*
+ * Standard Suite
+ */
+
+// The application‘s top-level scripting object.
+@interface TerminalApplication : SBApplication
+
+- (SBElementArray *) windows;
+
+@property (copy, readonly) NSString *name;  // The name of the application.
+@property (readonly) BOOL frontmost;  // Is this the frontmost (active) application?
+@property (copy, readonly) NSString *version;  // The version of the application.
+
+- (void) open:(NSArray *)x;  // Open a document.
+- (void) print:(id)x withProperties:(NSDictionary *)withProperties printDialog:(BOOL)printDialog;  // Print a document.
+- (void) quitSaving:(TerminalSaveOptions)saving;  // Quit the application.
+- (TerminalTab *) doScript:(NSString *)x in:(id)in_;  // Runs a UNIX shell script or command.
+
+@end
+
+// A window.
+@interface TerminalWindow : SBObject
+
+- (SBElementArray *) tabs;
+
+@property (copy, readonly) NSString *name;  // The full title of the window.
+- (NSInteger) id;  // The unique identifier of the window.
+@property NSInteger index;  // The index of the window, ordered front to back.
+@property NSRect bounds;  // The bounding rectangle of the window.
+@property (readonly) BOOL closeable;  // Whether the window has a close box.
+@property (readonly) BOOL miniaturizable;  // Whether the window can be minimized.
+@property BOOL miniaturized;  // Whether the window is currently minimized.
+@property (readonly) BOOL resizable;  // Whether the window can be resized.
+@property BOOL visible;  // Whether the window is currently visible.
+@property (readonly) BOOL zoomable;  // Whether the window can be zoomed.
+@property BOOL zoomed;  // Whether the window is currently zoomed.
+@property BOOL frontmost;  // Whether the window is currently the frontmost Terminal window.
+@property NSPoint position;  // The position of the window, relative to the upper left corner of the screen.
+@property NSPoint origin;  // The position of the window, relative to the lower left corner of the screen.
+@property NSPoint size;  // The width and height of the window
+@property NSRect frame;  // The bounding rectangle, relative to the lower left corner of the screen.
+
+- (void) closeSaving:(TerminalSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
+- (void) saveIn:(NSURL *)in_;  // Save a document.
+- (void) printWithProperties:(NSDictionary *)withProperties printDialog:(BOOL)printDialog;  // Print a document.
+- (void) delete;  // Delete an object.
+- (void) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy object(s) and put the copies at a new location.
+- (BOOL) exists;  // Verify if an object exists.
+- (void) moveTo:(SBObject *)to;  // Move object(s) to a new location.
+
+@end
+
+
+
+/*
+ * Terminal Suite
+ */
+
+@interface TerminalApplication (TerminalSuite)
+
+- (SBElementArray *) settingsSets;
+
+@property (copy) TerminalSettingsSet *defaultSettings;  // The settings set used for new windows.
+@property (copy) TerminalSettingsSet *startupSettings;  // The settings set used for the window created on application startup.
+
+@end
+
+// A set of settings.
+@interface TerminalSettingsSet : SBObject
+
+- (NSInteger) id;  // The unique identifier of the settings set.
+@property (copy) NSString *name;  // The name of the settings set.
+@property NSInteger numberOfRows;  // The number of rows displayed in the tab.
+@property NSInteger numberOfColumns;  // The number of columns displayed in the tab.
+@property (copy) NSColor *cursorColor;  // The cursor color for the tab.
+@property (copy) NSColor *backgroundColor;  // The background color for the tab.
+@property (copy) NSColor *normalTextColor;  // The normal text color for the tab.
+@property (copy) NSColor *boldTextColor;  // The bold text color for the tab.
+@property (copy) NSString *fontName;  // The name of the font used to display the tab’s contents.
+@property NSInteger fontSize;  // The size of the font used to display the tab’s contents.
+@property BOOL fontAntialiasing;  // Whether the font used to display the tab’s contents is antialiased.
+@property (copy) NSArray *cleanCommands;  // The processes which will be ignored when checking whether a tab can be closed without showing a prompt.
+@property BOOL titleDisplaysDeviceName;  // Whether the title contains the device name.
+@property BOOL titleDisplaysShellPath;  // Whether the title contains the shell path.
+@property BOOL titleDisplaysWindowSize;  // Whether the title contains the tab’s size, in rows and columns.
+@property BOOL titleDisplaysSettingsName;  // Whether the title contains the settings name.
+@property BOOL titleDisplaysCustomTitle;  // Whether the title contains a custom title.
+@property (copy) NSString *customTitle;  // The tab’s custom title.
+
+- (void) closeSaving:(TerminalSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
+- (void) saveIn:(NSURL *)in_;  // Save a document.
+- (void) printWithProperties:(NSDictionary *)withProperties printDialog:(BOOL)printDialog;  // Print a document.
+- (void) delete;  // Delete an object.
+- (void) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy object(s) and put the copies at a new location.
+- (BOOL) exists;  // Verify if an object exists.
+- (void) moveTo:(SBObject *)to;  // Move object(s) to a new location.
+
+@end
+
+// A tab.
+@interface TerminalTab : SBObject
+
+@property NSInteger numberOfRows;  // The number of rows displayed in the tab.
+@property NSInteger numberOfColumns;  // The number of columns displayed in the tab.
+@property (copy, readonly) NSString *contents;  // The currently visible contents of the tab.
+@property (copy, readonly) NSString *history;  // The contents of the entire scrolling buffer of the tab.
+@property (readonly) BOOL busy;  // Whether the tab is busy running a process.
+@property (copy, readonly) NSArray *processes;  // The processes currently running in the tab.
+@property BOOL selected;  // Whether the tab is selected.
+@property BOOL titleDisplaysCustomTitle;  // Whether the title contains a custom title.
+@property (copy) NSString *customTitle;  // The tab’s custom title.
+@property (copy, readonly) NSString *tty;  // The tab’s TTY device.
+@property (copy) TerminalSettingsSet *currentSettings;  // The set of settings which control the tab’s behavior and appearance.
+@property (copy) NSColor *cursorColor;  // The cursor color for the tab.
+@property (copy) NSColor *backgroundColor;  // The background color for the tab.
+@property (copy) NSColor *normalTextColor;  // The normal text color for the tab.
+@property (copy) NSColor *boldTextColor;  // The bold text color for the tab.
+@property (copy) NSArray *cleanCommands;  // The processes which will be ignored when checking whether a tab can be closed without showing a prompt.
+@property BOOL titleDisplaysDeviceName;  // Whether the title contains the device name.
+@property BOOL titleDisplaysShellPath;  // Whether the title contains the shell path.
+@property BOOL titleDisplaysWindowSize;  // Whether the title contains the tab’s size, in rows and columns.
+@property BOOL titleDisplaysFileName;  // Whether the title contains the file name.
+@property (copy) NSString *fontName;  // The name of the font used to display the tab’s contents.
+@property NSInteger fontSize;  // The size of the font used to display the tab’s contents.
+@property BOOL fontAntialiasing;  // Whether the font used to display the tab’s contents is antialiased.
+
+- (void) closeSaving:(TerminalSaveOptions)saving savingIn:(NSURL *)savingIn;  // Close a document.
+- (void) saveIn:(NSURL *)in_;  // Save a document.
+- (void) printWithProperties:(NSDictionary *)withProperties printDialog:(BOOL)printDialog;  // Print a document.
+- (void) delete;  // Delete an object.
+- (void) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties;  // Copy object(s) and put the copies at a new location.
+- (BOOL) exists;  // Verify if an object exists.
+- (void) moveTo:(SBObject *)to;  // Move object(s) to a new location.
+
+@end
+