conemu_output.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from __future__ import unicode_literals
  2. from prompt_toolkit.renderer import Output
  3. from .win32_output import Win32Output
  4. from .vt100_output import Vt100_Output
  5. __all__ = (
  6. 'ConEmuOutput',
  7. )
  8. class ConEmuOutput(object):
  9. """
  10. ConEmu (Windows) output abstraction.
  11. ConEmu is a Windows console application, but it also supports ANSI escape
  12. sequences. This output class is actually a proxy to both `Win32Output` and
  13. `Vt100_Output`. It uses `Win32Output` for console sizing and scrolling, but
  14. all cursor movements and scrolling happens through the `Vt100_Output`.
  15. This way, we can have 256 colors in ConEmu and Cmder. Rendering will be
  16. even a little faster as well.
  17. http://conemu.github.io/
  18. http://gooseberrycreative.com/cmder/
  19. """
  20. def __init__(self, stdout):
  21. self.win32_output = Win32Output(stdout)
  22. self.vt100_output = Vt100_Output(stdout, lambda: None)
  23. def __getattr__(self, name):
  24. if name in ('get_size', 'get_rows_below_cursor_position',
  25. 'enable_mouse_support', 'disable_mouse_support',
  26. 'scroll_buffer_to_prompt', 'get_win32_screen_buffer_info',
  27. 'enable_bracketed_paste', 'disable_bracketed_paste'):
  28. return getattr(self.win32_output, name)
  29. else:
  30. return getattr(self.vt100_output, name)
  31. Output.register(ConEmuOutput)