check maxWidth od window to show full peer ID
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
1c60834a07
commit
ed94437bdd
10
json.go
10
json.go
|
@ -20,8 +20,14 @@ func (p Peer) String() string {
|
||||||
|
|
||||||
type peerId string
|
type peerId string
|
||||||
|
|
||||||
func (p Peer) AsTable() string {
|
func (p Peer) AsTable(maxWidth int) string {
|
||||||
return fmt.Sprintf("%15s | %30s | %s", p.Id, p.Name, strings.Join(p.Caps, ", "))
|
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
|
// the ID is too long to display in full in most places
|
||||||
|
|
3
main.go
3
main.go
|
@ -65,8 +65,9 @@ func writePeers(g *gocui.Gui, peers []Peer) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
v.Clear()
|
v.Clear()
|
||||||
|
maxWidth, _ := g.Size()
|
||||||
for _, peer := range peers {
|
for _, peer := range peers {
|
||||||
fmt.Fprintf(v, "%s\n", peer.AsTable())
|
fmt.Fprintf(v, "%s\n", peer.AsTable(maxWidth))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue