~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: Jelmer Vernooij
  • Date: 2012-06-18 11:43:07 UTC
  • mfrom: (6437.54.10 2.5)
  • mto: This revision was merged to the branch mainline in revision 6525.
  • Revision ID: jelmer@samba.org-20120618114307-zeazlym311p38m98
MergeĀ 2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
404
404
    this only prints the stack from the nominated current task up to the root.
405
405
    """
406
406
 
407
 
    def __init__(self, term_file):
 
407
    def __init__(self, term_file, encoding=None, errors="replace"):
408
408
        self._term_file = term_file
 
409
        if encoding is None:
 
410
            self._encoding = getattr(term_file, "encoding", None) or "ascii"
 
411
        else:
 
412
            self._encoding = encoding
 
413
        self._encoding_errors = errors
409
414
        # true when there's output on the screen we may need to clear
410
415
        self._have_output = False
411
416
        self._last_transport_msg = ''
432
437
        else:
433
438
            return w - 1
434
439
 
435
 
    def _show_line(self, s):
436
 
        # sys.stderr.write("progress %r\n" % s)
 
440
    def _show_line(self, u):
 
441
        s = u.encode(self._encoding, self._encoding_errors)
437
442
        width = self._avail_width()
438
443
        if width is not None:
 
444
            # GZ 2012-03-28: Counting bytes is wrong for calculating width of
 
445
            #                text but better than counting codepoints.
439
446
            s = '%-*.*s' % (width, width, s)
440
447
        self._term_file.write('\r' + s + '\r')
441
448