Repository navigation
Context menus: right-click tabs, contextArea, drawContextMenu; v0.12.0 - #144
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 anddangeritems. 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 whenonCloseis 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.onContextMenuandHitRegion.overlay: a right press goes to the topmost region with a menu and stops at modal overlays.renderToScreen(view, { contextMenu })andscreen.menufor tests.Also
onKey. Before this,Appswallowed them, which also broke arrow navigation in the emoji picker inside a real app.align: "center" | "right".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