vim_page_interaction.go RawHistoryFolder
1package dto
2
3// VimPageInteractionKind identifies an in-page Vim Mode interaction such as
4// link hints, visual selection, or a one-shot text-object yank.
5type VimPageInteractionKind int
6
7const (
8 // VimPageHintFollow labels visible clickable elements and activates the chosen one.
9 VimPageHintFollow VimPageInteractionKind = iota + 1
10 // VimPageHintFollowNew labels visible links and opens the chosen one in a new pane.
11 VimPageHintFollowNew
12 // VimPageHintYankURL labels visible links and copies the chosen URL.
13 VimPageHintYankURL
14 // VimPageVisual starts the caret and visual selection flow: text-anchor
15 // hints, a caret that motions move, and charwise or linewise selections
16 // that y copies without leaving the caret.
17 VimPageVisual
18 // VimPageYankObject copies one structural text object immediately.
19 VimPageYankObject
20)
21
22// CapturesKeys reports whether the interaction consumes page keys until the
23// page reports its end. One-shot yanks complete without key capture.
24func (k VimPageInteractionKind) CapturesKeys() bool {
25 switch k {
26 case VimPageHintFollow, VimPageHintFollowNew, VimPageHintYankURL, VimPageVisual:
27 return true
28 default:
29 return false
30 }
31}
32
33// VimPageMode is the sub-mode a key-capturing page interaction reports as it
34// moves between states, so the UI can label it.
35type VimPageMode string
36
37const (
38 // VimPageModeHints is showing text-anchor hints to place the caret.
39 VimPageModeHints VimPageMode = "hints"
40 // VimPageModeCaret is moving a visible caret without selecting.
41 VimPageModeCaret VimPageMode = "caret"
42 // VimPageModeVisual is extending a charwise selection.
43 VimPageModeVisual VimPageMode = "visual"
44 // VimPageModeVisualLine is extending a linewise selection.
45 VimPageModeVisualLine VimPageMode = "visual-line"
46)
47
48// Valid reports whether the mode is one the page runtime may report.
49func (m VimPageMode) Valid() bool {
50 switch m {
51 case VimPageModeHints, VimPageModeCaret, VimPageModeVisual, VimPageModeVisualLine:
52 return true
53 default:
54 return false
55 }
56}
57
58// VimPageTextObject identifies the structural block copied by a text-object yank.
59type VimPageTextObject int
60
61const (
62 VimPageTextObjectSection VimPageTextObject = iota + 1
63 VimPageTextObjectParagraph
64 VimPageTextObjectCode
65 VimPageTextObjectTable
66 VimPageTextObjectList
67)
68
69// VimPageInteractionRequest describes one in-page Vim interaction.
70type VimPageInteractionRequest struct {
71 Kind VimPageInteractionKind
72 Object VimPageTextObject
73 HighlightColor string
74}
75
76// VimNavigationOutcome tells the UI how to continue after a Vim action.
77type VimNavigationOutcome struct {
78 // CapturePageKeys asks the UI to forward keys to the page interaction until
79 // the page reports that the interaction ended.
80 CapturePageKeys bool
81 // PageKind and PageMode name the key-capturing interaction and the
82 // sub-mode it starts in, so the UI labels it without knowing actions.
83 // Both are zero when CapturePageKeys is false.
84 PageKind VimPageInteractionKind
85 PageMode VimPageMode
86}