diff --git a/pager/command.go b/pager/command.go index 993606821..efb58a2b4 100644 --- a/pager/command.go +++ b/pager/command.go @@ -48,6 +48,7 @@ func (o Options) Run() error { m, tea.WithAltScreen(), tea.WithContext(ctx), + tea.WithReportFocus(), ).Run() if err != nil { return fmt.Errorf("unable to start program: %w", err) diff --git a/pager/pager.go b/pager/pager.go index f9c9b3e53..8c6c25815 100644 --- a/pager/pager.go +++ b/pager/pager.go @@ -7,6 +7,7 @@ import ( "fmt" "strings" + "github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" @@ -34,10 +35,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.WindowSizeMsg: m.ProcessText(msg) case tea.KeyMsg: - return m.KeyHandler(msg) + return m.keyHandler(msg) } - return m, nil + var cmd tea.Cmd + m.search.input, cmd = m.search.input.Update(msg) + return m, cmd } func (m *model) ProcessText(msg tea.WindowSizeMsg) { @@ -84,7 +87,7 @@ func (m *model) ProcessText(msg tea.WindowSizeMsg) { const heightOffset = 2 -func (m model) KeyHandler(key tea.KeyMsg) (model, func() tea.Msg) { +func (m model) keyHandler(key tea.KeyMsg) (model, tea.Cmd) { var cmd tea.Cmd if m.search.active { switch key.String() { @@ -112,6 +115,7 @@ func (m model) KeyHandler(key tea.KeyMsg) (model, func() tea.Msg) { m.viewport.GotoBottom() case "/": m.search.Begin() + return m, textinput.Blink case "p", "N": m.search.PrevMatch(&m) m.ProcessText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width})