From patchwork Wed Feb 12 00:07:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: color: add debugcolor command (issue4094) From: Olle Lundberg X-Patchwork-Id: 3597 Message-Id: <7fe39106c0e1971f9e26.1392163666@se-c02kq0dadr55.lan> To: mercurial-devel@selenic.com Date: Wed, 12 Feb 2014 01:07:46 +0100 # HG changeset patch # User Olle Lundberg # Date 1392163251 -3600 # Wed Feb 12 01:00:51 2014 +0100 # Node ID 7fe39106c0e1971f9e26548ebce9125d42662563 # Parent 1478a9ce679097c03234201d179e48c58d0b5c1d color: add debugcolor command (issue4094) This patch adds a debugcolor command that prints all colors that the extension knows about. diff --git a/hgext/color.py b/hgext/color.py --- a/hgext/color.py +++ b/hgext/color.py @@ -424,10 +424,20 @@ # i18n: 'always', 'auto', and 'never' are keywords and should # not be translated _("when to colorize (boolean, always, auto, or never)"), _('TYPE'))) +def debugcolor(ui, repo, **opts): + global _styles + _styles = {} + for effect in _effects.keys(): + _styles[effect] = effect + ui.write(('colormode: %s\n') % ui._colormode) + ui.write(_('available colors:\n')) + for label, colors in _styles.items(): + ui.write(('%s\n') % colors, label=label) + if os.name != 'nt': w32effects = None else: import re, ctypes @@ -553,5 +563,10 @@ orig(m.group(2), **opts) m = re.match(ansire, m.group(3)) finally: # Explicitly reset original attributes _kernel32.SetConsoleTextAttribute(stdout, origattr) + +cmdtable = { + 'debugcolor': + (debugcolor, [], ('hg debugcolor')) +}