Skip to content

Commit

Permalink
Merge pull request #80 from blinklabs-io/fix/scroll-to-beginning
Browse files Browse the repository at this point in the history
fix: scroll to beginning of text
  • Loading branch information
wolf31o2 authored Sep 24, 2023
2 parents 14ffd7e + fc614e2 commit 6bd22d2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func main() {
checkPeers = true
pingPeers = false
showPeers = false
scrollPeers = false
text.Clear()
footerText.Clear()
footerText.SetText(" [yellow](esc/q) Quit[white] | [yellow](h) Return home")
Expand Down Expand Up @@ -254,6 +255,11 @@ func main() {
} else {
text.Clear()
text.SetText(getPeerText(ctx))
// Scroll to the top only once
if scrollPeers {
scrollPeers = false
text.ScrollToBeginning()
}
}
}
if active == "test" {
Expand Down Expand Up @@ -920,6 +926,7 @@ var peerAnalysisDate uint64
var checkPeers bool = false
var pingPeers bool = false
var showPeers bool = false
var scrollPeers bool = false

func getPeerText(ctx context.Context) string {
cfg := config.GetConfig()
Expand Down Expand Up @@ -1061,11 +1068,13 @@ func getPeerText(ctx context.Context) string {

checkPeers = false
pingPeers = true
scrollPeers = false
// sb.WriteString(fmt.Sprintf("checkPeers=%v, pingPeers=%v, showPeers=%v\n", checkPeers, pingPeers, showPeers))
failCount = 0
return sb.String()
} else if pingPeers {
pingPeers = false
scrollPeers = false
peerCount := len(peersFiltered)
printStart := width - (peerCount * 2) - 2
sb.WriteString(fmt.Sprintf("%"+strconv.Itoa(printStart-1)+"s [blue]%"+strconv.Itoa(peerCount)+"s[white]/[green]%d[white]\n",
Expand Down Expand Up @@ -1139,10 +1148,12 @@ func getPeerText(ctx context.Context) string {
peerAnalysisDate = uint64(time.Now().Unix() - 1)
checkPeers = false
showPeers = true
scrollPeers = true
// sb.WriteString(fmt.Sprintf("checkPeers=%v, pingPeers=%v, showPeers=%v\n", checkPeers, pingPeers, showPeers))
failCount = 0
return sb.String()
} else if showPeers {
scrollPeers = false
peerCount := len(peersFiltered)
sb.WriteString(" RTT : Peers / Percent\n")
sb.WriteString(fmt.Sprintf(
Expand Down

0 comments on commit 6bd22d2

Please sign in to comment.