Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions internal/ui/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,11 @@ func renderFrameTitleWithAction(width int, title, action string, color imagecolo
return borderStyle.Render(border.TopLeft + strings.Repeat(border.Top, width-2) + border.TopRight)
}
prefix := border.TopLeft + border.Top + " "
suffix := borderStyle.Render(" " + border.TopRight)
// Join the horizontal rule directly into the corner. Optional title actions
// retain their leading padding, but must not leave a visual hole after them.
suffix := borderStyle.Render(border.Top + border.TopRight)
if actionWidth > 0 {
suffix = borderStyle.Render(" ") + action + borderStyle.Render(" "+border.TopRight)
suffix = borderStyle.Render(" ") + action + borderStyle.Render(border.Top+border.TopRight)
}
middleWidth := max(width-lipgloss.Width(prefix)-lipgloss.Width(title)-lipgloss.Width(suffix), 0)
middle := ""
Expand Down
17 changes: 16 additions & 1 deletion internal/ui/view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,12 @@ func TestFrameTitlesAreIntegratedIntoBorderInsteadOfButtonBrackets(t *testing.T)
if len(lines) != 5 {
t.Fatalf("frame height = %d, want 5:\n%s", len(lines), output)
}
if !strings.HasPrefix(lines[0], "╭─ SESSION READOUT ") || !strings.HasSuffix(lines[0], "╮") {
if !strings.HasPrefix(lines[0], "╭─ SESSION READOUT ") || !strings.HasSuffix(lines[0], "─╮") {
t.Fatalf("title was not integrated into the top border: %q", lines[0])
}
if strings.HasSuffix(lines[0], " ╮") {
t.Fatalf("title frame left a gap before the top-right corner: %q", lines[0])
}
if strings.Contains(output, "[ SESSION READOUT ]") {
t.Fatalf("frame title still looks like a button:\n%s", output)
}
Expand All @@ -258,6 +261,18 @@ func TestFrameTitlesAreIntegratedIntoBorderInsteadOfButtonBrackets(t *testing.T)
t.Errorf("narrow line %d width = %d, want 5: %q", index, width, line)
}
}

const closeAction = "[ (X) CLOSE ]"
withAction := ansi.Strip(frameSizedWithTitleAction(48, 3, "RUN DETAIL", closeAction, "BODY", colors.primary, colors))
actionLines := strings.Split(withAction, "\n")
if !strings.HasSuffix(actionLines[0], closeAction+"─╮") {
t.Fatalf("title action did not reconnect to the top-right corner: %q", actionLines[0])
}
for index, line := range actionLines {
if width := lipgloss.Width(line); width != 48 {
t.Errorf("action frame line %d width = %d, want 48: %q", index, width, line)
}
}
}

func TestPieViewPlacesQuotaWindowsSideBySide(t *testing.T) {
Expand Down
Loading