check maxWidth od window to show full peer ID

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-06-20 17:32:50 -04:00 committed by Jakub
parent 1c60834a07
commit ed94437bdd
2 changed files with 10 additions and 3 deletions

10
json.go
View File

@ -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

View File

@ -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
})