Mercurial > hg
comparison hgext/color.py @ 31069:cf2bc3792ef4
color: minor simplification of some terminfo setup code
No logic change is introduced. The previous code were using a 'dict.update' with
a complex generator. That was a bit confusing to read and not so compact.
Instead we now use an explicit loop and conditional for the sake of clarity.
This also allow for more simplification coming in the next changeset.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Thu, 22 Dec 2016 13:06:53 +0100 |
parents | 27d3bc0c9093 |
children | ebd14a4b03fc |
comparison
equal
deleted
inserted
replaced
31068:27d3bc0c9093 | 31069:cf2bc3792ef4 |
---|---|
200 return | 200 return |
201 # Otherwise, see what the config file says. | 201 # Otherwise, see what the config file says. |
202 if mode not in ('auto', 'terminfo'): | 202 if mode not in ('auto', 'terminfo'): |
203 return | 203 return |
204 | 204 |
205 color._terminfo_params.update((key[6:], (False, int(val), '')) | 205 for key, val in ui.configitems('color'): |
206 for key, val in ui.configitems('color') | 206 if key.startswith('color.'): |
207 if key.startswith('color.')) | 207 newval = (False, int(val), '') |
208 color._terminfo_params.update((key[9:], | 208 color._terminfo_params[key[6:]] = newval |
209 (True, '', val.replace('\\E', '\x1b'))) | 209 |
210 for key, val in ui.configitems('color') | 210 for key, val in ui.configitems('color'): |
211 if key.startswith('terminfo.')) | 211 if key.startswith('terminfo.'): |
212 | 212 newval = (True, '', val.replace('\\E', '\x1b')) |
213 color._terminfo_params[key[9:]] = newval | |
213 try: | 214 try: |
214 curses.setupterm() | 215 curses.setupterm() |
215 except curses.error as e: | 216 except curses.error as e: |
216 color._terminfo_params.clear() | 217 color._terminfo_params.clear() |
217 return | 218 return |