~vila/bzr/bug957049

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: Vincent Ladeuil
  • Date: 2012-08-01 08:48:41 UTC
  • mfrom: (6494.2.11 2.5)
  • Revision ID: v.ladeuil+lp@free.fr-20120801084841-jjvbbcs9p1rs64zd
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