Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow transposing #14

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pkg/display/last_round_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,34 @@ 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,
}
}

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) {
Expand Down
9 changes: 8 additions & 1 deletion pkg/display/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type Wrapper struct {
IsHelpDisplayed bool

DisableEmojis bool
Transpose bool
}

func NewWrapper(
Expand All @@ -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")
Expand Down Expand Up @@ -125,6 +126,7 @@ func NewWrapper(
IsPaused: false,
IsHelpDisplayed: false,
DisableEmojis: config.DisableEmojis,
Transpose: false,
}
}

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions static/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading