diff --git a/json.go b/json.go index 6513ad3..427452e 100644 --- a/json.go +++ b/json.go @@ -20,8 +20,14 @@ func (p Peer) String() string { type peerId string -func (p Peer) AsTable() string { - return fmt.Sprintf("%15s | %30s | %s", p.Id, p.Name, strings.Join(p.Caps, ", ")) +func (p Peer) AsTable(maxWidth int) string { + var id string + if maxWidth > 50 { + id = string(p.Id) + } else { + id = p.Id.String() + } + return fmt.Sprintf("%15s | %30s | %s", id, p.Name, strings.Join(p.Caps, ", ")) } // the ID is too long to display in full in most places diff --git a/main.go b/main.go index 495faa8..5f14cfa 100644 --- a/main.go +++ b/main.go @@ -65,8 +65,9 @@ func writePeers(g *gocui.Gui, peers []Peer) { return err } v.Clear() + maxWidth, _ := g.Size() for _, peer := range peers { - fmt.Fprintf(v, "%s\n", peer.AsTable()) + fmt.Fprintf(v, "%s\n", peer.AsTable(maxWidth)) } return nil })