equal
deleted
inserted
replaced
128 } |
128 } |
129 |
129 |
130 def loadcolortable(ui, extname, colortable): |
130 def loadcolortable(ui, extname, colortable): |
131 _defaultstyles.update(colortable) |
131 _defaultstyles.update(colortable) |
132 |
132 |
133 def _terminfosetup(ui, mode): |
133 def _terminfosetup(ui, mode, formatted): |
134 '''Initialize terminfo data and the terminal if we're in terminfo mode.''' |
134 '''Initialize terminfo data and the terminal if we're in terminfo mode.''' |
135 |
135 |
136 # If we failed to load curses, we go ahead and return. |
136 # If we failed to load curses, we go ahead and return. |
137 if curses is None: |
137 if curses is None: |
138 return |
138 return |
162 # noisy and use ui.debug(). |
162 # noisy and use ui.debug(). |
163 ui.debug("no terminfo entry for %s\n" % e) |
163 ui.debug("no terminfo entry for %s\n" % e) |
164 del ui._terminfoparams[key] |
164 del ui._terminfoparams[key] |
165 if not curses.tigetstr('setaf') or not curses.tigetstr('setab'): |
165 if not curses.tigetstr('setaf') or not curses.tigetstr('setab'): |
166 # Only warn about missing terminfo entries if we explicitly asked for |
166 # Only warn about missing terminfo entries if we explicitly asked for |
167 # terminfo mode. |
167 # terminfo mode and we're in a formatted terminal. |
168 if mode == "terminfo": |
168 if mode == "terminfo" and formatted: |
169 ui.warn(_("no terminfo entry for setab/setaf: reverting to " |
169 ui.warn(_("no terminfo entry for setab/setaf: reverting to " |
170 "ECMA-48 color\n")) |
170 "ECMA-48 color\n")) |
171 ui._terminfoparams.clear() |
171 ui._terminfoparams.clear() |
172 |
172 |
173 def setup(ui): |
173 def setup(ui): |
240 realmode = 'ansi' |
240 realmode = 'ansi' |
241 |
241 |
242 def modewarn(): |
242 def modewarn(): |
243 # only warn if color.mode was explicitly set and we're in |
243 # only warn if color.mode was explicitly set and we're in |
244 # a formatted terminal |
244 # a formatted terminal |
245 if mode == realmode and ui.formatted(): |
245 if mode == realmode and formatted: |
246 ui.warn(_('warning: failed to set color mode to %s\n') % mode) |
246 ui.warn(_('warning: failed to set color mode to %s\n') % mode) |
247 |
247 |
248 if realmode == 'win32': |
248 if realmode == 'win32': |
249 ui._terminfoparams.clear() |
249 ui._terminfoparams.clear() |
250 if not w32effects: |
250 if not w32effects: |
251 modewarn() |
251 modewarn() |
252 return None |
252 return None |
253 elif realmode == 'ansi': |
253 elif realmode == 'ansi': |
254 ui._terminfoparams.clear() |
254 ui._terminfoparams.clear() |
255 elif realmode == 'terminfo': |
255 elif realmode == 'terminfo': |
256 _terminfosetup(ui, mode) |
256 _terminfosetup(ui, mode, formatted) |
257 if not ui._terminfoparams: |
257 if not ui._terminfoparams: |
258 ## FIXME Shouldn't we return None in this case too? |
258 ## FIXME Shouldn't we return None in this case too? |
259 modewarn() |
259 modewarn() |
260 realmode = 'ansi' |
260 realmode = 'ansi' |
261 else: |
261 else: |