@kitlangton/ghui 0.1.22 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/src/App.tsx +381 -357
- package/src/appCommands.ts +16 -4
- package/src/domain.ts +11 -0
- package/src/index.tsx +1 -7
- package/src/keyboard/opentuiAdapter.ts +43 -0
- package/src/keymap/all.ts +103 -0
- package/src/keymap/closeModal.ts +13 -0
- package/src/keymap/commandPalette.ts +16 -0
- package/src/keymap/commentModal.ts +73 -0
- package/src/keymap/commentThreadModal.ts +24 -0
- package/src/keymap/detailView.ts +30 -0
- package/src/keymap/diffView.ts +91 -0
- package/src/keymap/filterMode.ts +13 -0
- package/src/keymap/helpers.ts +24 -0
- package/src/keymap/labelModal.ts +16 -0
- package/src/keymap/listNav.ts +119 -0
- package/src/keymap/mergeModal.ts +23 -0
- package/src/keymap/openRepositoryModal.ts +13 -0
- package/src/keymap/themeModal.ts +49 -0
- package/src/mergeActions.ts +4 -1
- package/src/services/GitHubService.ts +41 -6
- package/src/services/MockGitHubService.ts +37 -2
- package/src/themeStore.ts +28 -11
- package/src/ui/CommandPalette.tsx +115 -65
- package/src/ui/DetailsPane.tsx +152 -32
- package/src/ui/LoadingLogo.tsx +75 -0
- package/src/ui/PullRequestDiffPane.tsx +19 -17
- package/src/ui/comments.tsx +143 -0
- package/src/ui/diff.ts +194 -8
- package/src/ui/modals.tsx +4 -39
- package/src/ui/primitives.tsx +5 -1
- package/src/ui/singleLineInput.ts +2 -1
- package/src/ui/spinner.ts +1 -0
- package/src/keyboard/createKeymap.ts +0 -25
- package/src/keyboard/useAppCommandRegistry.ts +0 -30
- package/src/keyboard/useScopedBindings.ts +0 -66
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { useBindings } from "@opentui/keymap/react"
|
|
2
|
-
import { useRef } from "react"
|
|
3
|
-
|
|
4
|
-
export type ScopedBindingAction = (() => void) | string
|
|
5
|
-
|
|
6
|
-
export interface ScopedBindingsOptions {
|
|
7
|
-
readonly when: boolean
|
|
8
|
-
readonly bindings: Readonly<Record<string, ScopedBindingAction>>
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Wraps `@opentui/keymap/react`'s `useBindings` so callers don't have to write
|
|
13
|
-
* the ref dance themselves. The layer registers exactly once (deps=[]); the
|
|
14
|
-
* `when` flag and the action callbacks read latest values via refs, so the
|
|
15
|
-
* binding-shape is captured at first render but closures stay fresh.
|
|
16
|
-
*
|
|
17
|
-
* Don't change which keys you bind across renders — only what they do.
|
|
18
|
-
*/
|
|
19
|
-
export const useScopedBindings = ({ when, bindings }: ScopedBindingsOptions): void => {
|
|
20
|
-
const activeRef = useRef(false)
|
|
21
|
-
activeRef.current = when
|
|
22
|
-
|
|
23
|
-
const actionsRef = useRef(bindings)
|
|
24
|
-
actionsRef.current = bindings
|
|
25
|
-
|
|
26
|
-
useBindings(() => ({
|
|
27
|
-
enabled: () => activeRef.current,
|
|
28
|
-
bindings: Object.entries(bindings).map(([key, action]) => ({
|
|
29
|
-
key,
|
|
30
|
-
cmd: typeof action === "string" ? action : () => {
|
|
31
|
-
const current = actionsRef.current[key]
|
|
32
|
-
if (typeof current === "function") current()
|
|
33
|
-
},
|
|
34
|
-
})),
|
|
35
|
-
}), [])
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Vim-style scroll bindings: j/k/up/down for line scroll, ctrl-u/d/v + pageup/down
|
|
40
|
-
* for half-page scroll. When `scrollTo` is given, also adds home/end and gg/G to
|
|
41
|
-
* jump to start/end.
|
|
42
|
-
*/
|
|
43
|
-
export const scrollBindings = (
|
|
44
|
-
scrollBy: (delta: number) => void,
|
|
45
|
-
halfPage: number,
|
|
46
|
-
scrollTo?: (y: number) => void,
|
|
47
|
-
): Record<string, ScopedBindingAction> => {
|
|
48
|
-
const bindings: Record<string, ScopedBindingAction> = {
|
|
49
|
-
up: () => scrollBy(-1),
|
|
50
|
-
k: () => scrollBy(-1),
|
|
51
|
-
down: () => scrollBy(1),
|
|
52
|
-
j: () => scrollBy(1),
|
|
53
|
-
pageup: () => scrollBy(-halfPage),
|
|
54
|
-
pagedown: () => scrollBy(halfPage),
|
|
55
|
-
"ctrl+u": () => scrollBy(-halfPage),
|
|
56
|
-
"ctrl+d": () => scrollBy(halfPage),
|
|
57
|
-
"ctrl+v": () => scrollBy(halfPage),
|
|
58
|
-
}
|
|
59
|
-
if (scrollTo) {
|
|
60
|
-
bindings.home = () => scrollTo(0)
|
|
61
|
-
bindings.end = () => scrollTo(Number.MAX_SAFE_INTEGER)
|
|
62
|
-
bindings["g g"] = () => scrollTo(0)
|
|
63
|
-
bindings["shift+g"] = () => scrollTo(Number.MAX_SAFE_INTEGER)
|
|
64
|
-
}
|
|
65
|
-
return bindings
|
|
66
|
-
}
|