6
6
from subprocess import check_output as shell
7
7
8
8
9
- blame_cache = {}
10
- template = '''
11
- <span>
9
+ template_scheme = {}
10
+ template_scheme ['light' ] = '''
12
11
<style>
13
- span {{
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 {
14
25
background-color: brown;
15
- }}
16
- a {{
26
+ }
27
+ a {
17
28
text-decoration: none;
18
- }}
29
+ }
19
30
</style>
31
+ '''
32
+
33
+ template = '''
34
+ <span>
35
+ {scheme}
20
36
<strong>Git Blame:</strong> ({user})
21
- Updated: {date} {time} |
37
+ Updated: {date} {time} |
22
38
<a href="copy-{sha}">[{sha}]</a> |
23
39
<a href="close">
24
40
<close>X</close>
@@ -58,7 +74,7 @@ def parse_blame(self, blame):
58
74
file_path = None
59
75
60
76
# Fix an issue where the username has a space
61
- # Im going to need to do something better though if people
77
+ # Im going to need to do something better though if people
62
78
# start to have multiple spaces in their names.
63
79
if not isinstance (date [0 ], int ):
64
80
user = "{0} {1}" .format (user , date )
@@ -70,7 +86,7 @@ def on_phantom_close(self, href):
70
86
if href .startswith ('copy' ):
71
87
sha = href .replace ('copy-' ,'' )
72
88
sublime .set_clipboard (sha )
73
-
89
+
74
90
self .view .erase_phantoms ('git-blame' )
75
91
76
92
@@ -82,13 +98,18 @@ def run(self, edit):
82
98
line = self .view .line (region )
83
99
(row , col ) = self .view .rowcol (region .begin ())
84
100
full_path = self .view .file_name ()
85
- result = self .get_blame (int (row )+ 1 , full_path )
101
+ result = self .get_blame (int (row ) + 1 , full_path )
86
102
if not result :
87
103
# Unable to get blame
88
104
return
89
105
90
106
sha , user , date , time = self .parse_blame (result )
91
- body = template .format (sha = sha , user = user , date = date , time = time )
107
+
108
+ settings = sublime .load_settings ('Preferences.sublime-settings' )
109
+ scheme_color = settings .get ('gitblame.scheme' ) or 'dark'
110
+
111
+ body = template .format (sha = sha , user = user , date = date , time = time ,
112
+ scheme = template_scheme .get (scheme_color , '' ))
92
113
93
114
phantom = sublime .Phantom (line , body , sublime .LAYOUT_BLOCK , self .on_phantom_close )
94
115
phantoms .append (phantom )
0 commit comments