summaryrefslogtreecommitdiffstats
path: root/color.py
diff options
context:
space:
mode:
Diffstat (limited to 'color.py')
-rw-r--r--color.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/color.py b/color.py
index d856313f..7970198a 100644
--- a/color.py
+++ b/color.py
@@ -126,6 +126,13 @@ class Coloring(object):
126 s._out.write(c(fmt, *args)) 126 s._out.write(c(fmt, *args))
127 return f 127 return f
128 128
129 def nofmt_printer(self, opt=None, fg=None, bg=None, attr=None):
130 s = self
131 c = self.nofmt_colorer(opt, fg, bg, attr)
132 def f(fmt):
133 s._out.write(c(fmt))
134 return f
135
129 def colorer(self, opt=None, fg=None, bg=None, attr=None): 136 def colorer(self, opt=None, fg=None, bg=None, attr=None):
130 if self._on: 137 if self._on:
131 c = self._parse(opt, fg, bg, attr) 138 c = self._parse(opt, fg, bg, attr)
@@ -138,6 +145,17 @@ class Coloring(object):
138 return fmt % args 145 return fmt % args
139 return f 146 return f
140 147
148 def nofmt_colorer(self, opt=None, fg=None, bg=None, attr=None):
149 if self._on:
150 c = self._parse(opt, fg, bg, attr)
151 def f(fmt):
152 return ''.join([c, fmt, RESET])
153 return f
154 else:
155 def f(fmt):
156 return fmt
157 return f
158
141 def _parse(self, opt, fg, bg, attr): 159 def _parse(self, opt, fg, bg, attr):
142 if not opt: 160 if not opt:
143 return _Color(fg, bg, attr) 161 return _Color(fg, bg, attr)