mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
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.]
This commit is contained in:
committed by
Pieter de Bie
parent
a8d298218b
commit
fc63af0709
@@ -20,6 +20,9 @@
|
||||
913D5E500E55645900CECEA2 /* gitx in Resources */ = {isa = PBXBuildFile; fileRef = 913D5E490E55644600CECEA2 /* gitx */; };
|
||||
913D5E5F0E556A9300CECEA2 /* PBCLIProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 913D5E5E0E556A9300CECEA2 /* PBCLIProxy.mm */; };
|
||||
91B103CC0E898EC300C84364 /* PBIconAndTextCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = 91B103CB0E898EC300C84364 /* PBIconAndTextCell.mm */; };
|
||||
93CB42C20EAB7B2200530609 /* PBGitDefaults.m in Sources */ = {isa = PBXBuildFile; fileRef = 93CB42C10EAB7B2200530609 /* PBGitDefaults.m */; };
|
||||
93F7857F0EA3ABF100C1F443 /* PBCommitMessageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 93F7857E0EA3ABF100C1F443 /* PBCommitMessageView.m */; };
|
||||
93FCCBA90EA8AF450061B02B /* PBGitConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 93FCCBA80EA8AF450061B02B /* PBGitConfig.m */; };
|
||||
D26DC6450E782C9000C777B2 /* gitx.icns in Resources */ = {isa = PBXBuildFile; fileRef = D26DC6440E782C9000C777B2 /* gitx.icns */; };
|
||||
F50FE0E30E07BE9600854FCD /* PBGitRevisionCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */; };
|
||||
F513085B0E0740F2000C8BCD /* PBQLOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = F513085A0E0740F2000C8BCD /* PBQLOutlineView.m */; };
|
||||
@@ -59,7 +62,6 @@
|
||||
F5B721C40E05CF7E00AF29DC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F5B721C20E05CF7E00AF29DC /* MainMenu.xib */; };
|
||||
F5C007750E731B48007B84B2 /* PBGitRef.m in Sources */ = {isa = PBXBuildFile; fileRef = F5C007740E731B48007B84B2 /* PBGitRef.m */; };
|
||||
F5C6F68D0E65FF9300478D97 /* PBGitLane.m in Sources */ = {isa = PBXBuildFile; fileRef = F5C6F68C0E65FF9300478D97 /* PBGitLane.m */; };
|
||||
F5D2DC870EA401A80034AD24 /* PBGitConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = F5D2DC860EA401A80034AD24 /* PBGitConfig.m */; };
|
||||
F5DFFA6C0E075D8800617813 /* PBEasyFS.m in Sources */ = {isa = PBXBuildFile; fileRef = F5DFFA6B0E075D8800617813 /* PBEasyFS.m */; };
|
||||
F5E4DBFB0EAB58D90013FAFC /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5E4DBFA0EAB58D90013FAFC /* SystemConfiguration.framework */; };
|
||||
F5E926060E8827D300056E75 /* PBViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F5E926050E8827D300056E75 /* PBViewController.m */; };
|
||||
@@ -122,6 +124,11 @@
|
||||
913D5E5E0E556A9300CECEA2 /* PBCLIProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PBCLIProxy.mm; sourceTree = "<group>"; };
|
||||
91B103CA0E898EC300C84364 /* PBIconAndTextCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBIconAndTextCell.h; sourceTree = "<group>"; };
|
||||
91B103CB0E898EC300C84364 /* PBIconAndTextCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PBIconAndTextCell.mm; sourceTree = "<group>"; };
|
||||
93CB42C00EAB7B2200530609 /* PBGitDefaults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitDefaults.h; sourceTree = "<group>"; };
|
||||
93CB42C10EAB7B2200530609 /* PBGitDefaults.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitDefaults.m; sourceTree = "<group>"; };
|
||||
93F7857D0EA3ABF100C1F443 /* PBCommitMessageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBCommitMessageView.h; sourceTree = "<group>"; };
|
||||
93F7857E0EA3ABF100C1F443 /* PBCommitMessageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBCommitMessageView.m; sourceTree = "<group>"; };
|
||||
93FCCBA80EA8AF450061B02B /* PBGitConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitConfig.m; sourceTree = "<group>"; };
|
||||
D26DC6440E782C9000C777B2 /* gitx.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = gitx.icns; sourceTree = "<group>"; };
|
||||
F50FE0E10E07BE9600854FCD /* PBGitRevisionCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRevisionCell.h; sourceTree = "<group>"; };
|
||||
F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRevisionCell.m; sourceTree = "<group>"; };
|
||||
@@ -181,7 +188,6 @@
|
||||
F5C6F68B0E65FF9300478D97 /* PBGitLane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitLane.h; sourceTree = "<group>"; };
|
||||
F5C6F68C0E65FF9300478D97 /* PBGitLane.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitLane.m; sourceTree = "<group>"; };
|
||||
F5D2DC850EA401A80034AD24 /* PBGitConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitConfig.h; sourceTree = "<group>"; };
|
||||
F5D2DC860EA401A80034AD24 /* PBGitConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitConfig.m; sourceTree = "<group>"; };
|
||||
F5DFFA6A0E075D8800617813 /* PBEasyFS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBEasyFS.h; sourceTree = "<group>"; };
|
||||
F5DFFA6B0E075D8800617813 /* PBEasyFS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBEasyFS.m; sourceTree = "<group>"; };
|
||||
F5E4DBFA0EAB58D90013FAFC /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
|
||||
@@ -348,7 +354,7 @@
|
||||
F53C4DF50E97FC630022AD59 /* PBGitBinary.h */,
|
||||
F53C4DF60E97FC630022AD59 /* PBGitBinary.m */,
|
||||
F5D2DC850EA401A80034AD24 /* PBGitConfig.h */,
|
||||
F5D2DC860EA401A80034AD24 /* PBGitConfig.m */,
|
||||
93FCCBA80EA8AF450061B02B /* PBGitConfig.m */,
|
||||
);
|
||||
name = Git;
|
||||
sourceTree = "<group>";
|
||||
@@ -360,6 +366,8 @@
|
||||
F5E927F90E883EF600056E75 /* Commit */,
|
||||
77C8280B06725ACE000B614F /* ApplicationController.h */,
|
||||
77C8280C06725ACE000B614F /* ApplicationController.m */,
|
||||
93CB42C00EAB7B2200530609 /* PBGitDefaults.h */,
|
||||
93CB42C10EAB7B2200530609 /* PBGitDefaults.m */,
|
||||
F57CC43F0E05E496000472E2 /* PBGitWindowController.h */,
|
||||
F57CC4400E05E496000472E2 /* PBGitWindowController.m */,
|
||||
911111F60E594F3F00BF76B4 /* PBRepositoryDocumentController.h */,
|
||||
@@ -466,6 +474,8 @@
|
||||
F59116E80E843BCB0072CCB1 /* PBGitCommitController.m */,
|
||||
F5E927FA0E883F0700056E75 /* PBWebChangesController.h */,
|
||||
F5E927FB0E883F0700056E75 /* PBWebChangesController.m */,
|
||||
93F7857D0EA3ABF100C1F443 /* PBCommitMessageView.h */,
|
||||
93F7857E0EA3ABF100C1F443 /* PBCommitMessageView.m */,
|
||||
);
|
||||
name = Commit;
|
||||
sourceTree = "<group>";
|
||||
@@ -609,7 +619,9 @@
|
||||
F56244090E9684B0002B6C44 /* PBUnsortableTableHeader.m in Sources */,
|
||||
F53C4DF70E97FC630022AD59 /* PBGitBinary.m in Sources */,
|
||||
F593DF780E9E636C003A8559 /* PBFileChangesTableView.m in Sources */,
|
||||
F5D2DC870EA401A80034AD24 /* PBGitConfig.m in Sources */,
|
||||
93F7857F0EA3ABF100C1F443 /* PBCommitMessageView.m in Sources */,
|
||||
93FCCBA90EA8AF450061B02B /* PBGitConfig.m in Sources */,
|
||||
93CB42C20EAB7B2200530609 /* PBGitDefaults.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// PBCommitMessageView.h
|
||||
// GitX
|
||||
//
|
||||
// Created by Jeff Mesnil on 13/10/08.
|
||||
// Copyright 2008 Jeff Mesnil (http://jmesnil.net/). All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface PBCommitMessageView : NSTextView {
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// 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
|
||||
+13
-5
@@ -3,12 +3,12 @@
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1050</int>
|
||||
<string key="IBDocument.SystemVersion">9F33</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">670</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">672</string>
|
||||
<string key="IBDocument.AppKitVersion">949.34</string>
|
||||
<string key="IBDocument.HIToolboxVersion">352.00</string>
|
||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<integer value="45"/>
|
||||
<integer value="130"/>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
@@ -1421,6 +1421,7 @@
|
||||
<string>130.IBPluginDependency</string>
|
||||
<string>131.IBPluginDependency</string>
|
||||
<string>132.IBPluginDependency</string>
|
||||
<string>133.CustomClassName</string>
|
||||
<string>133.IBPluginDependency</string>
|
||||
<string>163.IBPluginDependency</string>
|
||||
<string>164.IBPluginDependency</string>
|
||||
@@ -1453,7 +1454,7 @@
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilderKit</string>
|
||||
<string>com.apple.InterfaceBuilderKit</string>
|
||||
<string>{{358, 206}, {852, 432}}</string>
|
||||
<string>{{37, 206}, {852, 432}}</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<integer value="0" id="8"/>
|
||||
<reference ref="8"/>
|
||||
@@ -1463,6 +1464,7 @@
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>PBCommitMessageView</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
@@ -1516,6 +1518,14 @@
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">PBCommitMessageView</string>
|
||||
<string key="superclassName">NSTextView</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">PBCommitMessageView.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">PBFileChangesTableView</string>
|
||||
<string key="superclassName">NSTableView</string>
|
||||
@@ -1601,14 +1611,12 @@
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>cachedFilesController</string>
|
||||
<string>controller</string>
|
||||
<string>previousFile</string>
|
||||
<string>unstagedFilesController</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>NSArrayController</string>
|
||||
<string>PBGitCommitController</string>
|
||||
<string>id</string>
|
||||
<string>NSArrayController</string>
|
||||
</object>
|
||||
</object>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// PBGitDefaults.h
|
||||
// GitX
|
||||
//
|
||||
// Created by Jeff Mesnil on 19/10/08.
|
||||
// Copyright 2008 Jeff Mesnil (http://jmesnil.net/). All rights reserved.
|
||||
//
|
||||
|
||||
@interface PBGitDefaults : NSObject
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
+ (int) commitMessageViewVerticalLineLength;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// PBGitDefaults.m
|
||||
// GitX
|
||||
//
|
||||
// Created by Jeff Mesnil on 19/10/08.
|
||||
// Copyright 2008 Jeff Mesnil (http://jmesnil.net/). All rights reserved.
|
||||
//
|
||||
|
||||
#import "PBGitDefaults.h"
|
||||
|
||||
#define kDefaultVerticalLineLength 50
|
||||
#define kCommitMessageViewVerticalLineLength @"PBCommitMessageViewVerticalLineLength"
|
||||
|
||||
@implementation PBGitDefaults
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
NSMutableDictionary *defaultValues = [NSMutableDictionary dictionary];
|
||||
[defaultValues setObject:[NSNumber numberWithInt:kDefaultVerticalLineLength]
|
||||
forKey:kCommitMessageViewVerticalLineLength];
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];
|
||||
NSLog(@"registered defaults: %@", defaultValues);
|
||||
}
|
||||
|
||||
+ (int) commitMessageViewVerticalLineLength
|
||||
{
|
||||
return [[NSUserDefaults standardUserDefaults] integerForKey:kCommitMessageViewVerticalLineLength];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user