~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: John Arbash Meinel
  • Date: 2005-12-29 02:36:07 UTC
  • mto: (1185.50.36 bzr-jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1536.
  • Revision ID: john@arbash-meinel.com-20051229023607-95f3ed4a0404cfa5
test_revision_info.py is actually a blackbox test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import sys
24
24
 
25
25
import bzrlib.progress
26
 
from bzrlib.symbol_versioning import *
27
 
from bzrlib.ui import CLIUIFactory
28
 
 
29
 
 
30
 
class TextUIFactory(CLIUIFactory):
31
 
    """A UI factory for Text user interefaces."""
32
 
 
33
 
    def __init__(self, bar_type=None):
34
 
        """Create a TextUIFactory.
35
 
 
36
 
        :param bar_type: The type of progress bar to create. It defaults to 
37
 
                         letting the bzrlib.progress.ProgressBar factory auto
38
 
                         select.
39
 
        """
40
 
        super(TextUIFactory, self).__init__()
41
 
        self._bar_type = bar_type
42
 
        self.stdout = sys.stdout
43
 
 
44
 
    def prompt(self, prompt):
45
 
        """Emit prompt on the CLI."""
46
 
        self.stdout.write(prompt + "? [y/n]:")
47
 
        
48
 
    @deprecated_method(zero_eight)
 
26
from bzrlib.ui import UIFactory
 
27
 
 
28
 
 
29
class TextUIFactory(UIFactory):
49
30
    def progress_bar(self):
50
 
        """See UIFactory.nested_progress_bar()."""
 
31
 
51
32
        # this in turn is abstract, and creates either a tty or dots
52
33
        # bar depending on what we think of the terminal
53
34
        return bzrlib.progress.ProgressBar()
69
50
        except KeyboardInterrupt:
70
51
            return None
71
52
 
72
 
    def nested_progress_bar(self):
73
 
        """Return a nested progress bar.
74
 
        
75
 
        The actual bar type returned depends on the progress module which
76
 
        may return a tty or dots bar depending on the terminal.
77
 
        """
78
 
        if self._progress_bar_stack is None:
79
 
            self._progress_bar_stack = bzrlib.progress.ProgressBarStack(
80
 
                klass=self._bar_type)
81
 
        return self._progress_bar_stack.get_nested()
82
 
 
83
 
    def clear_term(self):
84
 
        """Prepare the terminal for output.
85
 
 
86
 
        This will, clear any progress bars, and leave the cursor at the
87
 
        leftmost position."""
88
 
        if self._progress_bar_stack is None:
89
 
            return
90
 
        overall_pb = self._progress_bar_stack.bottom()
91
 
        if overall_pb is not None:
92
 
            overall_pb.clear()