Render the model label with width-aware truncation. Returns: Text content, truncated from the left when necessary.
(self)
| 104 | return len(self._with_effort(full)) |
| 105 | |
| 106 | def render(self) -> RenderResult: |
| 107 | """Render the model label with width-aware truncation. |
| 108 | |
| 109 | Returns: |
| 110 | Text content, truncated from the left when necessary. |
| 111 | """ |
| 112 | width = self.content_size.width |
| 113 | if not self.model or width <= 0: |
| 114 | return "" |
| 115 | model = self._clean_model() |
| 116 | full = f"{self.provider}:{model}" if self.provider else model |
| 117 | full_with_effort = self._with_effort(full) |
| 118 | model_with_effort = self._with_effort(model) |
| 119 | if len(full_with_effort) <= width: |
| 120 | return Content(full_with_effort) |
| 121 | if len(model_with_effort) <= width: |
| 122 | return Content(model_with_effort) |
| 123 | if self.effort and width > len(self.effort) + 2: |
| 124 | model_width = width - len(self.effort) - 1 |
| 125 | return Content(f"\u2026{model[-(model_width - 1) :]} {self.effort}") |
| 126 | if len(model) <= width: |
| 127 | return Content(model) |
| 128 | if width > 1: |
| 129 | return Content("\u2026" + model[-(width - 1) :]) |
| 130 | return Content("\u2026") |
| 131 | |
| 132 | |
| 133 | class StatusBar(Horizontal): |