mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Add support for --left-right
This draws rectangles instead of circles when someone supplies --left-right as a GitX argument
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
NSString* details;
|
||||
NSArray* parents;
|
||||
NSDate* date;
|
||||
char sign;
|
||||
PBGitRepository* repository;
|
||||
}
|
||||
|
||||
@@ -28,6 +29,7 @@
|
||||
@property (retain) NSArray* parents;
|
||||
@property (copy) NSDate* date;
|
||||
@property (readonly) NSString* dateString;
|
||||
@property (assign) char sign;
|
||||
|
||||
@property (readonly) NSString* details;
|
||||
@property (readonly) PBGitTree* tree;
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
|
||||
@implementation PBGitCommit
|
||||
|
||||
@synthesize sha, repository, subject, author, date, parents;
|
||||
@synthesize sha, repository, subject, author, date, parents, sign;
|
||||
|
||||
|
||||
- (NSString *) dateString
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@
|
||||
|
||||
++row;
|
||||
previous = [[PBGraphCellInfo alloc] initWithPosition:newPos andLines:lines];
|
||||
|
||||
previous.sign = commit.sign;
|
||||
if (refs && [refs objectForKey:commit.sha])
|
||||
previous.refs = [refs objectForKey:commit.sha];
|
||||
|
||||
|
||||
+12
-3
@@ -56,9 +56,16 @@
|
||||
- (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev
|
||||
{
|
||||
|
||||
NSMutableArray * newArray = [NSMutableArray array];
|
||||
NSMutableArray* newArray = [NSMutableArray array];
|
||||
NSMutableArray* arguments;
|
||||
NSDate* start = [NSDate date];
|
||||
NSMutableArray* arguments = [NSMutableArray arrayWithObjects:@"log", @"--topo-order", @"--pretty=format:%H\01%an\01%s\01%P\01%at", nil];
|
||||
BOOL showSign = [rev hasLeftRight];
|
||||
|
||||
if (showSign)
|
||||
arguments = [NSMutableArray arrayWithObjects:@"log", @"--topo-order", @"--pretty=format:%H\01%an\01%s\01%P\01%at\01%m", nil];
|
||||
else
|
||||
arguments = [NSMutableArray arrayWithObjects:@"log", @"--topo-order", @"--pretty=format:%H\01%an\01%s\01%P\01%at", nil];
|
||||
|
||||
if (!rev)
|
||||
[arguments addObject:@"HEAD"];
|
||||
else
|
||||
@@ -100,7 +107,9 @@
|
||||
newCommit.subject = [components objectAtIndex:2];
|
||||
newCommit.author = [components objectAtIndex:1];
|
||||
newCommit.date = [NSDate dateWithTimeIntervalSince1970:[[components objectAtIndex:4] intValue]];
|
||||
|
||||
if (showSign)
|
||||
newCommit.sign = [[components objectAtIndex:5] characterAtIndex:0];
|
||||
|
||||
[newArray addObject: newCommit];
|
||||
num++;
|
||||
if (num % 10000 == 0)
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
- (BOOL) isSimpleRef;
|
||||
- (NSString*) simpleRef;
|
||||
- (BOOL) hasPathLimiter;
|
||||
- (BOOL) hasLeftRight;
|
||||
|
||||
- (BOOL) isEqualTo: (PBGitRevSpecifier*) other;
|
||||
@property(readonly) NSString* description;
|
||||
|
||||
@@ -55,6 +55,14 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) hasLeftRight
|
||||
{
|
||||
for (NSString* param in parameters)
|
||||
if ([param isEqualToString:@"--left-right"])
|
||||
return YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) isEqualTo: (PBGitRevSpecifier*) other
|
||||
{
|
||||
if ([self isSimpleRef] ^ [other isSimpleRef])
|
||||
|
||||
+41
-5
@@ -108,20 +108,21 @@
|
||||
|
||||
}
|
||||
|
||||
- (void) drawCircleForColumn: (int) c inRect: (NSRect) r
|
||||
- (void) drawCircleInRect: (NSRect) r
|
||||
{
|
||||
[[NSColor blackColor] set];
|
||||
|
||||
int c = cellInfo.position;
|
||||
int columnWidth = 10;
|
||||
NSPoint origin = r.origin;
|
||||
NSPoint columnOrigin = { origin.x + columnWidth * c, origin.y};
|
||||
|
||||
|
||||
NSRect oval = { columnOrigin.x - 5, columnOrigin.y + r.size.height * 0.5 - 5, 10, 10};
|
||||
|
||||
|
||||
NSBezierPath * path = [NSBezierPath bezierPath];
|
||||
path = [NSBezierPath bezierPathWithOvalInRect:oval];
|
||||
//[[col objectAtIndex:cellInfo.columns[c].color] set];
|
||||
|
||||
[[NSColor blackColor] set];
|
||||
[path fill];
|
||||
|
||||
NSRect smallOval = { columnOrigin.x - 3, columnOrigin.y + r.size.height * 0.5 - 3, 6, 6};
|
||||
@@ -130,6 +131,38 @@
|
||||
[path fill];
|
||||
}
|
||||
|
||||
- (void) drawTriangleInRect: (NSRect) r sign: (char) sign
|
||||
{
|
||||
int c = cellInfo.position;
|
||||
int columnHeight = 10;
|
||||
int columnWidth = 8;
|
||||
|
||||
NSPoint top;
|
||||
if (sign == '<')
|
||||
top.x = round(r.origin.x) + 10 * c + 4;
|
||||
else {
|
||||
top.x = round(r.origin.x) + 10 * c - 4;
|
||||
columnWidth *= -1;
|
||||
}
|
||||
top.y = r.origin.y + (r.size.height - columnHeight) / 2;
|
||||
|
||||
NSBezierPath * path = [NSBezierPath bezierPath];
|
||||
// Start at top
|
||||
[path moveToPoint: NSMakePoint(top.x, top.y)];
|
||||
// Go down
|
||||
[path lineToPoint: NSMakePoint(top.x, top.y + columnHeight)];
|
||||
// Go left top
|
||||
[path lineToPoint: NSMakePoint(top.x - columnWidth, top.y + columnHeight / 2)];
|
||||
// Go to top again
|
||||
[path closePath];
|
||||
|
||||
[[NSColor whiteColor] set];
|
||||
[path fill];
|
||||
[[NSColor blackColor] set];
|
||||
[path setLineWidth: 2];
|
||||
[path stroke];
|
||||
}
|
||||
|
||||
- (NSMutableDictionary*) attributesForRefLabelSelected: (BOOL) selected
|
||||
{
|
||||
NSMutableDictionary *attributes = [[[NSMutableDictionary alloc] initWithCapacity:2] autorelease];
|
||||
@@ -213,7 +246,10 @@
|
||||
[self drawLineFromColumn: line.from toColumn: line.to inRect:ownRect offset: 0 color:line.colorIndex];
|
||||
}
|
||||
|
||||
[self drawCircleForColumn: cellInfo.position inRect: ownRect];
|
||||
if (cellInfo.sign == '<' || cellInfo.sign == '>')
|
||||
[self drawTriangleInRect: ownRect sign: cellInfo.sign];
|
||||
else
|
||||
[self drawCircleInRect: ownRect];
|
||||
|
||||
if (cellInfo.refs)
|
||||
[self drawRefsInRect:&rect];
|
||||
|
||||
@@ -14,11 +14,13 @@
|
||||
int position;
|
||||
NSArray* lines;
|
||||
int numColumns;
|
||||
char sign;
|
||||
NSArray* refs;
|
||||
}
|
||||
@property(readonly) NSArray* lines;
|
||||
@property(retain) NSArray* refs;
|
||||
@property(assign) int position, numColumns;
|
||||
@property(assign) char sign;
|
||||
|
||||
- (id)initWithPosition: (int) p andLines: (NSArray*) l;
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
@implementation PBGraphCellInfo
|
||||
@synthesize lines, position, numColumns, refs;
|
||||
@synthesize lines, position, numColumns, refs, sign;
|
||||
- (id)initWithPosition: (int) p andLines: (NSArray*) l
|
||||
{
|
||||
position = p;
|
||||
|
||||
Reference in New Issue
Block a user