/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: Martin Pool
  • Date: 2010-07-09 15:47:01 UTC
  • mto: (5050.3.10 2.2)
  • mto: This revision was merged to the branch mainline in revision 5365.
  • Revision ID: mbp@canonical.com-20100709154701-ine84xsdxz557sm8
Show the progress spinner between the transport rate and the message.

Show diffs side-by-side

added added

removed removed

Lines of Context:
309
309
            return w - 1
310
310
 
311
311
    def _show_line(self, s):
312
 
        width = self._avail_width()
313
 
        if width is not None:
314
 
            if len(s) < width:
315
 
                s = s.ljust(width)
316
 
            elif len(s) > width:
317
 
                s = s[:width]
318
312
        self._term_file.write('\r' + s + '\r')
319
313
 
320
314
    def clear(self):
387
381
            trans = ''
388
382
        else:
389
383
            trans = self._last_transport_msg
390
 
            if trans:
391
 
                trans += ' | '
 
384
        # the bar separates the transport activity from the message, so even
 
385
        # if there's no bar or spinner, we must show something if both those
 
386
        # fields are present
 
387
        if (task_part or trans) and not bar_string:
 
388
            bar_string = '| '
392
389
        # preferentially truncate the task message if we don't have enough
393
390
        # space
394
 
        avail_len = self._avail_width()
395
 
        if avail_len is not None:
396
 
            # if terminal width is unknown, don't truncate
 
391
        avail_width = self._avail_width()
 
392
        if avail_width is not None:
 
393
            # if terminal avail_width is unknown, don't truncate
397
394
            current_len = len(bar_string) + len(trans) + len(task_part) + len(counter_part)
398
 
            gap = current_len - avail_len
 
395
            gap = current_len - avail_width
399
396
            if gap > 0:
400
397
                task_part = task_part[:-gap-2] + '..'
401
 
        return (bar_string + trans + task_part + counter_part)
 
398
        s = trans + bar_string + task_part + counter_part
 
399
        if avail_width is not None:
 
400
            if len(s) < avail_width:
 
401
                s = s.ljust(avail_width)
 
402
            elif len(s) > avail_width:
 
403
                s = s[:avail_width]
 
404
        return s
402
405
 
403
406
    def _repaint(self):
404
407
        s = self._render_line()
460
463
            rate = (self._bytes_since_update
461
464
                    / (now - self._transport_update_time))
462
465
            # using base-10 units (see HACKING.txt).
463
 
            msg = ("%6dkB %5dkB/s" %
 
466
            msg = ("%6dkB %5dkB/s " %
464
467
                    (self._total_byte_count / 1000, int(rate) / 1000,))
465
468
            self._transport_update_time = now
466
469
            self._last_repaint = now