v0.33.1 9577fee

mode_toaster_fake_test.go RawHistoryFolder

1package ui
2
3import (
4	"github.com/bnema/puregotk/v4/glib"
5
6	"github.com/bnema/dumber/internal/ui/input"
7)
8
9// fakeModeToasterView records what the mode toaster asks its view to paint.
10type fakeModeToasterView struct {
11	header      string
12	headers     []string // every distinct header, in order
13	mode        input.Mode
14	chevron     chevronState
15	pillShown   bool
16	interactive bool
17	bodyShown   bool
18	lingering   bool
19	animations  bool
20	style       string
21	groups      []legendGroup
22	dimmed      map[string]bool
23	flashed     map[string]bool
24	flashable   map[string]bool
25	rect        func() (int, int, int, int, bool)
26	destroyed   bool
27}
28
29func newFakeModeToasterView() *fakeModeToasterView {
30	return &fakeModeToasterView{dimmed: map[string]bool{}, flashed: map[string]bool{}, flashable: map[string]bool{}}
31}
32
33func (f *fakeModeToasterView) setHeader(text string) {
34	if text != f.header {
35		f.headers = append(f.headers, text)
36	}
37	f.header = text
38}
39func (f *fakeModeToasterView) setMode(mode input.Mode)          { f.mode = mode }
40func (f *fakeModeToasterView) setChevron(c chevronState)        { f.chevron = c }
41func (f *fakeModeToasterView) setPillVisible(v bool)            { f.pillShown = v }
42func (f *fakeModeToasterView) setPillInteractive(v bool)        { f.interactive = v }
43func (f *fakeModeToasterView) setStyle(style string)            { f.style = style }
44func (f *fakeModeToasterView) setAnimations(v bool)             { f.animations = v }
45func (f *fakeModeToasterView) setBodyVisible(v bool)            { f.bodyShown = v }
46func (f *fakeModeToasterView) setBodyLingering(v bool)          { f.lingering = v }
47func (f *fakeModeToasterView) setActionDimmed(a string, d bool) { f.dimmed[a] = d }
48func (f *fakeModeToasterView) clearFlash()                      { f.flashed = map[string]bool{} }
49func (f *fakeModeToasterView) destroy()                         { f.destroyed = true }
50func (f *fakeModeToasterView) setLegend(groups []legendGroup) {
51	f.groups = groups
52	f.dimmed = map[string]bool{} // new rows start undimmed
53	f.flashable = map[string]bool{}
54	for _, group := range groups {
55		for _, row := range group.Rows {
56			f.flashable[row.Action] = true
57		}
58	}
59}
60
61func (f *fakeModeToasterView) flashAction(action string) bool {
62	if !f.flashable[action] {
63		return false
64	}
65	f.flashed = map[string]bool{action: true}
66	return true
67}
68
69func (f *fakeModeToasterView) lingerRect() (int, int, int, int, bool) {
70	if f.rect == nil {
71		return 0, 0, 0, 0, false
72	}
73	return f.rect()
74}
75
76// newFakeModeToasterWindow returns a window whose mode toaster paints into a
77// fake view.
78func newFakeModeToasterWindow(id string) (*browserWindow, *fakeModeToasterView) {
79	view := newFakeModeToasterView()
80	return &browserWindow{id: id, modeToaster: newModeToasterWithView(view, nil)}, view
81}
82
83// pumpMainContext runs pending GLib sources (show delays, flash timers).
84func pumpMainContext() {
85	ctx := glib.MainContextDefault()
86	for ctx.Pending() {
87		ctx.Iteration(false)
88	}
89}

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