~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/__init__.py

Restore a working UI implementation suitable for emacs shells.

* bzrlib/ui/__init__.py:
(CLIUIFactory.prompt, CLIUIFactory.note): Default implementations.
(SilentUIFactory.prompt): Override default implementation.
(make_ui_for_terminal): Let user override automatic detection.

Show diffs side-by-side

added added

removed removed

Lines of Context:
172
172
 
173
173
    def prompt(self, prompt):
174
174
        """Emit prompt on the CLI."""
 
175
        self.stdout.write(prompt)
 
176
 
 
177
    def note(self, msg):
 
178
        """Write an already-formatted message."""
 
179
        self.stdout.write(msg + '\n')
175
180
 
176
181
    def clear_term(self):
177
182
        pass
195
200
    def get_password(self, prompt='', **kwargs):
196
201
        return None
197
202
 
 
203
    def prompt(self, prompt):
 
204
        pass
198
205
 
199
206
    def note(self, msg):
200
207
        pass
225
232
    elif os.environ.get('TERM') in (None, 'dumb', ''):
226
233
        # e.g. emacs compile window
227
234
        cls = CLIUIFactory
228
 
    else:
 
235
    # User may know better, otherwise default to TextUIFactory
 
236
    if (   os.environ.get('BZR_USE_TEXT_UI', None) is not None
 
237
        or cls is None):
229
238
        from bzrlib.ui.text import TextUIFactory
230
239
        cls = TextUIFactory
231
240
    return cls(stdin=stdin, stdout=stdout, stderr=stderr)