Clean input with autocomplete - simple and reliable. Full terminal width, minimal design. Args: show_separator: Whether to show top separator (default True) Returns: User input string
(show_separator: bool = True)
| 121 | |
| 122 | |
| 123 | def get_modern_input(show_separator: bool = True) -> str: |
| 124 | """ |
| 125 | Clean input with autocomplete - simple and reliable. |
| 126 | Full terminal width, minimal design. |
| 127 | |
| 128 | Args: |
| 129 | show_separator: Whether to show top separator (default True) |
| 130 | |
| 131 | Returns: |
| 132 | User input string |
| 133 | """ |
| 134 | # Ensure cursor is visible |
| 135 | _ensure_cursor_visible() |
| 136 | _safe_flush() |
| 137 | |
| 138 | # If prompt_toolkit not available, use fallback |
| 139 | if not PROMPT_TOOLKIT_AVAILABLE: |
| 140 | return get_minimal_input() |
| 141 | |
| 142 | try: |
| 143 | terminal_width = _get_terminal_width() |
| 144 | separator = "─" * terminal_width |
| 145 | |
| 146 | # Clean style with NVIDIA green |
| 147 | style = Style.from_dict({ |
| 148 | # Autocomplete menu |
| 149 | 'completion-menu': 'bg:#2a2a2a #ffffff', |
| 150 | 'completion-menu.completion': 'bg:#2a2a2a #ffffff', |
| 151 | 'completion-menu.completion.current': 'bg:#76B900 #000000', |
| 152 | |
| 153 | # Input |
| 154 | '': '#ffffff', |
| 155 | }) |
| 156 | |
| 157 | # Key bindings for better error handling |
| 158 | bindings = KeyBindings() |
| 159 | |
| 160 | @bindings.add('c-c') |
| 161 | def _(event): |
| 162 | """Handle Ctrl+C gracefully.""" |
| 163 | event.app.exit(exception=KeyboardInterrupt()) |
| 164 | |
| 165 | @bindings.add('c-d') |
| 166 | def _(event): |
| 167 | """Handle Ctrl+D gracefully.""" |
| 168 | event.app.exit(exception=EOFError()) |
| 169 | |
| 170 | completer = CleanCommandCompleter() |
| 171 | |
| 172 | # Top separator (only if requested) |
| 173 | if show_separator: |
| 174 | try: |
| 175 | console.print(f"[dim]{separator}[/dim]") |
| 176 | except: |
| 177 | print("-" * terminal_width) |
| 178 | |
| 179 | # Ensure clean terminal state before prompt |
| 180 | _safe_flush() |
no test coverage detected