mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Allow hunk navigation by using j/k keys
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<string key="IBDocument.HIToolboxVersion">352.00</string>
|
||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<integer value="48"/>
|
||||
<integer value="11"/>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
@@ -73,10 +73,9 @@
|
||||
<reference key="NSToolbarItemPaletteLabel" ref="904399424"/>
|
||||
<nil key="NSToolbarItemToolTip"/>
|
||||
<object class="NSSearchField" key="NSToolbarItemView" id="212418890">
|
||||
<reference key="NSNextResponder"/>
|
||||
<nil key="NSNextResponder"/>
|
||||
<int key="NSvFlags">265</int>
|
||||
<string key="NSFrame">{{0, 14}, {183, 22}}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSSearchFieldCell" key="NSCell" id="902542524">
|
||||
<int key="NSCellFlags">343014976</int>
|
||||
@@ -172,10 +171,9 @@
|
||||
<string key="NSToolbarItemPaletteLabel">Branch</string>
|
||||
<nil key="NSToolbarItemToolTip"/>
|
||||
<object class="NSPopUpButton" key="NSToolbarItemView" id="147646927">
|
||||
<reference key="NSNextResponder"/>
|
||||
<nil key="NSNextResponder"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{0, 14}, {134, 26}}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSPopUpButtonCell" key="NSCell" id="638300054">
|
||||
<int key="NSCellFlags">-2076049856</int>
|
||||
@@ -283,10 +281,9 @@
|
||||
<string key="NSToolbarItemPaletteLabel">View selector</string>
|
||||
<nil key="NSToolbarItemToolTip"/>
|
||||
<object class="NSSegmentedControl" key="NSToolbarItemView" id="1040507102">
|
||||
<reference key="NSNextResponder"/>
|
||||
<nil key="NSNextResponder"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{0, 14}, {114, 23}}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSSegmentedCell" key="NSCell" id="989754672">
|
||||
<int key="NSCellFlags">67239424</int>
|
||||
@@ -1109,7 +1106,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
<object class="NSTextView" id="199501869">
|
||||
<reference key="NSNextResponder" ref="1012939428"/>
|
||||
<int key="NSvFlags">2322</int>
|
||||
<string key="NSFrameSize">{835, 70}</string>
|
||||
<string key="NSFrameSize">{835, 0}</string>
|
||||
<reference key="NSSuperview" ref="1012939428"/>
|
||||
<object class="NSTextContainer" key="NSTextContainer" id="733720017">
|
||||
<object class="NSLayoutManager" key="NSLayoutManager">
|
||||
@@ -1473,7 +1470,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
<object class="NSTextView" id="857940771">
|
||||
<reference key="NSNextResponder" ref="686698782"/>
|
||||
<int key="NSvFlags">2322</int>
|
||||
<string key="NSFrameSize">{543, 112}</string>
|
||||
<string key="NSFrameSize">{543, 0}</string>
|
||||
<reference key="NSSuperview" ref="686698782"/>
|
||||
<object class="NSTextContainer" key="NSTextContainer" id="219857543">
|
||||
<object class="NSLayoutManager" key="NSLayoutManager">
|
||||
@@ -2238,6 +2235,14 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
</object>
|
||||
<int key="connectionID">218</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">webController</string>
|
||||
<reference key="source" ref="753736101"/>
|
||||
<reference key="destination" ref="422872293"/>
|
||||
</object>
|
||||
<int key="connectionID">233</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
@@ -2825,6 +2830,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
<string>3.windowTemplate.hasMinSize</string>
|
||||
<string>3.windowTemplate.maxSize</string>
|
||||
<string>3.windowTemplate.minSize</string>
|
||||
<string>31.IBAttributePlaceholdersKey</string>
|
||||
<string>31.IBPluginDependency</string>
|
||||
<string>34.IBPluginDependency</string>
|
||||
<string>35.IBPluginDependency</string>
|
||||
@@ -2915,9 +2921,9 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{334, 465}, {850, 418}}</string>
|
||||
<string>{{480, 439}, {850, 418}}</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{334, 465}, {850, 418}}</string>
|
||||
<string>{{480, 439}, {850, 418}}</string>
|
||||
<reference ref="9"/>
|
||||
<reference ref="9"/>
|
||||
<string>{{15, 196}, {850, 418}}</string>
|
||||
@@ -2925,6 +2931,15 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
<reference ref="9"/>
|
||||
<string>{3.40282e+38, 3.40282e+38}</string>
|
||||
<string>{213, 107}</string>
|
||||
<object class="NSMutableDictionary">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<string>com.apple.WebKitIBPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
@@ -2933,7 +2948,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
<string>PBQLOutlineView</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{451, 656}, {616, 227}}</string>
|
||||
<string>{{451, 883}, {616, 0}}</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{132, 614}, {616, 0}}</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
@@ -2996,7 +3011,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">218</int>
|
||||
<int key="maxID">233</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
@@ -3005,8 +3020,17 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
<string key="className">PBCommitList</string>
|
||||
<string key="superclassName">NSTableView</string>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
<string key="NS.key.0">webView</string>
|
||||
<string key="NS.object.0">WebView</string>
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSMutableArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>webController</string>
|
||||
<string>webView</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>PBWebGitController</string>
|
||||
<string>WebView</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
@@ -3092,16 +3116,22 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">PBWebGitController</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
<object class="NSMutableDictionary" key="actions">
|
||||
<string key="NS.key.0">doeHet:</string>
|
||||
<string key="NS.object.0">id</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSMutableArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>detailController</string>
|
||||
<string>source</string>
|
||||
<string>view</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>PBDetailController</string>
|
||||
<string>id</string>
|
||||
<string>WebView</string>
|
||||
</object>
|
||||
</object>
|
||||
@@ -3110,6 +3140,14 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
<string key="minorKey">PBWebGitController.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">PBWebGitController</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBUserSource</string>
|
||||
<string key="minorKey"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
F56173280E056ED2001DCD79 /* diffHighlighter.js in Resources */ = {isa = PBXBuildFile; fileRef = F56173270E056ED2001DCD79 /* diffHighlighter.js */; };
|
||||
F56174570E058893001DCD79 /* PBGitTree.m in Sources */ = {isa = PBXBuildFile; fileRef = F56174560E058893001DCD79 /* PBGitTree.m */; };
|
||||
F561777D0E05C88E001DCD79 /* DetailView.png in Resources */ = {isa = PBXBuildFile; fileRef = F561777C0E05C88E001DCD79 /* DetailView.png */; };
|
||||
F561E6CC0E7AFDD000521636 /* keyboardNavigation.js in Sources */ = {isa = PBXBuildFile; fileRef = F561E6CB0E7AFDD000521636 /* keyboardNavigation.js */; };
|
||||
F561E6CD0E7AFDDF00521636 /* keyboardNavigation.js in Resources */ = {isa = PBXBuildFile; fileRef = F561E6CB0E7AFDD000521636 /* keyboardNavigation.js */; };
|
||||
F56524BB0E02D22D00F03B52 /* NSFileHandleExt.m in Sources */ = {isa = PBXBuildFile; fileRef = F56524B90E02D22D00F03B52 /* NSFileHandleExt.m */; };
|
||||
F56524F00E02D45200F03B52 /* PBGitCommit.m in Sources */ = {isa = PBXBuildFile; fileRef = F56524EF0E02D45200F03B52 /* PBGitCommit.m */; };
|
||||
F56526240E03D85900F03B52 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F56526230E03D85900F03B52 /* WebKit.framework */; };
|
||||
@@ -107,6 +109,7 @@
|
||||
F56174550E058893001DCD79 /* PBGitTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitTree.h; sourceTree = "<group>"; };
|
||||
F56174560E058893001DCD79 /* PBGitTree.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitTree.m; sourceTree = "<group>"; };
|
||||
F561777C0E05C88E001DCD79 /* DetailView.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = DetailView.png; sourceTree = "<group>"; };
|
||||
F561E6CB0E7AFDD000521636 /* keyboardNavigation.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = keyboardNavigation.js; path = html/keyboardNavigation.js; sourceTree = "<group>"; };
|
||||
F56524B90E02D22D00F03B52 /* NSFileHandleExt.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSFileHandleExt.m; sourceTree = "<group>"; };
|
||||
F56524BA0E02D22D00F03B52 /* NSFileHandleExt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSFileHandleExt.h; sourceTree = "<group>"; };
|
||||
F56524EE0E02D45200F03B52 /* PBGitCommit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitCommit.h; sourceTree = "<group>"; };
|
||||
@@ -328,6 +331,7 @@
|
||||
children = (
|
||||
F561727C0E056A11001DCD79 /* diff_style.css */,
|
||||
F56526590E03E71B00F03B52 /* commit.html */,
|
||||
F561E6CB0E7AFDD000521636 /* keyboardNavigation.js */,
|
||||
F58A8F270E043698007E3FC0 /* commits.css */,
|
||||
F57ABDDE0E0441DE00A088B8 /* commit.js */,
|
||||
F57ABE180E04431D00A088B8 /* prototype.js */,
|
||||
@@ -415,6 +419,7 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F561E6CD0E7AFDDF00521636 /* keyboardNavigation.js in Resources */,
|
||||
913D5E500E55645900CECEA2 /* gitx in Resources */,
|
||||
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
|
||||
F565265A0E03E71B00F03B52 /* commit.html in Resources */,
|
||||
@@ -460,6 +465,7 @@
|
||||
F5C007750E731B48007B84B2 /* PBGitRef.m in Sources */,
|
||||
F5AD56790E79B78100EDAAFE /* PBCommitList.m in Sources */,
|
||||
F53FF2050E7ABB5300389171 /* PBGitRevSpecifier.m in Sources */,
|
||||
F561E6CC0E7AFDD000521636 /* keyboardNavigation.js in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <WebKit/WebView.h>
|
||||
#import "PBWebGitController.h"
|
||||
|
||||
@interface PBCommitList : NSTableView {
|
||||
IBOutlet WebView* webView;
|
||||
IBOutlet PBWebGitController* webController;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
else
|
||||
[webView scrollPageDown: self];
|
||||
}
|
||||
else if ([character rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"jk"]].location == 0)
|
||||
[webController sendKey: character];
|
||||
else
|
||||
[super keyDown: event];
|
||||
}
|
||||
|
||||
@@ -20,5 +20,7 @@
|
||||
}
|
||||
|
||||
- (void) changeContentTo: (PBGitCommit *) content;
|
||||
- (void) sendKey: (NSString*) key;
|
||||
|
||||
@property (readonly) NSString* diff;
|
||||
@end
|
||||
|
||||
@@ -67,6 +67,12 @@
|
||||
[detailController selectCommit:sha];
|
||||
}
|
||||
|
||||
- (void) sendKey: (NSString*) key
|
||||
{
|
||||
id script = [view windowScriptObject];
|
||||
[script callWebScriptMethod:@"handleKeyFromCocoa" withArguments: [NSArray arrayWithObject:key]];
|
||||
}
|
||||
|
||||
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
|
||||
{
|
||||
return NO;
|
||||
|
||||
+3
-2
@@ -1,12 +1,13 @@
|
||||
<html>
|
||||
<header>
|
||||
<head>
|
||||
<title>Details for commit</title>
|
||||
<link rel="stylesheet" href="commits.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<link rel="stylesheet" href="diff_style.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script src="prototype.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="commit.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="diffHighlighter.js" type="text/javascript" charset="utf-8"></script>
|
||||
</header>
|
||||
<script src="keyboardNavigation.js" type="text/javascript" charset="utf-8"></script>
|
||||
</head>
|
||||
|
||||
<body style="padding: 0px; border: 0px">
|
||||
<table id="commit_header">
|
||||
|
||||
+15
-1
@@ -14,12 +14,26 @@ var highlightDiffs = function() {
|
||||
|
||||
l = l.gsub("\t", " ");
|
||||
|
||||
if (l.startsWith("diff")) {
|
||||
newContent += "<div class='fileHeader'><div class='fileline'>" + l + "</div></div>";
|
||||
return;
|
||||
}
|
||||
if (l.startsWith("---")) {
|
||||
newContent += "<div class='oldfile'>" + l + "</div></div>";
|
||||
return;
|
||||
}
|
||||
|
||||
if (l.startsWith("+++")) {
|
||||
newContent += "<div class='newfile'>" + l + "</div></div>";
|
||||
return;
|
||||
}
|
||||
|
||||
if (l.startsWith("+"))
|
||||
newContent += "<div class='addline'>" + l + "</div>";
|
||||
else if (l.startsWith("-"))
|
||||
newContent += "<div class='delline'>" + l + "</div>";
|
||||
else if (l.startsWith("@"))
|
||||
newContent += "<div class='meta'>" + l + "</div>";
|
||||
newContent += "<div class='hunkheader'>" + l + "</div>";
|
||||
else
|
||||
newContent += l + "\n";
|
||||
});
|
||||
|
||||
+14
-3
@@ -1,14 +1,21 @@
|
||||
code .delline {
|
||||
code .delline, code .oldfile {
|
||||
background-color: #FEE;
|
||||
color: #B00;
|
||||
}
|
||||
|
||||
code .addline {
|
||||
code .addline, code .newfile {
|
||||
background-color: #DFD;
|
||||
color: #080;
|
||||
}
|
||||
code .fileline {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
code .meta {
|
||||
code .fileheader {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
code .hunkheader {
|
||||
background-color: #f7f7f7;
|
||||
color: #bbb;
|
||||
}
|
||||
@@ -22,4 +29,8 @@ pre code {
|
||||
display: table-cell;
|
||||
padding: 9px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#CurrentHunk {
|
||||
border-left: 5px solid black;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
var scrollToCenter = function(element) {
|
||||
var pos = element.cumulativeOffset();
|
||||
window.scrollTo(pos[0], pos[1] - 100);
|
||||
}
|
||||
|
||||
var handleKeys = function(event) {
|
||||
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
|
||||
return;
|
||||
if (event.keyCode == 74)
|
||||
return changeHunk(true);
|
||||
else if (event.keyCode == 75)
|
||||
return changeHunk(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var handleKeyFromCocoa = function(key) {
|
||||
if (key == 'j')
|
||||
changeHunk(true);
|
||||
else if (key == 'k')
|
||||
changeHunk(false);
|
||||
}
|
||||
|
||||
var changeHunk = function(next) {
|
||||
var hunks = $A(document.getElementsByClassName("hunkheader"));
|
||||
if (hunks.length == 0)
|
||||
return;
|
||||
|
||||
var currentHunk = document.getElementById("CurrentHunk");
|
||||
var newHunk;
|
||||
|
||||
if (currentHunk && hunks.indexOf(currentHunk) >= 0) {
|
||||
currentHunk.id = null;
|
||||
if (next)
|
||||
newHunk = hunks[hunks.indexOf(currentHunk) + 1];
|
||||
else
|
||||
newHunk = hunks[hunks.indexOf(currentHunk) - 1];
|
||||
}
|
||||
if (!newHunk)
|
||||
newHunk = hunks[0];
|
||||
|
||||
newHunk.id = 'CurrentHunk';
|
||||
scrollToCenter(newHunk);
|
||||
return false;
|
||||
}
|
||||
|
||||
document.onkeydown = function(event) {
|
||||
return handleKeys(event);
|
||||
};
|
||||
Reference in New Issue
Block a user