~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: Martin Pool
  • Date: 2009-11-15 22:10:30 UTC
  • mto: This revision was merged to the branch mainline in revision 4880.
  • Revision ID: mbp@sourcefrog.net-20091115221030-1jfiufckgs8t2whs
Add TextUIOutputStream coordinated with progress view

Show diffs side-by-side

added added

removed removed

Lines of Context:
365
365
            self._bytes_since_update = 0
366
366
            self._last_transport_msg = msg
367
367
            self._repaint()
 
368
 
 
369
 
 
370
class TextUIOutputStream(object):
 
371
    """Decorates an output stream so that the terminal is cleared before writing.
 
372
 
 
373
    This is supposed to ensure that the progress bar does not conflict with bulk
 
374
    text output.
 
375
    """
 
376
    # XXX: this does not handle the case of writing part of a line, then doing
 
377
    # progress bar output: the progress bar will probably write over it.
 
378
    # one option is just to buffer that text until we have a full line;
 
379
    # another is to save and restore it
 
380
 
 
381
    # XXX: might need to wrap more methods
 
382
 
 
383
    def __init__(self, ui_factory, wrapped_stream):
 
384
        self.ui_factory = ui_factory
 
385
        self.wrapped_stream = wrapped_stream
 
386
 
 
387
    def write(self, to_write):
 
388
        self.ui_factory.clear_term()
 
389
        self.wrapped_stream.write(to_write)