Show More
@@ -297,20 +297,6 b' def _modesetup(ui, coloropt):' | |||||
297 | return realmode |
|
297 | return realmode | |
298 | return None |
|
298 | return None | |
299 |
|
299 | |||
300 | def render_effects(text, effects): |
|
|||
301 | 'Wrap text in commands to turn on each effect.' |
|
|||
302 | if not text: |
|
|||
303 | return text |
|
|||
304 | if not color._terminfo_params: |
|
|||
305 | start = [str(color._effects[e]) for e in ['none'] + effects.split()] |
|
|||
306 | start = '\033[' + ';'.join(start) + 'm' |
|
|||
307 | stop = '\033[' + str(color._effects['none']) + 'm' |
|
|||
308 | else: |
|
|||
309 | start = ''.join(color._effect_str(effect) |
|
|||
310 | for effect in ['none'] + effects.split()) |
|
|||
311 | stop = color._effect_str('none') |
|
|||
312 | return ''.join([start, text, stop]) |
|
|||
313 |
|
||||
314 | class colorui(uimod.ui): |
|
300 | class colorui(uimod.ui): | |
315 | _colormode = 'ansi' |
|
301 | _colormode = 'ansi' | |
316 | def write(self, *args, **opts): |
|
302 | def write(self, *args, **opts): | |
@@ -369,7 +355,7 b' class colorui(uimod.ui):' | |||||
369 | effects.append(l) |
|
355 | effects.append(l) | |
370 | effects = ' '.join(effects) |
|
356 | effects = ' '.join(effects) | |
371 | if effects: |
|
357 | if effects: | |
372 | return '\n'.join([render_effects(line, effects) |
|
358 | return '\n'.join([color._render_effects(line, effects) | |
373 | for line in msg.split('\n')]) |
|
359 | for line in msg.split('\n')]) | |
374 | return msg |
|
360 | return msg | |
375 |
|
361 |
@@ -158,3 +158,17 b' def _effect_str(effect):' | |||||
158 | return curses.tparm(curses.tigetstr('setab'), val) |
|
158 | return curses.tparm(curses.tigetstr('setab'), val) | |
159 | else: |
|
159 | else: | |
160 | return curses.tparm(curses.tigetstr('setaf'), val) |
|
160 | return curses.tparm(curses.tigetstr('setaf'), val) | |
|
161 | ||||
|
162 | def _render_effects(text, effects): | |||
|
163 | 'Wrap text in commands to turn on each effect.' | |||
|
164 | if not text: | |||
|
165 | return text | |||
|
166 | if not _terminfo_params: | |||
|
167 | start = [str(_effects[e]) for e in ['none'] + effects.split()] | |||
|
168 | start = '\033[' + ';'.join(start) + 'm' | |||
|
169 | stop = '\033[' + str(_effects['none']) + 'm' | |||
|
170 | else: | |||
|
171 | start = ''.join(_effect_str(effect) | |||
|
172 | for effect in ['none'] + effects.split()) | |||
|
173 | stop = _effect_str('none') | |||
|
174 | return ''.join([start, text, stop]) |
General Comments 0
You need to be logged in to leave comments.
Login now