-
Notifications
You must be signed in to change notification settings - Fork 42
🎨 Palette: [UX improvement] Improve TUI Accessibility and Keyboard Navigation #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 2024-06-09 - Terminal UI Escape and Interrupt Handling | ||
| **Learning:** Raw terminal UI elements map specific standard interrupt bytes (like `\x03` for Ctrl-C and `\x04` for Ctrl-D) natively. For custom raw interaction loops, these must be explicitly handled. Additionally, rich styling uses brackets as markup, so if you inject options manually into a string for `Prompt.ask` (e.g. `title \[{options}]`) to avoid strict case-sensitive choices, you must escape the brackets to avoid styling issues. Furthermore, shortcut hints like "Esc/Ctrl-C to cancel" should be visible to avoid keyboard traps. | ||
| **Action:** Next time, ensure keyboard interrupts map correctly to exit actions in raw mode, and include clear shortcut hints to make the interface more accessible. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -67,7 +67,7 @@ def _render_selector(self, title, options, selected_index, help_text, default): | |||||
| style = 'bold green' if index == selected_index else '' | ||||||
| table.add_row(marker, label, style=style) | ||||||
|
|
||||||
| footer = help_text or 'Use Up/Down arrows and Enter to select.' | ||||||
| footer = help_text or 'Use Up/Down arrows and Enter to select. Esc/Ctrl-C to cancel.' | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update the cancel hint to include Ctrl-D. The selector now cancels on Suggested fix- footer = help_text or 'Use Up/Down arrows and Enter to select. Esc/Ctrl-C to cancel.'
+ footer = help_text or 'Use Up/Down arrows and Enter to select. Esc/Ctrl-C/Ctrl-D to cancel.'📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| self.console.print(Panel.fit(footer, title='Interpreter TUI', border_style='green')) | ||||||
| self.console.print(f"[bold cyan]{title}[/bold cyan]") | ||||||
| self.console.print(table) | ||||||
|
|
@@ -76,7 +76,7 @@ def _render_selector(self, title, options, selected_index, help_text, default): | |||||
| def _select_option(self, title, options, default, help_text=None): | ||||||
| if not sys.stdin.isatty(): | ||||||
| default_choice = default if default in options else options[0] | ||||||
| answer = Prompt.ask(f"{title}", default=default_choice).strip() | ||||||
| answer = Prompt.ask(f"{title} \\[{'|'.join(options)}]", default=default_choice).strip() | ||||||
| if answer in options: | ||||||
| return answer | ||||||
| for option in options: | ||||||
|
|
@@ -99,7 +99,7 @@ def _select_option(self, title, options, default, help_text=None): | |||||
| selected_index = (selected_index + 1) % len(options) | ||||||
| elif key == 'enter': | ||||||
| return options[selected_index] | ||||||
| elif key == 'escape': | ||||||
| elif key in ('escape', '\x03', '\x04'): | ||||||
| raise KeyboardInterrupt('Selection cancelled by user.') | ||||||
| elif isinstance(key, str) and len(key) == 1: | ||||||
| lowered = key.lower() | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the entry date to match this PR’s timeline.
The heading uses
2024-06-09, but this change set is from June 2026. Keeping dates accurate is important for learning-history traceability.🤖 Prompt for AI Agents