From abbb2081c4601595fb497ddb459b0e4503ab9931 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Thu, 10 Mar 2011 13:56:09 -0800 Subject: [PATCH 01/36] xcode 4 --- GitX.xcodeproj/project.pbxproj | 26 +++++++++++++++++--------- build_libgit2.sh | 2 +- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 4ccb7e9..5962e85 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -1344,6 +1344,7 @@ isa = PBXProject; buildConfigurationList = 26FC0A880875C7B200E6366F /* Build configuration list for PBXProject "GitX" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, @@ -1789,6 +1790,7 @@ INSTALL_PATH = "$(HOME)/Applications"; LIBRARY_SEARCH_PATHS = libgit2; PRODUCT_NAME = GitX; + SDKROOT = ""; WRAPPER_EXTENSION = app; ZERO_LINK = YES; }; @@ -1815,6 +1817,7 @@ INSTALL_PATH = "$(HOME)/Applications"; LIBRARY_SEARCH_PATHS = libgit2; PRODUCT_NAME = GitX; + SDKROOT = ""; WRAPPER_EXTENSION = app; }; name = Release; @@ -1822,7 +1825,7 @@ 26FC0A890875C7B200E6366F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_ENABLE_OBJC_GC = required; GCC_PREPROCESSOR_DEFINITIONS = DEBUG; GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = DEBUG_BUILD; @@ -1830,29 +1833,27 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_PREPROCESS = YES; + MACOSX_DEPLOYMENT_TARGET = 10.5; PREBINDING = NO; RUN_CLANG_STATIC_ANALYZER = YES; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; + SDKROOT = macosx10.5; }; name = Debug; }; 26FC0A8A0875C7B200E6366F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - ppc, - i386, - x86_64, - ); + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_ENABLE_OBJC_GC = required; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_PREFIX_HEADER = $PROJECT_TEMP_DIR/revision; INFOPLIST_PREPROCESS = YES; + MACOSX_DEPLOYMENT_TARGET = 10.5; PREBINDING = NO; RUN_CLANG_STATIC_ANALYZER = YES; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; + SDKROOT = macosx10.5; }; name = Release; }; @@ -1876,6 +1877,7 @@ ); PREBINDING = NO; PRODUCT_NAME = gitx_askpasswd; + SDKROOT = ""; }; name = Debug; }; @@ -1884,7 +1886,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEBUG_INFORMATION_FORMAT = dwarf; GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -1898,6 +1900,7 @@ ); PREBINDING = NO; PRODUCT_NAME = gitx_askpasswd; + SDKROOT = ""; ZERO_LINK = NO; }; name = Release; @@ -1919,6 +1922,7 @@ ); PREBINDING = NO; PRODUCT_NAME = gitx_askpasswd; + SDKROOT = ""; }; name = Install; }; @@ -1942,6 +1946,7 @@ ); PREBINDING = NO; PRODUCT_NAME = gitx; + SDKROOT = ""; ZERO_LINK = YES; }; name = Debug; @@ -1965,6 +1970,7 @@ ); PREBINDING = NO; PRODUCT_NAME = gitx; + SDKROOT = ""; ZERO_LINK = NO; }; name = Release; @@ -1976,6 +1982,7 @@ GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; PRODUCT_NAME = libgit2; + SDKROOT = ""; }; name = Debug; }; @@ -1986,6 +1993,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = libgit2; + SDKROOT = ""; ZERO_LINK = NO; }; name = Release; diff --git a/build_libgit2.sh b/build_libgit2.sh index a94257d..424cabf 100755 --- a/build_libgit2.sh +++ b/build_libgit2.sh @@ -17,7 +17,7 @@ buildAction () { git submodule update cd libgit2 rm -f libgit2.a - make CFLAGS="-arch i386 -arch ppc -arch x86_64" + make CFLAGS="-arch i386 -arch x86_64" ranlib libgit2.a else echo "error: Not a git repository." From f9ccf1fe8d7c782867f921b40ff032240095a61a Mon Sep 17 00:00:00 2001 From: German Laullon Date: Thu, 10 Mar 2011 16:04:45 -0800 Subject: [PATCH 02/36] Solved compilation warnings --- ApplicationController.m | 2 +- Commands/PBCommandFactory.h | 2 +- Commands/PBCommandWithParameter.m | 2 +- Commands/PBOpenDocumentCommand.m | 2 +- Commands/PBRemoteCommandFactory.m | 2 +- Commands/PBRevealWithFinderCommand.m | 2 +- Commands/PBStashCommandFactory.m | 2 +- Controller/PBArgumentPickerController.m | 2 +- Controller/PBGitResetController.m | 2 +- Controller/PBSubmoduleController.m | 2 +- DBPrefsWindowController.h | 2 +- GLFileView.m | 1 - GitX.xcodeproj/project.pbxproj | 8 ++++++-- Model/PBGitStash.m | 2 +- Model/PBGitSubmodule.m | 4 ++-- PBChangedFile.m | 4 ++-- PBCommandMenuItem.m | 2 +- PBGitHistoryController.h | 2 +- PBGitMenuItem.m | 2 +- PBGitRepository.m | 2 +- PBGitRevList.mm | 2 +- PBGitSidebarController.h | 2 +- PBGitSidebarController.m | 2 +- PBGitTree.m | 16 +++------------- PBGitWindowController.h | 2 +- PBGitWindowController.m | 1 - PBGitXProtocol.m | 2 +- PBSourceViewCell.m | 2 +- PBStashController.m | 2 +- PBViewController.m | 2 +- gitx_askpasswd_main.m | 8 ++++---- 31 files changed, 41 insertions(+), 49 deletions(-) diff --git a/ApplicationController.m b/ApplicationController.m index 8efcded..c4681ea 100644 --- a/ApplicationController.m +++ b/ApplicationController.m @@ -245,7 +245,7 @@ fileManager = [NSFileManager defaultManager]; applicationSupportFolder = [self applicationSupportFolder]; if ( ![fileManager fileExistsAtPath:applicationSupportFolder isDirectory:NULL] ) { - [fileManager createDirectoryAtPath:applicationSupportFolder attributes:nil]; + [fileManager createDirectoryAtPath:applicationSupportFolder withIntermediateDirectories:YES attributes:nil error:nil]; } url = [NSURL fileURLWithPath: [applicationSupportFolder stringByAppendingPathComponent: @"GitTest.xml"]]; diff --git a/Commands/PBCommandFactory.h b/Commands/PBCommandFactory.h index a613c7b..477a52b 100644 --- a/Commands/PBCommandFactory.h +++ b/Commands/PBCommandFactory.h @@ -9,5 +9,5 @@ #import "PBGitRepository.h" @protocol PBCommandFactory -+ (NSArray *) commandsForObject:(NSObject *) object repository:(PBGitRepository *) repository; ++ (NSArray *) commandsForObject:(id) object repository:(PBGitRepository *) repository; @end diff --git a/Commands/PBCommandWithParameter.m b/Commands/PBCommandWithParameter.m index 9f50b51..15b8afe 100644 --- a/Commands/PBCommandWithParameter.m +++ b/Commands/PBCommandWithParameter.m @@ -16,7 +16,7 @@ @synthesize parameterDisplayName; - initWithCommand:(PBCommand *) aCommand parameterName:(NSString *) param parameterDisplayName:(NSString *) paramDisplayName { - if (self = [super initWithDisplayName:[aCommand displayName] parameters:nil repository:[aCommand repository]]) { + if ((self = [super initWithDisplayName:[aCommand displayName] parameters:nil repository:[aCommand repository]])) { command = [aCommand retain]; parameterName = [param retain]; parameterDisplayName = [paramDisplayName retain]; diff --git a/Commands/PBOpenDocumentCommand.m b/Commands/PBOpenDocumentCommand.m index 16f6906..ff703ef 100644 --- a/Commands/PBOpenDocumentCommand.m +++ b/Commands/PBOpenDocumentCommand.m @@ -13,7 +13,7 @@ @implementation PBOpenDocumentCommand - (id) initWithDocumentAbsolutePath:(NSString *) path { - if (self = [super initWithDisplayName:@"Open" parameters:nil repository:nil]) { + if ((self = [super initWithDisplayName:@"Open" parameters:nil repository:nil])) { documentURL = [[NSURL alloc] initWithString:path]; } return self; diff --git a/Commands/PBRemoteCommandFactory.m b/Commands/PBRemoteCommandFactory.m index 2b02524..56f3146 100644 --- a/Commands/PBRemoteCommandFactory.m +++ b/Commands/PBRemoteCommandFactory.m @@ -58,7 +58,7 @@ return commands; } -+ (NSArray *) commandsForObject:(NSObject *) object repository:(PBGitRepository *) repository { ++ (NSArray *) commandsForObject:(id) object repository:(PBGitRepository *) repository { if ([object isKindOfClass:[PBGitSubmodule class]]) { return [PBRemoteCommandFactory commandsForSubmodule:(id)object inRepository:repository]; } diff --git a/Commands/PBRevealWithFinderCommand.m b/Commands/PBRevealWithFinderCommand.m index 2f94a58..055825f 100644 --- a/Commands/PBRevealWithFinderCommand.m +++ b/Commands/PBRevealWithFinderCommand.m @@ -17,7 +17,7 @@ return nil; } - if (self = [super initWithDisplayName:@"Reveal in Finder" parameters:nil repository:nil]) { + if ((self = [super initWithDisplayName:@"Reveal in Finder" parameters:nil repository:nil])) { documentURL = [[NSURL alloc] initWithString:path]; } return self; diff --git a/Commands/PBStashCommandFactory.m b/Commands/PBStashCommandFactory.m index 195cd7b..9601b40 100644 --- a/Commands/PBStashCommandFactory.m +++ b/Commands/PBStashCommandFactory.m @@ -22,7 +22,7 @@ @implementation PBStashCommandFactory -+ (NSArray *) commandsForObject:(NSObject *) object repository:(PBGitRepository *) repository { ++ (NSArray *) commandsForObject:(id) object repository:(PBGitRepository *) repository { NSArray *cmds = nil; if ([object isKindOfClass:[PBGitStash class]]) { cmds = [PBStashCommandFactory commandsForStash:(id)object repository:repository]; diff --git a/Controller/PBArgumentPickerController.m b/Controller/PBArgumentPickerController.m index 51d542e..420b547 100644 --- a/Controller/PBArgumentPickerController.m +++ b/Controller/PBArgumentPickerController.m @@ -13,7 +13,7 @@ @implementation PBArgumentPickerController - initWithCommandWithParameter:(PBCommandWithParameter *) aCommand { - if (self = [super initWithWindowNibName:@"PBArgumentPicker" owner:self]) { + if ((self = [super initWithWindowNibName:@"PBArgumentPicker" owner:self])) { cmdWithParameter = [aCommand retain]; } return self; diff --git a/Controller/PBGitResetController.m b/Controller/PBGitResetController.m index 773a74d..c9e5fb6 100644 --- a/Controller/PBGitResetController.m +++ b/Controller/PBGitResetController.m @@ -15,7 +15,7 @@ static NSString * const kCommandKey = @"command"; @implementation PBGitResetController - (id) initWithRepository:(PBGitRepository *) repo { - if (self = [super init]){ + if ((self = [super init])){ repository = [repo retain]; } return self; diff --git a/Controller/PBSubmoduleController.m b/Controller/PBSubmoduleController.m index 7da580b..c789778 100644 --- a/Controller/PBSubmoduleController.m +++ b/Controller/PBSubmoduleController.m @@ -19,7 +19,7 @@ @synthesize submodules; - (id) initWithRepository:(PBGitRepository *) repo { - if (self = [super init]){ + if ((self = [super init])){ repository = [repo retain]; } return self; diff --git a/DBPrefsWindowController.h b/DBPrefsWindowController.h index 5cb711e..417b295 100644 --- a/DBPrefsWindowController.h +++ b/DBPrefsWindowController.h @@ -42,7 +42,7 @@ #import -@interface DBPrefsWindowController : NSWindowController { +@interface DBPrefsWindowController : NSWindowController { NSMutableArray *toolbarIdentifiers; NSMutableDictionary *toolbarViews; NSMutableDictionary *toolbarItems; diff --git a/GLFileView.m b/GLFileView.m index a35b3bf..2c47262 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -485,7 +485,6 @@ int n; for(n=1;n 0); - if (self = [super init]) { + if ((self = [super init])) { unichar status = [submoduleStatusString characterAtIndex:0]; submoduleState = [PBGitSubmodule submoduleStateFromCharacter:status]; NSScanner *scanner = [NSScanner scannerWithString:[submoduleStatusString substringFromIndex:1]]; @@ -47,7 +47,7 @@ shouldContinue = [scanner scanString:@"(" intoString:NULL]; } if (shouldContinue) { - shouldContinue = [scanner scanUpToString:@")" intoString:&coName]; + [scanner scanUpToString:@")" intoString:&coName]; } self.path = [fullPath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; coName = [coName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; diff --git a/PBChangedFile.m b/PBChangedFile.m index 5a7492e..6905d71 100644 --- a/PBChangedFile.m +++ b/PBChangedFile.m @@ -26,9 +26,9 @@ { NSAssert(status == NEW || self.commitBlobSHA, @"File is not new, but doesn't have an index entry!"); if (!self.commitBlobSHA) - return [NSString stringWithFormat:@"0 0000000000000000000000000000000000000000\t%@\0", self.path]; + return [NSString stringWithFormat:@"0 0000000000000000000000000000000000000000\t%@", self.path]; else - return [NSString stringWithFormat:@"%@ %@\t%@\0", self.commitBlobMode, self.commitBlobSHA, self.path]; + return [NSString stringWithFormat:@"%@ %@\t%@", self.commitBlobMode, self.commitBlobSHA, self.path]; } + (NSImage *) iconForStatus:(PBChangedFileStatus) aStatus { diff --git a/PBCommandMenuItem.m b/PBCommandMenuItem.m index 50becd2..8eff7cd 100644 --- a/PBCommandMenuItem.m +++ b/PBCommandMenuItem.m @@ -18,7 +18,7 @@ @synthesize command; - initWithCommand:(PBCommand *) aCommand { - if (self = [super init]) { + if ((self = [super init])) { self.command = aCommand; super.title = [aCommand displayName]; [self setTarget:aCommand]; diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index d592943..4db3210 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -23,7 +23,7 @@ @class PBHistorySearchController; -@interface PBGitHistoryController : PBViewController { +@interface PBGitHistoryController : PBViewController { IBOutlet PBRefController *refController; IBOutlet NSSearchField *searchField; IBOutlet NSArrayController* commitController; diff --git a/PBGitMenuItem.m b/PBGitMenuItem.m index 38b6895..7d08c79 100644 --- a/PBGitMenuItem.m +++ b/PBGitMenuItem.m @@ -17,7 +17,7 @@ //--------------------------------------------------------------------------------------------- - initWithSourceObject:(id) anObject { - if (self = [super init]) { + if ((self = [super init])) { super.title = [anObject displayDescription]; sourceObject = [anObject retain]; } diff --git a/PBGitRepository.m b/PBGitRepository.m index 50be481..9362568 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -143,7 +143,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; NSURL* gitDirURL = [PBGitRepository gitDirForURL:[self fileURL]]; if (!gitDirURL) { if (outError) { - NSDictionary* userInfo = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"%@ does not appear to be a git repository.", [self fileName]] + NSDictionary* userInfo = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"%@ does not appear to be a git repository.", [self fileURL]] forKey:NSLocalizedRecoverySuggestionErrorKey]; *outError = [NSError errorWithDomain:PBGitRepositoryErrorDomain code:0 userInfo:userInfo]; } diff --git a/PBGitRevList.mm b/PBGitRevList.mm index 8ab64e1..18fcdf7 100644 --- a/PBGitRevList.mm +++ b/PBGitRevList.mm @@ -225,7 +225,7 @@ using namespace std; [self performSelectorOnMainThread:@selector(finishedParsing) withObject:nil waitUntilDone:NO]; } else { - NSLog(@"[%@ %s] thread has been canceled", [self class], NSStringFromSelector(_cmd)); + NSLog(@"[%@ %@] thread has been canceled", [self class], NSStringFromSelector(_cmd)); } [task terminate]; diff --git a/PBGitSidebarController.h b/PBGitSidebarController.h index 4126ff9..8bacbe2 100644 --- a/PBGitSidebarController.h +++ b/PBGitSidebarController.h @@ -13,7 +13,7 @@ @class PBGitHistoryController; @class PBGitCommitController; -@interface PBGitSidebarController : PBViewController { +@interface PBGitSidebarController : PBViewController { IBOutlet NSWindow *window; IBOutlet NSOutlineView *sourceView; IBOutlet NSView *sourceListControlsView; diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index eee30ea..a9a936e 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -244,7 +244,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; PBSourceViewItem *item = [self selectedItem]; if ([item isKindOfClass:[PBGitMenuItem class]]) { PBGitMenuItem *sidebarItem = (PBGitMenuItem *) item; - NSObject *sourceObject = [sidebarItem sourceObject]; + id sourceObject = [sidebarItem sourceObject]; if ([sourceObject isKindOfClass:[PBGitSubmodule class]]) { [[repository.submoduleController defaultCommandForSubmodule:(id)sourceObject] invoke]; } diff --git a/PBGitTree.m b/PBGitTree.m index f1ba694..dee9114 100644 --- a/PBGitTree.m +++ b/PBGitTree.m @@ -113,16 +113,6 @@ return NO; } -- (BOOL)hasBinaryHeader:(NSString*)contents -{ - if (!contents) - return NO; - - return [contents rangeOfString:@"\0" - options:0 - range:NSMakeRange(0, ([contents length] >= 8000) ? 7999 : [contents length])].location != NSNotFound; -} - - (BOOL)hasBinaryAttributes { // First ask git check-attr if the file has a binary attribute custom set @@ -231,7 +221,7 @@ } res=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff", sha, des,[self fullPath], nil]]; if ([res length]==0) { - NSLog(@"--%d",[res length]); + NSLog(@"--%@",[res length]); if (anError != NULL) { *anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"No Diff",NSLocalizedDescriptionKey,nil]]; } @@ -296,7 +286,7 @@ NSData* data = [handle readDataToEndOfFile]; [data writeToFile:newName atomically:YES]; } else { // Directory - [[NSFileManager defaultManager] createDirectoryAtPath:newName attributes:nil]; + [[NSFileManager defaultManager] createDirectoryAtPath:newName withIntermediateDirectories:YES attributes:nil error:nil]; for (PBGitTree* child in [self children]) [child saveToFolder: newName]; } @@ -383,7 +373,7 @@ - (void) finalize { if (localFileName) - [[NSFileManager defaultManager] removeFileAtPath:localFileName handler:nil]; + [[NSFileManager defaultManager] removeItemAtPath:localFileName error:nil]; [super finalize]; } @end diff --git a/PBGitWindowController.h b/PBGitWindowController.h index 70b268d..c481fa3 100644 --- a/PBGitWindowController.h +++ b/PBGitWindowController.h @@ -14,7 +14,7 @@ @class PBViewController, PBGitSidebarController, PBGitCommitController; -@interface PBGitWindowController : NSWindowController { +@interface PBGitWindowController : NSWindowController { __weak PBGitRepository* repository; PBViewController *contentController; diff --git a/PBGitWindowController.m b/PBGitWindowController.m index 498ddec..c4a445e 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -216,7 +216,6 @@ } - (IBAction) changeLayout:(id)sender{ - NSLog(@"selectedSegment=%ld (%d)",[sender selectedSegment],[sender isSelectedForSegment:[sender selectedSegment]]); NSSplitView *sp=nil; switch ([sender selectedSegment]) { case 0: diff --git a/PBGitXProtocol.m b/PBGitXProtocol.m index 052a667..ae06283 100644 --- a/PBGitXProtocol.m +++ b/PBGitXProtocol.m @@ -17,7 +17,7 @@ // note that this leaks! CFRetain(client); - if (self = [super initWithRequest:request cachedResponse:cachedResponse client:client]) + if ((self = [super initWithRequest:request cachedResponse:cachedResponse client:client])) { } diff --git a/PBSourceViewCell.m b/PBSourceViewCell.m index 06221d8..2c9fd5a 100644 --- a/PBSourceViewCell.m +++ b/PBSourceViewCell.m @@ -22,7 +22,7 @@ # pragma mark context menu delegate methods - init { - if (self = [super init]) { + if ((self = [super init])) { } return self; diff --git a/PBStashController.m b/PBStashController.m index eccde18..ec6bcf4 100644 --- a/PBStashController.m +++ b/PBStashController.m @@ -23,7 +23,7 @@ static NSString * const kCommandName = @"stash"; @synthesize stashes; - (id) initWithRepository:(PBGitRepository *) repo { - if (self = [super init]){ + if ((self = [super init])){ repository = [repo retain]; } return self; diff --git a/PBViewController.m b/PBViewController.m index 77e4f3f..a0de1da 100644 --- a/PBViewController.m +++ b/PBViewController.m @@ -19,7 +19,7 @@ { NSString *nibName = [[[self class] description] stringByReplacingOccurrencesOfString:@"Controller" withString:@"View"]; - if(self = [self initWithNibName:nibName bundle:nil]) { + if((self = [self initWithNibName:nibName bundle:nil])) { repository = theRepository; superController = controller; } diff --git a/gitx_askpasswd_main.m b/gitx_askpasswd_main.m index b6a63ce..12fcc93 100644 --- a/gitx_askpasswd_main.m +++ b/gitx_askpasswd_main.m @@ -30,7 +30,7 @@ #define WINDOWAUTOSAVENAME @"GitXAskPasswordWindowFrame" -@interface GAPAppDelegate : NSObject +@interface GAPAppDelegate : NSObject { NSPanel* mPasswordPanel; NSSecureTextField* mPasswordField; @@ -48,7 +48,7 @@ NSString* url; OSStatus StorePasswordKeychain (const char *url, UInt32 urlLength, void* password,UInt32 passwordLength); -@implementation GAPAppDelegate +@implementation GAPAppDelegate -(NSPanel*)passwordPanel:(NSString *)prompt remember:(BOOL)remember { @@ -167,7 +167,7 @@ OSStatus StorePasswordKeychain (const char *url, UInt32 urlLength, void* passw if ((rememberCheck!=nil) && [rememberCheck state]==NSOnState) { OSStatus status = StorePasswordKeychain ([url cStringUsingEncoding:NSASCIIStringEncoding], [url lengthOfBytesUsingEncoding:NSASCIIStringEncoding], - [pas cStringUsingEncoding:NSASCIIStringEncoding], + (void *)[pas cStringUsingEncoding:NSASCIIStringEncoding], [pas lengthOfBytesUsingEncoding:NSASCIIStringEncoding]); //Call if (status != noErr) { [[NSApplication sharedApplication] stopModalWithCode:-1]; @@ -329,7 +329,7 @@ int main( int argc, const char* argv[] ) void *passwordData = nil; SecKeychainItemRef itemRef = nil; - UInt32 passwordLength = nil; + UInt32 passwordLength = 0; OSStatus status = GetPasswordKeychain ([url cStringUsingEncoding:NSASCIIStringEncoding],[url lengthOfBytesUsingEncoding:NSASCIIStringEncoding],&passwordData,&passwordLength,&itemRef); if (status == noErr) { From b4211b2b01e0a57408d2477bc41ecfb27cf9b78c Mon Sep 17 00:00:00 2001 From: German Laullon Date: Thu, 10 Mar 2011 16:32:14 -0800 Subject: [PATCH 03/36] remove "-z" params to avoid "\0" --- PBGitIndex.m | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/PBGitIndex.m b/PBGitIndex.m index e41e5e5..ae2cad7 100644 --- a/PBGitIndex.m +++ b/PBGitIndex.m @@ -299,7 +299,7 @@ NSString *PBGitIndexOperationFailed = @"PBGitIndexOperationFailed"; PBChangedFile *file = [stageFiles objectAtIndex:i]; - [input appendFormat:@"%@\0", file.path]; + [input appendFormat:@"%@", file.path]; } @@ -390,9 +390,9 @@ NSString *PBGitIndexOperationFailed = @"PBGitIndexOperationFailed"; - (void)discardChangesForFiles:(NSArray *)discardFiles { NSArray *paths = [discardFiles valueForKey:@"path"]; - NSString *input = [paths componentsJoinedByString:@"\0"]; + NSString *input = [paths componentsJoinedByString:@"\n"]; - NSArray *arguments = [NSArray arrayWithObjects:@"checkout-index", @"--index", @"--quiet", @"--force", @"-z", @"--stdin", nil]; + NSArray *arguments = [NSArray arrayWithObjects:@"checkout-index", @"--index", @"--quiet", @"--force", @"--stdin", nil]; int ret = 1; [PBEasyPipe outputForCommand:[PBGitBinary path] withArgs:arguments inDir:[workingDirectory path] inputString:input retValue:&ret]; @@ -499,7 +499,7 @@ NSString *PBGitIndexOperationFailed = @"PBGitIndexOperationFailed"; // Other files (not tracked, not ignored) refreshStatus++; NSFileHandle *handle = [PBEasyPipe handleForCommand:[PBGitBinary path] - withArgs:[NSArray arrayWithObjects:@"ls-files", @"--others", @"--exclude-standard", @"-z", nil] + withArgs:[NSArray arrayWithObjects:@"ls-files", @"--others", @"--exclude-standard", nil] inDir:[workingDirectory path]]; [nc addObserver:self selector:@selector(readOtherFiles:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle]; [handle readToEndOfFileInBackgroundAndNotify]; @@ -507,7 +507,7 @@ NSString *PBGitIndexOperationFailed = @"PBGitIndexOperationFailed"; // Unstaged files refreshStatus++; handle = [PBEasyPipe handleForCommand:[PBGitBinary path] - withArgs:[NSArray arrayWithObjects:@"diff-files", @"-z", nil] + withArgs:[NSArray arrayWithObjects:@"diff-files", nil] inDir:[workingDirectory path]]; [nc addObserver:self selector:@selector(readUnstagedFiles:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle]; [handle readToEndOfFileInBackgroundAndNotify]; @@ -515,7 +515,7 @@ NSString *PBGitIndexOperationFailed = @"PBGitIndexOperationFailed"; // Staged files refreshStatus++; handle = [PBEasyPipe handleForCommand:[PBGitBinary path] - withArgs:[NSArray arrayWithObjects:@"diff-index", @"--cached", @"-z", [self parentTree], nil] + withArgs:[NSArray arrayWithObjects:@"diff-index", @"--cached", [self parentTree], nil] inDir:[workingDirectory path]]; [nc addObserver:self selector:@selector(readStagedFiles:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle]; [handle readToEndOfFileInBackgroundAndNotify]; @@ -641,35 +641,27 @@ NSString *PBGitIndexOperationFailed = @"PBGitIndexOperationFailed"; return [NSArray array]; NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - // FIXME: throw an error? if (!string) return [NSArray array]; - // Strip trailing null - if ([string hasSuffix:@"\0"]) - string = [string substringToIndex:[string length]-1]; - if ([string length] == 0) return [NSArray array]; - return [string componentsSeparatedByString:@"\0"]; + string=[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + return [string componentsSeparatedByString:@"\n"]; } - (NSMutableDictionary *)dictionaryForLines:(NSArray *)lines { - NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithCapacity:[lines count]/2]; - - // Fill the dictionary with the new information. These lines are in the form of: - // :00000 :0644 OTHER INDEX INFORMATION - // Filename - - NSAssert1([lines count] % 2 == 0, @"Lines must have an even number of lines: %@", lines); + NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithCapacity:[lines count]]; NSEnumerator *enumerator = [lines objectEnumerator]; - NSString *fileStatus; - while (fileStatus = [enumerator nextObject]) { - NSString *fileName = [enumerator nextObject]; - [dictionary setObject:[fileStatus componentsSeparatedByString:@" "] forKey:fileName]; + NSString *line; + while ((line = [enumerator nextObject])) { + NSArray *lineComp=[line componentsSeparatedByString:@"\t"]; + NSArray *fileStatus=[[lineComp objectAtIndex:0] componentsSeparatedByString:@" "]; + NSString *fileName = [lineComp objectAtIndex:1]; + [dictionary setObject:fileStatus forKey:fileName]; } return dictionary; From 6fe75b27ea266f2997fca66b443b03a0751e150b Mon Sep 17 00:00:00 2001 From: German Laullon Date: Thu, 10 Mar 2011 16:45:13 -0800 Subject: [PATCH 04/36] Replace tab characters with 4 blanks in GLFileView.m. (flyingblackhat) --- GLFileView.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/GLFileView.m b/GLFileView.m index 2c47262..77ba04e 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -218,6 +218,7 @@ txt=[txt stringByReplacingOccurrencesOfString:@"&" withString:@"&"]; txt=[txt stringByReplacingOccurrencesOfString:@"<" withString:@"<"]; txt=[txt stringByReplacingOccurrencesOfString:@">" withString:@">"]; + txt=[txt stringByReplacingOccurrencesOfString:@"\t" withString:@"    "]; return txt; } @@ -479,7 +480,6 @@ line=[lines objectAtIndex:i++]; }while([line characterAtIndex:0]!='\t'); line=[line substringFromIndex:1]; - line=[line stringByReplacingOccurrencesOfString:@"\t" withString:@"    "]; [code appendString:line]; [code appendString:@"\n"]; @@ -489,7 +489,6 @@ line=[lines objectAtIndex:i++]; }while([line characterAtIndex:0]!='\t'); line=[line substringFromIndex:1]; - line=[line stringByReplacingOccurrencesOfString:@"\t" withString:@"    "]; [code appendString:line]; [code appendString:@"\n"]; } From 1f7dff14c599c640f0a55bcadee11dcd58a6dc1b Mon Sep 17 00:00:00 2001 From: German Laullon Date: Thu, 10 Mar 2011 16:51:39 -0800 Subject: [PATCH 05/36] NSToolbarAllowsUserCustomization NO --- English.lproj/RepositoryWindow.xib | 684 ++--------------------------- 1 file changed, 37 insertions(+), 647 deletions(-) diff --git a/English.lproj/RepositoryWindow.xib b/English.lproj/RepositoryWindow.xib index 9baf874..02b6c5f 100644 --- a/English.lproj/RepositoryWindow.xib +++ b/English.lproj/RepositoryWindow.xib @@ -3,16 +3,32 @@ 1050 10J567 - 788 + 1305 1038.35 462.00 com.apple.InterfaceBuilder.CocoaPlugin - 788 + 1305 - + YES - + NSSegmentedCell + NSToolbar + NSToolbarFlexibleSpaceItem + NSSplitView + NSButton + NSSegmentedControl + NSButtonCell + NSTextFieldCell + NSToolbarSpaceItem + NSProgressIndicator + NSToolbarSeparatorItem + NSCustomView + NSCustomObject + NSView + NSWindowTemplate + NSTextField + NSToolbarItem YES @@ -47,7 +63,7 @@ YES YES - YES + NO YES 1 1 @@ -97,6 +113,7 @@ 268 {{38, 14}, {40, 25}} + YES -2080244224 @@ -143,6 +160,7 @@ 268 {{8, 14}, {32, 25}} + YES -2080244224 @@ -185,6 +203,7 @@ 268 {{0, 14}, {94, 25}} + YES 67239424 @@ -366,7 +385,6 @@ YES - {1.79769e+308, 1.79769e+308} {600, 450} @@ -383,6 +401,7 @@ 272 {184, 483} + NSView @@ -390,11 +409,13 @@ 274 {{185, 0}, {705, 483}} + NSView {{0, 31}, {890, 483}} + YES 2 sourceSplitView @@ -404,6 +425,7 @@ 292 {{0, 1}, {515, 31}} + NSView @@ -417,6 +439,7 @@ {{20, 7}, {16, 16}} + 20746 100 @@ -425,6 +448,7 @@ 266 {{41, 8}, {188, 14}} + YES 67239488 @@ -459,15 +483,17 @@ {{552, 0}, {246, 31}} + NSView - {890, 514} + {{7, 11}, {890, 514}} + {{0, 0}, {1440, 878}} {600, 528} - {1.79769e+308, 1.79769e+308} + {1e+13, 1e+13} GitX 31 @@ -831,10 +857,6 @@ 3.ImportedFromIB2 3.NSWindowTemplate.visibleAtLaunch 3.editorWindowContentRectSynchronizationRect - 3.windowTemplate.hasMaxSize - 3.windowTemplate.hasMinSize - 3.windowTemplate.maxSize - 3.windowTemplate.minSize 351.IBPluginDependency 352.IBPluginDependency 352.IBViewBoundsToFrameTransform @@ -874,10 +896,6 @@ {{15, 196}, {850, 418}} - - - {3.40282e+38, 3.40282e+38} - {600, 450} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -918,17 +936,13 @@ YES - - YES - + YES - - YES - + 423 @@ -936,20 +950,6 @@ YES - - NSApplication - - IBProjectSource - NSApplication+GitXScripting.h - - - - NSCell - - IBProjectSource - View/CellTrackingRect.h - - PBGitWindowController NSWindowController @@ -1096,616 +1096,7 @@ IBProjectSource - PBGitWindowController.h - - - - PBGitWindowController - NSWindowController - - IBUserSource - - - - - - YES - - NSActionCell - NSCell - - IBFrameworkSource - AppKit.framework/Headers/NSActionCell.h - - - - NSApplication - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSApplication.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSApplicationScripting.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSColorPanel.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSHelpManager.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSPageLayout.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSUserInterfaceItemSearching.h - - - - NSButton - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSButton.h - - - - NSButtonCell - NSActionCell - - IBFrameworkSource - AppKit.framework/Headers/NSButtonCell.h - - - - NSCell - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSCell.h - - - - NSControl - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSControl.h - - - - NSFormatter - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFormatter.h - - - - NSMenu - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSMenu.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSAccessibility.h - - - - NSObject - - - - NSObject - - - - NSObject - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDictionaryController.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDragging.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSFontManager.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSFontPanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSKeyValueBinding.h - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSNibLoading.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSOutlineView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSPasteboard.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSSavePanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTableView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSToolbarItem.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSView.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSArchiver.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSClassDescription.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSError.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFileManager.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueCoding.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueObserving.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyedArchiver.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSObject.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSObjectScripting.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSPortCoder.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSRunLoop.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptClassDescription.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptKeyValueCoding.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptObjectSpecifiers.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptWhoseTests.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSThread.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURL.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURLConnection.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURLDownload.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CAAnimation.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CALayer.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CIImageProvider.h - - - - NSObject - - IBFrameworkSource - ScriptingBridge.framework/Headers/SBApplication.h - - - - NSObject - - IBFrameworkSource - Sparkle.framework/Headers/SUAppcast.h - - - - NSObject - - IBFrameworkSource - Sparkle.framework/Headers/SUUpdater.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebDownload.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebEditingDelegate.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebFrameLoadDelegate.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebJavaPlugIn.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebPlugin.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebPluginContainer.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebPolicyDelegate.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebResourceLoadDelegate.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebScriptObject.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebUIDelegate.h - - - - NSProgressIndicator - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSProgressIndicator.h - - - - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSInterfaceStyle.h - - - - NSResponder - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSResponder.h - - - - NSSegmentedCell - NSActionCell - - IBFrameworkSource - AppKit.framework/Headers/NSSegmentedCell.h - - - - NSSegmentedControl - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSSegmentedControl.h - - - - NSSplitView - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSSplitView.h - - - - NSTextField - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSTextField.h - - - - NSTextFieldCell - NSActionCell - - IBFrameworkSource - AppKit.framework/Headers/NSTextFieldCell.h - - - - NSToolbar - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSToolbar.h - - - - NSToolbarItem - NSObject - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSClipView.h - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSMenuItem.h - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSRulerView.h - - - - NSView - NSResponder - - - - NSWindow - - IBFrameworkSource - AppKit.framework/Headers/NSDrawer.h - - - - NSWindow - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSWindow.h - - - - NSWindow - - IBFrameworkSource - AppKit.framework/Headers/NSWindowScripting.h - - - - NSWindowController - NSResponder - - showWindow: - id - - - showWindow: - - showWindow: - id - - - - IBFrameworkSource - AppKit.framework/Headers/NSWindowController.h + ./Classes/PBGitWindowController.h @@ -1725,7 +1116,6 @@ YES - ../GitX.xcodeproj 3 YES From 00bb148d7296bfb525bc8ccfc9c9e5eb5e12d4e2 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Thu, 10 Mar 2011 23:28:46 -0800 Subject: [PATCH 06/36] final details for 0.8.1 From f47fd3c6964467dfeaa0519cbab3c29c53fec9f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leszek=20S=CC=81laz=CC=87yn=CC=81ski?= Date: Mon, 14 Mar 2011 01:51:36 +0100 Subject: [PATCH 07/36] Feature: reset current branch to here --- Controller/PBGitResetController.h | 4 +- Controller/PBGitResetController.m | 39 +- GitX.xcodeproj/project.pbxproj | 10 + PBRefController.h | 1 + PBRefController.m | 7 + PBRefMenuItem.m | 9 + PBResetSheet.h | 35 + PBResetSheet.m | 67 ++ PBResetSheet.xib | 1109 +++++++++++++++++++++++++++++ 9 files changed, 1248 insertions(+), 33 deletions(-) create mode 100644 PBResetSheet.h create mode 100644 PBResetSheet.m create mode 100644 PBResetSheet.xib diff --git a/Controller/PBGitResetController.h b/Controller/PBGitResetController.h index b7a8d30..d8672a5 100644 --- a/Controller/PBGitResetController.h +++ b/Controller/PBGitResetController.h @@ -7,8 +7,10 @@ // #import +#import "PBResetSheet.h" @class PBGitRepository; +@protocol PBGitRefish; @interface PBGitResetController : NSObject { PBGitRepository *repository; @@ -17,8 +19,8 @@ - (NSArray *) menuItems; - // actions +- (void) resetToRefish: (id) spec type: (PBResetType) type; - (void) resetHardToHead; @end diff --git a/Controller/PBGitResetController.m b/Controller/PBGitResetController.m index c9e5fb6..1ef3309 100644 --- a/Controller/PBGitResetController.m +++ b/Controller/PBGitResetController.m @@ -9,8 +9,9 @@ #import "PBGitResetController.h" #import "PBGitRepository.h" #import "PBCommand.h" +#import "PBGitRefish.h" +#import "PBResetSheet.h" -static NSString * const kCommandKey = @"command"; @implementation PBGitResetController @@ -22,23 +23,11 @@ static NSString * const kCommandKey = @"command"; } - (void) resetHardToHead { - NSAlert *alert = [NSAlert alertWithMessageText:@"Reseting working copy and index" - defaultButton:@"Cancel" - alternateButton:nil - otherButton:@"Reset" - informativeTextWithFormat:@"Are you sure you want to reset your working copy and index? All changes to them will be gone!"]; - - NSArray *arguments = [NSArray arrayWithObjects:@"reset", @"--hard", @"HEAD", nil]; - PBCommand *cmd = [[PBCommand alloc] initWithDisplayName:@"Reset hard to HEAD" parameters:arguments repository:repository]; - cmd.commandTitle = cmd.displayName; - cmd.commandDescription = @"Reseting head"; - - NSMutableDictionary *info = [NSMutableDictionary dictionaryWithObject:cmd forKey:kCommandKey]; - - [alert beginSheetModalForWindow:[repository.windowController window] - modalDelegate:self - didEndSelector:@selector(confirmResetSheetDidEnd:returnCode:contextInfo:) - contextInfo:info]; + [self resetToRefish: [PBGitRef refFromString: @"HEAD"] type: PBResetTypeHard]; +} + +- (void) resetToRefish:(id) refish type:(PBResetType)type { + [PBResetSheet beginResetSheetForRepository: repository refish: refish andType: type]; } - (void) reset { @@ -70,18 +59,4 @@ static NSString * const kCommandKey = @"command"; [super dealloc]; } -#pragma mark - -#pragma mark Confirm Window - -- (void) confirmResetSheetDidEnd:(NSAlert *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo -{ - [[sheet window] orderOut:nil]; - - if (returnCode != NSAlertDefaultReturn) { - PBCommand *cmd = [(NSDictionary *)contextInfo objectForKey:kCommandKey]; - [cmd invoke]; - } -} - - @end diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 238406d..b42442e 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -72,6 +72,8 @@ 47DBDBCA0E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.m in Sources */ = {isa = PBXBuildFile; fileRef = 47DBDBC90E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.m */; }; 551BF11E112F376C00265053 /* gitx_askpasswd_main.m in Sources */ = {isa = PBXBuildFile; fileRef = 551BF11D112F376C00265053 /* gitx_askpasswd_main.m */; }; 551BF176112F3F4B00265053 /* gitx_askpasswd in Resources */ = {isa = PBXBuildFile; fileRef = 551BF111112F371800265053 /* gitx_askpasswd */; }; + 65D58BC4132D27A8003F7290 /* PBResetSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 65D58BC3132D27A7003F7290 /* PBResetSheet.xib */; }; + 65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 65D58BC6132D48C0003F7290 /* PBResetSheet.m */; }; 770B37ED0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel in Sources */ = {isa = PBXBuildFile; fileRef = 770B37EC0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel */; }; 77C8280E06725ACE000B614F /* ApplicationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C8280C06725ACE000B614F /* ApplicationController.m */; }; 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; @@ -365,6 +367,9 @@ 47DBDBC90E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBNSURLPathUserDefaultsTransfomer.m; sourceTree = ""; }; 551BF111112F371800265053 /* gitx_askpasswd */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = gitx_askpasswd; sourceTree = BUILT_PRODUCTS_DIR; }; 551BF11D112F376C00265053 /* gitx_askpasswd_main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = gitx_askpasswd_main.m; sourceTree = ""; }; + 65D58BC3132D27A7003F7290 /* PBResetSheet.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PBResetSheet.xib; sourceTree = ""; }; + 65D58BC5132D48BF003F7290 /* PBResetSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBResetSheet.h; sourceTree = ""; }; + 65D58BC6132D48C0003F7290 /* PBResetSheet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBResetSheet.m; sourceTree = ""; }; 770B37EC0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = wrapper.xcdatamodel; path = GitTest_DataModel.xcdatamodel; sourceTree = ""; }; 77C82804067257F0000B614F /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; 77C8280B06725ACE000B614F /* ApplicationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationController.h; sourceTree = ""; }; @@ -846,6 +851,7 @@ 21230ED11285EB5A0046E5A1 /* PBArgumentPicker.xib */, F58DB55F10566E3900CFDF4A /* PBGitSidebarView.xib */, D8022FE711E124A0003C21F6 /* PBGitXMessageSheet.xib */, + 65D58BC3132D27A7003F7290 /* PBResetSheet.xib */, ); name = Resources; sourceTree = ""; @@ -937,6 +943,8 @@ D8083E02111FA33700337480 /* PBCloneRepositoryPanel.m */, D8022FEB11E124C8003C21F6 /* PBGitXMessageSheet.h */, D8022FEC11E124C8003C21F6 /* PBGitXMessageSheet.m */, + 65D58BC5132D48BF003F7290 /* PBResetSheet.h */, + 65D58BC6132D48C0003F7290 /* PBResetSheet.m */, ); name = Sheets; sourceTree = ""; @@ -1437,6 +1445,7 @@ 31DAA7ED1317737100463846 /* gitx_l_pub.pem in Resources */, 316E7202131EE9C600AFBB36 /* list_Template.png in Resources */, 316E7203131EE9C600AFBB36 /* sidebar_Template.png in Resources */, + 65D58BC4132D27A8003F7290 /* PBResetSheet.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1606,6 +1615,7 @@ 217FF0BA12A1CB3300785A65 /* PBSubmoduleController.m in Sources */, 217FF0BB12A1CB3300785A65 /* PBGitResetController.m in Sources */, 217FF0BE12A1CB3E00785A65 /* PBRevealWithFinderCommand.m in Sources */, + 65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/PBRefController.h b/PBRefController.h index 15df74b..321409f 100644 --- a/PBRefController.h +++ b/PBRefController.h @@ -31,6 +31,7 @@ - (void) showConfirmPushRefSheet:(PBGitRef *)ref remote:(PBGitRef *)remoteRef; - (void) checkout:(PBRefMenuItem *)sender; +- (void) reset:(PBRefMenuItem *)sender; - (void) merge:(PBRefMenuItem *)sender; - (void) cherryPick:(PBRefMenuItem *)sender; - (void) rebaseHeadBranch:(PBRefMenuItem *)sender; diff --git a/PBRefController.m b/PBRefController.m index 2ca8941..34e22da 100644 --- a/PBRefController.m +++ b/PBRefController.m @@ -149,6 +149,13 @@ [historyController.repository checkoutRefish:refish]; } +#pragma mark Reset + +- (void) reset:(PBRefMenuItem *)sender +{ + id refish = [sender refish]; + [historyController.repository.resetController resetToRefish: refish type: PBResetTypeMixed]; +} #pragma mark Cherry Pick diff --git a/PBRefMenuItem.m b/PBRefMenuItem.m index aaaee1f..7b32b43 100644 --- a/PBRefMenuItem.m +++ b/PBRefMenuItem.m @@ -61,6 +61,10 @@ [items addObject:[PBRefMenuItem itemWithTitle:checkoutTitle action:@selector(checkout:) enabled:!isHead]]; [items addObject:[PBRefMenuItem separatorItem]]; + NSString *resetTitle = [NSString stringWithFormat:@"Reset %@ to %@", headRefName, targetRefName]; + [items addObject:[PBRefMenuItem itemWithTitle: resetTitle action:@selector(reset:) enabled:YES]]; + [items addObject:[PBRefMenuItem separatorItem]]; + // create branch NSString *createBranchTitle = [ref isRemoteBranch] ? [NSString stringWithFormat:@"Create branch that tracks %@…", targetRefName] : @"Create branch…"; [items addObject:[PBRefMenuItem itemWithTitle:createBranchTitle action:@selector(createBranch:) enabled:YES]]; @@ -156,7 +160,12 @@ [items addObject:[PBRefMenuItem itemWithTitle:@"Checkout Commit" action:@selector(checkout:) enabled:YES]]; [items addObject:[PBRefMenuItem separatorItem]]; + + NSString *resetTitle = [NSString stringWithFormat:@"Reset %@ to here", headBranchName]; + [items addObject:[PBRefMenuItem itemWithTitle: resetTitle action:@selector(reset:) enabled:YES]]; + [items addObject:[PBRefMenuItem separatorItem]]; + [items addObject:[PBRefMenuItem itemWithTitle:@"Create Branch…" action:@selector(createBranch:) enabled:YES]]; [items addObject:[PBRefMenuItem itemWithTitle:@"Create Tag…" action:@selector(createTag:) enabled:YES]]; [items addObject:[PBRefMenuItem separatorItem]]; diff --git a/PBResetSheet.h b/PBResetSheet.h new file mode 100644 index 0000000..edb8d06 --- /dev/null +++ b/PBResetSheet.h @@ -0,0 +1,35 @@ +// +// PBResetSheet.h +// GitX +// +// Created by Leszek Slazynski on 11-03-13. +// Copyright 2011 LSL. All rights reserved. +// + +#import + +@protocol PBGitRefish; +@class PBGitRepository; + +typedef enum PBResetType { + PBResetTypeNone, + PBResetTypeSoft, + PBResetTypeMixed, + PBResetTypeHard, + PBResetTypeMerge, + PBResetTypeKeep +} PBResetType; + +@interface PBResetSheet : NSWindowController { + IBOutlet NSSegmentedControl* resetType; + IBOutlet NSTabView* resetDesc; + PBResetType defaultType; + id targetRefish; + PBGitRepository* repository; +} + ++ (void) beginResetSheetForRepository:(PBGitRepository*) repo refish:(id)refish andType:(PBResetType)type; +- (IBAction)resetBranch:(id)sender; +- (IBAction)cancel:(id)sender; + +@end diff --git a/PBResetSheet.m b/PBResetSheet.m new file mode 100644 index 0000000..df07b5e --- /dev/null +++ b/PBResetSheet.m @@ -0,0 +1,67 @@ +// +// PBResetSheet.m +// GitX +// +// Created by Leszek Slazynski on 11-03-13. +// Copyright 2011 LSL. All rights reserved. +// + +#import "PBResetSheet.h" +#import "PBGitRefish.h" +#import "PBCommand.h" +#import "PBGitRepository.h" + +static const char* StringFromResetType(PBResetType type) { + static const char* resetTypes[] = { + "none", "soft", "mixed", "hard", "merge", "keep" + }; + return resetTypes[type]; +} + +@implementation PBResetSheet + +- (void) beginResetSheetForRepository:(PBGitRepository*) repo refish:(id)refish andType:(PBResetType)type { + defaultType = type; + targetRefish = refish; + repository = repo; + [NSApp beginSheet: [self window] + modalForWindow: [[repository windowController] window] + modalDelegate: self + didEndSelector: nil + contextInfo: NULL]; +} + ++ (void) beginResetSheetForRepository:(PBGitRepository*) repo refish:(id)refish andType:(PBResetType)type { + PBResetSheet* sheet = [[self alloc] initWithWindowNibName: @"PBResetSheet"]; + [sheet beginResetSheetForRepository: repo refish: refish andType: type]; +} + +- (id) init { + if ( (self = [super initWithWindowNibName: @"PBResetSheet"]) ) { + defaultType = PBResetTypeMixed; + } + return self; +} + +- (void) windowDidLoad { + [resetType setSelectedSegment: defaultType - 1]; + [resetDesc selectTabViewItemAtIndex: defaultType - 1]; +} + +- (IBAction)resetBranch:(id)sender { + [NSApp endSheet:[self window]]; + [[self window] orderOut:self]; + PBResetType type = [resetType selectedSegment] + 1; + + NSString* type_arg = [NSString stringWithFormat: @"--%s", StringFromResetType(type)]; + NSArray *arguments = [NSArray arrayWithObjects:@"reset", type_arg, [targetRefish refishName], nil]; + PBCommand *cmd = [[PBCommand alloc] initWithDisplayName:@"Reset branch" parameters:arguments repository:repository]; + [cmd invoke]; +} + +- (IBAction)cancel:(id)sender { + [NSApp endSheet:[self window]]; + [[self window] orderOut:self]; +} + +@end diff --git a/PBResetSheet.xib b/PBResetSheet.xib new file mode 100644 index 0000000..1cf0e70 --- /dev/null +++ b/PBResetSheet.xib @@ -0,0 +1,1109 @@ + + + + 1060 + 10J567 + 1305 + 1038.35 + 462.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 1305 + + + YES + NSTabViewItem + NSView + NSWindowTemplate + NSTabView + NSSegmentedControl + NSSegmentedCell + NSTextField + NSTextFieldCell + NSButtonCell + NSButton + NSCustomObject + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + YES + + YES + + + + + YES + + PBResetSheet + + + FirstResponder + + + NSApplication + + + 3 + 2 + {{196, 240}, {480, 205}} + 544736256 + Reset branch + NSWindow + + + + 256 + + YES + + + 18 + {{16, 56}, {448, 78}} + + + + 2 + + YES + + 1 + + + 256 + + YES + + + 274 + {{0, 45}, {428, 13}} + + + 2 + YES + + 67239488 + 1346635776 + Resets the head but does not touch the index file nor the working tree at all. + + LucidaGrande + 10 + 16 + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + 3 + MAA + + + + + + + 268 + {{0, 21}, {428, 16}} + + + 2 + YES + + 68288064 + 272892928 + This leaves all your changes intact - as changes to be committed. + + LucidaGrande-Bold + 12 + 16 + + + + + + + + {{10, 7}, {428, 58}} + + 2 + + soft + + + + + 2 + + + 256 + + YES + + + 274 + {{0, 45}, {428, 13}} + + + YES + + 67239488 + 272893952 + Resets the index but not the working tree and reports what has not been updated. + + + + + + + + + 268 + {{0, 21}, {428, 16}} + + + YES + + 68288064 + 272892928 + This preserves changes but they are not marked for commit. + + + + + + + + {{10, 7}, {428, 58}} + + + mixed + + + + + + + 256 + + YES + + + 274 + {{0, 32}, {428, 26}} + + + + YES + + 67239424 + 272891904 + Resets the index and working tree. Any changes to tracked files in the working tree are discarded. + + + + + + + + + 268 + {{0, 8}, {437, 16}} + + + + YES + + 68288064 + 272892928 + Warning! This discards all changes. It may be hard to recover them. + + + + + + + + {{10, 7}, {428, 58}} + + + + + hard + + + + + + + 256 + + YES + + + 274 + {{0, -95}, {428, 153}} + + YES + + 67239424 + 272891904 + Resets the index and updates the files in the working tree that are different between target and HEAD, but keeps those which are different between the index and working tree (i.e. which have changes which have not been added). If a file that is different between target and the index has unstaged changes, reset is aborted. + + + + + + + + {{10, 7}, {428, 58}} + + + merge + + + + + + + 256 + + YES + + + 274 + {{0, -95}, {428, 153}} + + YES + + 67239424 + 272891904 + UmVzZXRzIHRoZSBpbmRleCwgdXBkYXRlcyBmaWxlcyBpbiB0aGUgd29ya2luZyB0cmVlIHRoYXQgYXJl +IGRpZmZlcmVudCBiZXR3ZWVuIHRhcmdldCBhbmQgSEVBRCwgYnV0IGtlZXBzIHRob3NlIHdoaWNoIGFy +ZSBkaWZmZXJlbnQgYmV0d2VlbiBIRUFEIGFuZCB0aGUgd29ya2luZyB0cmVlIChpLmUuIHdoaWNoIGhh +dmUgbG9jYWwgY2hhbmdlcykuIElmIGEgZmlsZSB0aGF0IGlzIGRpZmZlcmVudCBiZXR3ZWVuIHRhcmdl +dCBhbmQgSEVBRCBoYXMgbG9jYWwgY2hhbmdlcywgcmVzZXQgaXMgYWJvcnRlZC4KA + + + + + + + + {{10, 7}, {428, 58}} + + + keep + + + + + + + LucidaGrande + 13 + 1044 + + 4 + YES + YES + + YES + + + + + + 268 + {{185, 138}, {275, 25}} + + + + 2 + YES + + 67239424 + 0 + + LucidaGrande + 13 + 16 + + + + YES + + soft + 0 + + + mixed + 1 + YES + 0 + + + hard + 0 + + + merge + 0 + + + keep + 0 + + + 1 + 2 + + + + + 268 + {{17, 143}, {83, 17}} + + + + 2 + YES + + 68288064 + 272630784 + Reset type: + + + YES + + + + + + + 289 + {{370, 12}, {96, 32}} + + + + 2 + YES + + 67239424 + 134217728 + Reset + + + -2038284033 + 129 + + DQ + 200 + 25 + + + + + 289 + {{274, 12}, {96, 32}} + + + + 2 + YES + + 67239424 + 134217728 + Cancel + + + -2038284033 + 129 + + Gw + 200 + 25 + + + + + 268 + {{17, 168}, {446, 17}} + + + + 2 + YES + + 68288064 + 272630784 + Are you sure you want to reset current branch? + + LucidaGrande-Bold + 13 + 16 + + + + + + + + {{7, 11}, {480, 205}} + + + + 2 + + {{0, 0}, {1280, 778}} + {1e+13, 1e+13} + + + + + YES + + + takeSelectedTabViewItemFromSender: + + + + 20 + + + + window + + + + 57 + + + + resetBranch: + + + + 58 + + + + cancel: + + + + 59 + + + + resetType + + + + 60 + + + + + YES + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + YES + + + + Reset branch + + + 2 + + + YES + + + + + + + + + + + 3 + + + YES + + + + + + + + Type Description + + + 4 + + + YES + + + + soft + + + 5 + + + YES + + + + mixed + + + 6 + + + YES + + + + + + + 7 + + + YES + + + + + View + + + 8 + + + YES + + + + hard + + + 9 + + + YES + + + + + + + 10 + + + YES + + + + merge + + + 11 + + + YES + + + + + + 12 + + + YES + + + + keep + + + 13 + + + YES + + + + + + 14 + + + YES + + + + Type Select + + + 15 + + + Segmented Cell - soft, mixed, hard, merge, keep + + + 16 + + + YES + + + + Type Label + + + 17 + + + + + 31 + + + YES + + + + Reset + + + 32 + + + + + 35 + + + YES + + + + Are you sure + + + 36 + + + + + 37 + + + YES + + + + + + 38 + + + + + 39 + + + YES + + + + + + 40 + + + + + 41 + + + YES + + + + + + 42 + + + + + 43 + + + YES + + + + + + 44 + + + + + 29 + + + YES + + + + + + 30 + + + + + 50 + + + YES + + + + + + 51 + + + + + 53 + + + YES + + + + + + 54 + + + + + 55 + + + YES + + + + + + 56 + + + + + 33 + + + YES + + + + Cancel + + + 34 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 1.IBPluginDependency + 1.IBWindowTemplateEditedContentRect + 1.NSWindowTemplate.visibleAtLaunch + 1.WindowOrigin + 1.editorWindowContentRectSynchronizationRect + 14.IBNSSegmentedControlTracker.RoundRobinState + 14.IBNSSegmentedControlTracker.WasGrowing + 14.IBPluginDependency + 15.IBNSSegmentedControlInspectorSelectedSegmentMetadataKey + 15.IBPluginDependency + 16.IBPluginDependency + 17.IBPluginDependency + 2.IBPluginDependency + 29.IBPluginDependency + 3.IBAttributePlaceholdersKey + 3.IBPluginDependency + 30.IBPluginDependency + 31.IBPluginDependency + 32.IBPluginDependency + 33.IBPluginDependency + 33.IBViewIntegration.shadowBlurRadius + 33.IBViewIntegration.shadowColor + 33.IBViewIntegration.shadowOffsetHeight + 33.IBViewIntegration.shadowOffsetWidth + 34.IBPluginDependency + 35.IBPluginDependency + 36.IBPluginDependency + 37.IBPluginDependency + 38.IBPluginDependency + 39.IBPluginDependency + 4.IBPluginDependency + 40.IBPluginDependency + 41.IBPluginDependency + 42.IBPluginDependency + 43.IBPluginDependency + 44.IBPluginDependency + 5.IBPluginDependency + 50.IBPluginDependency + 51.IBPluginDependency + 53.IBPluginDependency + 54.IBPluginDependency + 55.IBPluginDependency + 56.IBPluginDependency + 7.notes + 7.showNotes + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{357, 418}, {480, 270}} + + {196, 240} + {{357, 418}, {480, 270}} + + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + InitialTabViewItem + + InitialTabViewItem + + + + + 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 + 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 + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + aaa + + + YES + + YES + NSFont + NSParagraphStyle + + + YES + + Helvetica + 12 + 16 + + + 4 + + + + + + + + + + YES + + + + + + YES + + + + + 60 + + + + YES + + PBResetSheet + NSWindowController + + YES + + YES + cancel: + resetBranch: + + + YES + id + id + + + + YES + + YES + cancel: + resetBranch: + + + YES + + cancel: + id + + + resetBranch: + id + + + + + YES + + YES + resetDesc + resetType + + + YES + NSTabView + NSSegmentedControl + + + + YES + + YES + resetDesc + resetType + + + YES + + resetDesc + NSTabView + + + resetType + NSSegmentedControl + + + + + IBProjectSource + ./Classes/PBResetSheet.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + 3 + + From 3ca61355c203d9c7d6e9f6cc71a5f61c703b621d Mon Sep 17 00:00:00 2001 From: Uwe Hees Date: Sat, 12 Mar 2011 11:31:55 +0100 Subject: [PATCH 08/36] Make 'Diff with ...' context menu item work again --- PBWebDiffController.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PBWebDiffController.m b/PBWebDiffController.m index 01efde7..d09d9c7 100644 --- a/PBWebDiffController.m +++ b/PBWebDiffController.m @@ -7,6 +7,7 @@ // #import "PBWebDiffController.h" +#import "GLFileView.h" @implementation PBWebDiffController @@ -46,7 +47,7 @@ if ([diff length] == 0) [script callWebScriptMethod:@"setMessage" withArguments:[NSArray arrayWithObject:@"There are no differences"]]; else - [script callWebScriptMethod:@"showDiff" withArguments:[NSArray arrayWithObject:diff]]; + [script callWebScriptMethod:@"showFile" withArguments:[NSArray arrayWithObject:[GLFileView parseDiff:diff]]]; } @end From 8e98e0b48ed7c525c2baadfe8bc8c3072c9e929b Mon Sep 17 00:00:00 2001 From: Uwe Hees Date: Wed, 16 Mar 2011 11:06:21 +0100 Subject: [PATCH 09/36] Tweak the CSS of the diff view. --- html/views/diff/diffWindow.css | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/html/views/diff/diffWindow.css b/html/views/diff/diffWindow.css index d752659..b80b988 100644 --- a/html/views/diff/diffWindow.css +++ b/html/views/diff/diffWindow.css @@ -57,4 +57,21 @@ table.diff thead tr td { table.diff tbody tr.header { background-image: -webkit-gradient(linear,left top,left bottom, color-stop(0, rgba(244, 244, 244,1)), color-stop(1, rgba(215,215,215,1))); -} \ No newline at end of file +} + +table.diff .filemerge { + float: right; + text-align: center; +} + +#diff { + width: 100%; + display: block; + overflow: auto; +} + +#diff table.diff { + -webkit-box-shadow: 5px 5px 5px #ccc; + width: 98%; + margin: auto auto 20px 1%; +} From 95cb498e378bb5a97f247c6e2ff645d97810e95e Mon Sep 17 00:00:00 2001 From: German Laullon Date: Fri, 18 Mar 2011 12:58:21 -0700 Subject: [PATCH 10/36] [14] The "blame", "history" and "diff" commands are broken Related with tabs & spaces --- GLFileView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GLFileView.m b/GLFileView.m index 77ba04e..1c3bc06 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -119,6 +119,7 @@ id script = [view windowScriptObject]; if(!theError){ NSString *filePath = [file fullPath]; + fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"\t" withString:@"    "]; [script callWebScriptMethod:@"showFile" withArguments:[NSArray arrayWithObjects:fileTxt, filePath, nil]]; }else{ [script callWebScriptMethod:@"setMessage" withArguments:[NSArray arrayWithObjects:[theError localizedDescription], nil]]; @@ -218,7 +219,6 @@ txt=[txt stringByReplacingOccurrencesOfString:@"&" withString:@"&"]; txt=[txt stringByReplacingOccurrencesOfString:@"<" withString:@"<"]; txt=[txt stringByReplacingOccurrencesOfString:@">" withString:@">"]; - txt=[txt stringByReplacingOccurrencesOfString:@"\t" withString:@"    "]; return txt; } From 1ec2ef2596a729116dbac6c79752672d27aa232a Mon Sep 17 00:00:00 2001 From: German Laullon Date: Sat, 19 Mar 2011 13:32:30 -0700 Subject: [PATCH 11/36] FileMerge.app on FileView diffs --- GLFileView.h | 2 ++ GLFileView.m | 25 ++++++++++++++++++++----- PBWebHistoryController.h | 2 +- PBWebHistoryController.m | 10 ++++++---- html/views/diff/diffWindow.js | 8 ++++++++ html/views/history/history.js | 7 +++++-- 6 files changed, 42 insertions(+), 12 deletions(-) diff --git a/GLFileView.h b/GLFileView.h index a734dd0..ea43ccf 100644 --- a/GLFileView.h +++ b/GLFileView.h @@ -42,6 +42,8 @@ +(BOOL)isImage:(NSString*)file; +(BOOL)isDiffHeader:(NSString*)line; +- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2; + @property(retain) NSMutableArray *groups; @property(retain) NSString *logFormat; diff --git a/GLFileView.m b/GLFileView.m index 1c3bc06..7ead74b 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -120,6 +120,12 @@ if(!theError){ NSString *filePath = [file fullPath]; fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"\t" withString:@"    "]; + fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA}" withString:file.sha]; + if(diffType==@"h") { + fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA2}" withString:@"HEAD"]; + }else { + fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA2}" withString:@"--"]; + } [script callWebScriptMethod:@"showFile" withArguments:[NSArray arrayWithObjects:fileTxt, filePath, nil]]; }else{ [script callWebScriptMethod:@"setMessage" withArguments:[NSArray arrayWithObjects:[theError localizedDescription], nil]]; @@ -140,6 +146,13 @@ [historyController selectCommit:[PBGitSHA shaWithString:c]]; } +// TODO: need to be refactoring +- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2; +{ + NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",sha,sha2,file,nil]; + [historyController.repository handleInWorkDirForArguments:args]; +} + #pragma mark MGScopeBarDelegate methods - (int)numberOfGroupsInScopeBar:(MGScopeBar *)theScopeBar @@ -275,10 +288,10 @@ NSArray *lines = [txt componentsSeparatedByString:@"\n"]; NSString *line; NSMutableString *res=[NSMutableString string]; - + int l_line,l_end; int r_line,r_end; - + int i=0; do { line=[lines objectAtIndex:i]; @@ -291,10 +304,10 @@ }while([GLFileView isDiffHeader:line]); [res appendString:@""]; if(![self isBinaryFile:line]){ - [res appendString:[NSString stringWithFormat:@"",fileName]]; + [res appendString:[NSString stringWithFormat:@"",fileName]]; } [res appendString:@""]; - + if([self isBinaryFile:line]){ NSArray *files=[self getFilesNames:line]; if(![[files objectAtIndex:0] isAbsolutePath]){ @@ -340,7 +353,9 @@ }else if([s isEqualToString:@"+"]){ [res appendString:[NSString stringWithFormat:@"%d",r_line++]]; } - [res appendString:[NSString stringWithFormat:@"%@",[line substringFromIndex:1]]]; + if(![s isEqualToString:@"\\"]){ + [res appendString:[NSString stringWithFormat:@"%@",[line substringFromIndex:1]]]; + } }while((l_line%@",header,fileList,diffs]; - html=[html stringByReplacingOccurrencesOfString:@"{SHA}" withString:[currentSha string]]; + html=[html stringByReplacingOccurrencesOfString:@"{SHA}" withString:[NSString stringWithFormat:@"%@^",[currentSha string]]]; + html=[html stringByReplacingOccurrencesOfString:@"{SHA2}" withString:[currentSha string]]; [[view windowScriptObject] callWebScriptMethod:@"showCommit" withArguments:[NSArray arrayWithObject:html]]; @@ -224,10 +225,11 @@ [historyController selectCommit:[PBGitSHA shaWithString:sha]]; } -- (void) openFileMerge:(NSString*)file sha:(NSString *)sha +// TODO: need to be refactoring +- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2 { - NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",[NSString stringWithFormat:@"%@^",sha],sha,@"--",file,nil]; - [historyController.repository handleForArguments:args]; + NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",sha,sha2,@"--",file,nil]; + [historyController.repository handleInWorkDirForArguments:args]; } diff --git a/html/views/diff/diffWindow.js b/html/views/diff/diffWindow.js index 61eeb7c..cb33f92 100644 --- a/html/views/diff/diffWindow.js +++ b/html/views/diff/diffWindow.js @@ -9,3 +9,11 @@ var showFile = function(txt) { $("diff").innerHTML = txt; $("message").style.display = "none"; } + +// TODO: need to be refactoring +var openFileMerge = function(file,sha,sha2) { + alert(file); + alert(sha); + alert(sha2); + Controller.openFileMerge_sha_sha2_(file,sha,sha2); +} diff --git a/html/views/history/history.js b/html/views/history/history.js index 6a3b3e1..9a4057a 100644 --- a/html/views/history/history.js +++ b/html/views/history/history.js @@ -1,11 +1,14 @@ +// TODO: need to be refactoring var selectCommit = function(a) { Controller.selectCommit_(a); } -var openFileMerge = function(file,sha) { +// TODO: need to be refactoring +var openFileMerge = function(file,sha,sha2) { alert(file); alert(sha); - Controller.openFileMerge_sha_(file,sha); + alert(sha2); + Controller.openFileMerge_sha_sha2_(file,sha,sha2); } var showImage = function(element, filename) From 6d95d179abfd0398617054796a36b0b40dd16a1e Mon Sep 17 00:00:00 2001 From: apla Date: Wed, 30 Mar 2011 00:56:35 +0400 Subject: [PATCH 12/36] reload commit history after commit --- PBGitCommitController.m | 1 + 1 file changed, 1 insertion(+) diff --git a/PBGitCommitController.m b/PBGitCommitController.m index 4d236ac..f0e42e0 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -172,6 +172,7 @@ [commitMessageView setEditable:YES]; [commitMessageView setString:@""]; [webController setStateMessage:[NSString stringWithFormat:[[notification userInfo] objectForKey:@"description"]]]; + [repository reloadRefs]; } - (void)commitFailed:(NSNotification *)notification From 8cafefbb8feb400dd62691e2c0ffe11a2cfab3d4 Mon Sep 17 00:00:00 2001 From: apla Date: Wed, 30 Mar 2011 00:58:42 +0400 Subject: [PATCH 13/36] retain selected commit position in commit history ticket #281 --- PBGitHistoryController.h | 1 + PBGitHistoryController.m | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index 4db3210..8d9472c 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -55,6 +55,7 @@ PBGitTree *gitTree; PBGitCommit *webCommit; PBGitCommit *selectedCommit; + PBGitCommit *selectedCommitBeforeRefresh; } @property (readonly) NSTreeController* treeController; diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index ab221f1..1187525 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -250,7 +250,9 @@ }else if([(NSString *)context isEqualToString:@"updateCommitCount"] || [(NSString *)context isEqualToString:@"revisionListUpdating"]) { [self updateStatus]; - if ([repository.currentBranch isSimpleRef]) + if (selectedCommitBeforeRefresh && [repository commitForSHA:[selectedCommitBeforeRefresh sha]]) + [self selectCommit:[selectedCommitBeforeRefresh sha]]; + else if ([repository.currentBranch isSimpleRef]) [self selectCommit:[repository shaForRef:[repository.currentBranch ref]]]; else [self selectCommit:[[self firstCommit] sha]]; @@ -405,6 +407,7 @@ - (IBAction) refresh:(id)sender { + selectedCommitBeforeRefresh = selectedCommit; [repository forceUpdateRevisions]; } From 78955b5717b3bd9a639033a2e40903a44707e116 Mon Sep 17 00:00:00 2001 From: apla Date: Wed, 30 Mar 2011 00:59:49 +0400 Subject: [PATCH 14/36] fix for push error when origin has mirror flag --- PBGitRepository.m | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/PBGitRepository.m b/PBGitRepository.m index 9362568..cce1bad 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -690,22 +690,34 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; } NSString *remoteName = [remoteRef remoteName]; [arguments addObject:remoteName]; - + NSString *branchName = nil; - if ([ref isRemote] || !ref) { - branchName = @"all updates"; - } - else if ([ref isTag]) { - branchName = [NSString stringWithFormat:@"tag '%@'", [ref tagName]]; - [arguments addObject:@"tag"]; - [arguments addObject:[ref tagName]]; - } - else { - branchName = [ref shortName]; - [arguments addObject:branchName]; + NSString *actionType = nil; + + if ([config valueForKeyPath:[NSString stringWithFormat:@"remote.%@.mirror", remoteName]]) { + // we must check for mirror parameter in config. + // if we push branch name in this case to the arguments, push failed + actionType = @"Mirroring"; + } else { + + if ([ref isRemote] || !ref) { + branchName = @"all updates"; + } + else if ([ref isTag]) { + branchName = [NSString stringWithFormat:@"tag '%@'", [ref tagName]]; + [arguments addObject:@"tag"]; + [arguments addObject:[ref tagName]]; + } + else { + branchName = [ref shortName]; + [arguments addObject:branchName]; + } + + actionType = [NSString stringWithFormat:@"Pushing %@", branchName]; + } - NSString *description = [NSString stringWithFormat:@"Pushing %@ to %@", branchName, remoteName]; + NSString *description = [actionType stringByAppendingFormat:@" to %@", remoteName]; NSString *title = @"Pushing to remote"; [PBRemoteProgressSheet beginRemoteProgressSheetForArguments:arguments title:title description:description inRepository:self]; } From 816be194b5c8e9a52917f43dc67c76b47e678374 Mon Sep 17 00:00:00 2001 From: apla Date: Wed, 30 Mar 2011 02:00:26 +0400 Subject: [PATCH 15/36] diff can contain no changes, permissions only --- GLFileView.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/GLFileView.m b/GLFileView.m index 77ba04e..a08850f 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -287,7 +287,9 @@ [res appendString:[NSString stringWithFormat:@""]; + if (!line) + break; // do nothing, this is probably header-only diff (permissions change, maybe) + if([self isBinaryFile:line]){ NSArray *files=[self getFilesNames:line]; if(![[files objectAtIndex:0] isAbsolutePath]){ From dcb3bd8abedafb5ead84abde663fe8b5595ab4f4 Mon Sep 17 00:00:00 2001 From: Ole Zorn Date: Sun, 16 Jan 2011 08:41:10 +0800 Subject: [PATCH 16/36] Removed logs --- PBGitRepository.m | 2 +- PBGitWindowController.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PBGitRepository.m b/PBGitRepository.m index cce1bad..0ca06a6 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -1282,7 +1282,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; - (void) finalize { - NSLog(@"Dealloc of repository"); + //NSLog(@"Dealloc of repository"); [super finalize]; } @end diff --git a/PBGitWindowController.m b/PBGitWindowController.m index c4a445e..fb40446 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -33,7 +33,7 @@ - (void)windowWillClose:(NSNotification *)notification { - NSLog(@"Window will close!"); + //NSLog(@"Window will close!"); if (sidebarController) [sidebarController closeView]; From 21ad166517248250f9ebbde3ac75a09e7e97825f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leszek=20S=CC=81laz=CC=87yn=CC=81ski?= Date: Mon, 14 Mar 2011 03:37:45 +0800 Subject: [PATCH 17/36] Build fixes - do not analye on every build - sync submodule url --- GitX.xcodeproj/project.pbxproj | 2 -- build_libgit2.sh | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index b42442e..a2035d9 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -1845,7 +1845,6 @@ INFOPLIST_PREPROCESS = YES; MACOSX_DEPLOYMENT_TARGET = 10.5; PREBINDING = NO; - RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = macosx10.5; }; name = Debug; @@ -1862,7 +1861,6 @@ INFOPLIST_PREPROCESS = YES; MACOSX_DEPLOYMENT_TARGET = 10.5; PREBINDING = NO; - RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = macosx10.5; }; name = Release; diff --git a/build_libgit2.sh b/build_libgit2.sh index 424cabf..27f4346 100755 --- a/build_libgit2.sh +++ b/build_libgit2.sh @@ -14,6 +14,7 @@ buildAction () { then export PATH=$PATH:$HOME/bin:$HOME/local/bin:/sw/bin:/opt/local/bin:`"$TARGET_BUILD_DIR"/gitx --git-path` git submodule init + git submodule sync git submodule update cd libgit2 rm -f libgit2.a From f6d7fea449aeae6080ffae153edc3c6518e4b436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leszek=20S=CC=81laz=CC=87yn=CC=81ski?= Date: Sun, 20 Mar 2011 01:52:30 +0800 Subject: [PATCH 18/36] Bugfix: sidebar and history out of sync after commit --- PBGitHistoryController.m | 1 + PBGitIndex.m | 1 + 2 files changed, 2 insertions(+) diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index 1187525..657b2df 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -413,6 +413,7 @@ - (void) updateView { + [self refresh: nil]; [self updateKeys]; } diff --git a/PBGitIndex.m b/PBGitIndex.m index ae2cad7..4c63ab2 100644 --- a/PBGitIndex.m +++ b/PBGitIndex.m @@ -235,6 +235,7 @@ NSString *PBGitIndexOperationFailed = @"PBGitIndexOperationFailed"; return; repository.hasChanged = YES; + [repository reloadRefs]; amendEnvironment = nil; if (amend) From f0f5c916dd05679a75d9a4c46f8fd7db101a833a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leszek=20S=CC=81laz=CC=87yn=CC=81ski?= Date: Sun, 20 Mar 2011 10:28:08 +0800 Subject: [PATCH 19/36] Workaround for 'refresh' not refreshing everything --- PBGitWindowController.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PBGitWindowController.m b/PBGitWindowController.m index fb40446..294fb23 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -175,7 +175,8 @@ - (IBAction) refresh:(id)sender { - [contentController refresh:self]; + [sidebarController.historyViewController refresh: self]; + [sidebarController.commitViewController refresh: self]; } - (void) updateStatus From 18027a02ef5f31089ed07a3864cc210d43e1ff79 Mon Sep 17 00:00:00 2001 From: apla Date: Wed, 30 Mar 2011 09:30:36 +0400 Subject: [PATCH 20/36] fix for git error: No submodule mapping found in .gitmodules for path "..." --- Controller/PBSubmoduleController.m | 3 ++- Model/PBGitSubmodule.h | 1 + Model/PBGitSubmodule.m | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Controller/PBSubmoduleController.m b/Controller/PBSubmoduleController.m index c789778..cd45014 100644 --- a/Controller/PBSubmoduleController.m +++ b/Controller/PBSubmoduleController.m @@ -42,7 +42,8 @@ if ([submoduleLine length] == 0) continue; PBGitSubmodule *submodule = [[PBGitSubmodule alloc] initWithRawSubmoduleStatusString:submoduleLine]; - [loadedSubmodules addObject:submodule]; + if (submodule) + [loadedSubmodules addObject:submodule]; } NSMutableArray *groupedSubmodules = [[NSMutableArray alloc] init]; diff --git a/Model/PBGitSubmodule.h b/Model/PBGitSubmodule.h index 5d1db18..88d6789 100644 --- a/Model/PBGitSubmodule.h +++ b/Model/PBGitSubmodule.h @@ -13,6 +13,7 @@ typedef enum { PBGitSubmoduleStateNotInitialized, PBGitSubmoduleStateMatchingIndex, PBGitSubmoduleStateDoesNotMatchIndex, + PBGitSubmoduleStateFailed, } PBGitSubmoduleState; @interface PBGitSubmodule : NSObject { diff --git a/Model/PBGitSubmodule.m b/Model/PBGitSubmodule.m index 3bb6a1b..56b1140 100644 --- a/Model/PBGitSubmodule.m +++ b/Model/PBGitSubmodule.m @@ -35,6 +35,10 @@ if ((self = [super init])) { unichar status = [submoduleStatusString characterAtIndex:0]; submoduleState = [PBGitSubmodule submoduleStateFromCharacter:status]; + if (submoduleState == PBGitSubmoduleStateFailed) { + NSLog(@"Submodule status failed:\n %@", submoduleStatusString); + return nil; + } NSScanner *scanner = [NSScanner scannerWithString:[submoduleStatusString substringFromIndex:1]]; NSString *sha1 = nil; NSString *fullPath = nil; @@ -114,7 +118,7 @@ } else if (character == '+') { state = PBGitSubmoduleStateDoesNotMatchIndex; } else if (character != ' ') { - NSAssert1(NO, @"Ooops unsupported submodule status character: %c", character); + return PBGitSubmoduleStateFailed; } return state; From c0965e37707966a988792343493588a0efca1e9c Mon Sep 17 00:00:00 2001 From: German Laullon Date: Wed, 30 Mar 2011 00:11:41 -0700 Subject: [PATCH 21/36] basic search capability on FileVew --- GLFileView.h | 4 + GLFileView.m | 22 +- GitX.xcodeproj/project.pbxproj | 10 + PBGitHistoryView.xib | 1437 ++++---------------------------- SearchWebView.h | 18 + SearchWebView.m | 97 +++ html/css/GitX.css | 4 + html/lib/SearchWebView.js | 100 +++ html/views/fileview/index.html | 1 + 9 files changed, 434 insertions(+), 1259 deletions(-) create mode 100644 SearchWebView.h create mode 100644 SearchWebView.m create mode 100644 html/lib/SearchWebView.js diff --git a/GLFileView.h b/GLFileView.h index ea43ccf..a7a5a06 100644 --- a/GLFileView.h +++ b/GLFileView.h @@ -12,6 +12,7 @@ #import "PBGitCommit.h" #import "PBGitHistoryController.h" #import "PBRefContextDelegate.h" +#import "SearchWebView.h" @class PBGitGradientBarView; @@ -23,6 +24,7 @@ NSString *diffType; IBOutlet NSView *accessoryView; IBOutlet NSSplitView *fileListSplitView; + IBOutlet NSSearchField *searchField; } - (void)showFile; @@ -44,6 +46,8 @@ - (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2; +-(IBAction)updateSearch:(NSSearchField *)sender; + @property(retain) NSMutableArray *groups; @property(retain) NSString *logFormat; diff --git a/GLFileView.m b/GLFileView.m index 7ead74b..255af36 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -131,11 +131,14 @@ [script callWebScriptMethod:@"setMessage" withArguments:[NSArray arrayWithObjects:[theError localizedDescription], nil]]; } } + + [self updateSearch:searchField]; #ifdef DEBUG_BUILD - NSString *dom=[[[[view mainFrame] DOMDocument] documentElement] outerHTML]; + DOMHTMLElement *dom=(DOMHTMLElement *)[[[view mainFrame] DOMDocument] documentElement]; + NSString *domH=[dom outerHTML]; NSString *tmpFile=@"~/tmp/test.html"; - [dom writeToFile:[tmpFile stringByExpandingTildeInPath] atomically:true encoding:NSUTF8StringEncoding error:nil]; + [domH writeToFile:[tmpFile stringByExpandingTildeInPath] atomically:true encoding:NSUTF8StringEncoding error:nil]; #endif } @@ -583,6 +586,21 @@ [fileListSplitView setHidden:NO]; } +#pragma mark IBActions + +-(IBAction)updateSearch:(NSSearchField *)sender +{ + NSString *searchString = [sender stringValue]; + NSLog(@"searchString:%@",searchString); + + if([searchString length]>0){ + [view highlightAllOccurencesOfString:searchString]; + }else{ + [view removeAllHighlights]; + } +} + +#pragma mark - @synthesize groups; diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index b42442e..c26e33e 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -62,6 +62,8 @@ 31460CD6124185BA00B90AED /* TODO in Resources */ = {isa = PBXBuildFile; fileRef = 31460CB1124185BA00B90AED /* TODO */; }; 316E7202131EE9C600AFBB36 /* list_Template.png in Resources */ = {isa = PBXBuildFile; fileRef = 316E7200131EE9C600AFBB36 /* list_Template.png */; }; 316E7203131EE9C600AFBB36 /* sidebar_Template.png in Resources */ = {isa = PBXBuildFile; fileRef = 316E7201131EE9C600AFBB36 /* sidebar_Template.png */; }; + 3177607D133554A80025876E /* SearchWebView.js in Sources */ = {isa = PBXBuildFile; fileRef = 3177607C133554A80025876E /* SearchWebView.js */; }; + 31776089133569350025876E /* SearchWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 31776088133569350025876E /* SearchWebView.m */; }; 31DAA7ED1317737100463846 /* gitx_l_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 31DAA7EC1317737100463846 /* gitx_l_pub.pem */; }; 3BC07F4C0ED5A5C5009A7768 /* HistoryViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */; }; 3BC07F4D0ED5A5C5009A7768 /* CommitViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4B0ED5A5C5009A7768 /* CommitViewTemplate.png */; }; @@ -353,6 +355,9 @@ 31460CB1124185BA00B90AED /* TODO */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TODO; sourceTree = ""; }; 316E7200131EE9C600AFBB36 /* list_Template.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = list_Template.png; sourceTree = ""; }; 316E7201131EE9C600AFBB36 /* sidebar_Template.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = sidebar_Template.png; sourceTree = ""; }; + 3177607C133554A80025876E /* SearchWebView.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = SearchWebView.js; path = html/lib/SearchWebView.js; sourceTree = ""; }; + 31776087133569350025876E /* SearchWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchWebView.h; sourceTree = ""; }; + 31776088133569350025876E /* SearchWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SearchWebView.m; sourceTree = ""; }; 31DAA7EC1317737100463846 /* gitx_l_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = gitx_l_pub.pem; sourceTree = ""; }; 32CA4F630368D1EE00C91783 /* GitX_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GitX_Prefix.pch; sourceTree = ""; }; 3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = HistoryViewTemplate.png; path = Images/HistoryViewTemplate.png; sourceTree = ""; }; @@ -761,6 +766,7 @@ 29B97314FDCFA39411CA2CEA /* GitTest */ = { isa = PBXGroup; children = ( + 3177607C133554A80025876E /* SearchWebView.js */, F5886A080ED5D26B0066E74C /* SpeedTest */, 913D5E420E5563FD00CECEA2 /* cli */, D89E9B4C1218C22A0097A90B /* GitXScripting */, @@ -1084,6 +1090,8 @@ D8EB6169122F643E00FCCAF4 /* GitXRelativeDateFormatter.m */, D87129FE122B14EC00012334 /* GitXTextFieldCell.h */, D87129FF122B14EC00012334 /* GitXTextFieldCell.m */, + 31776087133569350025876E /* SearchWebView.h */, + 31776088133569350025876E /* SearchWebView.m */, ); name = Aux; sourceTree = ""; @@ -1616,6 +1624,8 @@ 217FF0BB12A1CB3300785A65 /* PBGitResetController.m in Sources */, 217FF0BE12A1CB3E00785A65 /* PBRevealWithFinderCommand.m in Sources */, 65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */, + 3177607D133554A80025876E /* SearchWebView.js in Sources */, + 31776089133569350025876E /* SearchWebView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/PBGitHistoryView.xib b/PBGitHistoryView.xib index 1671ac9..30ae89a 100644 --- a/PBGitHistoryView.xib +++ b/PBGitHistoryView.xib @@ -2,10 +2,10 @@ 1050 - 10J567 - 762 + 10J869 + 1305 1038.35 - 462.00 + 461.00 YES @@ -15,13 +15,38 @@ YES - 762 - 762 + 1305 + 30 - + YES - + WebView + NSButton + NSCustomObject + NSArrayController + NSSplitView + NSTableView + NSCustomView + NSDateFormatter + NSSearchField + NSTextField + NSSearchFieldCell + NSTextFieldCell + NSTreeController + NSButtonCell + NSTableColumn + NSSegmentedControl + NSBox + NSView + NSOutlineView + NSScrollView + NSTabViewItem + NSProgressIndicator + NSSegmentedCell + NSScroller + NSTableHeaderView + NSTabView YES @@ -113,6 +138,7 @@ 292 {{267, 3}, {71, 25}} + YES -2080244224 @@ -155,6 +181,7 @@ 268 {{206, 3}, {37, 25}} + YES -2080244224 @@ -179,6 +206,7 @@ 268 {{161, 3}, {37, 25}} + YES -2080244224 @@ -203,6 +231,7 @@ 268 {{116, 3}, {37, 25}} + YES -2080244224 @@ -227,6 +256,7 @@ 268 {{55, 3}, {37, 25}} + YES -2080244224 @@ -251,6 +281,7 @@ 268 {{10, 3}, {37, 25}} + YES -2080244224 @@ -275,6 +306,7 @@ 10 {{0, -2}, {955, 5}} + {0, 0} 67239424 @@ -303,6 +335,7 @@ {{0, 404}, {955, 30}} + PBGitGradientBarView @@ -320,6 +353,7 @@ 10 {{0, 144}, {955, 5}} + {0, 0} 67239424 @@ -352,12 +386,14 @@ 4352 {955, 130} + YES 256 {955, 17} + @@ -365,6 +401,7 @@ -2147483392 {{-26, 0}, {16, 17}} + YES @@ -491,7 +528,7 @@ - MMMM d, yyyy h:mm a + d 'de' MMMM 'de' yyyy HH:mm NO @@ -630,6 +667,7 @@ -2147483392 {{837, 17}, {15, 179}} + _doScroller: 0.87603306770324707 @@ -639,6 +677,7 @@ -2147483392 {{0, 123}, {852, 15}} + 1 _doScroller: @@ -683,6 +722,7 @@ {{740, 3}, {16, 16}} + 20746 100 @@ -691,6 +731,7 @@ 265 {{765, 2}, {180, 19}} + YES 343014976 @@ -752,6 +793,7 @@ 265 {{714, 3}, {43, 18}} + YES 67239424 @@ -788,6 +830,7 @@ 265 {{630, 5}, {80, 14}} + YES 68288064 @@ -809,6 +852,7 @@ 268 {{49, 2}, {57, 17}} + 1 YES @@ -834,6 +878,7 @@ 268 {{114, 2}, {103, 17}} + 2 YES @@ -855,6 +900,7 @@ 268 {{11, 2}, {30, 17}} + YES 67239424 @@ -873,11 +919,13 @@ {{0, 147}, {955, 24}} + PBGitGradientBarView {955, 171} + NSView @@ -890,6 +938,7 @@ 18 {955, 233} + YES @@ -951,6 +1000,7 @@ {955, 233} + Details @@ -978,12 +1028,13 @@ 266 {{5, 212.5}, {196, 19}} + YES 343014976 268698624 - + LucidaGrande 9 3614 @@ -1053,6 +1104,7 @@ 4368 {190, 208} + YES @@ -1117,6 +1169,7 @@ 256 {{191, 1}, {15, 208}} + _doScroller: 0.98701298701298701 @@ -1126,6 +1179,7 @@ -2147483392 {{-100, -100}, {502, 15}} + 1 _doScroller: @@ -1145,6 +1199,7 @@ {207, 235} + NSView @@ -1162,11 +1217,74 @@ 265 YES + + + 268 + {{50, 2}, {158, 19}} + + + YES + + 343014976 + 268698688 + + + + YES + 1 + + + + 130560 + 0 + search + + _searchFieldSearch: + + 138690815 + 0 + + 400 + 75 + + + 130560 + 0 + clear + + YES + + YES + + YES + AXDescription + NSAccessibilityEncodedAttributesValueType + + + YES + cancel + + + + + + _searchFieldCancel: + + 138690815 + 0 + + 400 + 75 + + 255 + + 289 - {{41, 1.5}, {29, 19}} + {{216, 1}, {29, 19}} + YES -2080244224 @@ -1191,18 +1309,20 @@ - {{665, 0}, {84, 24}} + {{490, 0}, {259, 24}} + NSView {{0, 211}, {749, 24}} + MGScopeBar - 274 + 4370 YES @@ -1230,23 +1350,26 @@ - YES + NO YES {{208, 0}, {749, 235}} + NSView {{-1, -1}, {957, 235}} + YES 2 {955, 233} + Tree @@ -1266,16 +1389,19 @@ {{0, 172}, {955, 233}} + NSView {955, 405} + 2 {955, 434} + NSView @@ -2091,6 +2217,22 @@ 495 + + + updateSearch: + + + + 506 + + + + searchField + + + + 508 + @@ -2649,6 +2791,7 @@ YES + @@ -2735,6 +2878,20 @@ + + 496 + + + YES + + + + + + 497 + + + @@ -2853,6 +3010,8 @@ 491.IBPluginDependency 492.IBPluginDependency 493.IBPluginDependency + 496.IBPluginDependency + 497.IBPluginDependency 50.IBPluginDependency 51.IBPluginDependency 6.IBPluginDependency @@ -2879,9 +3038,7 @@ YES - - YES - + com.apple.WebKitIBPlugin PBCommitList @@ -3013,9 +3170,7 @@ YES - - YES - + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3057,1256 +3212,25 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin YES - - YES - + YES - - YES - + - 495 - - - - YES - - GLFileView - PBWebController - - YES - - YES - accessoryView - fileListSplitView - historyController - typeBar - - - YES - NSView - NSSplitView - PBGitHistoryController - MGScopeBar - - - - IBProjectSource - GLFileView.h - - - - GitXRelativeDateFormatter - NSFormatter - - IBProjectSource - GitXRelativeDateFormatter.h - - - - GitXTextFieldCell - NSTextFieldCell - - contextMenuDelegate - id - - - IBProjectSource - GitXTextFieldCell.h - - - - MGScopeBar - NSView - - delegate - id - - - IBProjectSource - MGScopeBar/MGScopeBar.h - - - - NSApplication - - IBProjectSource - NSApplication+GitXScripting.h - - - - NSCell - - IBProjectSource - View/CellTrackingRect.h - - - - NSOutlineView - - IBProjectSource - NSOutlineViewExt.h - - - - PBCollapsibleSplitView - PBNiceSplitView - - IBProjectSource - PBCollapsibleSplitView.h - - - - PBCommitList - NSTableView - - YES - - YES - controller - searchController - webController - webView - - - YES - PBGitHistoryController - PBHistorySearchController - PBWebHistoryController - WebView - - - - IBProjectSource - PBCommitList.h - - - - PBGitGradientBarView - NSView - - IBProjectSource - PBGitGradientBarView.h - - - - PBGitGradientBarView - NSView - - IBUserSource - - - - - PBGitHistoryController - PBViewController - - YES - - YES - cherryPick: - createBranch: - createTag: - merge: - openFilesAction: - openSelectedFile: - rebase: - refresh: - selectNext: - selectPrevious: - setBranchFilter: - setDetailedView: - setTreeView: - showAddRemoteSheet: - showCommitsFromTree: - showInFinderAction: - toggleQLPreviewPanel: - updateSearch: - - - YES - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - - - - YES - - YES - allBranchesFilterItem - cherryPickButton - commitController - commitList - fileBrowser - fileView - filesSearchField - historySplitView - localRemoteBranchesFilterItem - mergeButton - rebaseButton - refController - scopeBarView - searchController - searchField - selectedBranchFilterItem - treeController - upperToolbarView - webHistoryController - webView - - - YES - NSButton - NSButton - NSArrayController - PBCommitList - NSOutlineView - GLFileView - NSSearchField - PBCollapsibleSplitView - NSButton - NSButton - NSButton - PBRefController - PBGitGradientBarView - PBHistorySearchController - NSSearchField - NSButton - NSTreeController - PBGitGradientBarView - PBWebHistoryController - id - - - - IBProjectSource - PBGitHistoryController.h - - - - PBGitHistoryController - PBViewController - - IBUserSource - - - - - PBGitRevisionCell - NSActionCell - - YES - - YES - contextMenuDelegate - controller - - - YES - id - PBGitHistoryController - - - - IBProjectSource - PBGitRevisionCell.h - - - - PBHistorySearchController - NSObject - - YES - - YES - selectSearchMode: - stepperPressed: - updateSearch: - - - YES - id - id - id - - - - YES - - YES - commitController - historyController - numberOfMatchesField - progressIndicator - searchField - stepper - - - YES - NSArrayController - PBGitHistoryController - NSTextField - NSProgressIndicator - NSSearchField - NSSegmentedControl - - - - IBProjectSource - PBHistorySearchController.h - - - - PBIconAndTextCell - NSTextFieldCell - - IBProjectSource - PBIconAndTextCell.h - - - - PBNiceSplitView - NSSplitView - - IBProjectSource - PBNiceSplitView.h - - - - PBQLOutlineView - NSOutlineView - - controller - PBGitHistoryController - - - IBProjectSource - PBQLOutlineView.h - - - - PBRefController - NSObject - - YES - - YES - checkout: - cherryPick: - copyPatch: - copySHA: - createBranch: - createTag: - diffWithHEAD: - fetchRemote: - merge: - pullRemote: - pushDefaultRemoteForRef: - pushToRemote: - pushUpdatesToRemote: - rebaseHeadBranch: - showTagInfoSheet: - - - YES - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - PBRefMenuItem - - - - YES - - YES - branchPopUp - commitController - commitList - historyController - - - YES - NSPopUpButton - NSArrayController - PBCommitList - PBGitHistoryController - - - - IBProjectSource - PBRefController.h - - - - PBRefMenuItem - NSMenuItem - - refish - id - - - IBProjectSource - PBRefMenuItem.h - - - - PBUnsortableTableHeader - NSTableHeaderView - - controller - NSArrayController - - - IBProjectSource - PBUnsortableTableHeader.h - - - - PBViewController - NSViewController - - refresh: - id - - - IBProjectSource - PBViewController.h - - - - PBWebController - NSObject - - YES - - YES - repository - view - - - YES - id - WebView - - - - IBProjectSource - PBWebController.h - - - - PBWebHistoryController - PBWebController - - YES - - YES - contextMenuDelegate - historyController - - - YES - id - PBGitHistoryController - - - - IBProjectSource - PBWebHistoryController.h - - - - PBWebHistoryController - PBWebController - - view - WebView - - - IBUserSource - - - - - - YES - - NSActionCell - NSCell - - IBFrameworkSource - AppKit.framework/Headers/NSActionCell.h - - - - NSApplication - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSApplication.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSApplicationScripting.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSColorPanel.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSHelpManager.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSPageLayout.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSUserInterfaceItemSearching.h - - - - NSArrayController - NSObjectController - - IBFrameworkSource - AppKit.framework/Headers/NSArrayController.h - - - - NSBox - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSBox.h - - - - NSButton - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSButton.h - - - - NSButtonCell - NSActionCell - - IBFrameworkSource - AppKit.framework/Headers/NSButtonCell.h - - - - NSCell - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSCell.h - - - - NSControl - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSControl.h - - - - NSController - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSController.h - - - - NSDateFormatter - NSFormatter - - IBFrameworkSource - Foundation.framework/Headers/NSDateFormatter.h - - - - NSFormatter - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFormatter.h - - - - NSManagedObjectContext - NSObject - - IBFrameworkSource - CoreData.framework/Headers/NSManagedObjectContext.h - - - - NSMenu - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSMenu.h - - - - NSMenuItem - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSMenuItem.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSAccessibility.h - - - - NSObject - - - - NSObject - - - - NSObject - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDictionaryController.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDragging.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSFontManager.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSFontPanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSKeyValueBinding.h - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSNibLoading.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSOutlineView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSPasteboard.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSSavePanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTableView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSToolbarItem.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSView.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSArchiver.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSClassDescription.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSError.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFileManager.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueCoding.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueObserving.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyedArchiver.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSObject.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSObjectScripting.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSPortCoder.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSRunLoop.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptClassDescription.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptKeyValueCoding.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptObjectSpecifiers.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptWhoseTests.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSThread.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURL.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURLConnection.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURLDownload.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CAAnimation.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CALayer.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CIImageProvider.h - - - - NSObject - - IBFrameworkSource - ScriptingBridge.framework/Headers/SBApplication.h - - - - NSObject - - IBFrameworkSource - Sparkle.framework/Headers/SUAppcast.h - - - - NSObject - - IBFrameworkSource - Sparkle.framework/Headers/SUUpdater.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebDownload.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebEditingDelegate.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebFrameLoadDelegate.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebJavaPlugIn.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebPlugin.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebPluginContainer.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebPolicyDelegate.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebResourceLoadDelegate.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebScriptObject.h - - - - NSObject - - IBFrameworkSource - WebKit.framework/Headers/WebUIDelegate.h - - - - NSObjectController - NSController - - IBFrameworkSource - AppKit.framework/Headers/NSObjectController.h - - - - NSOutlineView - NSTableView - - - - NSPopUpButton - NSButton - - IBFrameworkSource - AppKit.framework/Headers/NSPopUpButton.h - - - - NSProgressIndicator - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSProgressIndicator.h - - - - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSInterfaceStyle.h - - - - NSResponder - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSResponder.h - - - - NSScrollView - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSScrollView.h - - - - NSScroller - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSScroller.h - - - - NSSearchField - NSTextField - - IBFrameworkSource - AppKit.framework/Headers/NSSearchField.h - - - - NSSearchFieldCell - NSTextFieldCell - - IBFrameworkSource - AppKit.framework/Headers/NSSearchFieldCell.h - - - - NSSegmentedCell - NSActionCell - - IBFrameworkSource - AppKit.framework/Headers/NSSegmentedCell.h - - - - NSSegmentedControl - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSSegmentedControl.h - - - - NSSplitView - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSSplitView.h - - - - NSTabView - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSTabView.h - - - - NSTabViewItem - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTabViewItem.h - - - - NSTableColumn - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTableColumn.h - - - - NSTableHeaderView - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSTableHeaderView.h - - - - NSTableView - NSControl - - - - NSTextField - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSTextField.h - - - - NSTextFieldCell - NSActionCell - - IBFrameworkSource - AppKit.framework/Headers/NSTextFieldCell.h - - - - NSTreeController - NSObjectController - - IBFrameworkSource - AppKit.framework/Headers/NSTreeController.h - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSClipView.h - - - - NSView - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSRulerView.h - - - - NSView - NSResponder - - - - NSViewController - NSResponder - - view - NSView - - - IBFrameworkSource - AppKit.framework/Headers/NSViewController.h - - - - WebView - NSView - - YES - - YES - goBack: - goForward: - makeTextLarger: - makeTextSmaller: - makeTextStandardSize: - reload: - reloadFromOrigin: - stopLoading: - takeStringURLFrom: - toggleContinuousSpellChecking: - toggleSmartInsertDelete: - - - YES - id - id - id - id - id - id - id - id - id - id - id - - - - IBFrameworkSource - WebKit.framework/Headers/WebView.h - - - + 508 + 0 IBCocoaFramework @@ -4322,7 +3246,6 @@ YES - GitX.xcodeproj 3 YES diff --git a/SearchWebView.h b/SearchWebView.h new file mode 100644 index 0000000..1f90e46 --- /dev/null +++ b/SearchWebView.h @@ -0,0 +1,18 @@ +// +// SearchWebView.h +// GitX +// +// Created by German Laullon on 19/03/11. +// Copyright 2011 __MyCompanyName__. All rights reserved. +// + +#import +#import + +@interface WebView (SearchWebView) + +- (NSInteger)highlightAllOccurencesOfString:(NSString*)str; +- (NSInteger)highlightAllOccurencesOfString:(NSString*)str inNode:(DOMNode *)node; +- (void)removeAllHighlights; + +@end diff --git a/SearchWebView.m b/SearchWebView.m new file mode 100644 index 0000000..6718a94 --- /dev/null +++ b/SearchWebView.m @@ -0,0 +1,97 @@ +// +// SearchWebView.m +// GitX +// +// Created by German Laullon on 19/03/11. +// Copyright 2011 __MyCompanyName__. All rights reserved. +// + +#import "SearchWebView.h" + +@implementation WebView (SearchWebView) + +- (NSInteger)highlightAllOccurencesOfString:(NSString*)str inNode:(DOMNode *)_node +{ + NSInteger count=0; + DOMDocument *document=[[self mainFrame] DOMDocument]; + + DOMNodeList *nodes=[_node childNodes]; + DOMNode *node=[nodes item:0]; + while(node!=nil){ + if([node nodeType]==DOM_TEXT_NODE){ + NSString *block; + if([[node nodeValue] rangeOfString:str options:NSCaseInsensitiveSearch].location!=NSNotFound){ + NSScanner *scanner=[NSScanner scannerWithString:[node nodeValue]]; + [scanner setCharactersToBeSkipped:nil]; + [scanner setCaseSensitive:NO]; + while([scanner scanUpToString:str intoString:&block]){ + DOMNode *newNode=[document createTextNode:block]; + [[node parentNode] appendChild:newNode]; + + while([scanner scanString:str intoString:&block]){ + DOMElement *span=[document createElement:@"span"]; + [span setAttribute:@"id" value:[NSString stringWithFormat:@"SWVHL_%d",count++]]; + [span setAttribute:@"class" value:@"SWVHL"]; + newNode=[document createTextNode:block]; + [span appendChild:newNode]; + [[node parentNode] appendChild:span]; + } + } + [[node parentNode] removeChild:node]; + } + }else if([node nodeType]==DOM_ELEMENT_NODE){ + count+=[self highlightAllOccurencesOfString:str inNode:node]; + }else{ + NSLog(@"--->%@",node); + } + node=[node nextSibling]; + } + + return count; +} + +- (NSInteger)highlightAllOccurencesOfString:(NSString*)str +{ + NSInteger count=0; + + if([[[[self mainFrame] DOMDocument] documentElement] isKindOfClass:[DOMHTMLElement class]]){ + DOMHTMLElement *dom=(DOMHTMLElement *)[[[self mainFrame] DOMDocument] documentElement]; + if(![str isEqualToString:[dom getAttribute:@"searchStr"]]){ + [self removeAllHighlights]; + count=[self highlightAllOccurencesOfString:str inNode:dom]; + } + } + + return count; +} + +- (void)removeAllHighlights:(DOMNode *)_node +{ + DOMNode *node=[_node firstChild]; + while(node!=nil){ + if ([node nodeType]==DOM_ELEMENT_NODE) { + if ([[(DOMElement *)node getAttribute:@"class"] isEqualToString:@"SWVHL"]) { + DOMNode *txt=[node firstChild]; + DOMNode *parent=[node parentNode]; + [node removeChild:txt]; + [parent insertBefore:txt refChild:node]; + [parent removeChild:node]; + [parent normalize]; + [self removeAllHighlights:parent]; + }else{ + [self removeAllHighlights:node]; + } + } + node=[node nextSibling]; + } +} + +- (void)removeAllHighlights +{ + if([[[[self mainFrame] DOMDocument] documentElement] isKindOfClass:[DOMHTMLElement class]]){ + DOMHTMLElement *dom=(DOMHTMLElement *)[[[self mainFrame] DOMDocument] documentElement]; + [self removeAllHighlights:dom]; + } +} + +@end diff --git a/html/css/GitX.css b/html/css/GitX.css index 7e84871..ea4b40f 100644 --- a/html/css/GitX.css +++ b/html/css/GitX.css @@ -24,3 +24,7 @@ body { -webkit-border-radius: 10px; } +.SWVHL{ + background-color: yellow; + black: black; +} diff --git a/html/lib/SearchWebView.js b/html/lib/SearchWebView.js new file mode 100644 index 0000000..c09aa88 --- /dev/null +++ b/html/lib/SearchWebView.js @@ -0,0 +1,100 @@ +// Based on http://www.icab.de/blog/2010/01/12/search-and-highlight-text-in-uiwebview/ + +// We're using a global variable to store the number of occurrences +var SearchResultCount = 0; +var SearchResultShow = 0; + +// helper function, recursively searches in elements and their child nodes +function HighlightAllOccurencesOfStringForElement(element,keyword) { + if (element) { + if (element.nodeType == 3) { // Text node + while (true) { + var value = element.nodeValue; // Search for keyword in text node + var idx = value.toLowerCase().indexOf(keyword); + + if (idx < 0) break; // not found, abort + + var span = document.createElement("span"); + var text = document.createTextNode(value.substr(idx,keyword.length)); + span.appendChild(text); + span.setAttribute("id","Highlight"+SearchResultCount); + span.setAttribute("class","Highlight"); + span.style.backgroundColor="yellow"; + span.style.color="black"; + text = document.createTextNode(value.substr(idx+keyword.length)); + element.deleteData(idx, value.length - idx); + var next = element.nextSibling; + element.parentNode.insertBefore(span, next); + element.parentNode.insertBefore(text, next); + element = text; + SearchResultCount++; // update the counter + } + } else if (element.nodeType == 1) { // Element node + if (element.style.display != "none" && element.nodeName.toLowerCase() != 'select') { + for (var i=0; i"+element.childNodes[i].getAttribute('class')); + HighlightAllOccurencesOfStringForElement(element.childNodes[i],keyword); + } + } + } + } + return SearchResultCount; +} + +// the main entry point to start the search +function HighlightAllOccurencesOfString(keyword) { + RemoveAllHighlights(); + var c=HighlightAllOccurencesOfStringForElement(document.body, keyword.toLowerCase()); + if(c>0){ + span=$("Highlight0"); + span.style.backgroundColor="cyan"; + } + return c; +} + +function HighlightNext(){ + alert("SearchResultShow="+SearchResultShow+" SearchResultCount="+SearchResultCount); + if(SearchResultCount>0){ + var span=$("Highlight"+SearchResultShow); + span.style.backgroundColor="yellow"; + SearchResultShow++; + if(SearchResultShow >= SearchResultCount) + SearchResultShow=0; + span=$("Highlight"+SearchResultShow); + span.style.backgroundColor="cyan"; + location.href = "#Highlight"+SearchResultShow; + } +} + +// helper function, recursively removes the highlights in elements and their childs +function RemoveAllHighlightsForElement(element) { + if (element) { + if (element.nodeType == 1) { + if (element.getAttribute("class") == "Highlight") { + var text = element.removeChild(element.firstChild); + element.parentNode.insertBefore(text,element); + element.parentNode.removeChild(element); + return true; + } else { + var normalize = false; + for (var i=element.childNodes.length-1; i>=0; i--) { + if (RemoveAllHighlightsForElement(element.childNodes[i])) { + normalize = true; + } + } + if (normalize) { + element.normalize(); + } + } + } + } + return false; +} + +// the main entry point to remove the highlights +function RemoveAllHighlights() { + SearchResultCount = 0; + SearchResultShow=0; + RemoveAllHighlightsForElement(document.body); +} diff --git a/html/views/fileview/index.html b/html/views/fileview/index.html index a307f55..4684f22 100644 --- a/html/views/fileview/index.html +++ b/html/views/fileview/index.html @@ -31,6 +31,7 @@ tags. */ - scriptScriptTags : { left: /(<|<)\s*script.*?(>|>)/gi, right: /(<|<)\/\s*script\s*(>|>)/gi } - }, - - toolbar : { - /** - * Creates new toolbar for a highlighter. - * @param {Highlighter} highlighter Target highlighter. - */ - create : function(highlighter) - { - var div = document.createElement('DIV'), - items = sh.toolbar.items - ; - - div.className = 'toolbar'; - - for (var name in items) - { - var constructor = items[name], - command = new constructor(highlighter), - element = command.create() - ; - - highlighter.toolbarCommands[name] = command; - - if (element == null) - continue; - - if (typeof(element) == 'string') - element = sh.toolbar.createButton(element, highlighter.id, name); - - element.className += 'item ' + name; - div.appendChild(element); - } - - return div; - }, - - /** - * Create a standard anchor button for the toolbar. - * @param {String} label Label text to display. - * @param {String} highlighterId Highlighter ID that this button would belong to. - * @param {String} commandName Command name that would be executed. - * @return {Element} Returns an 'A' element. - */ - createButton : function(label, highlighterId, commandName) - { - var a = document.createElement('a'), - style = a.style, - config = sh.config, - width = config.toolbarItemWidth, - height = config.toolbarItemHeight - ; - - a.href = '#' + commandName; - a.title = label; - a.highlighterId = highlighterId; - a.commandName = commandName; - a.innerHTML = label; - - if (isNaN(width) == false) - style.width = width + 'px'; - - if (isNaN(height) == false) - style.height = height + 'px'; - - a.onclick = function(e) - { - try - { - sh.toolbar.executeCommand( - this, - e || window.event, - this.highlighterId, - this.commandName - ); - } - catch(e) - { - sh.utils.alert(e.message); - } - - return false; - }; - - return a; - }, - - /** - * Executes a toolbar command. - * @param {Element} sender Sender element. - * @param {MouseEvent} event Original mouse event object. - * @param {String} highlighterId Highlighter DIV element ID. - * @param {String} commandName Name of the command to execute. - * @return {Object} Passes out return value from command execution. - */ - executeCommand : function(sender, event, highlighterId, commandName, args) - { - var highlighter = sh.vars.highlighters[highlighterId], - command - ; - - if (highlighter == null || (command = highlighter.toolbarCommands[commandName]) == null) - return null; - - return command.execute(sender, event, args); - }, - - /** Collection of toolbar items. */ - items : { - expandSource : function(highlighter) - { - this.create = function() - { - if (highlighter.getParam('collapse') != true) - return; - - return sh.config.strings.expandSource; - }; - - this.execute = function(sender, event, args) - { - var div = highlighter.div; - - sender.parentNode.removeChild(sender); - div.className = div.className.replace('collapsed', ''); - }; - }, - - /** - * Command to open a new window and display the original unformatted source code inside. - */ - viewSource : function(highlighter) - { - this.create = function() - { - return sh.config.strings.viewSource; - }; - - this.execute = function(sender, event, args) - { - var code = sh.utils.fixInputString(highlighter.originalCode).replace(/' + code + ''); - wnd.document.close(); - }; - }, - - /** - * Command to copy the original source code in to the clipboard. - * Uses Flash method if clipboardSwf is configured. - */ - copyToClipboard : function(highlighter) - { - var flashDiv, flashSwf, - highlighterId = highlighter.id - ; - - this.create = function() - { - var config = sh.config; - - // disable functionality if running locally - if (config.clipboardSwf == null) - return null; - - function params(list) - { - var result = ''; - - for (var name in list) - result += ""; - - return result; - }; - - function attributes(list) - { - var result = ''; - - for (var name in list) - result += " " + name + "='" + list[name] + "'"; - - return result; - }; - - var args1 = { - width : config.toolbarItemWidth, - height : config.toolbarItemHeight, - id : highlighterId + '_clipboard', - type : 'application/x-shockwave-flash', - title : sh.config.strings.copyToClipboard - }, - - // these arguments are used in IE's collection - args2 = { - allowScriptAccess : 'always', - wmode : 'transparent', - flashVars : 'highlighterId=' + highlighterId, - menu : 'false' - }, - swf = config.clipboardSwf, - html - ; - - if (/msie/i.test(navigator.userAgent)) - { - html = '' - + params(args2) - + params({ movie : swf }) - + '' - ; - } - else - { - html = '' - ; - } - - flashDiv = document.createElement('div'); - flashDiv.innerHTML = html; - - return flashDiv; - }; - - this.execute = function(sender, event, args) - { - var command = args.command; - - switch (command) - { - case 'get': - var code = sh.utils.unindent( - sh.utils.fixInputString(highlighter.originalCode) - .replace(/</g, '<') - .replace(/>/g, '>') - .replace(/&/g, '&') - ); - - if(window.clipboardData) - // will fall through to the confirmation because there isn't a break - window.clipboardData.setData('text', code); - else - return sh.utils.unindent(code); - - case 'ok': - sh.utils.alert(sh.config.strings.copyToClipboardConfirmation); - break; - - case 'error': - sh.utils.alert(args.message); - break; - } - }; - }, - - /** Command to print the colored source code. */ - printSource : function(highlighter) - { - this.create = function() - { - return sh.config.strings.print; - }; - - this.execute = function(sender, event, args) - { - var iframe = document.createElement('IFRAME'), - doc = null - ; - - // make sure there is never more than one hidden iframe created by SH - if (sh.vars.printFrame != null) - document.body.removeChild(sh.vars.printFrame); - - sh.vars.printFrame = iframe; - - // this hides the iframe - iframe.style.cssText = 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;'; - - document.body.appendChild(iframe); - doc = iframe.contentWindow.document; - - copyStyles(doc, window.document); - doc.write('
' + highlighter.div.innerHTML + '
'); - doc.close(); - - iframe.contentWindow.focus(); - iframe.contentWindow.print(); - - function copyStyles(destDoc, sourceDoc) - { - var links = sourceDoc.getElementsByTagName('link'); - - for(var i = 0; i < links.length; i++) - if(links[i].rel.toLowerCase() == 'stylesheet' && /shCore\.css$/.test(links[i].href)) - destDoc.write(''); - }; - }; - }, - - /** Command to display the about dialog window. */ - about : function(highlighter) - { - this.create = function() - { - return sh.config.strings.help; - }; - - this.execute = function(sender, event) - { - var wnd = sh.utils.popup('', '_blank', 500, 250, 'scrollbars=0'), - doc = wnd.document - ; - - doc.write(sh.config.strings.aboutDialog); - doc.close(); - wnd.focus(); - }; - } - } - }, - - utils : { - /** - * Finds an index of element in the array. - * @ignore - * @param {Object} searchElement - * @param {Number} fromIndex - * @return {Number} Returns index of element if found; -1 otherwise. - */ - indexOf : function(array, searchElement, fromIndex) - { - fromIndex = Math.max(fromIndex || 0, 0); - - for (var i = fromIndex; i < array.length; i++) - if(array[i] == searchElement) - return i; - - return -1; - }, - - /** - * Generates a unique element ID. - */ - guid : function(prefix) - { - return prefix + Math.round(Math.random() * 1000000).toString(); - }, - - /** - * Merges two objects. Values from obj2 override values in obj1. - * Function is NOT recursive and works only for one dimensional objects. - * @param {Object} obj1 First object. - * @param {Object} obj2 Second object. - * @return {Object} Returns combination of both objects. - */ - merge: function(obj1, obj2) - { - var result = {}, name; - - for (name in obj1) - result[name] = obj1[name]; - - for (name in obj2) - result[name] = obj2[name]; - - return result; - }, - - /** - * Attempts to convert string to boolean. - * @param {String} value Input string. - * @return {Boolean} Returns true if input was "true", false if input was "false" and value otherwise. - */ - toBoolean: function(value) - { - switch (value) - { - case "true": - return true; - - case "false": - return false; - } - - return value; - }, - - /** - * Opens up a centered popup window. - * @param {String} url URL to open in the window. - * @param {String} name Popup name. - * @param {int} width Popup width. - * @param {int} height Popup height. - * @param {String} options window.open() options. - * @return {Window} Returns window instance. - */ - popup: function(url, name, width, height, options) - { - var x = (screen.width - width) / 2, - y = (screen.height - height) / 2 - ; - - options += ', left=' + x + - ', top=' + y + - ', width=' + width + - ', height=' + height - ; - options = options.replace(/^,/, ''); - - var win = window.open(url, name, options); - win.focus(); - return win; - }, - - /** - * Adds event handler to the target object. - * @param {Object} obj Target object. - * @param {String} type Name of the event. - * @param {Function} func Handling function. - */ - addEvent: function(obj, type, func) - { - if (obj.attachEvent) - { - obj['e' + type + func] = func; - obj[type + func] = function() - { - obj['e' + type + func](window.event); - } - obj.attachEvent('on' + type, obj[type + func]); - } - else - { - obj.addEventListener(type, func, false); - } - }, - - /** - * Displays an alert. - * @param {String} str String to display. - */ - alert: function(str) - { - alert(sh.config.strings.alert + str) - }, - - /** - * Finds a brush by its alias. - * - * @param {String} alias Brush alias. - * @param {Boolean} alert Suppresses the alert if false. - * @return {Brush} Returns bursh constructor if found, null otherwise. - */ - findBrush: function(alias, alert) - { - var brushes = sh.vars.discoveredBrushes, - result = null - ; - - if (brushes == null) - { - brushes = {}; - - // Find all brushes - for (var brush in sh.brushes) - { - var aliases = sh.brushes[brush].aliases; - - if (aliases == null) - continue; - - // keep the brush name - sh.brushes[brush].name = brush.toLowerCase(); - - for (var i = 0; i < aliases.length; i++) - brushes[aliases[i]] = brush; - } - - sh.vars.discoveredBrushes = brushes; - } - - result = sh.brushes[brushes[alias]]; - - if (result == null && alert != false) - sh.utils.alert(sh.config.strings.noBrush + alias); - - return result; - }, - - /** - * Executes a callback on each line and replaces each line with result from the callback. - * @param {Object} str Input string. - * @param {Object} callback Callback function taking one string argument and returning a string. - */ - eachLine: function(str, callback) - { - var lines = str.split('\n'); - - for (var i = 0; i < lines.length; i++) - lines[i] = callback(lines[i]); - - return lines.join('\n'); - }, - - /** - * This is a special trim which only removes first and last empty lines - * and doesn't affect valid leading space on the first line. - * - * @param {String} str Input string - * @return {String} Returns string without empty first and last lines. - */ - trimFirstAndLastLines: function(str) - { - return str.replace(/^[ ]*[\n]+|[\n]*[ ]*$/g, ''); - }, - - /** - * Parses key/value pairs into hash object. - * - * Understands the following formats: - * - name: word; - * - name: [word, word]; - * - name: "string"; - * - name: 'string'; - * - * For example: - * name1: value; name2: [value, value]; name3: 'value' - * - * @param {String} str Input string. - * @return {Object} Returns deserialized object. - */ - parseParams: function(str) - { - var match, - result = {}, - arrayRegex = new XRegExp("^\\[(?(.*?))\\]$"), - regex = new XRegExp( - "(?[\\w-]+)" + - "\\s*:\\s*" + - "(?" + - "[\\w-%#]+|" + // word - "\\[.*?\\]|" + // [] array - '".*?"|' + // "" string - "'.*?'" + // '' string - ")\\s*;?", - "g" - ) - ; - - while ((match = regex.exec(str)) != null) - { - var value = match.value - .replace(/^['"]|['"]$/g, '') // strip quotes from end of strings - ; - - // try to parse array value - if (value != null && arrayRegex.test(value)) - { - var m = arrayRegex.exec(value); - value = m.values.length > 0 ? m.values.split(/\s*,\s*/) : []; - } - - result[match.name] = value; - } - - return result; - }, - - /** - * Wraps each line of the string into tag with given style applied to it. - * - * @param {String} str Input string. - * @param {String} css Style name to apply to the string. - * @return {String} Returns input string with each line surrounded by tag. - */ - decorate: function(str, css) - { - if (str == null || str.length == 0 || str == '\n') - return str; - - str = str.replace(/... to them so that - // leading spaces aren't included. - if (css != null) - str = sh.utils.eachLine(str, function(line) - { - if (line.length == 0) - return ''; - - var spaces = ''; - - line = line.replace(/^( | )+/, function(s) - { - spaces = s; - return ''; - }); - - if (line.length == 0) - return spaces; - - return spaces + '' + line + ''; - }); - - return str; - }, - - /** - * Pads number with zeros until it's length is the same as given length. - * - * @param {Number} number Number to pad. - * @param {Number} length Max string length with. - * @return {String} Returns a string padded with proper amount of '0'. - */ - padNumber : function(number, length) - { - var result = number.toString(); - - while (result.length < length) - result = '0' + result; - - return result; - }, - - /** - * Measures width of a single space character. - * @return {Number} Returns width of a single space character. - */ - measureSpace : function() - { - var container = document.createElement('div'), - span, - result = 0, - body = document.body, - id = sh.utils.guid('measureSpace'), - - // variable names will be compressed, so it's better than a plain string - divOpen = '
' - + divOpen + 'lines">' - + divOpen + 'line">' - + divOpen + 'content' - + '"> ' + closeSpan + closeSpan - + closeDiv - + closeDiv - + closeDiv - + closeDiv - ; - - body.appendChild(container); - span = document.getElementById(id); - - if (/opera/i.test(navigator.userAgent)) - { - var style = window.getComputedStyle(span, null); - result = parseInt(style.getPropertyValue("width")); - } - else - { - result = span.offsetWidth; - } - - body.removeChild(container); - - return result; - }, - - /** - * Replaces tabs with spaces. - * - * @param {String} code Source code. - * @param {Number} tabSize Size of the tab. - * @return {String} Returns code with all tabs replaces by spaces. - */ - processTabs : function(code, tabSize) - { - var tab = ''; - - for (var i = 0; i < tabSize; i++) - tab += ' '; - - return code.replace(/\t/g, tab); - }, - - /** - * Replaces tabs with smart spaces. - * - * @param {String} code Code to fix the tabs in. - * @param {Number} tabSize Number of spaces in a column. - * @return {String} Returns code with all tabs replaces with roper amount of spaces. - */ - processSmartTabs : function(code, tabSize) - { - var lines = code.split('\n'), - tab = '\t', - spaces = '' - ; - - // Create a string with 1000 spaces to copy spaces from... - // It's assumed that there would be no indentation longer than that. - for (var i = 0; i < 50; i++) - spaces += ' '; // 20 spaces * 50 - - // This function inserts specified amount of spaces in the string - // where a tab is while removing that given tab. - function insertSpaces(line, pos, count) - { - return line.substr(0, pos) - + spaces.substr(0, count) - + line.substr(pos + 1, line.length) // pos + 1 will get rid of the tab - ; - }; - - // Go through all the lines and do the 'smart tabs' magic. - code = sh.utils.eachLine(code, function(line) - { - if (line.indexOf(tab) == -1) - return line; - - var pos = 0; - - while ((pos = line.indexOf(tab)) != -1) - { - // This is pretty much all there is to the 'smart tabs' logic. - // Based on the position within the line and size of a tab, - // calculate the amount of spaces we need to insert. - var spaces = tabSize - pos % tabSize; - line = insertSpaces(line, pos, spaces); - } - - return line; - }); - - return code; - }, - - /** - * Performs various string fixes based on configuration. - */ - fixInputString : function(str) - { - var br = /|<br\s*\/?>/gi; - - if (sh.config.bloggerMode == true) - str = str.replace(br, '\n'); - - if (sh.config.stripBrs == true) - str = str.replace(br, ''); - - return str; - }, - - /** - * Removes all white space at the begining and end of a string. - * - * @param {String} str String to trim. - * @return {String} Returns string without leading and following white space characters. - */ - trim: function(str) - { - return str.replace(/^\s+|\s+$/g, ''); - }, - - /** - * Unindents a block of text by the lowest common indent amount. - * @param {String} str Text to unindent. - * @return {String} Returns unindented text block. - */ - unindent: function(str) - { - var lines = sh.utils.fixInputString(str).split('\n'), - indents = new Array(), - regex = /^\s*/, - min = 1000 - ; - - // go through every line and check for common number of indents - for (var i = 0; i < lines.length && min > 0; i++) - { - var line = lines[i]; - - if (sh.utils.trim(line).length == 0) - continue; - - var matches = regex.exec(line); - - // In the event that just one line doesn't have leading white space - // we can't unindent anything, so bail completely. - if (matches == null) - return str; - - min = Math.min(matches[0].length, min); - } - - // trim minimum common number of white space from the begining of every line - if (min > 0) - for (var i = 0; i < lines.length; i++) - lines[i] = lines[i].substr(min); - - return lines.join('\n'); - }, - - /** - * Callback method for Array.sort() which sorts matches by - * index position and then by length. - * - * @param {Match} m1 Left object. - * @param {Match} m2 Right object. - * @return {Number} Returns -1, 0 or -1 as a comparison result. - */ - matchesSortCallback: function(m1, m2) - { - // sort matches by index first - if(m1.index < m2.index) - return -1; - else if(m1.index > m2.index) - return 1; - else - { - // if index is the same, sort by length - if(m1.length < m2.length) - return -1; - else if(m1.length > m2.length) - return 1; - } - - return 0; - }, - - /** - * Executes given regular expression on provided code and returns all - * matches that are found. - * - * @param {String} code Code to execute regular expression on. - * @param {Object} regex Regular expression item info from regexList collection. - * @return {Array} Returns a list of Match objects. - */ - getMatches: function(code, regexInfo) - { - function defaultAdd(match, regexInfo) - { - return [new sh.Match(match[0], match.index, regexInfo.css)]; - }; - - var index = 0, - match = null, - result = [], - func = regexInfo.func ? regexInfo.func : defaultAdd - ; - - while((match = regexInfo.regex.exec(code)) != null) - result = result.concat(func(match, regexInfo)); - - return result; - }, - - processUrls: function(code) - { - var lt = '<', - gt = '>' - ; - - return code.replace(sh.regexLib.url, function(m) - { - var suffix = '', prefix = ''; - - // We include < and > in the URL for the common cases like - // The problem is that they get transformed into <http://google.com> - // Where as > easily looks like part of the URL string. - - if (m.indexOf(lt) == 0) - { - prefix = lt; - m = m.substring(lt.length); - } - - if (m.indexOf(gt) == m.length - gt.length) - { - m = m.substring(0, m.length - gt.length); - suffix = gt; - } - - return prefix + '' + m + '' + suffix; - }); - }, - - /** - * Finds all - - - - - - - - - - - - - - - - - - - - - - - -

SyntaxHihglighter Test

-

This is a test file to insure that everything is working well.

- -
-function test() : String
-{
-	return 10;
-}
-
- From e109d03a4dc4ffa0eec1e9c61a75dc0982af7b47 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Wed, 20 Apr 2011 12:20:24 -0700 Subject: [PATCH 32/36] Better file view search --- GLFileView.m | 9 +- PBGitHistoryView.xib | 937 +++++++++++++++++++++++++++++++++++++++++-- SearchWebView.h | 3 +- SearchWebView.m | 28 +- 4 files changed, 938 insertions(+), 39 deletions(-) diff --git a/GLFileView.m b/GLFileView.m index 7087130..512bfa3 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -639,14 +639,7 @@ -(IBAction)updateSearch:(NSSearchField *)sender { - NSString *searchString = [sender stringValue]; - DLog(@"searchString:%@",searchString); - - if([searchString length]>0){ - [view highlightAllOccurencesOfString:searchString]; - }else{ - [view removeAllHighlights]; - } + [view updateSearch:sender]; } #pragma mark - diff --git a/PBGitHistoryView.xib b/PBGitHistoryView.xib index 30ae89a..5f632e9 100644 --- a/PBGitHistoryView.xib +++ b/PBGitHistoryView.xib @@ -138,6 +138,7 @@ 292 {{267, 3}, {71, 25}} + YES @@ -181,6 +182,7 @@ 268 {{206, 3}, {37, 25}} + YES @@ -206,6 +208,7 @@ 268 {{161, 3}, {37, 25}} + YES @@ -231,6 +234,7 @@ 268 {{116, 3}, {37, 25}} + YES @@ -256,6 +260,7 @@ 268 {{55, 3}, {37, 25}} + YES @@ -281,6 +286,7 @@ 268 {{10, 3}, {37, 25}} + YES @@ -306,6 +312,7 @@ 10 {{0, -2}, {955, 5}} + {0, 0} @@ -335,6 +342,7 @@ {{0, 404}, {955, 30}} + PBGitGradientBarView @@ -351,8 +359,9 @@ 10 - {{0, 144}, {955, 5}} + {{0, 140}, {955, 5}} + {0, 0} @@ -384,15 +393,17 @@ 4352 - {955, 130} + {955, 126} - + + YES 256 {955, 17} + @@ -401,6 +412,7 @@ -2147483392 {{-26, 0}, {16, 17}} + @@ -655,8 +667,9 @@ 0 - {{0, 17}, {955, 130}} + {{0, 17}, {955, 126}} + @@ -667,6 +680,7 @@ -2147483392 {{837, 17}, {15, 179}} + _doScroller: @@ -677,6 +691,7 @@ -2147483392 {{0, 123}, {852, 15}} + 1 @@ -693,6 +708,7 @@ {955, 17} + @@ -700,9 +716,10 @@ - {955, 147} + {955, 143} - + + 560 @@ -722,6 +739,7 @@ {{740, 3}, {16, 16}} + 20746 100 @@ -731,6 +749,7 @@ 265 {{765, 2}, {180, 19}} + YES @@ -793,6 +812,7 @@ 265 {{714, 3}, {43, 18}} + YES @@ -830,6 +850,7 @@ 265 {{630, 5}, {80, 14}} + YES @@ -852,6 +873,7 @@ 268 {{49, 2}, {57, 17}} + 1 YES @@ -878,6 +900,7 @@ 268 {{114, 2}, {103, 17}} + 2 YES @@ -900,6 +923,7 @@ 268 {{11, 2}, {30, 17}} + YES @@ -917,14 +941,16 @@ - {{0, 147}, {955, 24}} + {{0, 143}, {955, 24}} + PBGitGradientBarView - {955, 171} + {955, 167} + NSView @@ -936,8 +962,9 @@ 18 - {955, 233} + {955, 228} + YES @@ -1026,8 +1053,9 @@ 266 - {{5, 212.5}, {196, 19}} + {{5, 207}, {196, 19}} + YES @@ -1102,9 +1130,10 @@ 4368 - {190, 208} + {190, 203} - + + YES @@ -1157,8 +1186,9 @@ 0 - {{1, 1}, {190, 208}} + {{1, 1}, {190, 203}} + @@ -1167,8 +1197,9 @@ 256 - {{191, 1}, {15, 208}} + {{191, 1}, {15, 203}} + _doScroller: @@ -1179,6 +1210,7 @@ -2147483392 {{-100, -100}, {502, 15}} + 1 @@ -1187,9 +1219,10 @@ 0.99801188707351685 - {{0, 0.5}, {207, 210}} + {207, 205} - + + 18 @@ -1197,8 +1230,9 @@ QSAAAEEgAABBmAAAQZgAAA - {207, 235} + {207, 230} + NSView @@ -1222,6 +1256,7 @@ 268 {{50, 2}, {158, 19}} + YES @@ -1284,6 +1319,7 @@ 289 {{216, 1}, {29, 19}} + YES @@ -1311,12 +1347,14 @@ {{490, 0}, {259, 24}} - + + NSView - {{0, 211}, {749, 24}} + {{0, 206}, {749, 24}} + MGScopeBar @@ -1344,8 +1382,9 @@ public.url-name
- {749, 210} + {749, 205} + @@ -1354,21 +1393,24 @@ YES - {{208, 0}, {749, 235}} + {{208, 0}, {749, 230}} + NSView - {{-1, -1}, {957, 235}} + {{-1, -1}, {957, 230}} + YES 2 - {955, 233} + {955, 228} + Tree @@ -1387,20 +1429,23 @@ - {{0, 172}, {955, 233}} + {{0, 177}, {955, 228}} + NSView {955, 405} + - 2 + 3 {955, 434} + NSView @@ -2907,7 +2952,6 @@ 18.IBPluginDependency 19.CustomClassName 19.IBPluginDependency - 2.CustomClassName 2.IBEditorWindowLastContentRect 2.IBPluginDependency 2.ImportedFromIB2 @@ -3030,7 +3074,6 @@ com.apple.InterfaceBuilder.CocoaPlugin PBIconAndTextCell com.apple.InterfaceBuilder.CocoaPlugin - PBCollapsibleSplitView {{312, 577}, {852, 384}} com.apple.InterfaceBuilder.CocoaPlugin @@ -3230,7 +3273,845 @@ 508 - + + + YES + + GLFileView + PBWebController + + updateSearch: + NSSearchField + + + updateSearch: + + updateSearch: + NSSearchField + + + + YES + + YES + accessoryView + fileListSplitView + historyController + searchField + typeBar + + + YES + NSView + NSSplitView + PBGitHistoryController + NSSearchField + MGScopeBar + + + + YES + + YES + accessoryView + fileListSplitView + historyController + searchField + typeBar + + + YES + + accessoryView + NSView + + + fileListSplitView + NSSplitView + + + historyController + PBGitHistoryController + + + searchField + NSSearchField + + + typeBar + MGScopeBar + + + + + IBProjectSource + ./Classes/GLFileView.h + + + + GitXRelativeDateFormatter + NSFormatter + + IBProjectSource + ./Classes/GitXRelativeDateFormatter.h + + + + GitXTextFieldCell + NSTextFieldCell + + contextMenuDelegate + id + + + contextMenuDelegate + + contextMenuDelegate + id + + + + IBProjectSource + ./Classes/GitXTextFieldCell.h + + + + MGScopeBar + NSView + + delegate + id + + + delegate + + delegate + id + + + + IBProjectSource + ./Classes/MGScopeBar.h + + + + PBCollapsibleSplitView + NSSplitView + + IBProjectSource + ./Classes/PBCollapsibleSplitView.h + + + + PBCommitList + NSTableView + + YES + + YES + controller + searchController + webController + webView + + + YES + PBGitHistoryController + PBHistorySearchController + PBWebHistoryController + WebView + + + + YES + + YES + controller + searchController + webController + webView + + + YES + + controller + PBGitHistoryController + + + searchController + PBHistorySearchController + + + webController + PBWebHistoryController + + + webView + WebView + + + + + IBProjectSource + ./Classes/PBCommitList.h + + + + PBGitGradientBarView + NSView + + IBProjectSource + ./Classes/PBGitGradientBarView.h + + + + PBGitHistoryController + PBViewController + + YES + + YES + cherryPick: + createBranch: + createTag: + merge: + openSelectedFile: + rebase: + refresh: + selectNext: + selectPrevious: + setBranchFilter: + setDetailedView: + setTreeView: + showAddRemoteSheet: + toggleQLPreviewPanel: + updateSearch: + + + YES + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + + + + YES + + YES + cherryPick: + createBranch: + createTag: + merge: + openSelectedFile: + rebase: + refresh: + selectNext: + selectPrevious: + setBranchFilter: + setDetailedView: + setTreeView: + showAddRemoteSheet: + toggleQLPreviewPanel: + updateSearch: + + + YES + + cherryPick: + id + + + createBranch: + id + + + createTag: + id + + + merge: + id + + + openSelectedFile: + id + + + rebase: + id + + + refresh: + id + + + selectNext: + id + + + selectPrevious: + id + + + setBranchFilter: + id + + + setDetailedView: + id + + + setTreeView: + id + + + showAddRemoteSheet: + id + + + toggleQLPreviewPanel: + id + + + updateSearch: + id + + + + + YES + + YES + allBranchesFilterItem + cherryPickButton + commitController + commitList + fileBrowser + fileView + filesSearchField + historySplitView + localRemoteBranchesFilterItem + mergeButton + rebaseButton + refController + scopeBarView + searchController + searchField + selectedBranchFilterItem + treeController + upperToolbarView + webHistoryController + webView + + + YES + NSButton + NSButton + NSArrayController + PBCommitList + NSOutlineView + GLFileView + NSSearchField + PBCollapsibleSplitView + NSButton + NSButton + NSButton + PBRefController + PBGitGradientBarView + PBHistorySearchController + NSSearchField + NSButton + NSTreeController + PBGitGradientBarView + PBWebHistoryController + id + + + + YES + + YES + allBranchesFilterItem + cherryPickButton + commitController + commitList + fileBrowser + fileView + filesSearchField + historySplitView + localRemoteBranchesFilterItem + mergeButton + rebaseButton + refController + scopeBarView + searchController + searchField + selectedBranchFilterItem + treeController + upperToolbarView + webHistoryController + webView + + + YES + + allBranchesFilterItem + NSButton + + + cherryPickButton + NSButton + + + commitController + NSArrayController + + + commitList + PBCommitList + + + fileBrowser + NSOutlineView + + + fileView + GLFileView + + + filesSearchField + NSSearchField + + + historySplitView + PBCollapsibleSplitView + + + localRemoteBranchesFilterItem + NSButton + + + mergeButton + NSButton + + + rebaseButton + NSButton + + + refController + PBRefController + + + scopeBarView + PBGitGradientBarView + + + searchController + PBHistorySearchController + + + searchField + NSSearchField + + + selectedBranchFilterItem + NSButton + + + treeController + NSTreeController + + + upperToolbarView + PBGitGradientBarView + + + webHistoryController + PBWebHistoryController + + + webView + id + + + + + IBProjectSource + ./Classes/PBGitHistoryController.h + + + + PBGitRevisionCell + NSActionCell + + YES + + YES + contextMenuDelegate + controller + + + YES + id + PBGitHistoryController + + + + YES + + YES + contextMenuDelegate + controller + + + YES + + contextMenuDelegate + id + + + controller + PBGitHistoryController + + + + + IBProjectSource + ./Classes/PBGitRevisionCell.h + + + + PBHistorySearchController + NSObject + + YES + + YES + stepperPressed: + updateSearch: + + + YES + id + id + + + + YES + + YES + stepperPressed: + updateSearch: + + + YES + + stepperPressed: + id + + + updateSearch: + id + + + + + YES + + YES + commitController + historyController + numberOfMatchesField + progressIndicator + searchField + stepper + + + YES + NSArrayController + PBGitHistoryController + NSTextField + NSProgressIndicator + NSSearchField + NSSegmentedControl + + + + YES + + YES + commitController + historyController + numberOfMatchesField + progressIndicator + searchField + stepper + + + YES + + commitController + NSArrayController + + + historyController + PBGitHistoryController + + + numberOfMatchesField + NSTextField + + + progressIndicator + NSProgressIndicator + + + searchField + NSSearchField + + + stepper + NSSegmentedControl + + + + + IBProjectSource + ./Classes/PBHistorySearchController.h + + + + PBIconAndTextCell + NSTextFieldCell + + IBProjectSource + ./Classes/PBIconAndTextCell.h + + + + PBQLOutlineView + NSOutlineView + + controller + PBGitHistoryController + + + controller + + controller + PBGitHistoryController + + + + IBProjectSource + ./Classes/PBQLOutlineView.h + + + + PBRefController + NSObject + + YES + + YES + branchPopUp + commitController + commitList + historyController + + + YES + NSPopUpButton + NSArrayController + PBCommitList + PBGitHistoryController + + + + YES + + YES + branchPopUp + commitController + commitList + historyController + + + YES + + branchPopUp + NSPopUpButton + + + commitController + NSArrayController + + + commitList + PBCommitList + + + historyController + PBGitHistoryController + + + + + IBProjectSource + ./Classes/PBRefController.h + + + + PBUnsortableTableHeader + NSTableHeaderView + + controller + NSArrayController + + + controller + + controller + NSArrayController + + + + IBProjectSource + ./Classes/PBUnsortableTableHeader.h + + + + PBViewController + NSViewController + + refresh: + id + + + refresh: + + refresh: + id + + + + IBProjectSource + ./Classes/PBViewController.h + + + + PBWebController + NSObject + + YES + + YES + repository + view + + + YES + id + WebView + + + + YES + + YES + repository + view + + + YES + + repository + id + + + view + WebView + + + + + IBProjectSource + ./Classes/PBWebController.h + + + + PBWebHistoryController + PBWebController + + YES + + YES + contextMenuDelegate + historyController + + + YES + id + PBGitHistoryController + + + + YES + + YES + contextMenuDelegate + historyController + + + YES + + contextMenuDelegate + id + + + historyController + PBGitHistoryController + + + + + IBProjectSource + ./Classes/PBWebHistoryController.h + + + + WebView + + reloadFromOrigin: + id + + + reloadFromOrigin: + + reloadFromOrigin: + id + + + + IBProjectSource + ./Classes/WebView.h + + + + 0 IBCocoaFramework diff --git a/SearchWebView.h b/SearchWebView.h index 1f90e46..6438df3 100644 --- a/SearchWebView.h +++ b/SearchWebView.h @@ -11,8 +11,9 @@ @interface WebView (SearchWebView) -- (NSInteger)highlightAllOccurencesOfString:(NSString*)str; +- (DOMRange *)highlightAllOccurencesOfString:(NSString*)str; - (NSInteger)highlightAllOccurencesOfString:(NSString*)str inNode:(DOMNode *)node; - (void)removeAllHighlights; +- (void)updateSearch:(NSSearchField *)sender; @end diff --git a/SearchWebView.m b/SearchWebView.m index 5a21e40..7daa148 100644 --- a/SearchWebView.m +++ b/SearchWebView.m @@ -50,19 +50,43 @@ return count; } -- (NSInteger)highlightAllOccurencesOfString:(NSString*)str +- (DOMRange *)highlightAllOccurencesOfString:(NSString*)str { NSInteger count=0; + DOMRange *res=nil; if([[[[self mainFrame] DOMDocument] documentElement] isKindOfClass:[DOMHTMLElement class]]){ DOMHTMLElement *dom=(DOMHTMLElement *)[[[self mainFrame] DOMDocument] documentElement]; if(![str isEqualToString:[dom getAttribute:@"searchStr"]]){ [self removeAllHighlights]; count=[self highlightAllOccurencesOfString:str inNode:dom]; + if(count>0){ + [dom setAttribute:@"searchStr" value:str]; + } + } + if([self searchFor:str direction:YES caseSensitive:NO wrap:YES]){ + res=[self selectedDOMRange]; } } - return count; + return res; +} + +- (void)updateSearch:(NSSearchField *)sender +{ + NSString *searchString = [sender stringValue]; + DLog(@"searchString:%@",searchString); + + DOMRange *selection; + + if([searchString length]>0){ + selection=[self highlightAllOccurencesOfString:searchString]; + [[sender window] makeFirstResponder:sender]; + if(selection!=nil) + [self setSelectedDOMRange:selection affinity:NSSelectionAffinityDownstream]; + }else{ + [self removeAllHighlights]; + } } - (void)removeAllHighlights:(DOMNode *)_node From 09011b82e97ceea8045f1acb48c6ca232f47c5cf Mon Sep 17 00:00:00 2001 From: German Laullon Date: Wed, 20 Apr 2011 12:51:24 -0700 Subject: [PATCH 33/36] avoid unnecessary reloads --- GLFileView.h | 1 + GLFileView.m | 78 +++++++++++++++++++++++++++------------------------- PBGitTree.m | 5 ++++ 3 files changed, 47 insertions(+), 37 deletions(-) diff --git a/GLFileView.h b/GLFileView.h index a7a5a06..8084ddc 100644 --- a/GLFileView.h +++ b/GLFileView.h @@ -25,6 +25,7 @@ IBOutlet NSView *accessoryView; IBOutlet NSSplitView *fileListSplitView; IBOutlet NSSearchField *searchField; + PBGitTree *lastFile; } - (void)showFile; diff --git a/GLFileView.m b/GLFileView.m index 512bfa3..52c677d 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -102,42 +102,46 @@ NSArray *files=[historyController.treeController selectedObjects]; if ([files count]>0) { PBGitTree *file=[files objectAtIndex:0]; - - NSString *fileTxt = @""; - if(startFile==@"fileview"){ - fileTxt=[file textContents:&theError]; - if(!theError) - fileTxt=[GLFileView parseHTML:fileTxt]; - }else if(startFile==@"blame"){ - fileTxt=[file blame:&theError]; - if(!theError) - fileTxt=[self parseBlame:fileTxt]; - }else if(startFile==@"log"){ - fileTxt=[file log:logFormat error:&theError]; - }else if(startFile==@"diff"){ - fileTxt=[file diff:diffType error:&theError]; - if(!theError) - fileTxt=[GLFileView parseDiff:fileTxt]; - } - - id script = [view windowScriptObject]; - if(!theError){ - NSString *filePath = [file fullPath]; - fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"\t" withString:@"    "]; - DLog(@"file.sha='%@'",file.sha); - fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:file.sha]; - if(diffType==@"h") { - fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA}" withString:@"HEAD"]; - }else { - fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA}" withString:@"--"]; + DLog(@"file=%@ == %@ => %d",file,lastFile,[file isEqualTo:lastFile]); + if(![file isEqualTo:lastFile]){ + lastFile=file; + + NSString *fileTxt = @""; + if(startFile==@"fileview"){ + fileTxt=[file textContents:&theError]; + if(!theError) + fileTxt=[GLFileView parseHTML:fileTxt]; + }else if(startFile==@"blame"){ + fileTxt=[file blame:&theError]; + if(!theError) + fileTxt=[self parseBlame:fileTxt]; + }else if(startFile==@"log"){ + fileTxt=[file log:logFormat error:&theError]; + }else if(startFile==@"diff"){ + fileTxt=[file diff:diffType error:&theError]; + if(!theError) + fileTxt=[GLFileView parseDiff:fileTxt]; } - [script callWebScriptMethod:@"showFile" withArguments:[NSArray arrayWithObjects:fileTxt, filePath, nil]]; - }else{ - [script callWebScriptMethod:@"setMessage" withArguments:[NSArray arrayWithObjects:[theError localizedDescription], nil]]; - } + + id script = [view windowScriptObject]; + if(!theError){ + NSString *filePath = [file fullPath]; + fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"\t" withString:@"    "]; + DLog(@"file.sha='%@'",file.sha); + fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:file.sha]; + if(diffType==@"h") { + fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA}" withString:@"HEAD"]; + }else { + fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA}" withString:@"--"]; + } + [script callWebScriptMethod:@"showFile" withArguments:[NSArray arrayWithObjects:fileTxt, filePath, nil]]; + }else{ + [script callWebScriptMethod:@"setMessage" withArguments:[NSArray arrayWithObjects:[theError localizedDescription], nil]]; + } + [self updateSearch:searchField]; + } } - [self updateSearch:searchField]; #ifdef DEBUG_BUILD DOMHTMLElement *dom=(DOMHTMLElement *)[[[view mainFrame] DOMDocument] documentElement]; @@ -338,10 +342,10 @@ NSMutableString *res=[NSMutableString string]; NSScanner *scan=[NSScanner scannerWithString:txt]; NSString *block; - + [scan scanUpToString:@"Binary files" intoString:NULL]; [scan scanUpToString:@"" intoString:&block]; - + NSArray *files=[self getFilesNames:block]; [res appendString:@"
"]; - + return res; } @@ -383,7 +387,7 @@ l_line=abs([[pos_l objectAtIndex:0]integerValue]); r_line=[[pos_r objectAtIndex:0]integerValue]; - + [res appendString:[NSString stringWithFormat:@"",line]]; while((line=[lines nextObject])){ NSString *s=[line substringToIndex:1]; diff --git a/PBGitTree.m b/PBGitTree.m index 8c33b73..ad9e1db 100644 --- a/PBGitTree.m +++ b/PBGitTree.m @@ -376,4 +376,9 @@ [[NSFileManager defaultManager] removeItemAtPath:localFileName error:nil]; [super finalize]; } + +- (BOOL)isEqualTo:(PBGitTree *)object +{ + return [sha isEqualTo:[object sha]] && [[self fullPath] isEqualTo:[object fullPath]]; +} @end From cc10bda03258832f634d2f38ec0a804ba4d35cd0 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Fri, 22 Apr 2011 15:47:02 -0700 Subject: [PATCH 34/36] openFileMerge on "diff with..." --- PBDiffWindowController.m | 8 +++++++- PBWebDiffController.m | 11 +++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/PBDiffWindowController.m b/PBDiffWindowController.m index 4aacfe2..3d8456f 100644 --- a/PBDiffWindowController.m +++ b/PBDiffWindowController.m @@ -10,6 +10,7 @@ #import "PBGitRepository.h" #import "PBGitCommit.h" #import "PBGitDefaults.h" +#import "GLFileView.h" @implementation PBDiffWindowController @@ -21,6 +22,7 @@ return nil; diff = aDiff; + return self; } @@ -50,8 +52,12 @@ DLog(@"diff failed with retValue: %d for command: '%@' output: '%@'", retValue, [arguments componentsJoinedByString:@" "], diff); return; } + + diff=[GLFileView parseDiff:diff]; + diff=[diff stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[startCommit realSha]]; + diff=[diff stringByReplacingOccurrencesOfString:@"{SHA}" withString:[diffCommit realSha]]; - PBDiffWindowController *diffController = [[PBDiffWindowController alloc] initWithDiff:[diff copy]]; + PBDiffWindowController *diffController = [[PBDiffWindowController alloc] initWithDiff:diff]; [diffController showWindow:nil]; } diff --git a/PBWebDiffController.m b/PBWebDiffController.m index d09d9c7..8901c33 100644 --- a/PBWebDiffController.m +++ b/PBWebDiffController.m @@ -7,7 +7,6 @@ // #import "PBWebDiffController.h" -#import "GLFileView.h" @implementation PBWebDiffController @@ -47,7 +46,15 @@ if ([diff length] == 0) [script callWebScriptMethod:@"setMessage" withArguments:[NSArray arrayWithObject:@"There are no differences"]]; else - [script callWebScriptMethod:@"showFile" withArguments:[NSArray arrayWithObject:[GLFileView parseDiff:diff]]]; + [script callWebScriptMethod:@"showFile" withArguments:[NSArray arrayWithObject:diff]]; } +// TODO: need to be refactoring +- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2; +{ + NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",sha,sha2,file,nil]; + [repository handleInWorkDirForArguments:args]; +} + + @end From f6e69682d1b59f2a03ae1db9f641c8ba8641b9c6 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Fri, 22 Apr 2011 15:48:19 -0700 Subject: [PATCH 35/36] better hide/show splitviews --- English.lproj/RepositoryWindow.xib | 58 ++++++------- GLFileView.m | 1 + GitX.xcodeproj/project.pbxproj | 32 -------- Images/mainSplitterBar.tiff | Bin 456 -> 0 bytes Images/mainSplitterDimple.tiff | Bin 24140 -> 0 bytes PBCollapsibleSplitView.h | 29 ------- PBCollapsibleSplitView.m | 57 ------------- PBGitCommitController.m | 9 +-- PBGitHistoryController.h | 7 +- PBGitHistoryController.m | 55 +++++-------- PBGitWindowController.h | 10 ++- PBGitWindowController.m | 126 ++++++++++++++++++----------- PBNiceSplitView.h | 15 ---- PBNiceSplitView.m | 45 ----------- 14 files changed, 141 insertions(+), 303 deletions(-) delete mode 100644 Images/mainSplitterBar.tiff delete mode 100644 Images/mainSplitterDimple.tiff delete mode 100644 PBCollapsibleSplitView.h delete mode 100644 PBCollapsibleSplitView.m delete mode 100644 PBNiceSplitView.h delete mode 100644 PBNiceSplitView.m diff --git a/English.lproj/RepositoryWindow.xib b/English.lproj/RepositoryWindow.xib index 02b6c5f..7a5139c 100644 --- a/English.lproj/RepositoryWindow.xib +++ b/English.lproj/RepositoryWindow.xib @@ -2,10 +2,10 @@ 1050 - 10J567 + 10J869 1305 1038.35 - 462.00 + 461.00 com.apple.InterfaceBuilder.CocoaPlugin 1305 @@ -109,11 +109,9 @@ Clone Repository To - + 268 {{38, 14}, {40, 25}} - - YES -2080244224 @@ -156,11 +154,9 @@ Refresh - + 268 {{8, 14}, {32, 25}} - - YES -2080244224 @@ -199,11 +195,9 @@ View - + 268 {{0, 14}, {94, 25}} - - YES 67239424 @@ -402,6 +396,7 @@ {184, 483} + NSView @@ -410,12 +405,14 @@ {{185, 0}, {705, 483}} + NSView {{0, 31}, {890, 483}} + YES 2 sourceSplitView @@ -426,6 +423,7 @@ {{0, 1}, {515, 31}} + NSView @@ -440,6 +438,7 @@ {{20, 7}, {16, 16}} + 20746 100 @@ -449,6 +448,7 @@ {{41, 8}, {188, 14}} + YES 67239488 @@ -484,14 +484,16 @@ {{552, 0}, {246, 31}} + NSView {{7, 11}, {890, 514}} + - {{0, 0}, {1440, 878}} + {{0, 0}, {1680, 1028}} {600, 528} {1e+13, 1e+13} GitX @@ -533,14 +535,6 @@ 356 - - - splitView - - - - 357 - sourceListControlsView @@ -621,6 +615,14 @@ 423 + + + mainSplitView + + + + 424 + @@ -945,7 +947,7 @@ - 423 + 424 @@ -1026,10 +1028,10 @@ YES contentSplitView finderItem + mainSplitView progressIndicator sourceListControlsView sourceSplitView - splitView statusField terminalItem @@ -1037,10 +1039,10 @@ YES NSView NSToolbarItem + NSSplitView NSProgressIndicator NSView NSView - NSSplitView NSTextField NSToolbarItem @@ -1051,10 +1053,10 @@ YES contentSplitView finderItem + mainSplitView progressIndicator sourceListControlsView sourceSplitView - splitView statusField terminalItem @@ -1068,6 +1070,10 @@ finderItem NSToolbarItem + + mainSplitView + NSSplitView + progressIndicator NSProgressIndicator @@ -1080,10 +1086,6 @@ sourceSplitView NSView - - splitView - NSSplitView - statusField NSTextField diff --git a/GLFileView.m b/GLFileView.m index 52c677d..d51fa6a 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -219,6 +219,7 @@ [[view mainFrame] reload]; } } + lastFile=nil; } - (NSView *)accessoryViewForScopeBar:(MGScopeBar *)scopeBar diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index f4effcb..4fb3606 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -62,7 +62,6 @@ 31460CD6124185BA00B90AED /* TODO in Resources */ = {isa = PBXBuildFile; fileRef = 31460CB1124185BA00B90AED /* TODO */; }; 316E7202131EE9C600AFBB36 /* list_Template.png in Resources */ = {isa = PBXBuildFile; fileRef = 316E7200131EE9C600AFBB36 /* list_Template.png */; }; 316E7203131EE9C600AFBB36 /* sidebar_Template.png in Resources */ = {isa = PBXBuildFile; fileRef = 316E7201131EE9C600AFBB36 /* sidebar_Template.png */; }; - 3177607D133554A80025876E /* SearchWebView.js in Sources */ = {isa = PBXBuildFile; fileRef = 3177607C133554A80025876E /* SearchWebView.js */; }; 31776089133569350025876E /* SearchWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 31776088133569350025876E /* SearchWebView.m */; }; 31DAA7ED1317737100463846 /* gitx_l_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 31DAA7EC1317737100463846 /* gitx_l_pub.pem */; }; 3BC07F4C0ED5A5C5009A7768 /* HistoryViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */; }; @@ -142,10 +141,6 @@ D8FDDA6F114335E8005647F6 /* PBGitSVStageItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA67114335E8005647F6 /* PBGitSVStageItem.m */; }; D8FDDA70114335E8005647F6 /* PBGitSVTagItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA69114335E8005647F6 /* PBGitSVTagItem.m */; }; D8FDDBF41143F318005647F6 /* AddRemote.png in Resources */ = {isa = PBXBuildFile; fileRef = D8FDDBF31143F318005647F6 /* AddRemote.png */; }; - EB2A734A0FEE3F09006601CF /* PBCollapsibleSplitView.m in Sources */ = {isa = PBXBuildFile; fileRef = EB2A73490FEE3F09006601CF /* PBCollapsibleSplitView.m */; }; - F50A411F0EBB874C00208746 /* mainSplitterBar.tiff in Resources */ = {isa = PBXBuildFile; fileRef = F50A411D0EBB874C00208746 /* mainSplitterBar.tiff */; }; - F50A41200EBB874C00208746 /* mainSplitterDimple.tiff in Resources */ = {isa = PBXBuildFile; fileRef = F50A411E0EBB874C00208746 /* mainSplitterDimple.tiff */; }; - F50A41230EBB875D00208746 /* PBNiceSplitView.m in Sources */ = {isa = PBXBuildFile; fileRef = F50A41220EBB875D00208746 /* PBNiceSplitView.m */; }; F50FE0E30E07BE9600854FCD /* PBGitRevisionCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */; }; F513085B0E0740F2000C8BCD /* PBQLOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = F513085A0E0740F2000C8BCD /* PBQLOutlineView.m */; }; F5140DC90E8A8EB20091E9F3 /* RoundedRectangle.m in Sources */ = {isa = PBXBuildFile; fileRef = F5140DC80E8A8EB20091E9F3 /* RoundedRectangle.m */; }; @@ -355,7 +350,6 @@ 31460CB1124185BA00B90AED /* TODO */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TODO; sourceTree = ""; }; 316E7200131EE9C600AFBB36 /* list_Template.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = list_Template.png; sourceTree = ""; }; 316E7201131EE9C600AFBB36 /* sidebar_Template.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = sidebar_Template.png; sourceTree = ""; }; - 3177607C133554A80025876E /* SearchWebView.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = SearchWebView.js; path = html/lib/SearchWebView.js; sourceTree = ""; }; 31776087133569350025876E /* SearchWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchWebView.h; sourceTree = ""; }; 31776088133569350025876E /* SearchWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SearchWebView.m; sourceTree = ""; }; 31DAA7EC1317737100463846 /* gitx_l_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = gitx_l_pub.pem; sourceTree = ""; }; @@ -477,12 +471,6 @@ D8FDDA69114335E8005647F6 /* PBGitSVTagItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitSVTagItem.m; sourceTree = ""; }; D8FDDA7311433634005647F6 /* PBSourceViewItems.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBSourceViewItems.h; sourceTree = ""; }; D8FDDBF31143F318005647F6 /* AddRemote.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = AddRemote.png; path = Images/AddRemote.png; sourceTree = ""; }; - EB2A73480FEE3F09006601CF /* PBCollapsibleSplitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBCollapsibleSplitView.h; sourceTree = ""; }; - EB2A73490FEE3F09006601CF /* PBCollapsibleSplitView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBCollapsibleSplitView.m; sourceTree = ""; }; - F50A411D0EBB874C00208746 /* mainSplitterBar.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = mainSplitterBar.tiff; path = Images/mainSplitterBar.tiff; sourceTree = ""; }; - F50A411E0EBB874C00208746 /* mainSplitterDimple.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = mainSplitterDimple.tiff; path = Images/mainSplitterDimple.tiff; sourceTree = ""; }; - F50A41210EBB875D00208746 /* PBNiceSplitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBNiceSplitView.h; sourceTree = ""; }; - F50A41220EBB875D00208746 /* PBNiceSplitView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBNiceSplitView.m; sourceTree = ""; }; F50FE0E10E07BE9600854FCD /* PBGitRevisionCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRevisionCell.h; sourceTree = ""; }; F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRevisionCell.m; sourceTree = ""; }; F51308590E0740F2000C8BCD /* PBQLOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBQLOutlineView.h; sourceTree = ""; }; @@ -766,7 +754,6 @@ 29B97314FDCFA39411CA2CEA /* GitTest */ = { isa = PBXGroup; children = ( - 3177607C133554A80025876E /* SearchWebView.js */, F5886A080ED5D26B0066E74C /* SpeedTest */, 913D5E420E5563FD00CECEA2 /* cli */, D89E9B4C1218C22A0097A90B /* GitXScripting */, @@ -835,7 +822,6 @@ 02B41A5F123E307F00DFC531 /* PBCommitHookFailedSheet.xib */, F5F7D0641062E7940072C81C /* UpdateKey.pem */, 31DAA7EC1317737100463846 /* gitx_l_pub.pem */, - F50A41130EBB872D00208746 /* Widgets */, 47DBDB920E94F47200671A1E /* Preference Icons */, D26DC6440E782C9000C777B2 /* gitx.icns */, 8D1107310486CEB800E47090 /* Info.plist */, @@ -992,15 +978,6 @@ name = "Source View Items"; sourceTree = ""; }; - F50A41130EBB872D00208746 /* Widgets */ = { - isa = PBXGroup; - children = ( - F50A411D0EBB874C00208746 /* mainSplitterBar.tiff */, - F50A411E0EBB874C00208746 /* mainSplitterDimple.tiff */, - ); - name = Widgets; - sourceTree = ""; - }; F56174540E05887E001DCD79 /* Git */ = { isa = PBXGroup; children = ( @@ -1075,10 +1052,6 @@ F5140DC80E8A8EB20091E9F3 /* RoundedRectangle.m */, F56244070E9684B0002B6C44 /* PBUnsortableTableHeader.h */, F56244080E9684B0002B6C44 /* PBUnsortableTableHeader.m */, - F50A41210EBB875D00208746 /* PBNiceSplitView.h */, - F50A41220EBB875D00208746 /* PBNiceSplitView.m */, - EB2A73480FEE3F09006601CF /* PBCollapsibleSplitView.h */, - EB2A73490FEE3F09006601CF /* PBCollapsibleSplitView.m */, F5FC41F20EBCBD4300191D80 /* PBGitXProtocol.h */, F5FC41F30EBCBD4300191D80 /* PBGitXProtocol.m */, D823487410CB382C00944BDE /* Terminal.h */, @@ -1399,8 +1372,6 @@ F59116E60E843BB50072CCB1 /* PBGitCommitView.xib in Resources */, F5E92A230E88569500056E75 /* new_file.png in Resources */, F5E424110EA3E4D60046E362 /* PBDiffWindow.xib in Resources */, - F50A411F0EBB874C00208746 /* mainSplitterBar.tiff in Resources */, - F50A41200EBB874C00208746 /* mainSplitterDimple.tiff in Resources */, 056438B70ED0C40B00985397 /* DetailViewTemplate.png in Resources */, F56ADDD90ED19F9E002AC78F /* AddBranchTemplate.png in Resources */, F56ADDDA0ED19F9E002AC78F /* AddLabelTemplate.png in Resources */, @@ -1564,7 +1535,6 @@ F5E424150EA3E4E10046E362 /* PBDiffWindowController.m in Sources */, F5E424180EA3E4EB0046E362 /* PBWebDiffController.m in Sources */, F5FE6C030EB13BC900F30D12 /* PBServicesController.m in Sources */, - F50A41230EBB875D00208746 /* PBNiceSplitView.m in Sources */, F5FC41F40EBCBD4300191D80 /* PBGitXProtocol.m in Sources */, F574A2850EAE2EAC003F2CB1 /* PBRefController.m in Sources */, F5FC43FE0EBD08EE00191D80 /* PBRefMenuItem.m in Sources */, @@ -1573,7 +1543,6 @@ 47DBDB670E94EE8B00671A1E /* PBPrefsWindowController.m in Sources */, 47DBDBCA0E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.m in Sources */, F562C8870FE1766C000EC528 /* NSString_RegEx.m in Sources */, - EB2A734A0FEE3F09006601CF /* PBCollapsibleSplitView.m in Sources */, F59F1DD5105C4FF300115F88 /* PBGitIndex.m in Sources */, D854948610D5C01B0083B917 /* PBCreateBranchSheet.m in Sources */, D8E3B34D10DCA958001096A3 /* PBCreateTagSheet.m in Sources */, @@ -1624,7 +1593,6 @@ 217FF0BB12A1CB3300785A65 /* PBGitResetController.m in Sources */, 217FF0BE12A1CB3E00785A65 /* PBRevealWithFinderCommand.m in Sources */, 65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */, - 3177607D133554A80025876E /* SearchWebView.js in Sources */, 31776089133569350025876E /* SearchWebView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Images/mainSplitterBar.tiff b/Images/mainSplitterBar.tiff deleted file mode 100644 index 0e7425df6a6a0b93a86376cd6baae20da5fb51c6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 456 zcmebEWzb?^U=(Q3ObD=05#wcVaY_u>kzyvx-{F!JXtDT{u6U1Ia^Q|9Ww!DYJW_%z zRi^o>Pq9n&UzxHkR)2<1TCnAkYau^pol6hq-1Dy1YTo%5!Q1zW^|~(!$_&|+YBtw@ zMMzet)zYxF;g#32Lw7wb+Z(?jA}7pRb=ukVEm65)+e^3I&EF9{_q%oPsh0&icfY&7 zdiAc)wfkc~NZ6=e``^0l;Ro~C&-A``9f>oD;A#E#>E)TU;>bPE%5CRg$S8@jRja+a z{L-_McWeE&$1b~)K4-S=vg>J&@8oWe-uvu(?fwS^6)|?|;=RWoZvPpxFWr3Z`4=Ts zv3ASD*Iv&rtNOd|dHLQ`T@^KP_UhBmKL6<8z`)DMz`)D^3=#%6Ai)S_a{<{*U^Y;W zaT6mmRGbyaV}r7pfNVhq7O-9h1`bA1s5nT67+ib~qd1Js$iXPZ05kz;7X#xCMrkk--1} diff --git a/Images/mainSplitterDimple.tiff b/Images/mainSplitterDimple.tiff deleted file mode 100644 index 8f69b30bc1cd50f0f63437329d2c40f44f451a11..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24140 zcmeGkZEzdKbS`XF5RX=XCfe^lM6iQlQgzs=nR3lTNbi z_zILHy|Zui_U(Ib-@bkO-kmhN=`^|uA=HaT(7#b9Kos1#aFLH*fGGp+2e^a4&_?xB zE(6~MwQd9M0C?DxbNCTzvw;VJ)QACN?rjE)Wo|d=(Glt*1k!N#)DZQ-I=q9r*dpf& z1IB$Z2ugGbKyHd9@K%7M)I@`(73WUw&*n}Z%kg>7WVC;LDY8^5mqbl) zFO`aNC9*W(5pdrTfHB(VaT5~l*n~${>QFl4jw`C@_Kz{6IhqT){lPId6b!Mn*PT{m zcT${pGdyTUhukb1VYrB&a~qc@+7HmUnqP>_CXz;I>3KXN2WmyxJM&-(-x)4)NLagLesjNxRHI^&PD^+d6Jq?SaA(ab$a6C;AyIqOUat30<$LI$&9iF_v#d_vUDS2b7rI^u^8nH39a~6 zzD!Y&1vRe73sRw~>b)~&?`_&z`47#C6{T1uTEjAc%g5l-5Mga@WxZi-R%>%BYlHKk zENOLfwV+$M4ycj{3yJ7zj?s#1rQZ*v$HjzH5G&9}An0WSA-KbE^IkT{dfAX4Zoq~8 z-T+6#%>WGeFz03YpqHZ=FUN%8=Dh(HZjJ>U$O+MK18oS`1JDjP=jYg~LmU_K`{Prw zP$I^Jr$c-oNkcEmc+4M&C)tEy)+WsiwRN|(gamW#kOg7EpDk1@3FUfBYKj!lurg2p zG7?usK@$^jM{(#IWoY=%(xC{$Mgr^}nvGzGXrZ)N8@HsDytJ@v$_Qf_9FsL;{2rRA z%dk+k%7FEg7c^mAQmnKsa>#fTHLEDa=$h%sGAM)m-JXnmu09v#s#+x3A)oV!MX?0F zT!Hyunge$}7g%Xx=APG(}zZ)%~1g1dF5B8*rwu;McJL(&_fYF_%E8)NFOYr_+&?T+swMC#Dk7 zYE{Zd5=B9pL=LeVX~+?dcJhq*d}hZdo}g7#kre zRz~6gbMO!+Mn@qs6CMk$mAonZalvrV@AcDs zkR~OB+z`X+B}*`R$pJpV=rn#W<_eJ#!ZUgys5<)Y;5SXEaP#)qS(Bl&5 zq2zHH21+P#UmS#eT;g6hNC&tCUMLAKBm+O=hgMvIwovMr5P`$EECydHFEr<-?eU4`UjhCp0`mU@VO%(s&;C$P<}7)`X>*pchh*7t)qD z=nZ+pUfv6)VHhvNdKu2k_`Q&lfQSisA%DT+Eelx3RaTw1%fr>CW9`XYCLvEd_3K z{Rtzs*MPNDbRQR0yt!k-1A9L`Zc)y`1}wQS;W?O1j)utw*`0|4@$3zmX?M8@TW#E# zgHto9xZ5-8^To=rW7FqLWE1YpOlmIc#`{No)B8Pc>tatjb+mN6jeH@ zz`njBZ2uegVR~RQ*xU1K65cI5mc!fD6xHPE8?V4tOu1m`?j~hkrychhZT)>~ij*|5 z6jN1Uxgk`*RZs~SO{G?marR+hA)s_I8iF071i*6F)ChJYX=1V{6zUoQJs43eh-wt} z=a?W-&}V8m?laYfy<_X03Cmtev$Oh;+s@ImgJ4?NWFn1GVJvzIwuj-s)N0f;F_vN=iW>);@nN zy~-FYc9ts2sPI19x^-5Y9`j=Po2nH}%wy!NnA6Tjm;dhuh-b;Nkf25qIXwmr-AL(Y zL5ISy!+0fiAiy`FEeqj)zt+}i9*BDvxC69~a1{?2W$@uX_$`M#QJWsH3OdZf@?J?D z2!)!^=a>h8DN>LR;q~>r4#6v3d#!<;^KrSM{6Sf`AOrKdM!3ql{C|kd?d=2D3nw(M zZ-}e-z$!s_74-QXo6F_=g&Ut&8=NIZzu)gDt;xlB8;WI8@CJ;(x^6rx8?RC{J;uV* zW8=kYt+z#OxommCGV2eyg3`I*%u!MyH8|-LU;X%8P;zw;ecmMSKIB_ifR-YZ-2_7!m@}XId>z9= z3x#fk(xeFx%xD8cWd0rM2$d14wY^+_z|C!&YVV|tSO!i%g$s`r#@TU=ej8SV(^KKX zR@Cit5r$kjDD?5*Dz*?lAr*eGK_w(03CU;<#!>`GgFg|eC;@PZ;6yYAI0-GlAL$Xw z=F7A;#$u`ZoLFeA1SZ;0A6MmSu?Qdd@YilQW>n5s4$R+#RW|r$a~cCRGN>#Z+geoQ z0@TShBQ9vx`jn=Wj5<+cwy`u zQY|;3y5R>RI2Klvt0mwWn4ZJZ;cI=sL4Bi8)s(%WEW+WJVjd7E3xUBP?$?Pi2DhY2 z1vh-W*W-7=L4VolLs{s`FfKNJGbUXrh)tMop{QkrLKAK^0F%#C?m3dNNj&3Z|tt>4S&g*K{;+_T^lzMa)30y)sl zV%%X}{?y)j1F)d|ii~aDrzzzFRjneLj)B|yi{MBrumkgo1`f3XzX7Irv6Y;x%`31l zGypd>`5J-sbvR65%7|KUt}$HLp((9NaiGI5@O*aBy%dE(W*iEW_&&Pfe zboF%icDV*PXdHHR?%d3D#Xcl#@!Wh1+r9P9Gxtwjx@%jXK{Pbh@YQgPKAAC{#>jSs_;F;=g-$-75_kAD#=BFS3=}Uk6(t|&I z_T@LPTR49EXTJQcCw}(3w?ccbFPymJvtRl4lRy9c+ry}%1GMcVI`wpS1&9hena!P` z!Ofm6UFUiF6&i4nK8MjHdNug$ThAT%v-Z(1zWqIBeE%!Y#sB!v;I0R1=q-NN-8EGE zrS6A2iJ1>V3BHKXCKN+?q@Z~S`fij#ivVkIR|r%FiY;fMaHBXR4-N|?J#0D+Afg6J zf-I$Gld~p1CMR&neID+Wp&w2WM<|w@v#v;#gzquh25M`!Mre7eqeaJT@k<^l`G{tt%M>SIk5tFPWRZ}0F7R(-J;<80=yq;$jlF;xvCKtwS zIzzyVOAD$55KeX$JLu8))RjlC>D{$$W6y1qJ2Rii2j1Lt`{PG{vUK0b{o5CwIC^jR z`Fke1mVb2g>sPvG(_P1}O+Ee4p6?v)I{M@IGvPg-EKYtQc9?r;&(}Wk^66MyqaWPX s|I&SlucrSYUbVYp_L+NV=+1T8IRCv?L+Ese9)UoU-qWr+Y-I2M04eb&>;M1& diff --git a/PBCollapsibleSplitView.h b/PBCollapsibleSplitView.h deleted file mode 100644 index 1a52c0d..0000000 --- a/PBCollapsibleSplitView.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// PBCollapsibleSplitView.h -// GitX -// -// This is a limited subclass of a SplitView. It adds methods to aid in -// collapsing/uncollapsing subviews using the mouse or programmatically. -// Right now it only works for vertical layouts and with two subviews. -// -// Created by Johannes Gilger on 6/21/09. -// Copyright 2009 Johannes Gilger. All rights reserved. -// - -#import -#import "PBNiceSplitView.h" - -@interface PBCollapsibleSplitView : PBNiceSplitView { - CGFloat topViewMin; - CGFloat bottomViewMin; - CGFloat splitterPosition; -} - -@property (readonly) CGFloat topViewMin; -@property (readonly) CGFloat bottomViewMin; - -- (void)setTopMin:(CGFloat)topMin andBottomMin:(CGFloat)bottomMin; -- (void)uncollapse; -- (void)keyDown:(NSEvent *)event; - -@end diff --git a/PBCollapsibleSplitView.m b/PBCollapsibleSplitView.m deleted file mode 100644 index 9665cac..0000000 --- a/PBCollapsibleSplitView.m +++ /dev/null @@ -1,57 +0,0 @@ -// -// PBCollapsibleSplitView.m -// GitX -// -// Created by Johannes Gilger on 6/21/09. -// Copyright 2009 Johannes Gilger. All rights reserved. -// - -#import "PBCollapsibleSplitView.h" - -@implementation PBCollapsibleSplitView -@synthesize topViewMin, bottomViewMin; - -- (void)setTopMin:(CGFloat)topMin andBottomMin:(CGFloat)bottomMin { - topViewMin = topMin; - bottomViewMin = bottomMin; -} - -- (void)uncollapse { - for (NSView *subview in [self subviews]) { - if([self isSubviewCollapsed:subview]) { - [self setPosition:[self frame].size.height / 3 ofDividerAtIndex:0]; - [self adjustSubviews]; - } - } -} - -- (void)collapseSubview:(NSInteger)index { - // Already collapsed, just uncollapse - if ([self isSubviewCollapsed:[[self subviews] objectAtIndex:index]]) { - [self setPosition:splitterPosition ofDividerAtIndex:0]; - return; - } - - // Store splitterposition if the other view isn't collapsed - if (![self isSubviewCollapsed:[[self subviews] objectAtIndex:(index + 1) % 2]]) - splitterPosition = [[[self subviews] objectAtIndex:0] frame].size.height; - - if (index == 0) // Top view - [self setPosition:0.0 ofDividerAtIndex:0]; - else // Bottom view - [self setPosition:[self frame].size.height ofDividerAtIndex:0]; -} - -- (void)keyDown:(NSEvent *)event { - if (!([event modifierFlags] & NSShiftKeyMask && [event modifierFlags] & NSCommandKeyMask)) - return [super keyDown:event]; - - if ([event keyCode] == 0x07E) { // Up-Key - [self collapseSubview:0]; - [[self window] makeFirstResponder:[[self subviews] objectAtIndex:1]]; - } else if ([event keyCode] == 0x07D) { // Down-Key - [self collapseSubview:1]; - [[self window] makeFirstResponder:[[self subviews] objectAtIndex:0]]; - } -} -@end diff --git a/PBGitCommitController.m b/PBGitCommitController.m index f0e42e0..6ea4c95 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -11,7 +11,6 @@ #import "PBChangedFile.h" #import "PBWebChangesController.h" #import "PBGitIndex.h" -#import "PBNiceSplitView.h" #define kCommitSplitViewPositionDefault @"Commit SplitView Position" @@ -229,16 +228,16 @@ - (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex { - if (splitView == commitSplitView) + if (proposedMin < kCommitSplitViewTopViewMin) return kCommitSplitViewTopViewMin; - return proposedMin; } - (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex { - if (splitView == commitSplitView) - return [splitView frame].size.height - [splitView dividerThickness] - kCommitSplitViewBottomViewMin; + CGFloat max=[splitView frame].size.height - [splitView dividerThickness] - kCommitSplitViewBottomViewMin; + if (max < proposedMax) + return max; return proposedMax; } diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index 8d9472c..fe373f5 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -10,7 +10,6 @@ #import "PBGitCommit.h" #import "PBGitTree.h" #import "PBViewController.h" -#import "PBCollapsibleSplitView.h" @class PBGitSidebarController; @class PBWebHistoryController; @@ -32,7 +31,7 @@ IBOutlet NSOutlineView* fileBrowser; NSArray *currentFileBrowserSelectionPath; IBOutlet PBCommitList* commitList; - IBOutlet PBCollapsibleSplitView *historySplitView; + IBOutlet NSSplitView *historySplitView; IBOutlet PBWebHistoryController *webHistoryController; QLPreviewPanel* previewPanel; IBOutlet PBHistorySearchController *searchController; @@ -59,7 +58,7 @@ } @property (readonly) NSTreeController* treeController; -@property (readonly) PBCollapsibleSplitView *historySplitView; +@property (readonly) NSSplitView *historySplitView; @property (assign) int selectedCommitDetailsIndex; @property (retain) PBGitCommit *webCommit; @property (retain) PBGitTree* gitTree; @@ -107,7 +106,5 @@ - (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview; - (BOOL)splitView:(NSSplitView *)splitView shouldCollapseSubview:(NSView *)subview forDoubleClickOnDividerAtIndex:(NSInteger)dividerIndex; -- (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)offset; -- (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)offset; @end diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index 657b2df..ff1c597 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -83,7 +83,7 @@ // Add a menu that allows a user to select which columns to view [[commitList headerView] setMenu:[self tableColumnMenu]]; - [historySplitView setTopMin:58.0 andBottomMin:100.0]; +// [historySplitView setTopMin:58.0 andBottomMin:100.0]; [historySplitView setHidden:YES]; [self performSelector:@selector(restoreSplitViewPositiion) withObject:nil afterDelay:0]; @@ -628,42 +628,6 @@ return FALSE; } -- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex -{ - return historySplitView.topViewMin; -} - -- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex -{ - return [splitView frame].size.height - [splitView dividerThickness] - historySplitView.bottomViewMin; -} - -// while the user resizes the window keep the upper (history) view constant and just resize the lower view -// unless the lower view gets too small -- (void)splitView:(NSSplitView *)splitView resizeSubviewsWithOldSize:(NSSize)oldSize -{ - NSRect newFrame = [splitView frame]; - - float dividerThickness = [splitView dividerThickness]; - - NSView *upperView = [[splitView subviews] objectAtIndex:0]; - NSRect upperFrame = [upperView frame]; - upperFrame.size.width = newFrame.size.width; - - if ((newFrame.size.height - upperFrame.size.height - dividerThickness) < historySplitView.bottomViewMin) { - upperFrame.size.height = newFrame.size.height - historySplitView.bottomViewMin - dividerThickness; - } - - NSView *lowerView = [[splitView subviews] objectAtIndex:1]; - NSRect lowerFrame = [lowerView frame]; - lowerFrame.origin.y = upperFrame.size.height + dividerThickness; - lowerFrame.size.height = newFrame.size.height - lowerFrame.origin.y; - lowerFrame.size.width = newFrame.size.width; - - [upperView setFrame:upperFrame]; - [lowerView setFrame:lowerFrame]; -} - // NSSplitView does not save and restore the position of the SplitView correctly so do it manually - (void)saveSplitViewPosition { @@ -684,6 +648,23 @@ } +- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex +{ + if (proposedMin < 100) + return 100; + return proposedMin; +} + +- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex +{ + CGFloat max=[splitView frame].size.height - [splitView dividerThickness] - 100; + if (max < proposedMax) + return max; + + return proposedMax; +} + + #pragma mark Repository Methods - (IBAction) createBranch:(id)sender diff --git a/PBGitWindowController.h b/PBGitWindowController.h index c481fa3..0eb02df 100644 --- a/PBGitWindowController.h +++ b/PBGitWindowController.h @@ -21,7 +21,7 @@ PBGitSidebarController *sidebarController; IBOutlet NSView *sourceListControlsView; - IBOutlet NSSplitView *splitView; + IBOutlet NSSplitView *mainSplitView; IBOutlet NSView *sourceSplitView; IBOutlet NSView *contentSplitView; @@ -30,6 +30,9 @@ IBOutlet NSToolbarItem *terminalItem; IBOutlet NSToolbarItem *finderItem; + + NSArray *splitViews; + NSMutableArray *splitViewsSize; } @property (assign) __weak PBGitRepository *repository; @@ -42,7 +45,9 @@ - (void)showMessageSheet:(NSString *)messageText infoText:(NSString *)infoText; - (void)showErrorSheet:(NSError *)error; - (void)showErrorSheetTitle:(NSString *)title message:(NSString *)message arguments:(NSArray *)arguments output:(NSString *)output; -- (void)collapseSplitView:(NSSplitView *)sp show:(BOOL)show; + +-(void)initChangeLayout; +-(IBAction)changeLayout:(id)sender; - (IBAction) showCommitView:(id)sender; - (IBAction) showHistoryView:(id)sender; @@ -50,7 +55,6 @@ - (IBAction) openInTerminal:(id)sender; - (IBAction) cloneTo:(id)sender; - (IBAction) refresh:(id)sender; -- (IBAction) changeLayout:(id)sender; - (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode; diff --git a/PBGitWindowController.m b/PBGitWindowController.m index 929bf61..bca2b1f 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -25,19 +25,19 @@ { if (!(self = [self initWithWindowNibName:@"RepositoryWindow"])) return nil; - + self.repository = theRepository; - + return self; } - (void)windowWillClose:(NSNotification *)notification { //DLog(@"Window will close!"); - + if (sidebarController) [sidebarController closeView]; - + if (contentController) [contentController removeObserver:self forKeyPath:@"status"]; } @@ -59,22 +59,23 @@ [[self window] setDelegate:self]; [[self window] setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge]; [[self window] setContentBorderThickness:31.0f forEdge:NSMinYEdge]; - + sidebarController = [[PBGitSidebarController alloc] initWithRepository:repository superController:self]; [[sidebarController view] setFrame:[sourceSplitView bounds]]; [sourceSplitView addSubview:[sidebarController view]]; [sourceListControlsView addSubview:sidebarController.sourceListControlsView]; - + [[statusField cell] setBackgroundStyle:NSBackgroundStyleRaised]; [progressIndicator setUsesThreadedAnimation:YES]; - + NSImage *finderImage = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kFinderIcon)]; [finderItem setImage:finderImage]; - + NSImage *terminalImage = [[NSWorkspace sharedWorkspace] iconForFile:@"/Applications/Utilities/Terminal.app/"]; [terminalItem setImage:terminalImage]; - + [self showWindow:nil]; + [self initChangeLayout]; } - (void) removeAllContentSubViews @@ -88,17 +89,17 @@ { if (!controller || (contentController == controller)) return; - + if (contentController) [contentController removeObserver:self forKeyPath:@"status"]; - + [self removeAllContentSubViews]; - + contentController = controller; [[contentController view] setFrame:[contentSplitView bounds]]; [contentSplitView addSubview:[contentController view]]; - + [self setNextResponder: contentController]; [[self window] makeFirstResponder:[contentController firstResponder]]; [contentController updateView]; @@ -183,14 +184,14 @@ { NSString *status = contentController.status; BOOL isBusy = contentController.isBusy; - + if (!status) { status = @""; isBusy = NO; } - + [statusField setStringValue:status]; - + if (isBusy) { [progressIndicator startAnimation:self]; [progressIndicator setHidden:NO]; @@ -207,7 +208,7 @@ [self updateStatus]; return; } - + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } @@ -216,46 +217,77 @@ [sidebarController setHistorySearch:searchString mode:mode]; } -- (IBAction) changeLayout:(id)sender{ - NSSplitView *sp=nil; - switch ([sender selectedSegment]) { - case 0: - sp=splitView; - break; - case 1: - sp=[[sidebarController historyViewController] historySplitView]; - break; - } - DLog(@"sp=%@",sp); - if(sp!=nil) { - [self collapseSplitView:sp show:[sender isSelectedForSegment:[sender selectedSegment]]]; - } +#pragma mark - SplitView changeLayout +-(void)initChangeLayout +{ + splitViews=[NSArray arrayWithObjects:mainSplitView,[[sidebarController historyViewController] historySplitView], nil]; + splitViewsSize=[NSMutableArray arrayWithCapacity:[splitViews count]]; + for (int n=0; n<[splitViews count]; n++) { + NSSplitView *splitView=[splitViews objectAtIndex:n]; + NSView *left=[[splitView subviews] objectAtIndex:0]; + [splitViewsSize addObject:[NSNumber numberWithInt:[left frame].size.width]]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(resizeSubviewsHandler:) + name:NSSplitViewWillResizeSubviewsNotification + object:splitView + ]; + } } -- (void)collapseSplitView:(NSSplitView *)sp show:(BOOL)show{ - NSView *clipview = [[sp subviews] objectAtIndex:0]; - NSRect clipFrame = [clipview frame]; +- (IBAction)changeLayout:(id)sender +{ + NSInteger index=[sender selectedSegment]; + NSSplitView *splitView=[splitViews objectAtIndex:index]; + NSView *left=[[splitView subviews] objectAtIndex:0]; + + CGFloat pos; + if ([splitView isSubviewCollapsed:left]) + pos=[[splitViewsSize objectAtIndex:index] intValue]; + else + pos=[splitView minPossiblePositionOfDividerAtIndex:0]; - if ([sp isVertical]) { - clipFrame.size.width = kGitSplitViewMinWidth * show; - }else{ - clipFrame.size.height = kGitSplitViewMinWidth * show; - } + [splitView setPosition:pos ofDividerAtIndex:0 ]; +} - [[clipview animator] setFrame:clipFrame]; - [sp adjustSubviews]; +- (void)resizeSubviewsHandler:(NSNotification *)notif +{ + NSSplitView *splitView=[notif object]; + NSInteger index=[splitViews indexOfObject:splitView]; + NSView *left=[[splitView subviews] objectAtIndex:0]; + + NSNumber *pos; + if([splitView isVertical]){ + pos=[NSNumber numberWithInt:[left frame].size.width]; + }else{ + pos=[NSNumber numberWithInt:[left frame].size.height]; + } + + [splitViewsSize removeObjectAtIndex:index]; + [splitViewsSize insertObject:pos atIndex:index]; } #pragma mark - #pragma mark SplitView Delegates +- (BOOL)splitView:(NSSplitView *)sp canCollapseSubview:(NSView *)subview +{ + return TRUE; +} + +- (BOOL)splitView:(NSSplitView *)splitView shouldCollapseSubview:(NSView *)subview forDoubleClickOnDividerAtIndex:(NSInteger)dividerIndex +{ + NSUInteger index = [[splitView subviews] indexOfObject:subview]; + return index==0; +} + #pragma mark min/max widths while moving the divider - (CGFloat)splitView:(NSSplitView *)view constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex { if (proposedMin < kGitSplitViewMinWidth) return kGitSplitViewMinWidth; - + return proposedMin; } @@ -263,7 +295,7 @@ { if (dividerIndex == 0) return kGitSplitViewMaxWidth; - + return proposedMax; } @@ -272,19 +304,19 @@ - (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize:(NSSize)oldSize { NSRect newFrame = [sender frame]; - + float dividerThickness = [sender dividerThickness]; - + NSView *sourceView = [[sender subviews] objectAtIndex:0]; NSRect sourceFrame = [sourceView frame]; sourceFrame.size.height = newFrame.size.height; - + NSView *mainView = [[sender subviews] objectAtIndex:1]; NSRect mainFrame = [mainView frame]; mainFrame.origin.x = sourceFrame.size.width + dividerThickness; mainFrame.size.width = newFrame.size.width - mainFrame.origin.x; mainFrame.size.height = newFrame.size.height; - + [sourceView setFrame:sourceFrame]; [mainView setFrame:mainFrame]; } diff --git a/PBNiceSplitView.h b/PBNiceSplitView.h deleted file mode 100644 index f5969e7..0000000 --- a/PBNiceSplitView.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// PBNiceSplitView.h -// GitX -// -// Created by Pieter de Bie on 31-10-08. -// Copyright 2008 Pieter de Bie. All rights reserved. -// - -#import - -@interface PBNiceSplitView : NSSplitView { - -} - -@end diff --git a/PBNiceSplitView.m b/PBNiceSplitView.m deleted file mode 100644 index 994e6d4..0000000 --- a/PBNiceSplitView.m +++ /dev/null @@ -1,45 +0,0 @@ -// -// PBNiceSplitView.m -// GitX -// -// Created by Pieter de Bie on 31-10-08. -// Copyright 2008 Pieter de Bie. All rights reserved. -// - -#import "PBNiceSplitView.h" - -static NSImage *bar; -static NSImage *grip; - -@implementation PBNiceSplitView - -+(void) initialize -{ - NSString *barPath = [[NSBundle mainBundle] pathForResource:@"mainSplitterBar" ofType:@"tiff"]; - bar = [[NSImage alloc] initWithContentsOfFile: barPath]; - [bar setFlipped: YES]; - - NSString *gripPath = [[NSBundle mainBundle] pathForResource:@"mainSplitterDimple" ofType:@"tiff"]; - grip = [[NSImage alloc] initWithContentsOfFile: gripPath]; - [grip setFlipped: YES]; -} - -- (void)drawDividerInRect:(NSRect)aRect -{ - // Draw bar and grip onto the canvas - NSRect gripRect = aRect; - gripRect.origin.x = (NSMidX(aRect) - ([grip size].width/2)); - gripRect.size.width = 8; - - [self lockFocus]; - [bar drawInRect:aRect fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0]; - [grip drawInRect:gripRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; - [self unlockFocus]; -} - -- (CGFloat)dividerThickness -{ - return 10.0; -} - -@end From 5e9210d2c2d787dd105c913db7af68b28979774d Mon Sep 17 00:00:00 2001 From: German Laullon Date: Thu, 28 Apr 2011 10:12:56 -0700 Subject: [PATCH 36/36] [laullon/gitx GH-41] Open in FileMerge link doesn't always work --- GLFileView.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/GLFileView.m b/GLFileView.m index d51fa6a..f6d68c6 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -430,8 +430,10 @@ +(NSString *)getFileName:(NSString *)line { - NSRange b = [line rangeOfString:@"b/"]; - NSString *file=[line substringFromIndex:b.location+2]; + NSRange b = [line rangeOfString:@" b/"]; + NSString *file=[line substringFromIndex:b.location+3]; + DLog(@"line=%@",line); + DLog(@"file=%@",file); return file; }
",fileName]]; do{ [res appendString:[NSString stringWithFormat:@"

%@

",line]]; - line=[lines objectAtIndex:++i]; + line=nil; + if (i<([lines count]-1)) + line = [lines objectAtIndex:++i]; }while([GLFileView isDiffHeader:line]); [res appendString:@"
"]; if(![self isBinaryFile:line]){ @@ -295,6 +297,9 @@ } [res appendString:@"
"]; [res appendString:[NSString stringWithFormat:@"%@
",[files objectAtIndex:0]]]; @@ -358,7 +362,7 @@ } } [res appendString:@"
%@