v0.50.1 a637010

changelog_dialog.go RawHistoryFolder

1package modes
2
3import (
4	"fmt"
5	"strings"
6
7	"github.com/bnema/zut/packages/tui"
8)
9
10// changelogDialog is the one-shot release-notes overlay shown the
11// first time a user launches a new zut version. The body is the
12// markdown from the GitHub release page, rendered through the same
13// pipeline used for assistant messages so code fences + bold +
14// links look right.
15//
16// Any key dismisses; the parent Interactive then persists the
17// version-shown marker so the dialog never reappears for that
18// version.
19type changelogDialog struct {
20	active  bool
21	version string
22	url     string
23	body    string
24	scroll  int
25}
26
27func newChangelogDialog() *changelogDialog { return &changelogDialog{} }
28
29// Open populates and shows the dialog.
30func (d *changelogDialog) Open(version, url, body string) {
31	d.active = true
32	d.version = version
33	d.url = url
34	d.body = strings.TrimSpace(body)
35	d.scroll = 0
36}
37
38// Close hides the dialog.
39func (d *changelogDialog) Close() { d.active = false }
40
41// Active reports whether the overlay is visible and consuming keys.
42func (d *changelogDialog) Active() bool { return d != nil && d.active }
43
44// HandleKey: any key (other than scroll) closes the dialog. Returns
45// closed=true when the user dismissed; the parent uses that as the
46// signal to persist LastChangelogShown.
47func (d *changelogDialog) HandleKey(k tui.Key) (closed bool) {
48	if !d.Active() {
49		return false
50	}
51	switch k.Kind {
52	case tui.KeyUp:
53		if d.scroll > 0 {
54			d.scroll--
55		}
56		return false
57	case tui.KeyDown:
58		d.scroll++
59		return false
60	case tui.KeyPageUp:
61		d.scroll -= 8
62		if d.scroll < 0 {
63			d.scroll = 0
64		}
65		return false
66	case tui.KeyPageDown:
67		d.scroll += 8
68		return false
69	}
70	d.Close()
71	return true
72}
73
74// Render returns the dialog lines.
75func (d *changelogDialog) Render(th tui.Theme, width int) []string {
76	if !d.Active() {
77		return nil
78	}
79	title := fmt.Sprintf("zut %s \u2014 release notes (any key to dismiss)", d.version)
80	out := []string{frameHeaderColor(th, title, width, th.Accent)}
81	if d.url != "" {
82		out = append(out, "  "+th.FGColor(th.Muted, d.url))
83		out = append(out, "")
84	}
85
86	var bodyLines []string
87	for _, l := range strings.Split(d.body, "\n") {
88		if strings.HasPrefix(l, "\x00H:") {
89			// Heading: render in accent color, bold.
90			heading := strings.TrimPrefix(l, "\x00H:")
91			styled := th.FGColor(th.Accent, tui.Bold(heading))
92			bodyLines = append(bodyLines, wrapDialogTextRows(styled, width)...)
93		} else {
94			// Regular line: render and wrap through the shared dialog
95			// markdown path so ANSI styling does not affect display width.
96			bodyLines = append(bodyLines, renderDialogMarkdownRows(l, th, width)...)
97		}
98	}
99
100	const maxRows = 18
101	if d.scroll > len(bodyLines)-1 {
102		d.scroll = len(bodyLines) - 1
103	}
104	if d.scroll < 0 {
105		d.scroll = 0
106	}
107	end := d.scroll + maxRows
108	if end > len(bodyLines) {
109		end = len(bodyLines)
110	}
111	out = append(out, bodyLines[d.scroll:end]...)
112	if end < len(bodyLines) {
113		out = append(out, "  "+th.FGColor(th.Muted, fmt.Sprintf("\u2193 %d more lines (down/pgdn)", len(bodyLines)-end)))
114	}
115	out = append(out, frameRuleColor(th, width, th.Accent))
116	return out
117}

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