()
| 196 | console.print() |
| 197 | |
| 198 | def run_selection_loop(): |
| 199 | nonlocal selected_key, selected_index |
| 200 | _transient = sys.platform != "win32" |
| 201 | with Live(create_selection_panel(), console=console, transient=_transient, auto_refresh=False) as live: |
| 202 | while True: |
| 203 | try: |
| 204 | key = get_key() |
| 205 | if key == 'up': |
| 206 | selected_index = (selected_index - 1) % len(option_keys) |
| 207 | elif key == 'down': |
| 208 | selected_index = (selected_index + 1) % len(option_keys) |
| 209 | elif key == 'enter': |
| 210 | selected_key = option_keys[selected_index] |
| 211 | break |
| 212 | elif key == 'escape': |
| 213 | console.print("\n[yellow]Selection cancelled[/yellow]") |
| 214 | raise typer.Exit(code=1) |
| 215 | |
| 216 | live.update(create_selection_panel(), refresh=True) |
| 217 | |
| 218 | except KeyboardInterrupt: |
| 219 | console.print("\n[yellow]Selection cancelled[/yellow]") |
| 220 | raise typer.Exit(code=1) |
| 221 | |
| 222 | run_selection_loop() |
| 223 |
no test coverage detected