MCPcopy
hub / github.com/Textualize/rich / ConsoleOptions

Class ConsoleOptions

rich/console.py:113–243  ·  view source on GitHub ↗

Options for __rich_console__ method.

Source from the content-addressed store, hash-verified

111
112@dataclass
113class ConsoleOptions:
114 """Options for __rich_console__ method."""
115
116 size: ConsoleDimensions
117 """Size of console."""
118 legacy_windows: bool
119 """legacy_windows: flag for legacy windows."""
120 min_width: int
121 """Minimum width of renderable."""
122 max_width: int
123 """Maximum width of renderable."""
124 is_terminal: bool
125 """True if the target is a terminal, otherwise False."""
126 encoding: str
127 """Encoding of terminal."""
128 max_height: int
129 """Height of container (starts as terminal)"""
130 justify: Optional[JustifyMethod] = None
131 """Justify value override for renderable."""
132 overflow: Optional[OverflowMethod] = None
133 """Overflow value override for renderable."""
134 no_wrap: Optional[bool] = False
135 """Disable wrapping for text."""
136 highlight: Optional[bool] = None
137 """Highlight override for render_str."""
138 markup: Optional[bool] = None
139 """Enable markup when rendering strings."""
140 height: Optional[int] = None
141
142 @property
143 def ascii_only(self) -> bool:
144 """Check if renderables should use ascii only."""
145 return not self.encoding.startswith("utf")
146
147 def copy(self) -> "ConsoleOptions":
148 """Return a copy of the options.
149
150 Returns:
151 ConsoleOptions: a copy of self.
152 """
153 options: ConsoleOptions = ConsoleOptions.__new__(ConsoleOptions)
154 options.__dict__ = self.__dict__.copy()
155 return options
156
157 def update(
158 self,
159 *,
160 width: Union[int, NoChange] = NO_CHANGE,
161 min_width: Union[int, NoChange] = NO_CHANGE,
162 max_width: Union[int, NoChange] = NO_CHANGE,
163 justify: Union[Optional[JustifyMethod], NoChange] = NO_CHANGE,
164 overflow: Union[Optional[OverflowMethod], NoChange] = NO_CHANGE,
165 no_wrap: Union[Optional[bool], NoChange] = NO_CHANGE,
166 highlight: Union[Optional[bool], NoChange] = NO_CHANGE,
167 markup: Union[Optional[bool], NoChange] = NO_CHANGE,
168 height: Union[Optional[int], NoChange] = NO_CHANGE,
169 ) -> "ConsoleOptions":
170 """Update values, return a copy."""

Calls

no outgoing calls