diff --git a/main.go b/main.go index 3afc917..bd9779e 100644 --- a/main.go +++ b/main.go @@ -2,10 +2,13 @@ package main import ( "github.com/alecthomas/kong" + "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/sodapop/internal/stdin" + "github.com/muesli/termenv" ) func main() { + lipgloss.SetColorProfile(termenv.ANSI256) pop := &Pop{} ctx := kong.Parse(pop, kong.Name("pop"), diff --git a/search/command.go b/search/command.go index ad00812..7ae1823 100644 --- a/search/command.go +++ b/search/command.go @@ -10,14 +10,11 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/sodapop/internal/log" "github.com/charmbracelet/sodapop/internal/stdin" - "github.com/muesli/termenv" ) // Run provides a shell script interface for the search bubble. // https://github.com/charmbracelet/bubbles/search func (o Options) Run() { - lipgloss.SetColorProfile(termenv.ANSI256) - i := textinput.New() i.Focus() diff --git a/search/search.go b/search/search.go index a9ad230..b4949f4 100644 --- a/search/search.go +++ b/search/search.go @@ -17,10 +17,15 @@ type model struct { selected int indicator string height int + quitting bool } func (m model) Init() tea.Cmd { return nil } func (m model) View() string { + if m.quitting { + return "" + } + var s strings.Builder // Since there are matches, display them so that the user can see, in real @@ -73,6 +78,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeyMsg: switch msg.String() { case "ctrl+c", "esc", "enter": + m.quitting = true return m, tea.Quit case "ctrl+n": m.selected = clamp(0, len(m.matches)-1, m.selected+1)