##// END OF EJS Templates
color: move 'write' logic to the core ui class...
Pierre-Yves David -
r31091:ad074f90 default
parent child Browse files
Show More
@@ -297,21 +297,6 b' def _modesetup(ui, coloropt):'
297 return None
297 return None
298
298
299 class colorui(uimod.ui):
299 class colorui(uimod.ui):
300 def write(self, *args, **opts):
301 if self._colormode is None:
302 return super(colorui, self).write(*args, **opts)
303
304 label = opts.get('label', '')
305 if self._buffers and not opts.get('prompt', False):
306 if self._bufferapplylabels:
307 self._buffers[-1].extend(self.label(a, label) for a in args)
308 else:
309 self._buffers[-1].extend(args)
310 elif self._colormode == 'win32':
311 color.win32print(super(colorui, self).write, *args, **opts)
312 else:
313 return super(colorui, self).write(
314 *[self.label(a, label) for a in args], **opts)
315
300
316 def write_err(self, *args, **opts):
301 def write_err(self, *args, **opts):
317 if self._colormode is None:
302 if self._colormode is None:
@@ -779,24 +779,35 b' class ui(object):'
779 def write(self, *args, **opts):
779 def write(self, *args, **opts):
780 '''write args to output
780 '''write args to output
781
781
782 By default, this method simply writes to the buffer or stdout,
782 By default, this method simply writes to the buffer or stdout.
783 but extensions or GUI tools may override this method,
783 Color mode can be set on the UI class to have the output decorated
784 write_err(), popbuffer(), and label() to style output from
784 with color modifier before being written to stdout.
785 various parts of hg.
786
785
787 An optional keyword argument, "label", can be passed in.
786 The color used is controlled by an optional keyword argument, "label".
788 This should be a string containing label names separated by
787 This should be a string containing label names separated by space.
789 space. Label names take the form of "topic.type". For example,
788 Label names take the form of "topic.type". For example, ui.debug()
790 ui.debug() issues a label of "ui.debug".
789 issues a label of "ui.debug".
791
790
792 When labeling output for a specific command, a label of
791 When labeling output for a specific command, a label of
793 "cmdname.type" is recommended. For example, status issues
792 "cmdname.type" is recommended. For example, status issues
794 a label of "status.modified" for modified files.
793 a label of "status.modified" for modified files.
795 '''
794 '''
796 if self._buffers and not opts.get('prompt', False):
795 if self._buffers and not opts.get('prompt', False):
797 self._buffers[-1].extend(a for a in args)
796 if self._bufferapplylabels:
797 label = opts.get('label', '')
798 self._buffers[-1].extend(self.label(a, label) for a in args)
799 else:
800 self._buffers[-1].extend(args)
801 elif self._colormode == 'win32':
802 # windows color printing is its own can of crab, defer to
803 # the color module and that is it.
804 color.win32print(self._write, *args, **opts)
798 else:
805 else:
799 self._write(*args, **opts)
806 msgs = args
807 if self._colormode is not None:
808 label = opts.get('label', '')
809 msgs = [self.label(a, label) for a in args]
810 self._write(*msgs, **opts)
800
811
801 def _write(self, *msgs, **opts):
812 def _write(self, *msgs, **opts):
802 self._progclear()
813 self._progclear()
General Comments 0
You need to be logged in to leave comments. Login now