Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/prompt_toolkit/output/plain_text.py: 52%
88 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-20 06:09 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-20 06:09 +0000
1from __future__ import annotations
3from typing import TextIO
5from prompt_toolkit.cursor_shapes import CursorShape
6from prompt_toolkit.data_structures import Size
7from prompt_toolkit.styles import Attrs
9from .base import Output
10from .color_depth import ColorDepth
11from .flush_stdout import flush_stdout
13__all__ = ["PlainTextOutput"]
16class PlainTextOutput(Output):
17 """
18 Output that won't include any ANSI escape sequences.
20 Useful when stdout is not a terminal. Maybe stdout is redirected to a file.
21 In this case, if `print_formatted_text` is used, for instance, we don't
22 want to include formatting.
24 (The code is mostly identical to `Vt100_Output`, but without the
25 formatting.)
26 """
28 def __init__(self, stdout: TextIO) -> None:
29 assert all(hasattr(stdout, a) for a in ("write", "flush"))
31 self.stdout: TextIO = stdout
32 self._buffer: list[str] = []
34 def fileno(self) -> int:
35 "There is no sensible default for fileno()."
36 return self.stdout.fileno()
38 def encoding(self) -> str:
39 return "utf-8"
41 def write(self, data: str) -> None:
42 self._buffer.append(data)
44 def write_raw(self, data: str) -> None:
45 self._buffer.append(data)
47 def set_title(self, title: str) -> None:
48 pass
50 def clear_title(self) -> None:
51 pass
53 def flush(self) -> None:
54 if not self._buffer:
55 return
57 data = "".join(self._buffer)
58 self._buffer = []
59 flush_stdout(self.stdout, data)
61 def erase_screen(self) -> None:
62 pass
64 def enter_alternate_screen(self) -> None:
65 pass
67 def quit_alternate_screen(self) -> None:
68 pass
70 def enable_mouse_support(self) -> None:
71 pass
73 def disable_mouse_support(self) -> None:
74 pass
76 def erase_end_of_line(self) -> None:
77 pass
79 def erase_down(self) -> None:
80 pass
82 def reset_attributes(self) -> None:
83 pass
85 def set_attributes(self, attrs: Attrs, color_depth: ColorDepth) -> None:
86 pass
88 def disable_autowrap(self) -> None:
89 pass
91 def enable_autowrap(self) -> None:
92 pass
94 def cursor_goto(self, row: int = 0, column: int = 0) -> None:
95 pass
97 def cursor_up(self, amount: int) -> None:
98 pass
100 def cursor_down(self, amount: int) -> None:
101 self._buffer.append("\n")
103 def cursor_forward(self, amount: int) -> None:
104 self._buffer.append(" " * amount)
106 def cursor_backward(self, amount: int) -> None:
107 pass
109 def hide_cursor(self) -> None:
110 pass
112 def show_cursor(self) -> None:
113 pass
115 def set_cursor_shape(self, cursor_shape: CursorShape) -> None:
116 pass
118 def reset_cursor_shape(self) -> None:
119 pass
121 def ask_for_cpr(self) -> None:
122 pass
124 def bell(self) -> None:
125 pass
127 def enable_bracketed_paste(self) -> None:
128 pass
130 def disable_bracketed_paste(self) -> None:
131 pass
133 def scroll_buffer_to_prompt(self) -> None:
134 pass
136 def get_size(self) -> Size:
137 return Size(rows=40, columns=80)
139 def get_rows_below_cursor_position(self) -> int:
140 return 8
142 def get_default_color_depth(self) -> ColorDepth:
143 return ColorDepth.DEPTH_1_BIT