From d86e5e99024d097ffa5e67e87ca79bf2d3400b82 Mon Sep 17 00:00:00 2001 From: Sergey Date: Wed, 21 Feb 2024 18:28:49 +0300 Subject: [PATCH] feat: allow transposing --- pkg/display/last_round_table.go | 14 +++++++++++++- pkg/display/wrapper.go | 9 ++++++++- static/help.txt | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pkg/display/last_round_table.go b/pkg/display/last_round_table.go index fe55c6d..1938ee5 100644 --- a/pkg/display/last_round_table.go +++ b/pkg/display/last_round_table.go @@ -13,13 +13,15 @@ type LastRoundTableData struct { Validators types.ValidatorsWithInfo ColumnsCount int DisableEmojis bool + Transpose bool } -func NewLastRoundTableData(columnsCount int, disableEmojis bool) *LastRoundTableData { +func NewLastRoundTableData(columnsCount int, disableEmojis bool, transpose bool) *LastRoundTableData { return &LastRoundTableData{ ColumnsCount: columnsCount, Validators: make(types.ValidatorsWithInfo, 0), DisableEmojis: disableEmojis, + Transpose: transpose, } } @@ -27,8 +29,18 @@ func (d *LastRoundTableData) SetColumnsCount(count int) { d.ColumnsCount = count } +func (d *LastRoundTableData) SetTranspose(transpose bool) { + d.Transpose = transpose +} + func (d *LastRoundTableData) GetCell(row, column int) *tview.TableCell { index := row*d.ColumnsCount + column + + if d.Transpose { + rows := d.GetRowCount() + index = column*rows + row + } + text := "" if index < len(d.Validators) { diff --git a/pkg/display/wrapper.go b/pkg/display/wrapper.go index f01df44..253cb9e 100644 --- a/pkg/display/wrapper.go +++ b/pkg/display/wrapper.go @@ -52,6 +52,7 @@ type Wrapper struct { IsHelpDisplayed bool DisableEmojis bool + Transpose bool } func NewWrapper( @@ -60,7 +61,7 @@ func NewWrapper( pauseChannel chan bool, appVersion string, ) *Wrapper { - lastRoundTableData := NewLastRoundTableData(DefaultColumnsCount, config.DisableEmojis) + lastRoundTableData := NewLastRoundTableData(DefaultColumnsCount, config.DisableEmojis, false) allRoundsTableData := NewAllRoundsTableData(config.DisableEmojis) helpTextBytes, _ := static.TemplatesFs.ReadFile("help.txt") @@ -125,6 +126,7 @@ func NewWrapper( IsPaused: false, IsHelpDisplayed: false, DisableEmojis: config.DisableEmojis, + Transpose: false, } } @@ -158,6 +160,11 @@ func (w *Wrapper) Start() { w.ChangeColumnsCount(false) } + if event.Rune() == 't' { + w.Transpose = !w.Transpose + w.LastRoundTableData.SetTranspose(w.Transpose) + } + if event.Rune() == 'p' { w.IsPaused = !w.IsPaused w.PauseChannel <- w.IsPaused diff --git a/static/help.txt b/static/help.txt index 812fafa..336f343 100644 --- a/static/help.txt +++ b/static/help.txt @@ -10,6 +10,7 @@ You can use the following shortcuts: - display [m[]more or [l[]ess columns in validators table - display or hide this [h[]elp message - [p[]ause new updates +- [t[]ranspose the last round validators' view - [q[]uit the app (or Ctrl+C) You can also press [Tab[] to switch between modes, which are: