renderDiffHeader renders the header for the diff view.
()
| 804 | |
| 805 | // renderDiffHeader renders the header for the diff view. |
| 806 | func (a *App) renderDiffHeader() string { |
| 807 | // Branding |
| 808 | brand := headerStyle.Render("chief") |
| 809 | |
| 810 | // View indicator - show story ID if viewing a story-specific diff |
| 811 | viewLabel := "[Diff View]" |
| 812 | if a.diffViewer.storyID != "" { |
| 813 | viewLabel = fmt.Sprintf("[Diff: %s]", a.diffViewer.storyID) |
| 814 | } |
| 815 | viewIndicator := lipgloss.NewStyle(). |
| 816 | Foreground(PrimaryColor). |
| 817 | Bold(true). |
| 818 | Render(viewLabel) |
| 819 | |
| 820 | // State indicator |
| 821 | stateStyle := GetStateStyle(a.state) |
| 822 | state := stateStyle.Render(fmt.Sprintf("[%s]", a.state.String())) |
| 823 | |
| 824 | // Scroll position |
| 825 | var scrollInfo string |
| 826 | if len(a.diffViewer.lines) > 0 { |
| 827 | pct := 0 |
| 828 | if a.diffViewer.maxOffset() > 0 { |
| 829 | pct = a.diffViewer.offset * 100 / a.diffViewer.maxOffset() |
| 830 | } |
| 831 | scrollInfo = SubtitleStyle.Render(fmt.Sprintf("%d lines %d%%", len(a.diffViewer.lines), pct)) |
| 832 | } |
| 833 | |
| 834 | // Combine elements |
| 835 | leftPart := lipgloss.JoinHorizontal(lipgloss.Center, brand, " ", viewIndicator, " ", state) |
| 836 | rightPart := scrollInfo |
| 837 | |
| 838 | // Create the full header line with proper spacing |
| 839 | spacing := strings.Repeat(" ", max(0, a.width-lipgloss.Width(leftPart)-lipgloss.Width(rightPart)-2)) |
| 840 | headerLine := lipgloss.JoinHorizontal(lipgloss.Center, leftPart, spacing, rightPart) |
| 841 | |
| 842 | // Stats line (show diffstat summary if available) |
| 843 | var statsLine string |
| 844 | if a.diffViewer.stats != "" { |
| 845 | statsLines := strings.Split(a.diffViewer.stats, "\n") |
| 846 | if len(statsLines) > 0 { |
| 847 | summary := statsLines[len(statsLines)-1] |
| 848 | statsLine = SubtitleStyle.Render(" " + strings.TrimSpace(summary)) |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | // Add a border below |
| 853 | border := DividerStyle.Render(strings.Repeat("─", a.width)) |
| 854 | |
| 855 | if statsLine != "" { |
| 856 | return lipgloss.JoinVertical(lipgloss.Left, headerLine, statsLine, border) |
| 857 | } |
| 858 | return lipgloss.JoinVertical(lipgloss.Left, headerLine, border) |
| 859 | } |
| 860 | |
| 861 | // renderNarrowDiffHeader renders a condensed header for the diff view in narrow mode. |
| 862 | func (a *App) renderNarrowDiffHeader() string { |
no test coverage detected