Skip to content

Commit 9664efa

Browse files
authored
Merge pull request #10 from braver/phantom-colors
borrow styling from exec.py
2 parents f96366a + f62ce03 commit 9664efa

File tree

3 files changed

+46
-48
lines changed

3 files changed

+46
-48
lines changed

Preferences.sublime-settings

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@ View on [packagecontrol.io](https://packagecontrol.io/packages/Git%20blame)
1616
1717
> Right click > Git blame
1818
19+
## Example
1920

20-
## Examples
21-
22-
23-
### Light scheme
24-
![image](https://cloud.githubusercontent.com/assets/1134201/23709870/bcde89cc-0412-11e7-9464-3f97713bf747.png)
25-
26-
Light: (with a light theme)
27-
28-
![image](https://cloud.githubusercontent.com/assets/1134201/23709882/ce0c2ea2-0412-11e7-9bac-e5297629a15a.png)
29-
30-
31-
### Dark scheme
32-
![image](https://cloud.githubusercontent.com/assets/1134201/23709854/acfe8ed0-0412-11e7-8329-3aa51e530d19.png)
21+
![image](https://user-images.githubusercontent.com/2543659/28410198-331b1ec8-6d3d-11e7-9ac1-57d43fb6ab60.png)

git-blame.py

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,57 @@
55
import subprocess
66
from subprocess import check_output as shell
77

8-
9-
template_scheme = {}
10-
template_scheme['light'] = '''
11-
<style>
12-
span {
13-
background-color: #aee;
14-
color: #444;
15-
}
16-
strong, a {
17-
text-decoration: none;
18-
color: #000;
19-
}
20-
</style>
21-
'''
22-
template_scheme['dark'] = '''
23-
<style>
24-
span {
25-
background-color: brown;
26-
}
27-
a {
28-
text-decoration: none;
29-
}
30-
</style>
8+
stylesheet = '''
9+
<style>
10+
div.blame-arrow {
11+
border-top: 0.4rem solid transparent;
12+
border-left: 0.5rem solid color(var(--greenish) blend(var(--background) 30%));
13+
width: 0;
14+
height: 0;
15+
}
16+
div.blame {
17+
padding: 0.4rem 0 0.4rem 0.7rem;
18+
margin: 0 0 0.2rem;
19+
border-radius: 0 0.2rem 0.2rem 0.2rem;
20+
background-color: color(var(--greenish) blend(var(--background) 30%));
21+
}
22+
div.blame span.message {
23+
padding-right: 0.7rem;
24+
}
25+
div.blame a {
26+
text-decoration: inherit;
27+
}
28+
div.blame a.close {
29+
padding: 0.35rem 0.7rem 0.45rem 0.8rem;
30+
position: relative;
31+
bottom: 0.05rem;
32+
border-radius: 0 0.2rem 0.2rem 0;
33+
font-weight: bold;
34+
}
35+
html.dark div.blame a.close {
36+
background-color: #00000018;
37+
}
38+
html.light div.blame a.close {
39+
background-color: #ffffff18;
40+
}
41+
</style>
3142
'''
3243

3344
template = '''
34-
<span>
35-
{scheme}
36-
&nbsp;<strong>Git Blame:</strong> ({user})
45+
<body>
46+
{stylesheet}
47+
<div class="blame-arrow"></div>
48+
<div class="blame">
49+
<span class="message">
50+
<strong>Git Blame:</strong> ({user})
3751
Updated: {date} {time} |
3852
{sha}
3953
<a href="copy-{sha}">[Copy]</a>
4054
<a href="show-{sha}">[Show]</a>
41-
<a href="close"><close>[X]</close></a>&nbsp;
55+
<a class="close" href="close">''' + chr(0x00D7) + '''</a>
4256
</span>
57+
</div>
58+
</body>
4359
'''
4460

4561
# Sometimes this fails on other OS, just error silently
@@ -130,11 +146,7 @@ def run(self, edit):
130146

131147
sha, user, date, time = self.parse_blame(result)
132148

133-
settings = sublime.load_settings('Preferences.sublime-settings')
134-
scheme_color = settings.get('gitblame.scheme') or 'dark'
135-
136-
body = template.format(sha=sha, user=user, date=date, time=time,
137-
scheme=template_scheme.get(scheme_color, ''))
149+
body = template.format(sha=sha, user=user, date=date, time=time, stylesheet=stylesheet)
138150

139151
phantom = sublime.Phantom(line, body, sublime.LAYOUT_BLOCK, self.on_phantom_close)
140152
phantoms.append(phantom)

0 commit comments

Comments
 (0)