main 6af0a61

encryption.go RawHistoryFolder

1package models
2
3// EncryptionOption represents a selectable encryption option.
4type EncryptionOption struct {
5	Value       string
6	Label       string
7	Description string
8	Recommended bool
9}
10
11// EncryptionModelImpl holds encryption selection state.
12type EncryptionModelImpl struct {
13	options  []EncryptionOption
14	selected int
15}
16
17// NewEncryptionModel creates a new encryption selection model.
18func NewEncryptionModel() *EncryptionModelImpl {
19	options := []EncryptionOption{
20		{Value: "luks", Label: "LUKS2", Description: "Full disk encryption (recommended)", Recommended: true},
21		{Value: "none", Label: "None", Description: "No encryption"},
22	}
23	selected := 0
24	for i, o := range options {
25		if o.Recommended {
26			selected = i
27			break
28		}
29	}
30	return &EncryptionModelImpl{options: options, selected: selected}
31}
32
33// Options returns the selectable encryption options.
34func (em *EncryptionModelImpl) Options() []EncryptionOption { return em.options }
35
36// SelectedIndex returns the current selection index.
37func (em *EncryptionModelImpl) SelectedIndex() int { return em.selected }
38
39// SelectedOption returns the currently selected option.
40func (em *EncryptionModelImpl) SelectedOption() EncryptionOption {
41	if len(em.options) == 0 {
42		return EncryptionOption{}
43	}
44	if em.selected < 0 || em.selected >= len(em.options) {
45		return em.options[0]
46	}
47	return em.options[em.selected]
48}
49
50// MoveUp moves selection up (wraps).
51func (em *EncryptionModelImpl) MoveUp() {
52	if len(em.options) == 0 {
53		return
54	}
55	if em.selected == 0 {
56		em.selected = len(em.options) - 1
57		return
58	}
59	em.selected--
60}
61
62// MoveDown moves selection down (wraps).
63func (em *EncryptionModelImpl) MoveDown() {
64	if len(em.options) == 0 {
65		return
66	}
67	em.selected = (em.selected + 1) % len(em.options)
68}
69
70// SetSelectedValue selects an option by value string.
71func (em *EncryptionModelImpl) SetSelectedValue(v string) {
72	for i, o := range em.options {
73		if o.Value == v {
74			em.selected = i
75			return
76		}
77	}
78}

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 1

Tags 0

    ↑↓ moveenter openesc close