diff options
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | internal/atable/table.go | 4 | ||||
| -rw-r--r-- | internal/ui/table.go | 39 |
3 files changed, 42 insertions, 4 deletions
@@ -21,7 +21,7 @@ Task Samurai invokes the `task` command to read and modify tasks. The tasks are - `↑/k` and `↓/j`: move up and down - `←/h` and `→/l`: move left and right - `b/pgup`: page up -- `f/pgdn/space`: page down +- `pgdn/space`: page down - `u` or `ctrl+u`: half page up - `ctrl+d`: half page down - `g/home/0`: go to start @@ -49,6 +49,7 @@ Task Samurai invokes the `task` command to read and modify tasks. The tasks are ### Misc +- `f`: change filter - `H`: toggle help - `q` or `esc`: close search/help or quit (press `q` when nothing is open) diff --git a/internal/atable/table.go b/internal/atable/table.go index c22d479..44f1c9f 100644 --- a/internal/atable/table.go +++ b/internal/atable/table.go @@ -85,8 +85,8 @@ func DefaultKeyMap() KeyMap { key.WithHelp("b/pgup", "page up"), ), PageDown: key.NewBinding( - key.WithKeys("f", "pgdown", spacebar), - key.WithHelp("f/pgdn", "page down"), + key.WithKeys("pgdown", spacebar), + key.WithHelp("pgdn", "page down"), ), HalfPageUp: key.NewBinding( key.WithKeys("u", "ctrl+u"), diff --git a/internal/ui/table.go b/internal/ui/table.go index bcfa017..3b1dacf 100644 --- a/internal/ui/table.go +++ b/internal/ui/table.go @@ -54,6 +54,9 @@ type Model struct { dueID int dueDate time.Time + filterEditing bool + filterInput textinput.Model + searching bool searchInput textinput.Model searchRegex *regexp.Regexp @@ -112,6 +115,8 @@ func New(filters []string) (Model, error) { m.dueDate = time.Now() m.searchInput = textinput.New() m.searchInput.Prompt = "search: " + m.filterInput = textinput.New() + m.filterInput.Prompt = "filter: " m.defaultTheme = DefaultTheme() m.theme = m.defaultTheme @@ -349,6 +354,25 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } return m, nil } + if m.filterEditing { + switch msg.Type { + case tea.KeyEnter: + m.filters = strings.Fields(m.filterInput.Value()) + m.filterEditing = false + m.filterInput.Blur() + m.reload() + m.updateTableHeight() + return m, nil + case tea.KeyEsc: + m.filterEditing = false + m.filterInput.Blur() + m.updateTableHeight() + return m, nil + } + var cmd tea.Cmd + m.filterInput, cmd = m.filterInput.Update(msg) + return m, cmd + } if m.searching { switch msg.Type { case tea.KeyEnter: @@ -511,6 +535,12 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil } } + case "f": + m.filterEditing = true + m.filterInput.SetValue(strings.Join(m.filters, " ")) + m.filterInput.Focus() + m.updateTableHeight() + return m, nil case "t": m.theme = RandomTheme() m.applyTheme() @@ -644,6 +674,7 @@ func (m Model) View() string { "a: annotate task", "A: replace annotations", "p: set priority", + "f: change filter", "t: randomize theme", "T: reset theme", "/, ?: search", @@ -695,6 +726,12 @@ func (m Model) View() string { m.tagsInput.View(), ) } + if m.filterEditing { + view = lipgloss.JoinVertical(lipgloss.Left, + view, + m.filterInput.View(), + ) + } if m.searching { view = lipgloss.JoinVertical(lipgloss.Left, view, @@ -980,7 +1017,7 @@ func (m *Model) updateTableHeight() { if m.cellExpanded { h-- } - if m.annotating || m.dueEditing || m.prioritySelecting || m.searching || m.descEditing || m.tagsEditing { + if m.annotating || m.dueEditing || m.prioritySelecting || m.searching || m.descEditing || m.tagsEditing || m.filterEditing { h-- } if h < 1 { |
