diff --git a/confirm/command.go b/confirm/command.go index 88d7db4..4ea4547 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -7,12 +7,10 @@ import ( "github.com/alecthomas/kong" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/style" ) -// Aborted is the exit code when the user aborts the confirmation. -const Aborted = 130 - // Run provides a shell script interface for prompting a user to confirm an // action with an affirmative or negative answer. func (o Options) Run() error { @@ -34,7 +32,7 @@ func (o Options) Run() error { } if m.(model).aborted { - os.Exit(Aborted) + os.Exit(exit.StatusAborted) } else if m.(model).confirmation { os.Exit(0) } else { diff --git a/pager/pager.go b/pager/pager.go index 49235f1..a3eed04 100644 --- a/pager/pager.go +++ b/pager/pager.go @@ -84,9 +84,10 @@ func (m *model) ProcessText(msg tea.WindowSizeMsg) { m.viewport.SetContent(text.String()) } +const heightOffset = 2 + func (m model) KeyHandler(key tea.KeyMsg) (model, func() tea.Msg) { var cmd tea.Cmd - const HeightOffset = 2 if m.search.active { switch key.String() { case "enter": @@ -96,7 +97,7 @@ func (m model) KeyHandler(key tea.KeyMsg) (model, func() tea.Msg) { // Trigger a view update to highlight the found matches. m.search.NextMatch(&m) - m.ProcessText(tea.WindowSizeMsg{Height: m.viewport.Height + HeightOffset, Width: m.viewport.Width}) + m.ProcessText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width}) } else { m.search.Done() } @@ -115,10 +116,10 @@ func (m model) KeyHandler(key tea.KeyMsg) (model, func() tea.Msg) { m.search.Begin() case "p", "N": m.search.PrevMatch(&m) - m.ProcessText(tea.WindowSizeMsg{Height: m.viewport.Height + HeightOffset, Width: m.viewport.Width}) + m.ProcessText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width}) case "n": m.search.NextMatch(&m) - m.ProcessText(tea.WindowSizeMsg{Height: m.viewport.Height + HeightOffset, Width: m.viewport.Width}) + m.ProcessText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width}) case "q", "ctrl+c", "esc": return m, tea.Quit }