]> Sergey Matveev's repositories - vors.git/commitdiff
Shorter flags v3.0.0
authorSergey Matveev <stargrave@stargrave.org>
Mon, 29 Apr 2024 11:18:55 +0000 (14:18 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 29 Apr 2024 11:28:12 +0000 (14:28 +0300)
cmd/client/main.go
cmd/client/stats.go
cmd/server/main.go
cmd/server/room.go

index 00ccce1ff5b449382a1d78a4211ae591444e7a2c878073648fd54a3d46b5a5f3..023303a6b2668d16a4528492d06512820fd5ccf68a93fbd9ec862b6cf8838fc1 100644 (file)
@@ -116,9 +116,10 @@ Press F10 to quit.
 Each peer contains various statistics: number of packets received from
 it (or sent, if it is you), traffic amount, number of silence seconds,
 number of bad packets (malformed or altered, number of lost packets,
-number of reordered packets. "TALK" means that recently an audio packet
-was received. "MUTE" means that peer is in muted mode. "SILENT" means
-that peer is locally muted.`)
+number of reordered packets.
+Gree "T" means that recently an audio packet was received.
+Red "MUTE" means that peer is in muted mode.
+Magenta "S" means that peer is locally muted.`)
        }
        flag.Parse()
        log.SetFlags(log.Lmicroseconds)
index 985c3aef491dd0ef4ad5189bb0b58f3fce3c08c7539dcf23de1b52023504142b..56200c8af750c22ceea22b216555238335564e2b012bef6e779b414a0fb8e777 100644 (file)
@@ -64,7 +64,7 @@ func statsDrawer(s *Stream) {
                        return
                case now = <-tick:
                        l := fmt.Sprintf(
-                               "%s  |  %s  |  S/B/L/R: %s/%s/%s/%s",
+                               " %s  |  %s  |  S/B/L/R: %s/%s/%s/%s",
                                humanize.Comma(s.stats.pkts),
                                humanize.IBytes(s.stats.bytes),
                                humanize.Comma(int64(s.actr-(s.ctr&0x00FFFF))/50),
@@ -72,19 +72,21 @@ func statsDrawer(s *Stream) {
                                humanize.Comma(s.stats.lost),
                                humanize.Comma(s.stats.reorder),
                        )
+                       peerFlags := []string{" ", " ", " "}
                        if s.name == *Name && Muted {
-                               l += "  |  " + vors.CRed + "MUTE" + vors.CReset
+                               peerFlags[0] = vors.CRed + "M" + vors.CReset
                        } else {
                                if s.silenced {
-                                       l += "  |  " + vors.CMagenta + "SILENT" + vors.CReset
+                                       peerFlags[2] = vors.CMagenta + "S" + vors.CReset
                                }
                                if s.stats.last.Add(vors.ScreenRefresh).After(now) {
-                                       l += "  |  " + vors.CGreen + "TALK" + vors.CReset
+                                       peerFlags[1] = vors.CGreen + "T" + vors.CReset
                                }
                                if s.muted {
-                                       l += "  |  " + vors.CRed + "MUTE" + vors.CReset
+                                       peerFlags[0] = vors.CRed + "M" + vors.CReset
                                }
                        }
+                       l = strings.Join(peerFlags, "") + l
                        v, err = GUI.View(s.name)
                        if err == nil {
                                v.Clear()
index b102cfd4124ca3f7a78802e9afca19c32a72b34a6ceab806a8ebb7feaeec3eb1..82008ca143c7bca541d6825eedaec3e8277c12149bd3b8ca268b4eafeadcda9d 100644 (file)
@@ -380,8 +380,9 @@ List of known rooms is shown by default. If room requires password
 authentication, then "protected" is written nearby. Each room's member
 username and IP address is shown, together with various statistics:
 number of received, transmitted packets, number of bad packets (failed
-authentication), amount of traffic. "TALK" means that recently an audio
-packet was received. "MUTE" means that peer is in muted mode.
+authentication), amount of traffic.
+Green "T" means that recently an audio packet was received.
+Red "M" means that peer is in muted mode.
 Press F10 to quit.`)
        }
        flag.Parse()
index 1d924fc308ede370df69b646541c9e0e2016a14259f19eb864bf70d4bbbbeb27..78a79bcade27220e361fa3c02ca73bd65bccf21dba66bf62ac1c010068ce55a1 100644 (file)
@@ -3,6 +3,7 @@ package main
 import (
        "fmt"
        "sort"
+       "strings"
        "sync"
        "time"
 
@@ -37,8 +38,9 @@ func (room *Room) Stats(now time.Time) []string {
                if peer == nil {
                        continue
                }
+               peerFlags := []string{" ", " "}
                line := fmt.Sprintf(
-                       "%12s  |  %s | Rx/Tx/Bad: %s / %s / %s |  %s / %s",
+                       "%10s  |  %s | Rx/Tx/Bad: %s / %s / %s |  %s / %s",
                        peer.name,
                        peer.addr,
                        humanize.Comma(peer.stats.pktsRx),
@@ -48,12 +50,12 @@ func (room *Room) Stats(now time.Time) []string {
                        humanize.IBytes(peer.stats.bytesTx),
                )
                if peer.muted {
-                       line += "  |  " + vors.CRed + "MUTE" + vors.CReset
+                       peerFlags[0] = vors.CRed + "M" + vors.CReset
                }
                if peer.stats.last.Add(vors.ScreenRefresh).After(now) {
-                       line += "  |  " + vors.CGreen + "TALK" + vors.CReset
+                       peerFlags[1] = vors.CGreen + "T" + vors.CReset
                }
-               lines = append(lines, line)
+               lines = append(lines, strings.Join(peerFlags, "")+line)
        }
        return lines
 }