Files
gitx/PBCommitMessageView.m
T
Kevin Ballard e168123c0e Draw commit message line more accurately
When drawing the commit message line, the given rect should not be used
for anything other than clipping. According to the comment, the code that
draws the line relies on the text view always drawing complete lines.
However, it also draws fragments, specifically when the insertion point
is flashing. By ignoring the given rect, not only is our line more accurate
in its positioning, but we also handle the case where the insertion point
is sitting on top of the line.
2010-11-17 19:50:40 -07:00

36 lines
998 B
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
{
[super drawRect:aRect];
// draw a vertical line after the given size (used as an indicator
// for the first line of the commit message)
if ([PBGitDefaults commitMessageViewHasVerticalLine]) {
float characterWidth = [@" " sizeWithAttributes:[self typingAttributes]].width;
float lineWidth = characterWidth * [PBGitDefaults commitMessageViewVerticalLineLength];
[[NSColor lightGrayColor] set];
float padding = [[self textContainer] lineFragmentPadding];
NSRect line;
line.origin.x = padding + lineWidth;
line.origin.y = 0;
line.size.width = 1;
line.size.height = [self bounds].size.height;
NSRectFill(line);
}
}
@end