Trakt lists: right-align the numbers
The grey number of every entry ("1.2k watching", "on 18k lists") stood
right after its title, so they did not line up. The rows are now padded
to the list's width on every draw where it changed, putting the numbers
against the right edge; a title too long for that keeps the number right
after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
|
||||
"git.stinnesbeck.com/nils/arr-tui/internal/radarr"
|
||||
)
|
||||
|
||||
func TestTraktListsInTheSearchView(t *testing.T) {
|
||||
@@ -86,3 +88,43 @@ func TestTraktListsInTheSearchView(t *testing.T) {
|
||||
t.Errorf("search row %q", main)
|
||||
}
|
||||
}
|
||||
|
||||
func TestListNumbersAreRightAligned(t *testing.T) {
|
||||
sim := tcell.NewSimulationScreen("")
|
||||
if err := sim.Init(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer sim.Fini()
|
||||
sim.SetSize(60, 6)
|
||||
|
||||
a := newTestApp(t)
|
||||
v := a.searches[0]
|
||||
a.trakt.Reconfigure("id")
|
||||
v.discover[0] = &discovered{at: time.Now(),
|
||||
results: []result{movieResult{Movie: radarr.Movie{Title: "Dune", Year: 2021}}, movieResult{Movie: radarr.Movie{Title: "A Much Longer Title", Year: 2024}}},
|
||||
notes: []string{"1.2k watching", "5 watching"}}
|
||||
v.showList()
|
||||
|
||||
ends := func(width int) []int {
|
||||
sim.Clear()
|
||||
l := notesList{v.list, v}
|
||||
l.SetRect(0, 0, width, 6)
|
||||
l.Draw(sim)
|
||||
var out []int
|
||||
for y := 1; y <= 2; y++ {
|
||||
row := strings.TrimRight(rowText(sim, y, 0, width), " │")
|
||||
out = append(out, len([]rune(row)))
|
||||
if !strings.HasSuffix(row, "watching") {
|
||||
t.Errorf("row %d does not end with its number: %q", y, row)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
if e := ends(60); e[0] != e[1] {
|
||||
t.Errorf("numbers end in columns %v, want the same", e)
|
||||
}
|
||||
// After a resize they line up at the new edge.
|
||||
if e := ends(44); e[0] != e[1] || e[0] > 44 {
|
||||
t.Errorf("after resize: numbers end in columns %v", e)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user