diff --git a/main.go b/main.go index 0cf39b7..1574f3b 100644 --- a/main.go +++ b/main.go @@ -74,7 +74,7 @@ func main() { if propIdx >= 0 { proposer = v.GetInfo(propIdx) } - SummaryChan <- fmt.Sprintf("height/round/step: %s - v: %.0f%% c: %.0f%% (%v)\n\nProposer:\n(rank/%%/moniker) %s", hrs, votePct*100, commitPct*100, dur, proposer) + SummaryChan <- fmt.Sprintf("height/round/step: %s - v: %.2f%% c: %.2f%% (%v)\n\nProposer:\n(rank/%%/moniker) %s", hrs, votePct*100, commitPct*100, dur, proposer) voteChan <- votes votePctChan <- votePct commitPctChan <- commitPct diff --git a/prevotes/term.go b/prevotes/term.go index 7dc7ea7..372c20c 100644 --- a/prevotes/term.go +++ b/prevotes/term.go @@ -109,21 +109,30 @@ func DrawScreen(network string, voteChan chan []VoteState, votePctChan, commitPc func splitVotes(votes []VoteState) ([][]VoteState, int) { split := make([][]VoteState, 0) + _, termHeight := ui.TerminalDimensions() + visibleRows := termHeight - 10 + var max int switch { - case len(votes) < 50: + case visibleRows >= len(votes): max = 1 split = append(split, votes) - case len(votes) < 100: + case visibleRows * 2 >= len(votes): max = 2 - split = append(split, votes[:50]) - split = append(split, votes[50:]) + if visibleRows >= 50 { + split = append(split, votes[:50]) + split = append(split, votes[50:]) + } else { + rowsPerColumn := (len(votes) + max - 1)/2 + split = append(split, votes[:rowsPerColumn]) + split = append(split, votes[rowsPerColumn:]) + } default: max = 3 - rows := (len(votes) + max - 1)/3 - split = append(split, votes[:rows]) - split = append(split, votes[rows:rows*2]) - split = append(split, votes[rows*2:]) + rowsPerColumn := (len(votes) + max - 1)/3 + split = append(split, votes[:rowsPerColumn]) + split = append(split, votes[rowsPerColumn:rowsPerColumn*2]) + split = append(split, votes[rowsPerColumn*2:]) } return split, max }