Detail panes: keep a margin between the poster and the text

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 22:06:53 +02:00
co-authored by Claude Sonnet 5.5
parent b1e368418b
commit fa7e77c56d
2 changed files with 11 additions and 5 deletions
+5 -1
View File
@@ -9,6 +9,8 @@ import (
)
const (
coverGapCols = 2 // empty columns between the poster and the text left of it
coverGapRows = 1 // empty rows between the poster and the text below it
minCoverRows = 6 // a smaller poster is not worth showing
minCoverCols = 8
minTextRows = 6 // the poster never takes these rows from the text
@@ -91,7 +93,9 @@ func (d *detailPane) Draw(screen tcell.Screen) {
narrow, rows := w, 0
if d.coverW > 0 {
narrow, rows = w-d.coverW-1, d.coverH // one column of space left of the poster
// The text keeps clear of the poster: columns to its left, and one more
// line is wrapped narrow so nothing sits right under it.
narrow, rows = w-d.coverW-coverGapCols, d.coverH+coverGapRows
}
if !d.laidOut.valid || d.laidOut.width != w || d.laidOut.narrow != narrow || d.laidOut.rows != rows {
d.laidOut.width, d.laidOut.narrow, d.laidOut.rows, d.laidOut.valid = w, narrow, rows, true
+6 -4
View File
@@ -84,12 +84,14 @@ func TestDetailPaneFlowsAroundPoster(t *testing.T) {
if got := rowText(screen, 4, 1, 30); !strings.HasPrefix(got, "plot plot") {
t.Errorf("the plot starts beside the poster, right after the head: %q", got)
}
// Beside the poster the text stays left of it (34 columns), below it it uses the full width.
for y := 1; y <= d.coverH; y++ {
if got := strings.TrimRight(rowText(screen, y, 1, 35), " "); len([]rune(got)) > 34 {
t.Errorf("row %d runs into the poster: %q", y, got)
// Beside the poster the text stays left of it with a gap of two columns
// (58-23-2 = 33 columns), and the row right under the poster is kept clear too.
for y := 1; y <= d.coverH+coverGapRows; y++ {
if got := strings.TrimRight(rowText(screen, y, 1, 36), " "); len([]rune(got)) > 33 {
t.Errorf("row %d runs into the poster's margin: %q", y, got)
}
}
// Further down it uses the full width.
if got := strings.TrimSpace(rowText(screen, d.coverH+3, 1, 59)); len(got) < 50 {
t.Errorf("below the poster the text should use the full width: %q", got)
}