-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
816 additions
and
275 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ src/** | |
.gitignore | ||
tsconfig.json | ||
vsc-extension-quickstart.md | ||
images/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
font-family: monospace; | ||
} | ||
html, body { | ||
width: 100%; | ||
max-width: 100%; | ||
height: 100%; | ||
max-height: 100%; | ||
} | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
max-width: 100%; | ||
height: 100%; | ||
max-height: 100%; | ||
flex-grow: 0; | ||
} | ||
.commits { | ||
display: flex; | ||
flex-direction: column; | ||
height: 300px; | ||
min-height: 300px; | ||
flex-shrink: 0; | ||
border-bottom: 1px solid #fff; | ||
overflow-y: auto; | ||
} | ||
.commits:focus { | ||
outline: none; | ||
} | ||
.detail { | ||
overflow: auto; | ||
flex-grow: 0; | ||
} | ||
|
||
.commit { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
margin-top: 3px; | ||
margin-bottom: 3px; | ||
cursor: pointer; | ||
flex-shrink: 0; | ||
text-decoration: none; | ||
color: #fff; | ||
} | ||
.commit:focus { | ||
outline: none; | ||
} | ||
|
||
.commit.selected { | ||
font-weight: bold; | ||
color: #80da51; | ||
} | ||
|
||
.commit > div { | ||
margin-left: 5px; | ||
margin-right: 5px; | ||
} | ||
|
||
.commit .hash { | ||
width: 80px; | ||
flex-shrink: 0; | ||
} | ||
|
||
.commit .message { | ||
flex: 2; | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
} | ||
|
||
.commit .date { | ||
width: 200px; | ||
text-align: right; | ||
flex-shrink: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
(function(document, global) { | ||
|
||
document.querySelector('.commits').addEventListener('dblclick', (e) => { | ||
const cNode = global.getCommitNode(e.target); | ||
if (!cNode) { | ||
return; | ||
} | ||
copyTextToClipboard(cNode.querySelector('.hash').innerHTML); | ||
}, false); | ||
|
||
function copyTextToClipboard(text) { | ||
const textArea = document.createElement('textarea'); | ||
|
||
textArea.style.position = 'fixed'; | ||
textArea.style.top = 0; | ||
textArea.style.left = 0; | ||
textArea.style.width = '2em'; | ||
textArea.style.height = '2em'; | ||
textArea.style.padding = 0; | ||
textArea.style.border = 'none'; | ||
textArea.style.outline = 'none'; | ||
textArea.style.boxShadow = 'none'; | ||
textArea.style.background = 'transparent'; | ||
textArea.value = text; | ||
document.body.appendChild(textArea); | ||
textArea.select(); | ||
try { | ||
document.execCommand('copy'); | ||
} catch (err) { | ||
console.log('Oops, unable to copy'); | ||
} | ||
document.body.removeChild(textArea); | ||
} | ||
|
||
}(document, window)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(function(document) { | ||
//display detail of first commit if no one selected before | ||
setTimeout(() => { | ||
if (!document.querySelector('.commit.selected')) { | ||
document.querySelector('.commit').click(); | ||
} | ||
}); | ||
|
||
}(document)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
(function(document, global) { | ||
|
||
const commitsEle = document.querySelector('.commits'); | ||
const lineHeight = height(document.querySelector('.commit')); | ||
|
||
document.querySelector('.commits').addEventListener('keydown', (e) => { | ||
if (e.keyCode !== 40 && e.keyCode !== 38) { | ||
return; | ||
} | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
|
||
const selectedEle = document.querySelector('.commit.selected'); | ||
|
||
const nextEle = e.keyCode === 40 ? selectedEle.nextElementSibling : selectedEle.previousElementSibling; | ||
|
||
if (!nextEle) { | ||
return; | ||
} | ||
if (e.keyCode === 40 && nextEle.offsetTop + lineHeight > commitsEle.offsetHeight) { | ||
commitsEle.scrollTop += lineHeight; | ||
} | ||
if (e.keyCode === 38 && nextEle.offsetTop < commitsEle.scrollTop) { | ||
commitsEle.scrollTop -= lineHeight; | ||
} | ||
|
||
nextEle.click(); | ||
}, false); | ||
|
||
function height(el) { | ||
|
||
const styles = global.getComputedStyle(el); | ||
const margin = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom); | ||
|
||
return Math.ceil(el.offsetHeight + margin); | ||
} | ||
|
||
}(document, window)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(function(document, localStorage) { | ||
//restore scroll position while detail changed | ||
if (document.querySelector('.commit.selected')) { | ||
document.querySelector('.commits').scrollTop = +localStorage.getItem('pos'); | ||
localStorage.setItem('pos', 0); | ||
} | ||
|
||
//record scroll position before detail gets changed | ||
document.querySelector('.commits').addEventListener('click', () => { | ||
localStorage.setItem('pos', document.querySelector('.commits').scrollTop); | ||
}, false); | ||
|
||
}(document, localStorage)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(function(document) { | ||
setTimeout(() => { | ||
document.querySelector('.commits').focus(); | ||
}); | ||
}(document)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(function(global) { | ||
|
||
global.getCommitNode = function(node) { | ||
if (node.tagName === 'BODY') { | ||
return; | ||
} | ||
if (node.classList.contains('commit')) { | ||
return node; | ||
} | ||
return global.getCommitNode(node.parentNode); | ||
}; | ||
|
||
}(window)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,70 @@ | ||
{ | ||
"name": "vscode-gitk", | ||
"displayName": "gitk", | ||
"description": "show commit log for selected source code information in an individual view", | ||
"version": "1.0.5", | ||
"publisher": "howardzuo", | ||
"engines": { | ||
"vscode": "^1.12.0" | ||
"name": "vscode-gitk", | ||
"displayName": "gitk", | ||
"description": "show commit log for selected source code information in an individual view", | ||
"version": "1.1.0", | ||
"publisher": "howardzuo", | ||
"engines": { | ||
"vscode": "^1.12.0" | ||
}, | ||
"scripts": { | ||
"vscode:prepublish": "tsc -p ./", | ||
"compile": "tsc -watch -p ./", | ||
"postinstall": "node ./node_modules/vscode/bin/install" | ||
}, | ||
"categories": [ | ||
"Debuggers" | ||
], | ||
"icon": "images/git-logo.png", | ||
"bugs": { | ||
"url": "https://github.com/leftstick/vscode-gitk/issues", | ||
"email": "leftstick@qq.com" | ||
}, | ||
"homepage": "https://github.com/leftstick/vscode-gitk/blob/master/README.md", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/leftstick/vscode-gitk.git" | ||
}, | ||
"activationEvents": [ | ||
"onCommand:extension.gitk" | ||
], | ||
"license": "GPL-3.0", | ||
"main": "./out/src", | ||
"contributes": { | ||
"menus": { | ||
"explorer/context": [ | ||
{ | ||
"command": "extension.gitk", | ||
"group": "sourcecontrol" | ||
} | ||
], | ||
"editor/context": [ | ||
{ | ||
"command": "extension.gitk", | ||
"group": "sourcecontrol" | ||
} | ||
] | ||
}, | ||
"scripts": { | ||
"vscode:prepublish": "tsc -p ./", | ||
"compile": "tsc -watch -p ./", | ||
"postinstall": "node ./node_modules/vscode/bin/install" | ||
}, | ||
"categories": [ | ||
"Debuggers" | ||
"commands": [ | ||
{ | ||
"command": "extension.gitk", | ||
"title": "Gitk" | ||
} | ||
], | ||
"icon": "images/git-logo.png", | ||
"bugs": { | ||
"url": "https://github.com/leftstick/vscode-gitk/issues", | ||
"email": "leftstick@qq.com" | ||
}, | ||
"homepage": "https://github.com/leftstick/vscode-gitk/blob/master/README.md", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/leftstick/vscode-gitk.git" | ||
}, | ||
"activationEvents": [ | ||
"onCommand:extension.gitk" | ||
], | ||
"license": "GPL-3.0", | ||
"main": "./out/src", | ||
"contributes": { | ||
"menus": { | ||
"explorer/context": [{ | ||
"command": "extension.gitk", | ||
"group": "sourcecontrol" | ||
}], | ||
"editor/context": [{ | ||
"command": "extension.gitk", | ||
"group": "sourcecontrol" | ||
}] | ||
}, | ||
"commands": [{ | ||
"command": "extension.gitk", | ||
"title": "Gitk" | ||
}], | ||
"keybindings": [{ | ||
"command": "extension.gitk", | ||
"key": "alt+k" | ||
}] | ||
}, | ||
"devDependencies": { | ||
"typescript": "^2.3.2", | ||
"vscode": "^1.1.0", | ||
"@types/node": "^7.0.18" | ||
} | ||
} | ||
"keybindings": [ | ||
{ | ||
"command": "extension.gitk", | ||
"key": "alt+k" | ||
} | ||
] | ||
}, | ||
"devDependencies": { | ||
"@types/lodash": "^4.14.64", | ||
"@types/node": "^7.0.18", | ||
"typescript": "^2.3.2", | ||
"vscode": "^1.1.0" | ||
}, | ||
"dependencies": { | ||
"lodash.template": "^4.4.0" | ||
} | ||
} |
Oops, something went wrong.