Show More
@@ -90,9 +90,9 b' from mercurial.i18n import _' | |||
|
90 | 90 | 'cyan_background': 46, |
|
91 | 91 | 'white_background': 47} |
|
92 | 92 | |
|
93 |
def render_effects(text, |
|
|
93 | def render_effects(text, effects): | |
|
94 | 94 | 'Wrap text in commands to turn on each effect.' |
|
95 |
start = [str(_effect_params[e]) for e in |
|
|
95 | start = [str(_effect_params[e]) for e in ['none'] + effects] | |
|
96 | 96 | start = '\033[' + ';'.join(start) + 'm' |
|
97 | 97 | stop = '\033[' + str(_effect_params['none']) + 'm' |
|
98 | 98 | return ''.join([start, text, stop]) |
@@ -120,7 +120,7 b' def colorstatus(orig, ui, repo, *pats, *' | |||
|
120 | 120 | status = _status_abbreviations[lines_with_status[i][0]] |
|
121 | 121 | effects = _status_effects[status] |
|
122 | 122 | if effects: |
|
123 |
lines[i] = render_effects(lines[i], |
|
|
123 | lines[i] = render_effects(lines[i], effects) | |
|
124 | 124 | ui.write(lines[i] + delimiter) |
|
125 | 125 | return retval |
|
126 | 126 | |
@@ -133,14 +133,14 b' def colorstatus(orig, ui, repo, *pats, *' | |||
|
133 | 133 | 'C': 'clean', |
|
134 | 134 | ' ': 'copied', } |
|
135 | 135 | |
|
136 |
_status_effects = { 'modified': |
|
|
137 |
'added': |
|
|
138 |
'removed': |
|
|
139 |
'deleted': |
|
|
140 |
'unknown': |
|
|
141 |
'ignored': |
|
|
142 |
'clean': |
|
|
143 |
'copied': |
|
|
136 | _status_effects = { 'modified': ['blue', 'bold'], | |
|
137 | 'added': ['green', 'bold'], | |
|
138 | 'removed': ['red', 'bold'], | |
|
139 | 'deleted': ['cyan', 'bold', 'underline'], | |
|
140 | 'unknown': ['magenta', 'bold', 'underline'], | |
|
141 | 'ignored': ['black', 'bold'], | |
|
142 | 'clean': ['none'], | |
|
143 | 'copied': ['none'], } | |
|
144 | 144 | |
|
145 | 145 | def colorqseries(orig, ui, repo, *dummy, **opts): |
|
146 | 146 | '''run the qseries command with colored output''' |
@@ -162,12 +162,12 b' def colorqseries(orig, ui, repo, *dummy,' | |||
|
162 | 162 | effects = _patch_effects['applied'] |
|
163 | 163 | else: |
|
164 | 164 | effects = _patch_effects['unapplied'] |
|
165 |
ui.write(render_effects(patch, |
|
|
165 | ui.write(render_effects(patch, effects) + '\n') | |
|
166 | 166 | return retval |
|
167 | 167 | |
|
168 |
_patch_effects = { 'applied': |
|
|
169 |
'missing': |
|
|
170 |
'unapplied': |
|
|
168 | _patch_effects = { 'applied': ['blue', 'bold', 'underline'], | |
|
169 | 'missing': ['red', 'bold'], | |
|
170 | 'unapplied': ['black', 'bold'], } | |
|
171 | 171 | |
|
172 | 172 | def colorwrap(orig, s): |
|
173 | 173 | '''wrap ui.write for colored diff output''' |
@@ -179,11 +179,11 b' def colorwrap(orig, s):' | |||
|
179 | 179 | stripline = line.rstrip() |
|
180 | 180 | for prefix, style in _diff_prefixes: |
|
181 | 181 | if stripline.startswith(prefix): |
|
182 |
lines[i] = render_effects(stripline, |
|
|
182 | lines[i] = render_effects(stripline, _diff_effects[style]) | |
|
183 | 183 | break |
|
184 | 184 | if line != stripline: |
|
185 | 185 | lines[i] += render_effects( |
|
186 |
line[len(stripline):], |
|
|
186 | line[len(stripline):], _diff_effects['trailingwhitespace']) | |
|
187 | 187 | orig('\n'.join(lines)) |
|
188 | 188 | |
|
189 | 189 | def colorshowpatch(orig, self, node): |
@@ -214,15 +214,15 b' def colordiff(orig, ui, repo, *pats, **o' | |||
|
214 | 214 | ('-', 'deleted'), |
|
215 | 215 | ('+', 'inserted')] |
|
216 | 216 | |
|
217 |
_diff_effects = {'diffline': |
|
|
218 |
'extended': |
|
|
219 |
'file_a': |
|
|
220 |
'file_b': |
|
|
221 |
'hunk': |
|
|
222 |
'deleted': |
|
|
223 |
'inserted': |
|
|
224 |
'changed': |
|
|
225 |
'trailingwhitespace': |
|
|
217 | _diff_effects = {'diffline': ['bold',], | |
|
218 | 'extended': ['cyan', 'bold'], | |
|
219 | 'file_a': ['red', 'bold'], | |
|
220 | 'file_b': ['green', 'bold'], | |
|
221 | 'hunk': ['magenta',], | |
|
222 | 'deleted': ['red',], | |
|
223 | 'inserted': ['green',], | |
|
224 | 'changed': ['white',], | |
|
225 | 'trailingwhitespace': ['bold', 'red_background'],} | |
|
226 | 226 | |
|
227 | 227 | def uisetup(ui): |
|
228 | 228 | '''Initialize the extension.''' |
General Comments 0
You need to be logged in to leave comments.
Login now