Skip to content

Commit

Permalink
Make blur keybind configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Evertras committed Apr 19, 2022
1 parent 451d0c8 commit f3b7364
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion table/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ type KeyMap struct {
PageFirst key.Binding
PageLast key.Binding

Filter key.Binding
// Filter allows the user to start typing and filter the rows.
Filter key.Binding

// FilterBlur is the key that stops the user's input from typing into the filter.
FilterBlur key.Binding

// FilterClear will clear the filter while it's blurred.
FilterClear key.Binding
}

Expand Down Expand Up @@ -45,6 +51,9 @@ func DefaultKeyMap() KeyMap {
Filter: key.NewBinding(
key.WithKeys("/"),
),
FilterBlur: key.NewBinding(
key.WithKeys("enter", "esc"),
),
FilterClear: key.NewBinding(
key.WithKeys("esc"),
),
Expand Down
2 changes: 1 addition & 1 deletion table/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (m Model) updateFilterTextInput(msg tea.Msg) (Model, tea.Cmd) {
var cmd tea.Cmd
switch msg := msg.(type) {
case tea.KeyMsg:
if msg.Type == tea.KeyEnter || msg.Type == tea.KeyEscape {
if key.Matches(msg, m.keyMap.FilterBlur) {
m.filterTextInput.Blur()
}
}
Expand Down

0 comments on commit f3b7364

Please sign in to comment.