Skip to content

Commit

Permalink
feat: add vim style bindings for welcome and feed focus (merge fail)
Browse files Browse the repository at this point in the history
  • Loading branch information
TypicalAM committed Jun 16, 2023
1 parent b91d8a1 commit 57322d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions internal/model/simplelist/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
// Handle key presses
if msg, ok := msg.(tea.KeyMsg); ok {
switch msg.String() {
case "up":
case "up", "k":
// Select the previous item
m.selected--
if m.selected < 0 {
Expand All @@ -67,7 +67,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
m.page--
}

case "down":
case "down", "j":
// Select the next item
m.selected++
if m.selected >= len(m.items) {
Expand All @@ -80,12 +80,12 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
m.page++
}

case "shift+up":
case "shift+up", "K":
// Select the first item
m.selected = 0
m.page = 0

case "shift+down":
case "shift+down", "J":
// Select the last item
m.selected = len(m.items) - 1
m.page = len(m.items) / m.itemsPerPage
Expand Down
6 changes: 3 additions & 3 deletions internal/model/tab/feed/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func New(colors colorscheme.Colorscheme, width, height int, title string, reader
key.WithHelp("enter", "Open"),
),
ToggleFocus: key.NewBinding(
key.WithKeys("left", "right"),
key.WithHelp("left/right", "Toggle focus"),
key.WithKeys("left", "right", "alt+h", "alt+l"),
key.WithHelp("left(alt+h)/right(alt+l)", "Toggle focus"),
),
Refresh: key.NewBinding(
key.WithKeys("r"),
Expand Down Expand Up @@ -174,7 +174,7 @@ func (m Model) Update(msg tea.Msg) (tab.Tab, tea.Cmd) {
// Rerun with data fetching and loading
return m, tea.Batch(m.reader(m.title), m.loadingSpinner.Tick)

case "left", "right":
case "left", "right", "alt+l", "alt+h":
// If the viewport isn't open, don't do anything
if !m.isViewportOpen {
return m, nil
Expand Down

0 comments on commit 57322d5

Please sign in to comment.