Skip to content

Commit

Permalink
Merge pull request #15 from zMoooooritz/feat_advanced_keybinds
Browse files Browse the repository at this point in the history
Add keybinds to go to the start and end of articles
  • Loading branch information
zMoooooritz authored Oct 22, 2023
2 parents aa112f9 + c9662ae commit b5da116
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type keymap struct {
up key.Binding
down key.Binding
prev key.Binding
start key.Binding
end key.Binding
open key.Binding
video key.Binding
shortNews key.Binding
Expand All @@ -58,6 +60,8 @@ func (k keymap) FullHelp() [][]key.Binding {
{k.right},
{k.up},
{k.down},
{k.start},
{k.end},
{k.next},
{k.prev},
{k.open},
Expand Down Expand Up @@ -148,6 +152,14 @@ func InitialModel() Model {
key.WithKeys("k", "up"),
key.WithHelp("↑/k", "up"),
),
start: key.NewBinding(
key.WithKeys("g", "home"),
key.WithHelp("g/home", "start"),
),
end: key.NewBinding(
key.WithKeys("G", "end"),
key.WithHelp("G/end", "end"),
),
next: key.NewBinding(
key.WithKeys("tab"),
key.WithHelp("tab", "next"),
Expand Down Expand Up @@ -228,6 +240,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case key.Matches(msg, m.keymap.next):
m.readerFocused = false
m.activeListIndex = (m.activeListIndex + 1) % len(m.lists)
case key.Matches(msg, m.keymap.start):
if m.readerFocused {
m.reader.GotoTop()
}
case key.Matches(msg, m.keymap.end):
if m.readerFocused {
m.reader.GotoBottom()
}
case key.Matches(msg, m.keymap.prev):
m.readerFocused = false
m.activeListIndex = (len(m.lists) + m.activeListIndex - 1) % len(m.lists)
Expand Down

0 comments on commit b5da116

Please sign in to comment.