Skip to content

Commit

Permalink
perf: UI simplified, bindings added
Browse files Browse the repository at this point in the history
  • Loading branch information
097115 committed Feb 4, 2023
1 parent dcb34d1 commit 56dcab6
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { //nolint:ireturn,cyclo

case tea.KeyMsg:
switch msg.String() {
case "tab":
case "tab", "k":

m.groupSelectedIndex++

Expand All @@ -115,6 +115,17 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { //nolint:ireturn,cyclo

m.groupSelectedName = m.ctx.Groups[m.groupSelectedIndex].Name

return m, generateQuoteMsg(m, true)
case "shift+tab", "j":

m.groupSelectedIndex--

if m.groupSelectedIndex < 0 {
m.groupSelectedIndex = m.groupMaxIndex
}

m.groupSelectedName = m.ctx.Groups[m.groupSelectedIndex].Name

return m, generateQuoteMsg(m, true)
case "ctrl+c":
fallthrough
Expand All @@ -127,7 +138,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { //nolint:ireturn,cyclo
case tea.WindowSizeMsg:
m.watchlist.Width = msg.Width
m.summary.Width = msg.Width
viewportHeight := msg.Height - m.headerHeight - footerHeight
viewportHeight := msg.Height - m.headerHeight

if !m.ready {
m.viewport = viewport.Model{Width: msg.Width, Height: viewportHeight}
Expand Down Expand Up @@ -177,8 +188,7 @@ func (m Model) View() string {
}

return viewSummary +
m.viewport.View() + "\n" +
footer(m.viewport.Width, m.lastUpdateTime, m.groupSelectedName)
m.viewport.View()

}

Expand All @@ -199,7 +209,7 @@ func footer(width int, time string, groupSelectedName string) string {
Cells: []grid.Cell{
{Text: styleLogo(" ticker "), Width: 8},
{Text: styleGroup(" " + groupSelectedName + " "), Width: len(groupSelectedName) + 2, VisibleMinWidth: 95},
{Text: styleHelp(" q: exit ↑: scroll up ↓: scroll down ⭾: change group"), Width: 52},
{Text: styleHelp(" q: exit ↑: scroll up ↓: scroll down ⭾ : next group ⇧+⭾: previous group"), Width: 71},
{Text: styleHelp("↻ " + time), Align: grid.Right},
},
},
Expand Down

0 comments on commit 56dcab6

Please sign in to comment.