Add mouse support across the TUI
Drag to select copies on release. Request cards, the queue, attachments, the PR view and the key hints get clickable buttons. Prompts, folds, commands and diff files respond to clicks; prompts, replies, commands and the PR view get right-click menus. Clicking a pane focuses it, the wheel scrolls the thread list and palette, rows highlight under the pointer, and the thread list's border drags to resize.
This commit is contained in:
1 parent
fbdfb5c3e0
commit
12e1e0ba7a
27 files changed
+639
-116
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import type { MouseEvent } from "@opentui/core";
|
||||
|
||||
import { hintKey, type HintKey } from "../model/hints.ts";
|
||||
import { isLeftClick, useHover } from "./Button.tsx";
|
||||
import { colors } from "./theme.ts";
|
||||
|
||||
/** The key hints along the bottom; each one that names a single key presses it when clicked. */
|
||||
export function HintBar(props: { readonly text: string; readonly mode: string; readonly onPress: (key: HintKey) => void }) {
|
||||
const parts = props.text.split(" · ");
|
||||
return (
|
||||
<box flexDirection="row" overflow="hidden">
|
||||
{parts.map((part, index) => (
|
||||
<Hint key={`${index}:${part}`} text={part} separator={index > 0} hintKey={hintKey(part, props.mode)} onPress={props.onPress} />
|
||||
))}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
function Hint(props: { readonly text: string; readonly separator: boolean; readonly hintKey: HintKey | null; readonly onPress: (key: HintKey) => void }) {
|
||||
const [hover, hoverProps] = useHover();
|
||||
const key = props.hintKey;
|
||||
return (
|
||||
<box flexDirection="row" flexShrink={0}>
|
||||
{props.separator ? <text fg={colors.faint} selectable={false}>{" · "}</text> : null}
|
||||
<text
|
||||
fg={key && hover ? colors.text : colors.faint}
|
||||
selectable={false}
|
||||
{...(key ? { ...hoverProps, onMouseDown: (event: MouseEvent) => isLeftClick(event) && props.onPress(key) } : {})}
|
||||
>
|
||||
{props.text}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user