main 6af0a61

progress_view.go RawHistoryFolder

1package views
2
3import (
4	"fmt"
5	"strings"
6
7	"github.com/bnema/archup/internal/interfaces/tui/models"
8	"github.com/charmbracelet/lipgloss"
9)
10
11// RenderProgress renders the progress model to a styled string
12func RenderProgress(pm *models.ProgressModelImpl) string {
13	var b strings.Builder
14
15	b.WriteString("\n")
16	b.WriteString(lipgloss.NewStyle().
17		Bold(true).
18		Foreground(lipgloss.Color("12")).
19		Render("Installation Progress"))
20	b.WriteString("\n\n")
21
22	// Phase indicator
23	phaseNumber, totalPhases := pm.GetPhaseProgress()
24	if totalPhases > 0 {
25		phasePercent := int((float64(phaseNumber) / float64(totalPhases)) * 100)
26		currentPhase := pm.GetCurrentPhase()
27		b.WriteString(fmt.Sprintf("Phase %d/%d: %s [%d%%]\n", phaseNumber, totalPhases, currentPhase, phasePercent))
28	}
29
30	// Progress bar
31	b.WriteString("\n")
32	b.WriteString(renderProgressBar(pm))
33	b.WriteString("\n\n")
34
35	// Current message
36	message := pm.GetMessage()
37	if message != "" {
38		color := lipgloss.Color("11")
39		if pm.IsError() {
40			color = lipgloss.Color("1")
41		}
42		b.WriteString("Current: ")
43		b.WriteString(lipgloss.NewStyle().
44			Foreground(color).
45			Render(message))
46		b.WriteString("\n\n")
47	}
48
49	// Message history
50	history := pm.GetMessageHistory()
51	if len(history) > 0 {
52		b.WriteString(lipgloss.NewStyle().
53			Faint(true).
54			Render("Recent activities:"))
55		b.WriteString("\n")
56
57		start := 0
58		if len(history) > 5 {
59			start = len(history) - 5
60		}
61		for _, msg := range history[start:] {
62			b.WriteString(lipgloss.NewStyle().
63				Faint(true).
64				Render("  • " + msg))
65			b.WriteString("\n")
66		}
67	}
68
69	b.WriteString("\n")
70	b.WriteString(lipgloss.NewStyle().
71		Faint(true).
72		Render("Installation running... Press Ctrl+C to cancel"))
73
74	return b.String()
75}
76
77// renderProgressBar renders a visual progress bar
78func renderProgressBar(pm *models.ProgressModelImpl) string {
79	width := 40
80	progressPercent := pm.GetProgressPercent()
81	filled := (progressPercent * width) / 100
82
83	bar := strings.Repeat("█", filled) + strings.Repeat("░", width-filled)
84
85	return fmt.Sprintf("[%s] %d%%", bar, progressPercent)
86}

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