Prints alerts and updates the prompt any time the prompt is showing.
(self)
| 147 | return stylize(self.visible_prompt, style=status_color) |
| 148 | |
| 149 | def _add_alerts_func(self) -> None: |
| 150 | """Prints alerts and updates the prompt any time the prompt is showing.""" |
| 151 | self._alert_count = 0 |
| 152 | self._next_alert_time = 0 |
| 153 | |
| 154 | while not self._stop_event.is_set(): |
| 155 | # Get any alerts that need to be printed |
| 156 | alert_str = self._build_alert_str() |
| 157 | |
| 158 | # Build a new prompt |
| 159 | new_prompt = self._build_colored_prompt() |
| 160 | |
| 161 | # Check if we have alerts to print |
| 162 | if alert_str: |
| 163 | self.add_alert(msg=alert_str, prompt=new_prompt) |
| 164 | new_title = f"Alerts Printed: {self._alert_count}" |
| 165 | self.set_window_title(new_title) |
| 166 | |
| 167 | # Otherwise check if the prompt needs to be updated or refreshed |
| 168 | elif self.prompt != new_prompt: |
| 169 | self.add_alert(prompt=new_prompt) |
| 170 | |
| 171 | self._stop_event.wait(0.5) |
| 172 | |
| 173 | |
| 174 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected