Show More
@@ -332,22 +332,6 b' def render_effects(text, effects):' | |||||
332 | stop = _effect_str('none') |
|
332 | stop = _effect_str('none') | |
333 | return ''.join([start, text, stop]) |
|
333 | return ''.join([start, text, stop]) | |
334 |
|
334 | |||
335 | def configstyles(ui): |
|
|||
336 | for status, cfgeffects in ui.configitems('color'): |
|
|||
337 | if '.' not in status or status.startswith(('color.', 'terminfo.')): |
|
|||
338 | continue |
|
|||
339 | cfgeffects = ui.configlist('color', status) |
|
|||
340 | if cfgeffects: |
|
|||
341 | good = [] |
|
|||
342 | for e in cfgeffects: |
|
|||
343 | if color.valideffect(e): |
|
|||
344 | good.append(e) |
|
|||
345 | else: |
|
|||
346 | ui.warn(_("ignoring unknown color/effect %r " |
|
|||
347 | "(configured in color.%s)\n") |
|
|||
348 | % (e, status)) |
|
|||
349 | color._styles[status] = ' '.join(good) |
|
|||
350 |
|
||||
351 | class colorui(uimod.ui): |
|
335 | class colorui(uimod.ui): | |
352 | _colormode = 'ansi' |
|
336 | _colormode = 'ansi' | |
353 | def write(self, *args, **opts): |
|
337 | def write(self, *args, **opts): | |
@@ -420,7 +404,7 b' def uisetup(ui):' | |||||
420 | mode = _modesetup(ui_, opts['color']) |
|
404 | mode = _modesetup(ui_, opts['color']) | |
421 | colorui._colormode = mode |
|
405 | colorui._colormode = mode | |
422 | if mode and mode != 'debug': |
|
406 | if mode and mode != 'debug': | |
423 | configstyles(ui_) |
|
407 | color.configstyles(ui_) | |
424 | return orig(ui_, opts, cmd, cmdfunc) |
|
408 | return orig(ui_, opts, cmd, cmdfunc) | |
425 | def colorgit(orig, gitsub, commands, env=None, stream=False, cwd=None): |
|
409 | def colorgit(orig, gitsub, commands, env=None, stream=False, cwd=None): | |
426 | if gitsub.ui._colormode and len(commands) and commands[0] == "diff": |
|
410 | if gitsub.ui._colormode and len(commands) and commands[0] == "diff": |
@@ -7,6 +7,8 b'' | |||||
7 |
|
7 | |||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
|
10 | from .i18n import _ | |||
|
11 | ||||
10 | try: |
|
12 | try: | |
11 | import curses |
|
13 | import curses | |
12 | # Mapping from effect name to terminfo attribute name (or raw code) or |
|
14 | # Mapping from effect name to terminfo attribute name (or raw code) or | |
@@ -114,6 +116,22 b' except ImportError:' | |||||
114 | def loadcolortable(ui, extname, colortable): |
|
116 | def loadcolortable(ui, extname, colortable): | |
115 | _styles.update(colortable) |
|
117 | _styles.update(colortable) | |
116 |
|
118 | |||
|
119 | def configstyles(ui): | |||
|
120 | for status, cfgeffects in ui.configitems('color'): | |||
|
121 | if '.' not in status or status.startswith(('color.', 'terminfo.')): | |||
|
122 | continue | |||
|
123 | cfgeffects = ui.configlist('color', status) | |||
|
124 | if cfgeffects: | |||
|
125 | good = [] | |||
|
126 | for e in cfgeffects: | |||
|
127 | if valideffect(e): | |||
|
128 | good.append(e) | |||
|
129 | else: | |||
|
130 | ui.warn(_("ignoring unknown color/effect %r " | |||
|
131 | "(configured in color.%s)\n") | |||
|
132 | % (e, status)) | |||
|
133 | _styles[status] = ' '.join(good) | |||
|
134 | ||||
117 | def valideffect(effect): |
|
135 | def valideffect(effect): | |
118 | 'Determine if the effect is valid or not.' |
|
136 | 'Determine if the effect is valid or not.' | |
119 | return ((not _terminfo_params and effect in _effects) |
|
137 | return ((not _terminfo_params and effect in _effects) |
General Comments 0
You need to be logged in to leave comments.
Login now