Skip to content

Commit 7bff34f

Browse files
Use terminal width for the status line
1 parent 5e89036 commit 7bff34f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pkg/cmd/repo/garden/garden.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func gardenRun(opts *GardenOptions) error {
303303
}
304304

305305
// status line stuff
306-
sl := statusLine(garden, player)
306+
sl := statusLine(garden, player, opts.IO)
307307

308308
fmt.Fprint(out, "\033[;H") // move to top left
309309
for y := 0; y < player.Geo.Height-1; y++ {
@@ -450,14 +450,18 @@ func drawGarden(out io.Writer, garden [][]*Cell, player *Player) {
450450
fmt.Fprintln(out, utils.Bold(sl))
451451
}
452452

453-
func statusLine(garden [][]*Cell, player *Player) string {
454-
statusLine := garden[player.Y][player.X].StatusLine + " "
453+
func statusLine(garden [][]*Cell, player *Player, io *iostreams.IOStreams) string {
454+
statusLine := garden[player.Y][player.X].StatusLine
455+
455456
if player.ShoeMoistureContent > 1 {
456457
statusLine += "\nYour shoes squish with water from the stream."
457458
} else if player.ShoeMoistureContent == 1 {
458459
statusLine += "\nYour shoes seem to have dried out."
459-
} else {
460-
statusLine += "\n "
460+
}
461+
462+
if len(statusLine) < io.TerminalWidth() {
463+
paddingSize := io.TerminalWidth() - len(statusLine)
464+
statusLine += strings.Repeat(" ", paddingSize)
461465
}
462466

463467
return statusLine

0 commit comments

Comments
 (0)