proto_convert_picker.go RawHistoryFolder

1package sessionwire
2
3import (
4	"github.com/bnema/vev/internal/protocol"
5	"github.com/bnema/vev/internal/protocol/wire"
6)
7
8func pickerOfferToWire(message protocol.PickerOffer) (*wire.PickerOffer, error) {
9	if err := protocol.ValidatePickerOffer(message); err != nil {
10		return nil, err
11	}
12	return &wire.PickerOffer{
13		InteractionId: message.InteractionID,
14		RequestId:     message.RequestID,
15		Intent:        uint32(message.Intent),
16		MoveSourceKey: message.MoveSourceKey,
17		BarrierEpoch:  message.BarrierEpoch,
18		BarrierState:  message.BarrierState,
19		SizeEpoch:     message.SizeEpoch,
20		Title:         message.Title,
21	}, nil
22}
23
24func pickerOfferFromWire(message *wire.PickerOffer) (protocol.PickerOffer, error) {
25	if message == nil {
26		return protocol.PickerOffer{}, protocol.ErrInvalidNavigation
27	}
28	intent, err := enum8[protocol.PickerIntent](message.GetIntent())
29	if err != nil {
30		return protocol.PickerOffer{}, err
31	}
32	offer := protocol.PickerOffer{
33		InteractionID: message.GetInteractionId(),
34		RequestID:     message.GetRequestId(),
35		Intent:        intent,
36		MoveSourceKey: message.GetMoveSourceKey(),
37		BarrierEpoch:  message.GetBarrierEpoch(),
38		BarrierState:  message.GetBarrierState(),
39		SizeEpoch:     message.GetSizeEpoch(),
40		Title:         message.GetTitle(),
41	}
42	if err := protocol.ValidatePickerOffer(offer); err != nil {
43		return protocol.PickerOffer{}, err
44	}
45	return offer, nil
46}
47
48func pickerCloseToWire(message protocol.PickerClose) (*wire.PickerClose, error) {
49	if err := protocol.ValidatePickerClose(message); err != nil {
50		return nil, err
51	}
52	return &wire.PickerClose{InteractionId: message.InteractionID, RequestId: message.RequestID}, nil
53}
54
55func pickerCloseFromWire(message *wire.PickerClose) (protocol.PickerClose, error) {
56	if message == nil {
57		return protocol.PickerClose{}, protocol.ErrInvalidNavigation
58	}
59	closed := protocol.PickerClose{InteractionID: message.GetInteractionId(), RequestID: message.GetRequestId()}
60	if err := protocol.ValidatePickerClose(closed); err != nil {
61		return protocol.PickerClose{}, err
62	}
63	return closed, nil
64}
65
66func pickerClosedToWire(message protocol.PickerClosed) (*wire.PickerClosed, error) {
67	if err := protocol.ValidatePickerClosed(message); err != nil {
68		return nil, err
69	}
70	return &wire.PickerClosed{InteractionId: message.InteractionID, BarrierEpoch: message.BarrierEpoch, BarrierState: message.BarrierState}, nil
71}
72
73func pickerClosedFromWire(message *wire.PickerClosed) (protocol.PickerClosed, error) {
74	if message == nil {
75		return protocol.PickerClosed{}, protocol.ErrInvalidNavigation
76	}
77	closed := protocol.PickerClosed{InteractionID: message.GetInteractionId(), BarrierEpoch: message.GetBarrierEpoch(), BarrierState: message.GetBarrierState()}
78	if err := protocol.ValidatePickerClosed(closed); err != nil {
79		return protocol.PickerClosed{}, err
80	}
81	return closed, nil
82}
83
84func pickerSelectionToWire(message protocol.PickerSelection) (*wire.PickerSelection, error) {
85	if err := protocol.ValidatePickerSelection(message); err != nil {
86		return nil, err
87	}
88	return &wire.PickerSelection{
89		CauseActionId:  message.CauseActionID,
90		RequestId:      message.RequestID,
91		InteractionId:  message.InteractionID,
92		SourceId:       message.SourceID,
93		SourceRevision: message.SourceRevision,
94		Key:            message.Key,
95		Action:         uint32(message.Action),
96	}, nil
97}
98
99func pickerSelectionFromWire(message *wire.PickerSelection) (protocol.PickerSelection, error) {
100	if message == nil {
101		return protocol.PickerSelection{}, protocol.ErrInvalidNavigation
102	}
103	action, err := enum8[protocol.PickerAction](message.GetAction())
104	if err != nil {
105		return protocol.PickerSelection{}, err
106	}
107	selection := protocol.PickerSelection{
108		CauseActionID:  message.GetCauseActionId(),
109		RequestID:      message.GetRequestId(),
110		InteractionID:  message.GetInteractionId(),
111		SourceID:       message.GetSourceId(),
112		SourceRevision: message.GetSourceRevision(),
113		Key:            message.GetKey(),
114		Action:         action,
115	}
116	if err := protocol.ValidatePickerSelection(selection); err != nil {
117		return protocol.PickerSelection{}, err
118	}
119	return selection, nil
120}
121
122func pickerResultToWire(message protocol.PickerResult) (*wire.PickerResult, error) {
123	if err := protocol.ValidatePickerResult(message); err != nil {
124		return nil, err
125	}
126	return &wire.PickerResult{
127		CauseActionId: message.CauseActionID,
128		RequestId:     message.RequestID,
129		InteractionId: message.InteractionID,
130		SourceId:      message.SourceID,
131		Key:           message.Key,
132		Action:        uint32(message.Action),
133	}, nil
134}
135
136func pickerResultFromWire(message *wire.PickerResult) (protocol.PickerResult, error) {
137	if message == nil {
138		return protocol.PickerResult{}, protocol.ErrInvalidNavigation
139	}
140	action, err := enum8[protocol.PickerAction](message.GetAction())
141	if err != nil {
142		return protocol.PickerResult{}, err
143	}
144	result := protocol.PickerResult{
145		CauseActionID: message.GetCauseActionId(),
146		RequestID:     message.GetRequestId(),
147		InteractionID: message.GetInteractionId(),
148		SourceID:      message.GetSourceId(),
149		Key:           message.GetKey(),
150		Action:        action,
151	}
152	if err := protocol.ValidatePickerResult(result); err != nil {
153		return protocol.PickerResult{}, err
154	}
155	return result, nil
156}
157
158func pickerFailureToWire(message protocol.PickerFailure) (*wire.PickerFailure, error) {
159	if err := protocol.ValidatePickerFailure(message); err != nil {
160		return nil, err
161	}
162	return &wire.PickerFailure{
163		CauseActionId: message.CauseActionID,
164		RequestId:     message.RequestID,
165		InteractionId: message.InteractionID,
166		SourceId:      message.SourceID,
167		Key:           message.Key,
168		Action:        uint32(message.Action),
169		Code:          uint32(message.Code),
170	}, nil
171}
172
173func pickerFailureFromWire(message *wire.PickerFailure) (protocol.PickerFailure, error) {
174	if message == nil {
175		return protocol.PickerFailure{}, protocol.ErrInvalidNavigation
176	}
177	action, err := enum8[protocol.PickerAction](message.GetAction())
178	if err != nil {
179		return protocol.PickerFailure{}, err
180	}
181	code, err := enum8[protocol.PickerFailureCode](message.GetCode())
182	if err != nil {
183		return protocol.PickerFailure{}, err
184	}
185	failure := protocol.PickerFailure{
186		CauseActionID: message.GetCauseActionId(),
187		RequestID:     message.GetRequestId(),
188		InteractionID: message.GetInteractionId(),
189		SourceID:      message.GetSourceId(),
190		Key:           message.GetKey(),
191		Action:        action,
192		Code:          code,
193	}
194	if err := protocol.ValidatePickerFailure(failure); err != nil {
195		return protocol.PickerFailure{}, err
196	}
197	return failure, nil
198}

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 12

Tags 11

↑↓ moveenter openesc close