Skip to content

feat: UI improvements, mouse support, and keybind fixes#10

Open
turnipy wants to merge 2 commits intoAdarsh-codesOP:mainfrom
turnipy:feature/report-improvements
Open

feat: UI improvements, mouse support, and keybind fixes#10
turnipy wants to merge 2 commits intoAdarsh-codesOP:mainfrom
turnipy:feature/report-improvements

Conversation

@turnipy
Copy link
Copy Markdown

@turnipy turnipy commented Mar 25, 2026

Summary

This PR adds several UI and usability improvements built on top of the current upstream codebase:

  • Top bar menu improvements: Underlined first letter of each menu label to indicate Alt shortcut keys, proper highlight styling (black text on theme background) for selected menu items
  • Mouse support: Click to focus panels (sidebar/editor/terminal), click menu labels to open/close menus, click dropdown items to execute actions, double-click sidebar entries to open files/toggle folders, click sidebar entries to select them (with border offset correction)
  • Selection fixes: Shift+Left/Right arrow now extends selection instead of clearing it, Ctrl+Shift+Left/Right for word-by-word selection, Ctrl(+Shift)+Home/End/PageUp/PageDown properly fall through to editor instead of being caught by global Ctrl handler
  • Keyboard enhancement protocol: Best-effort DISAMBIGUATE_ESCAPE_CODES support with graceful fallback for terminals that don't support it (e.g. COSMIC Terminal, kitty)
  • Help text updates: Added all new keybinds to help overlay including mouse actions, menu shortcuts, LSP commands (hover info, code actions), and tree-sitter structural editing commands
  • Event loop stability: Reverted to upstream event loop design for reliable key repeat behavior

Changes by file

File Changes
src/app.rs Added last_click field for double-click detection timing
src/config.rs Updated HELP_TEXT with mouse, menu, and LSP keybind sections
src/events/mod.rs Added ctrl_nav_to_editor guard, fixed selection on Left/Right, added Ctrl+Shift word selection, sidebar click offset fix, double-click handling
src/main.rs Best-effort keyboard enhancement protocol, clean upstream event loop
src/ui/top_bar.rs Styled menu labels with underlined first letter, fixed highlight_style, fixed startup selection bug, menu position tracking for mouse clicks
src/ui/mod.rs Store sidebar area during render for mouse hit detection

Test plan

  • Open Klein and verify no menu is selected on startup
  • Click each menu label — verify it opens the correct dropdown with readable (black) text
  • Click sidebar files/folders — verify correct item is selected (not off by one)
  • Double-click sidebar folder to toggle, double-click file to open in editor
  • Test Shift+Arrow selection in editor (all directions)
  • Test Ctrl+Home/End to jump to file start/end
  • Test Ctrl+Shift+Left/Right for word selection
  • Press Ctrl+H to open help — verify new keybind sections are present
  • Test in terminals with and without keyboard enhancement support

This is a follow-up to the discussion in issue #8, rebuilt from scratch on top of the current upstream codebase.

🤖 Generated with Claude Code

turnipy and others added 2 commits March 25, 2026 18:37
… optimization

## Top Bar Menu
- Underline first letter of each menu item to indicate Alt+letter shortcut
- Selected menu item now shows black text on highlighted background
- Fixed: Navigation menu no longer appears selected on startup

## Mouse Support
- Click top bar menu labels to open/close dropdown menus
- Click dropdown items to execute actions
- Click in sidebar, editor, or terminal to switch panel focus
- Click in sidebar selects the clicked file entry
- Click outside an open menu closes it

## Selection Fixes
- Shift+Left/Right now extends selection character by character
- Ctrl+Shift+Left/Right extends selection word by word
- Ctrl+Shift+Home/End selects from cursor to start/end of document
- Ctrl+Home/End fixed (was silently consumed by global Ctrl handler)
- Ctrl+Shift+PageUp/PageDown now selects by page
- Ctrl+PageUp/PageDown fixed for page navigation in editor

## Event Loop Optimization
- Restructured event loop: process all pending events before drawing
- Filter key Release events at source to prevent unnecessary wakeups
- Single draw per event batch instead of per-event, improving responsiveness
- Removed 8ms sleep between frames

## Keyboard Enhancement
- Enable crossterm DISAMBIGUATE_ESCAPE_CODES for terminals that support it
- Best-effort: gracefully degrades on terminals without support
- Improves Ctrl+Shift modifier detection in Ghostty, ptyxis, etc.

## Sidebar Area Tracking
- Store sidebar render area for mouse click detection

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…icks, and update help text

- Revert event loop back to original upstream design (remove Release event
  filtering and process_event refactor that caused Shift+arrow lag)
- Fix menu highlight_style to match selected style (black text on theme bg)
  so selected menu labels are readable
- Fix Theme menu being selected on startup by removing .min(7) clamp
- Fix sidebar click offset (account for border +1)
- Add double-click support for sidebar (open file / toggle folder)
- Update HELP_TEXT with all new keybinds (mouse, menus, tree-sitter, LSP)
- Best-effort keyboard enhancement protocol (graceful fallback for
  terminals that don't support it)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant