Files
gitx/PBCommitMessageView.m
T
Jeff Mesnil fc63af0709 CommitView: Add a vertical line to the commit message
Since Git recommends to use 50 characters in the first line of a commit
message, this adds a vertical line to the commit message view to show where
the 50 char limit is.

[PB: This preference can be changed using a user default -- for now we don't
have a preference pane yet, so this is hidden.]
2008-10-21 14:56:43 +02:00

41 lines
1.1 KiB
Objective-C

//
// PBCommitMessageView.m
// GitX
//
// Created by Jeff Mesnil on 13/10/08.
// Copyright 2008 Jeff Mesnil (http://jmesnil.net/). All rights reserved.
//
#import "PBCommitMessageView.h"
#import "PBGitDefaults.h"
@implementation PBCommitMessageView
- (void)drawRect:(NSRect)aRect
{
NSColor *originalColor = [self backgroundColor];
[originalColor set];
NSRectFill(aRect);
// draw a vertical line after the given size (used as an indicator
// for the first line of the commit message)
float characterWidth = [@" " sizeWithAttributes:[self typingAttributes]].width;
float lineWidth = characterWidth * [PBGitDefaults commitMessageViewVerticalLineLength];
[[NSColor lightGrayColor] set];
// This depends upon the fact that NSTextView always redraws complete lines.
float padding = [[self textContainer] lineFragmentPadding];
NSRect line;
line.origin.x = padding + aRect.origin.x + lineWidth;
line.origin.y = aRect.origin.y;
line.size.width = 1;
line.size.height = aRect.size.height;
NSRectFill(line);
[self setBackgroundColor:nil];
[super drawRect:aRect];
[self setBackgroundColor:originalColor];
}
@end