123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- """
- Interface for an output.
- """
- from __future__ import unicode_literals
- from abc import ABCMeta, abstractmethod
- from six import with_metaclass
- from prompt_toolkit.layout.screen import Size
- __all__ = (
- 'Output',
- )
- class Output(with_metaclass(ABCMeta, object)):
- """
- Base class defining the output interface for a
- :class:`~prompt_toolkit.renderer.Renderer`.
- Actual implementations are
- :class:`~prompt_toolkit.terminal.vt100_output.Vt100_Output` and
- :class:`~prompt_toolkit.terminal.win32_output.Win32Output`.
- """
- @abstractmethod
- def fileno(self):
- " Return the file descriptor to which we can write for the output. "
- @abstractmethod
- def encoding(self):
- """
- Return the encoding for this output, e.g. 'utf-8'.
- (This is used mainly to know which characters are supported by the
- output the data, so that the UI can provide alternatives, when
- required.)
- """
- @abstractmethod
- def write(self, data):
- " Write text (Terminal escape sequences will be removed/escaped.) "
- @abstractmethod
- def write_raw(self, data):
- " Write text. "
- @abstractmethod
- def set_title(self, title):
- " Set terminal title. "
- @abstractmethod
- def clear_title(self):
- " Clear title again. (or restore previous title.) "
- @abstractmethod
- def flush(self):
- " Write to output stream and flush. "
- @abstractmethod
- def erase_screen(self):
- """
- Erases the screen with the background colour and moves the cursor to
- home.
- """
- @abstractmethod
- def enter_alternate_screen(self):
- " Go to the alternate screen buffer. (For full screen applications). "
- @abstractmethod
- def quit_alternate_screen(self):
- " Leave the alternate screen buffer. "
- @abstractmethod
- def enable_mouse_support(self):
- " Enable mouse. "
- @abstractmethod
- def disable_mouse_support(self):
- " Disable mouse. "
- @abstractmethod
- def erase_end_of_line(self):
- """
- Erases from the current cursor position to the end of the current line.
- """
- @abstractmethod
- def erase_down(self):
- """
- Erases the screen from the current line down to the bottom of the
- screen.
- """
- @abstractmethod
- def reset_attributes(self):
- " Reset color and styling attributes. "
- @abstractmethod
- def set_attributes(self, attrs):
- " Set new color and styling attributes. "
- @abstractmethod
- def disable_autowrap(self):
- " Disable auto line wrapping. "
- @abstractmethod
- def enable_autowrap(self):
- " Enable auto line wrapping. "
- @abstractmethod
- def cursor_goto(self, row=0, column=0):
- " Move cursor position. "
- @abstractmethod
- def cursor_up(self, amount):
- " Move cursor `amount` place up. "
- @abstractmethod
- def cursor_down(self, amount):
- " Move cursor `amount` place down. "
- @abstractmethod
- def cursor_forward(self, amount):
- " Move cursor `amount` place forward. "
- @abstractmethod
- def cursor_backward(self, amount):
- " Move cursor `amount` place backward. "
- @abstractmethod
- def hide_cursor(self):
- " Hide cursor. "
- @abstractmethod
- def show_cursor(self):
- " Show cursor. "
- def ask_for_cpr(self):
- """
- Asks for a cursor position report (CPR).
- (VT100 only.)
- """
- def bell(self):
- " Sound bell. "
- def enable_bracketed_paste(self):
- " For vt100 only. "
- def disable_bracketed_paste(self):
- " For vt100 only. "
- class DummyOutput(Output):
- """
- For testing. An output class that doesn't render anything.
- """
- def fileno(self):
- " There is no sensible default for fileno(). "
- raise NotImplementedError
- def encoding(self):
- return 'utf-8'
- def write(self, data): pass
- def write_raw(self, data): pass
- def set_title(self, title): pass
- def clear_title(self): pass
- def flush(self): pass
- def erase_screen(self): pass
- def enter_alternate_screen(self): pass
- def quit_alternate_screen(self): pass
- def enable_mouse_support(self): pass
- def disable_mouse_support(self): pass
- def erase_end_of_line(self): pass
- def erase_down(self): pass
- def reset_attributes(self): pass
- def set_attributes(self, attrs): pass
- def disable_autowrap(self): pass
- def enable_autowrap(self): pass
- def cursor_goto(self, row=0, column=0): pass
- def cursor_up(self, amount): pass
- def cursor_down(self, amount): pass
- def cursor_forward(self, amount): pass
- def cursor_backward(self, amount): pass
- def hide_cursor(self): pass
- def show_cursor(self): pass
- def ask_for_cpr(self): pass
- def bell(self): pass
- def enable_bracketed_paste(self): pass
- def disable_bracketed_paste(self): pass
- def get_size(self):
- return Size(rows=40, columns=80)
|