context_menu.go RawHistoryFolder

1package port
2
3import "context"
4
5// MenuAction identifies a normalized context menu action.
6type MenuAction string
7
8const (
9	MenuActionBack           MenuAction = "back"
10	MenuActionForward        MenuAction = "forward"
11	MenuActionReload         MenuAction = "reload"
12	MenuActionOpenLinkNewTab MenuAction = "open_link_new_tab"
13	MenuActionCopyLink       MenuAction = "copy_link"
14	MenuActionCopyImage      MenuAction = "copy_image"
15	MenuActionSaveImage      MenuAction = "save_image"
16	MenuActionInspectElement MenuAction = "inspect_element"
17	MenuActionCopySelection  MenuAction = "copy_selection"
18)
19
20// MenuContext captures the state needed to build and execute a context menu.
21type MenuContext struct {
22	PageURI       string
23	LinkURI       string
24	ImageURI      string
25	SelectionText string
26	HasSelection  bool
27	IsEditable    bool
28	CanGoBack     bool
29	CanGoForward  bool
30	X             int
31	Y             int
32}
33
34// MenuItem is a normalized context menu entry.
35type MenuItem struct {
36	Action MenuAction
37	Label  string
38}
39
40// ContextMenuBuilder builds normalized menu items from menu state.
41type ContextMenuBuilder interface {
42	Build(ctx context.Context, menuContext MenuContext) []MenuItem
43}
44
45// ContextMenuActionExecutor executes normalized context menu actions.
46type ContextMenuActionExecutor interface {
47	ExecuteMenuAction(ctx context.Context, action MenuAction, menuContext MenuContext) error
48}
49
50// ContextMenuActionExecutorFactory creates context menu action executors.
51type ContextMenuActionExecutorFactory interface {
52	NewContextMenuActionExecutor(
53		clipboard Clipboard,
54		resolver ImageDataResolver,
55		saver ResolvedImageSaver,
56		delegator MenuActionDelegator,
57	) ContextMenuActionExecutor
58}
59
60// MenuActionDelegator handles actions that are not shared application concerns.
61type MenuActionDelegator interface {
62	DelegateMenuAction(ctx context.Context, action MenuAction, menuContext MenuContext) error
63}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close