diff on file view

This commit is contained in:
German Laullon
2010-12-07 22:26:33 -08:00
parent d1d4a2e7b5
commit 4b85580e2f
5 changed files with 64 additions and 25 deletions
+1
View File
@@ -20,6 +20,7 @@
IBOutlet MGScopeBar *typeBar;
NSMutableArray *groups;
NSString *logFormat;
NSString *diffType;
IBOutlet NSView *accessoryView;
IBOutlet NSSplitView *fileListSplitView;
}
+52 -17
View File
@@ -53,14 +53,40 @@
@"log", ITEM_IDENTIFIER,
@"History", ITEM_NAME,
nil],
[NSDictionary dictionaryWithObjectsAndKeys:
@"diff", ITEM_IDENTIFIER,
@"Diff", ITEM_NAME,
nil],
nil];
[self.groups addObject:[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], GROUP_SEPARATOR,
[NSNumber numberWithInt:MGRadioSelectionMode], GROUP_SELECTION_MODE, // single selection group.
items, GROUP_ITEMS,
nil]];
NSArray *difft = [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
@"l", ITEM_IDENTIFIER,
@"Local", ITEM_NAME,
nil],
[NSDictionary dictionaryWithObjectsAndKeys:
@"h", ITEM_IDENTIFIER,
@"HEAD", ITEM_NAME,
nil],
[NSDictionary dictionaryWithObjectsAndKeys:
@"p", ITEM_IDENTIFIER,
@"Previous", ITEM_NAME,
nil],
nil];
[self.groups addObject:[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], GROUP_SEPARATOR,
[NSNumber numberWithInt:MGRadioSelectionMode], GROUP_SELECTION_MODE, // single selection group.
difft, GROUP_ITEMS,
@"Diff with:",GROUP_LABEL,
nil]];
[typeBar reloadData];
[fileListSplitView setHidden:YES];
[self performSelector:@selector(restoreSplitViewPositiion) withObject:nil afterDelay:0];
}
@@ -76,18 +102,20 @@
NSArray *files=[historyController.treeController selectedObjects];
if ([files count]>0) {
PBGitTree *file=[files objectAtIndex:0];
NSString *fileTxt = @"";
if(startFile==@"fileview")
fileTxt=[self parseHTML:[file textContents]];
else if(startFile==@"blame")
fileTxt=[self parseBlame:[file blame]];
else if(startFile==@"log")
fileTxt=[file log:logFormat];
fileTxt=[file log:logFormat];
else if(startFile==@"diff")
fileTxt=[file diff:diffType];
id script = [view windowScriptObject];
NSString *filePath = [file fullPath];
[script callWebScriptMethod:@"showFile" withArguments:[NSArray arrayWithObjects:fileTxt, filePath, nil]];
[script callWebScriptMethod:@"showFile" withArguments:[NSArray arrayWithObjects:fileTxt, filePath, nil]];
}
#if 0
@@ -146,11 +174,18 @@
- (void)scopeBar:(MGScopeBar *)theScopeBar selectedStateChanged:(BOOL)selected forItem:(NSString *)identifier inGroup:(int)groupNumber
{
startFile=identifier;
NSString *path = [NSString stringWithFormat:@"html/views/%@", identifier];
NSString *html = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:path];
NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:html]];
[[view mainFrame] loadRequest:request];
if(groupNumber==0){
NSString *path = [NSString stringWithFormat:@"html/views/%@", identifier];
NSString *html = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:path];
NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:html]];
[[view mainFrame] loadRequest:request];
startFile=identifier;
}else if(groupNumber==1){
diffType=identifier;
if(startFile==@"diff"){
[[view mainFrame] reload];
}
}
}
- (NSView *)accessoryViewForScopeBar:(MGScopeBar *)scopeBar
@@ -167,7 +202,7 @@
{
[historyController.treeController removeObserver:self forKeyPath:@"selection"];
[self saveSplitViewPosition];
[super closeView];
}
@@ -277,23 +312,23 @@
- (void)splitView:(NSSplitView *)splitView resizeSubviewsWithOldSize:(NSSize)oldSize
{
NSRect newFrame = [splitView frame];
float dividerThickness = [splitView dividerThickness];
NSView *leftView = [[splitView subviews] objectAtIndex:0];
NSRect leftFrame = [leftView frame];
leftFrame.size.height = newFrame.size.height;
if ((newFrame.size.width - leftFrame.size.width - dividerThickness) < kFileListSplitViewRightMin) {
leftFrame.size.width = newFrame.size.width - kFileListSplitViewRightMin - dividerThickness;
}
NSView *rightView = [[splitView subviews] objectAtIndex:1];
NSRect rightFrame = [rightView frame];
rightFrame.origin.x = leftFrame.size.width + dividerThickness;
rightFrame.size.width = newFrame.size.width - rightFrame.origin.x;
rightFrame.size.height = newFrame.size.height;
[leftView setFrame:leftFrame];
[rightView setFrame:rightFrame];
}
@@ -312,7 +347,7 @@
float position = [[NSUserDefaults standardUserDefaults] floatForKey:kHFileListSplitViewPositionDefault];
if (position < 1.0)
position = 200;
[fileListSplitView setPosition:position ofDividerAtIndex:0];
[fileListSplitView setHidden:NO];
}
+3 -2
View File
@@ -11,14 +11,14 @@
@interface PBGitTree : NSObject {
long long _fileSize;
NSString* sha;
NSString* path;
PBGitRepository* repository;
__weak PBGitTree* parent;
NSArray* children;
BOOL leaf;
NSString* localFileName;
NSDate* localMtime;
}
@@ -29,6 +29,7 @@
- (NSString *)textContents;
- (NSString *)blame;
- (NSString *) log:(NSString *)format;
- (NSString *) diff:(NSString *)format;
- (NSString*) tmpFileNameForContents;
- (long long)fileSize;
+8
View File
@@ -6,3 +6,11 @@ var setMessage = function(message) {
$("diff").style.display = "none";
}
var showDiff = function(diff) {
highlightDiff(diff, $("diff"));
}
var showFile = function(txt) {
showDiff(txt);
return;
}
-6
View File
@@ -9,12 +9,6 @@
<link rel="stylesheet" href="diffWindow.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="diffWindow.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
var showDiff = function(diff) {
highlightDiff(diff, $("diff"));
}
</script>
</head>
<body>