main 6af0a61

kernel.go RawHistoryFolder

1package models
2
3import "github.com/bnema/archup/internal/domain/packages"
4
5// KernelOption represents a selectable kernel option.
6type KernelOption struct {
7	Variant     packages.KernelVariant
8	Package     string
9	Description string
10	Recommended bool
11}
12
13// KernelModelImpl holds kernel selection state.
14type KernelModelImpl struct {
15	options  []KernelOption
16	selected int
17}
18
19// NewKernelModel creates a new kernel selection model.
20func NewKernelModel() *KernelModelImpl {
21	options := []KernelOption{
22		{
23			Variant:     packages.KernelStable,
24			Package:     packages.KernelStable.String(),
25			Description: "Stable mainline kernel",
26			Recommended: true,
27		},
28		{
29			Variant:     packages.KernelLTS,
30			Package:     packages.KernelLTS.String(),
31			Description: "Long-term support (maximum stability)",
32		},
33		{
34			Variant:     packages.KernelZen,
35			Package:     packages.KernelZen.String(),
36			Description: "Performance-optimized for general use",
37		},
38		{
39			Variant:     packages.KernelHardened,
40			Package:     packages.KernelHardened.String(),
41			Description: "Security-focused kernel",
42		},
43		{
44			Variant:     packages.KernelCachyOS,
45			Package:     packages.KernelCachyOS.String(),
46			Description: "Gaming-optimized",
47		},
48	}
49
50	selected := 0
51	for i, option := range options {
52		if option.Recommended {
53			selected = i
54			break
55		}
56	}
57
58	return &KernelModelImpl{
59		options:  options,
60		selected: selected,
61	}
62}
63
64// Options returns the selectable kernel options.
65func (km *KernelModelImpl) Options() []KernelOption {
66	return km.options
67}
68
69// SelectedIndex returns the current selection index.
70func (km *KernelModelImpl) SelectedIndex() int {
71	return km.selected
72}
73
74// SelectedOption returns the currently selected kernel option.
75func (km *KernelModelImpl) SelectedOption() KernelOption {
76	if len(km.options) == 0 {
77		return KernelOption{}
78	}
79	if km.selected < 0 || km.selected >= len(km.options) {
80		return km.options[0]
81	}
82	return km.options[km.selected]
83}
84
85// MoveUp moves selection up.
86func (km *KernelModelImpl) MoveUp() {
87	if len(km.options) == 0 {
88		return
89	}
90	if km.selected == 0 {
91		km.selected = len(km.options) - 1
92		return
93	}
94	km.selected--
95}
96
97// MoveDown moves selection down.
98func (km *KernelModelImpl) MoveDown() {
99	if len(km.options) == 0 {
100		return
101	}
102	km.selected = (km.selected + 1) % len(km.options)
103}
104
105// SetSelectedPackage selects a kernel by package name.
106func (km *KernelModelImpl) SetSelectedPackage(pkg string) {
107	if pkg == "" {
108		return
109	}
110	for i, option := range km.options {
111		if option.Package == pkg {
112			km.selected = i
113			return
114		}
115	}
116}

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