Patchwork color: add debugcolor command (issue4094)

login
register
mail settings
Submitter Olle Lundberg
Date Feb. 12, 2014, 12:07 a.m.
Message ID <7fe39106c0e1971f9e26.1392163666@se-c02kq0dadr55.lan>
Download mbox | patch
Permalink /patch/3597/
State Accepted
Commit a2c08adbb86ed8e65897ce35ec97ee947f26d2dd
Headers show

Comments

Matt Mackall - Feb. 11, 2014, 10:14 p.m.
On Wed, 2014-02-12 at 01:07 +0100, Olle Lundberg wrote:
> # HG changeset patch
> # User Olle Lundberg <geek@nerd.sh>
> # Date 1392163251 -3600
> #      Wed Feb 12 01:00:51 2014 +0100
> # Node ID 7fe39106c0e1971f9e26548ebce9125d42662563
> # Parent  1478a9ce679097c03234201d179e48c58d0b5c1d
> color: add debugcolor command (issue4094)

Excellent. Queued for default, thanks.
Olle Lundberg - Feb. 12, 2014, 12:07 a.m.
# HG changeset patch
# User Olle Lundberg <geek@nerd.sh>
# 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.

Patch

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'))
+}