~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

Merge with bzr.dev after 0.8 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
import bzrlib.progress
26
26
from bzrlib.symbol_versioning import *
27
 
from bzrlib.ui import UIFactory
28
 
 
29
 
 
30
 
class TextUIFactory(UIFactory):
31
 
 
 
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
        
32
48
    @deprecated_method(zero_eight)
33
49
    def progress_bar(self):
34
50
        """See UIFactory.nested_progress_bar()."""
60
76
        may return a tty or dots bar depending on the terminal.
61
77
        """
62
78
        if self._progress_bar_stack is None:
63
 
            self._progress_bar_stack = bzrlib.progress.ProgressBarStack()
 
79
            self._progress_bar_stack = bzrlib.progress.ProgressBarStack(
 
80
                klass=self._bar_type)
64
81
        return self._progress_bar_stack.get_nested()
65
82
 
66
83
    def clear_term(self):