v0.11.1 ab30a57

interactive_render.go RawHistoryFolder

1package modes
2
3import (
4	"sync"
5
6	"github.com/bnema/zut/packages/tui"
7)
8
9// renderRequest is deliberately a signal, not a frame. The render owner
10// reads the newest synchronized interactive state when it wakes, so a burst
11// replaces the one pending request instead of queueing stale snapshots.
12type renderRequest struct {
13	clear      bool
14	invalidate bool
15	theme      *tui.Theme
16}
17
18type latestFrameScheduler struct {
19	wake chan struct{}
20	done chan struct{}
21
22	mu         sync.Mutex
23	clear      bool
24	invalidate bool
25	theme      *tui.Theme
26	stopped    bool
27}
28
29func newLatestFrameScheduler() *latestFrameScheduler {
30	return &latestFrameScheduler{
31		wake: make(chan struct{}, 1),
32		done: make(chan struct{}),
33	}
34}
35
36func (s *latestFrameScheduler) request(clear, invalidate bool) bool {
37	s.mu.Lock()
38	defer s.mu.Unlock()
39	if s.stopped {
40		return false
41	}
42	s.clear = s.clear || clear
43	s.invalidate = s.invalidate || invalidate
44	select {
45	case s.wake <- struct{}{}:
46	default:
47	}
48	return true
49}
50
51func (s *latestFrameScheduler) requestTheme(theme tui.Theme) bool {
52	s.mu.Lock()
53	defer s.mu.Unlock()
54	if s.stopped {
55		return false
56	}
57	s.clear = true
58	s.theme = &theme
59	select {
60	case s.wake <- struct{}{}:
61	default:
62	}
63	return true
64}
65
66func (s *latestFrameScheduler) next() (renderRequest, bool) {
67	<-s.wake
68	s.mu.Lock()
69	defer s.mu.Unlock()
70	if s.stopped {
71		return renderRequest{}, false
72	}
73	req := renderRequest{clear: s.clear, invalidate: s.invalidate, theme: s.theme}
74	s.clear = false
75	s.invalidate = false
76	s.theme = nil
77	return req, true
78}
79
80func (s *latestFrameScheduler) run(render func(renderRequest)) {
81	defer close(s.done)
82	for {
83		req, ok := s.next()
84		if !ok {
85			return
86		}
87		render(req)
88	}
89}
90
91// stop waits for the in-flight render callback to finish. Callers must not
92// invoke it while holding i.mu: the callback may need to acquire i.mu.
93func (s *latestFrameScheduler) stop() {
94	s.mu.Lock()
95	if !s.stopped {
96		s.stopped = true
97		close(s.wake)
98	}
99	s.mu.Unlock()
100	<-s.done
101}

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 476

↑↓ moveenter openesc close