main 5041353

spinner.go RawHistoryFolder

1package styles
2
3import (
4	"github.com/charmbracelet/bubbles/spinner"
5	"github.com/charmbracelet/lipgloss"
6)
7
8// SpinnerType defines available spinner styles.
9type SpinnerType int
10
11const (
12	SpinnerDots SpinnerType = iota
13	SpinnerLine
14	SpinnerMiniDot
15	SpinnerJump
16	SpinnerPulse
17	SpinnerPoints
18	SpinnerGlobe
19	SpinnerMoon
20	SpinnerMonkey
21)
22
23// NewStyledSpinner creates a themed spinner.
24func NewStyledSpinner(theme *Theme, spinnerType SpinnerType) spinner.Model {
25	s := spinner.New()
26	s.Style = lipgloss.NewStyle().Foreground(theme.Accent)
27
28	switch spinnerType {
29	case SpinnerDots:
30		s.Spinner = spinner.Dot
31	case SpinnerLine:
32		s.Spinner = spinner.Line
33	case SpinnerMiniDot:
34		s.Spinner = spinner.MiniDot
35	case SpinnerJump:
36		s.Spinner = spinner.Jump
37	case SpinnerPulse:
38		s.Spinner = spinner.Pulse
39	case SpinnerPoints:
40		s.Spinner = spinner.Points
41	case SpinnerGlobe:
42		s.Spinner = spinner.Globe
43	case SpinnerMoon:
44		s.Spinner = spinner.Moon
45	case SpinnerMonkey:
46		s.Spinner = spinner.Monkey
47	default:
48		s.Spinner = spinner.Dot
49	}
50
51	return s
52}
53
54// NewDefaultSpinner creates the default themed spinner.
55func NewDefaultSpinner(theme *Theme) spinner.Model {
56	return NewStyledSpinner(theme, SpinnerDots)
57}
58
59// LoadingModel wraps a spinner with a message.
60type LoadingModel struct {
61	Spinner spinner.Model
62	Message string
63	theme   *Theme
64}
65
66// NewLoading creates a loading indicator with message.
67func NewLoading(theme *Theme, message string) LoadingModel {
68	return LoadingModel{
69		Spinner: NewDefaultSpinner(theme),
70		Message: message,
71		theme:   theme,
72	}
73}
74
75// View renders the loading indicator.
76func (m LoadingModel) View() string {
77	return lipgloss.JoinHorizontal(
78		lipgloss.Center,
79		m.Spinner.View(),
80		" ",
81		m.theme.Subtle.Render(m.Message),
82	)
83}

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