Skip to content

Context menus: right-click tabs, contextArea, drawContextMenu; v0.12.0 - #144

Merged
sh1pt-actions-fleet[bot] merged 1 commit into
mainfrom
feat/context-menu
Nov 2, 2026
Merged

sh1pt-actions-fleet[bot] merged 1 commit into
mainfrom
feat/context-menu

Conversation

@sh1pt-actions-fleet

Copy link
Copy Markdown
Contributor

Brings the readm3 tab right-click menu (profullstack/readm3#83) to hqtui as a reusable terminal widget.

API

  • widgets.drawContextMenu(root, { x, y, items, selected?, color?, minWidth?, shadow? }): ContextMenuLayout: rounded, themed like the palette, drop shadow, separators joined to the frame (├─┤), right-aligned muted hints, disabled and danger items. Clamped on screen: it slides left at the right edge and opens upward at the bottom.
  • contextMenuKey(items, selected, key), contextMenuStep, contextMenuLayout, MENU_SEPARATOR.
  • ui.tabs({ ..., onClose?, onCloseOthers?, onCloseAll?, menu? }): right-click opens "Close tab" / "Close all but this tab" / "Close all tabs", with any extra items (e.g. "Reload from disk") above a rule. Middle-click closes when onClose is set. Tabs without these keep the old behaviour.
  • ui.contextArea({ menu }, build): a right-click menu for any content. Left clicks pass through, and inner menus win.
  • ui.contextMenu({ ...options, onSelect, onClose, onChange? }): the same menu with state you own.
  • app.openContextMenu({ x, y, items }), app.closeContextMenu(), app.contextMenu: the app holds one open menu across frames (arrows, Enter, Esc, hover, click outside).
  • HitRegion.onContextMenu and HitRegion.overlay: a right press goes to the topmost region with a menu and stops at modal overlays.
  • renderToScreen(view, { contextMenu }) and screen.menu for tests.

Also

  • A modal with no focusable controls now gets the arrow keys through onKey. Before this, App swallowed them, which also broke arrow navigation in the emoji picker inside a real app.
  • Tab hit rects now follow align: "center" | "right".
  • Demo components screen: editor-style tabs that use the menu.
  • Docs: README and the overlays chapter of the book.
  • Version 0.12.0.

Tests: packages/hqtui/test/context-menu.test.ts (13 tests, including an end-to-end App run with SGR right and middle clicks plus arrows, Enter and Esc). The full suite passes: 515 tests, plus typecheck.

🤖 Generated with Claude Code

…ontextArea, drawContextMenu; v0.12.0

- widgets/context-menu.ts: drawContextMenu (items with hint, disabled,
  separator, danger), clamped inside the screen (slides left, opens upward),
  contextMenuLayout, contextMenuKey (up/down/home/end/enter/escape/letter),
  contextMenuStep, MENU_SEPARATOR.
- HitRegion.onContextMenu: a right press goes to the topmost region with a
  menu, stopping at modal overlays; a menu-only region is transparent to
  every other event.
- App keeps one open menu across frames: app.openContextMenu / closeContextMenu
  / contextMenu, ctx.openContextMenu for widgets.
- ui.contextMenu (state you own), ui.contextArea (menu for any content).
- ui.tabs: onClose (menu + middle-click), onCloseOthers, onCloseAll, menu
  extras (e.g. "Reload from disk"); tab hit rects now follow align.
- A modal with no focusable controls gets the arrow keys through onKey
  (this also un-swallows arrows in the emoji picker).
- renderToScreen: contextMenu option and screen.menu for tests.
- Demo components screen: editor tabs with the menu. README + book docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sh1pt-actions-fleet
sh1pt-actions-fleet Bot merged commit ecf3688 into main Nov 2, 2026
16 checks passed
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