Beautiful boxed input with full borders. Uses full terminal width dynamically. Returns: User input string
()
| 282 | |
| 283 | |
| 284 | def get_boxed_input() -> str: |
| 285 | """ |
| 286 | Beautiful boxed input with full borders. |
| 287 | Uses full terminal width dynamically. |
| 288 | |
| 289 | Returns: |
| 290 | User input string |
| 291 | """ |
| 292 | # Ensure cursor is visible |
| 293 | _ensure_cursor_visible() |
| 294 | _safe_flush() |
| 295 | |
| 296 | try: |
| 297 | terminal_width = _get_terminal_width() |
| 298 | box_width = terminal_width - 4 # Account for margins |
| 299 | |
| 300 | # Print top of box |
| 301 | try: |
| 302 | console.print() |
| 303 | console.print(f" [green]╭{'─' * box_width}╮[/green]") |
| 304 | console.print(f" [green]│[/green] ", end="") |
| 305 | except: |
| 306 | print() |
| 307 | print(" +" + "-" * box_width + "+") |
| 308 | sys.stdout.write(" | ") |
| 309 | |
| 310 | _safe_flush() |
| 311 | |
| 312 | # Get input |
| 313 | try: |
| 314 | user_input = input() |
| 315 | |
| 316 | # Close the box |
| 317 | try: |
| 318 | console.print(f" [green]╰{'─' * box_width}╯[/green]") |
| 319 | console.print() |
| 320 | except: |
| 321 | print(" +" + "-" * box_width + "+") |
| 322 | print() |
| 323 | |
| 324 | return user_input.strip() |
| 325 | |
| 326 | except (EOFError, KeyboardInterrupt): |
| 327 | # Close box before raising |
| 328 | try: |
| 329 | console.print(f" [green]╰{'─' * box_width}╯[/green]") |
| 330 | console.print() |
| 331 | except: |
| 332 | print(" +" + "-" * box_width + "+") |
| 333 | print() |
| 334 | raise |
| 335 | |
| 336 | except Exception: |
| 337 | # Fallback to minimal input |
| 338 | return get_minimal_input() |
| 339 | |
| 340 | |
| 341 | def get_confirmation(message: str, default: bool = False) -> bool: |
nothing calls this directly
no test coverage detected