Skip to content
Myr

chore: update to bubbletea v2 (#1112)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Drew Smirnoff · committed by GitHub · parent 7423ddf · Browse files · 33 files+383 added−315 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Signed-off-by: drew <me@andrinoff.com>

Diff stats

33 files+383 added−315 removed

  • other:+383 added−315 removed

33 files+383 added−315 removed

modified:choose/choose.go+20 added-11 removed
11 unmodified lines
1213import (14 "strings"1516 "github.com/charmbracelet/bubbles/help"17 "github.com/charmbracelet/bubbles/key"18 "github.com/charmbracelet/bubbles/paginator"19 tea "github.com/charmbracelet/bubbletea"20 "github.com/charmbracelet/lipgloss"16 "charm.land/bubbles/v2/help"17 "charm.land/bubbles/v2/key"18 "charm.land/bubbles/v2/paginator"19 tea "charm.land/bubbletea/v2"20 "charm.land/lipgloss/v2"21 "github.com/charmbracelet/x/exp/ordered"22)2324func defaultKeymap() keymap {
86 unmodified lines
111 limit int112 numSelected int113 currentOrder int114 paginator paginator.Model115 hasDarkBG bool116 showHelp bool117 help help.Model118 keymap keymap119
9 unmodified lines
129 selected bool130 order int131}132132func (m model) Init() tea.Cmd { return nil }133func (m model) Init() tea.Cmd { return tea.RequestBackgroundColor }134135func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {136 switch msg := msg.(type) {137 case tea.BackgroundColorMsg:138 m.hasDarkBG = msg.IsDark()139 return m, nil140 case tea.WindowSizeMsg:141 return m, nil142139 case tea.KeyMsg:143 case tea.KeyPressMsg:144 start, end := m.paginator.GetSliceBounds(len(m.items))145 km := m.keymap146 switch {147 case key.Matches(msg, km.Down):
95 unmodified lines
243 m.currentOrder = 0244 return m245}246243func (m model) View() string {247func (m model) View() tea.View {248 if m.quitting {245 return ""249 return tea.NewView("")250 }251252 var s strings.Builder253
17 unmodified lines
271 }272 }273274 if m.paginator.TotalPages > 1 {275 lightDark := lipgloss.LightDark(m.hasDarkBG)276 subduedStyle := lipgloss.NewStyle().Foreground(lightDark(lipgloss.Color("#847A85"), lipgloss.Color("#979797")))277 verySubduedStyle := lipgloss.NewStyle().Foreground(lightDark(lipgloss.Color("#DDDADA"), lipgloss.Color("#3C3C3C")))278 m.paginator.ActiveDot = subduedStyle.Render("•")279 m.paginator.InactiveDot = verySubduedStyle.Render("•")280 s.WriteString(strings.Repeat("\n", m.height-m.paginator.ItemsOnPage(len(m.items))+1))281 s.WriteString(" " + m.paginator.View())282 }283
7 unmodified lines
291 parts = append(parts, "", m.help.View(m.keymap))292 }293294 view := lipgloss.JoinVertical(lipgloss.Left, parts...)286 return lipgloss.NewStyle().295 return tea.NewView(lipgloss.NewStyle().296 Padding(m.padding...).288 Render(view)297 Render(view))298}
modified:choose/command.go+3 added-11 removed
6 unmodified lines
7 "slices"8 "sort"9 "strings"1011 "github.com/charmbracelet/bubbles/help"12 "github.com/charmbracelet/bubbles/paginator"13 tea "github.com/charmbracelet/bubbletea"11 "charm.land/bubbles/v2/help"12 "charm.land/bubbles/v2/paginator"13 tea "charm.land/bubbletea/v2"14 "github.com/charmbracelet/gum/internal/stdin"15 "github.com/charmbracelet/gum/internal/timeout"16 "github.com/charmbracelet/gum/internal/tty"17 "github.com/charmbracelet/gum/style"18 "github.com/charmbracelet/lipgloss"18)1920// Run provides a shell script interface for choosing between different through21// options.22func (o Options) Run() error {24 var (25 subduedStyle = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#847A85", Dark: "#979797"})26 verySubduedStyle = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#DDDADA", Dark: "#3C3C3C"})27 )2823 input, _ := stdin.Read(stdin.StripANSI(o.StripANSI))24 if len(o.Options) > 0 && len(o.Selected) == 0 {25 o.Selected = strings.Split(input, o.InputDelimiter)26 } else if len(o.Options) == 0 {
79 unmodified lines
106 pager := paginator.New()107 pager.SetTotalPages((len(items) + o.Height - 1) / o.Height)108 pager.PerPage = o.Height109 pager.Type = paginator.Dots116 pager.ActiveDot = subduedStyle.Render("•")117 pager.InactiveDot = verySubduedStyle.Render("•")110 pager.KeyMap = paginator.KeyMap{}111 pager.Page = startingIndex / o.Height112113 km := defaultKeymap()
61 unmodified lines
modified:confirm/command.go+2 added-2 removed
3 unmodified lines
4 "context"5 "fmt"6 "os"78 "github.com/charmbracelet/bubbles/help"9 tea "github.com/charmbracelet/bubbletea"8 "charm.land/bubbles/v2/help"9 tea "charm.land/bubbletea/v2"10 "github.com/charmbracelet/gum/internal/exit"11 "github.com/charmbracelet/gum/internal/stdin"12 "github.com/charmbracelet/gum/internal/timeout"13 "github.com/charmbracelet/gum/style"
58 unmodified lines
modified:confirm/confirm.go+9 added-9 removed
9 unmodified lines
10// $ gum confirm "Are you sure?" && rm file.txt11package confirm1213import (14 "github.com/charmbracelet/bubbles/help"15 "github.com/charmbracelet/bubbles/key"14 "charm.land/bubbles/v2/help"15 "charm.land/bubbles/v2/key"1617 tea "github.com/charmbracelet/bubbletea"18 "github.com/charmbracelet/lipgloss"17 tea "charm.land/bubbletea/v2"18 "charm.land/lipgloss/v2"19)2021func defaultKeymap(affirmative, negative string) keymap {22 return keymap{
76 unmodified lines
99func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {100 switch msg := msg.(type) {101 case tea.WindowSizeMsg:102 return m, nil103 case tea.KeyMsg:103 case tea.KeyPressMsg:104 switch {105 case key.Matches(msg, m.keys.Abort):106 m.confirmation = false107 return m, tea.Interrupt
21 unmodified lines
129 }130 return m, nil131}132133func (m model) View() string {133func (m model) View() tea.View {134 if m.quitting {135 return ""135 return tea.NewView("")136 }137138 var aff, neg string139
18 unmodified lines
158 if m.showHelp {159 parts = append(parts, "", m.help.View(m.keys))160 }161162 return lipgloss.NewStyle().162 return tea.NewView(lipgloss.NewStyle().163 Padding(m.padding...).164 Render(lipgloss.JoinVertical(165 lipgloss.Left,166 parts...,167 ))167 )))168}
modified:cursor/cursor.go+19 added-6 removed
1// Package cursor provides cursor modes.2package cursor34import (5 "charm.land/bubbles/v2/textarea"6 "charm.land/bubbles/v2/textinput"5 "github.com/charmbracelet/bubbles/cursor"7 "github.com/charmbracelet/gum/style"8)98// Modes maps strings to cursor modes.9var Modes = map[string]cursor.Mode{10 "blink": cursor.CursorBlink,11 "hide": cursor.CursorHide,12 "static": cursor.CursorStatic,10// TextInput applies the given cursor mode and style to the text input.11func TextInput(i *textinput.Model, mode string, s style.Styles) {12 styles := i.Styles()13 styles.Cursor.Color = s.ToLipgloss().GetForeground()14 styles.Cursor.Blink = mode == "blink"15 i.SetStyles(styles)16 i.SetVirtualCursor(mode != "hide")17}1819// TextArea applies the given cursor mode and style to the text area.20func TextArea(a *textarea.Model, mode string, s style.Styles) {21 styles := a.Styles()22 styles.Cursor.Color = s.ToLipgloss().GetForeground()23 styles.Cursor.Blink = mode == "blink"24 a.SetStyles(styles)25 a.SetVirtualCursor(mode != "hide")26}
modified:file/command.go+4 added-4 removed
4 unmodified lines
5 "fmt"6 "os"7 "path/filepath"89 "github.com/charmbracelet/bubbles/filepicker"10 "github.com/charmbracelet/bubbles/help"11 tea "github.com/charmbracelet/bubbletea"9 "charm.land/bubbles/v2/filepicker"10 "charm.land/bubbles/v2/help"11 tea "charm.land/bubbletea/v2"12 "github.com/charmbracelet/gum/internal/timeout"13 "github.com/charmbracelet/gum/style"14)15
45 unmodified lines
61 ctx, cancel := timeout.Context(o.Timeout)62 defer cancel()6364 tm, err := tea.NewProgram(65 &m,65 m,66 tea.WithOutput(os.Stderr),67 tea.WithContext(ctx),68 ).Run()69 if err != nil {
10 unmodified lines
modified:file/file.go+10 added-10 removed
11 unmodified lines
12// $ gum file $HOME13package file1415import (16 "github.com/charmbracelet/bubbles/filepicker"17 "github.com/charmbracelet/bubbles/help"18 "github.com/charmbracelet/bubbles/key"19 tea "github.com/charmbracelet/bubbletea"20 "github.com/charmbracelet/lipgloss"16 "charm.land/bubbles/v2/filepicker"17 "charm.land/bubbles/v2/help"18 "charm.land/bubbles/v2/key"19 tea "charm.land/bubbletea/v2"20 "charm.land/lipgloss/v2"21)2223type keymap filepicker.KeyMap24
48 unmodified lines
73 if m.showHelp {74 height -= lipgloss.Height(m.helpView())75 }76 m.filepicker.SetHeight(height)77 case tea.KeyMsg:77 case tea.KeyPressMsg:78 switch {79 case key.Matches(msg, keyAbort):80 m.quitting = true81 return m, tea.Interrupt
11 unmodified lines
93 }94 return m, cmd95}9697func (m model) View() string {97func (m model) View() tea.View {98 if m.quitting {99 return ""99 return tea.NewView("")100 }101 var parts []string102 if m.header != "" {103 parts = append(parts, m.headerStyle.Render(m.header))
1 unmodified line
105 parts = append(parts, m.filepicker.View())106 if m.showHelp {107 parts = append(parts, m.helpView())108 }109 return lipgloss.NewStyle().109 return tea.NewView(lipgloss.NewStyle().110 Padding(m.padding...).111 Render(lipgloss.JoinVertical(112 lipgloss.Left,113 parts...,114 ))114 )))115}116117func (m model) helpView() string {118 return m.help.View(m.keymap)
1 unmodified line
modified:filter/command.go+12 added-12 removed
5 unmodified lines
6 "os"7 "slices"8 "strings"910 "github.com/charmbracelet/bubbles/help"11 "github.com/charmbracelet/bubbles/textinput"12 "github.com/charmbracelet/bubbles/viewport"13 tea "github.com/charmbracelet/bubbletea"10 "charm.land/bubbles/v2/help"11 "charm.land/bubbles/v2/textinput"12 "charm.land/bubbles/v2/viewport"13 tea "charm.land/bubbletea/v2"14 "github.com/charmbracelet/gum/internal/files"15 "github.com/charmbracelet/gum/internal/stdin"16 "github.com/charmbracelet/gum/internal/timeout"17 "github.com/charmbracelet/gum/internal/tty"
8 unmodified lines
26 i := textinput.New()27 i.Focus()2829 i.Prompt = o.Prompt30 i.PromptStyle = o.PromptStyle.ToLipgloss()31 i.PlaceholderStyle = o.PlaceholderStyle.ToLipgloss()30 styles := i.Styles()31 styles.Focused.Prompt = o.PromptStyle.ToLipgloss()32 styles.Blurred.Prompt = o.PromptStyle.ToLipgloss()33 styles.Focused.Placeholder = o.PlaceholderStyle.ToLipgloss()34 styles.Blurred.Placeholder = o.PlaceholderStyle.ToLipgloss()35 i.SetStyles(styles)36 i.Placeholder = o.Placeholder33 i.Width = o.Width37 i.SetWidth(o.Width)3835 v := viewport.New(o.Width, o.Height)39 v := viewport.New(viewport.WithWidth(o.Width), viewport.WithHeight(o.Height))4041 if len(o.Options) == 0 {42 if input, _ := stdin.Read(stdin.StripANSI(o.StripANSI)); input != "" {43 o.Options = strings.Split(input, o.InputDelimiter)
10 unmodified lines
54 defer cancel()5556 options := []tea.ProgramOption{57 tea.WithOutput(os.Stderr),54 tea.WithReportFocus(),58 tea.WithContext(ctx),59 }57 if o.Height == 0 {58 options = append(options, tea.WithAltScreen())59 }6061 var matches []fuzzy.Match62 if o.Value != "" {63 i.SetValue(o.Value)
111 unmodified lines
modified:filter/filter.go+57 added-43 removed
11 unmodified lines
1213import (14 "strings"1516 "github.com/charmbracelet/bubbles/help"17 "github.com/charmbracelet/bubbles/key"18 "github.com/charmbracelet/bubbles/textinput"19 "github.com/charmbracelet/bubbles/viewport"20 tea "github.com/charmbracelet/bubbletea"21 "github.com/charmbracelet/lipgloss"16 "charm.land/bubbles/v2/help"17 "charm.land/bubbles/v2/key"18 "charm.land/bubbles/v2/textinput"19 "charm.land/bubbles/v2/viewport"20 tea "charm.land/bubbletea/v2"21 "charm.land/lipgloss/v2"22 "github.com/charmbracelet/x/exp/ordered"23 "github.com/rivo/uniseg"24 "github.com/sahilm/fuzzy"25)
132 unmodified lines
158}159160func (m model) Init() tea.Cmd { return textinput.Blink }161162func (m model) View() string {162func (m model) View() tea.View {163 if m.quitting {164 return ""164 return tea.NewView("")165 }166167 var s strings.Builder168 var lineTextStyle lipgloss.Style169170 // For reverse layout, if the number of matches is less than the viewport171 // height, we need to offset the matches so that the first match is at the172 // bottom edge of the viewport instead of in the middle.173 if m.reverse && len(m.matches) < m.viewport.Height {174 s.WriteString(strings.Repeat("\n", m.viewport.Height-len(m.matches)))173 if m.reverse && len(m.matches) < m.viewport.Height() {174 s.WriteString(strings.Repeat("\n", m.viewport.Height()-len(m.matches)))175 }176177 // Since there are matches, display them so that the user can see, in real178 // time, what they are searching for.
54 unmodified lines
233 m.viewport.SetContent(s.String())234235 // View the input and the filtered choices236 header := m.headerStyle.Render(m.header)237 var content string238 if m.reverse {238 view := m.viewport.View()239 if m.header != "" {240 view += "\n" + header241 }242 view += "\n" + m.textinput.View()243 if m.showHelp {244 view += m.helpView()245 }246 return lipgloss.NewStyle().247 Padding(m.padding...).248 Render(view)239 content = m.reverseView(header)240 } else {241 content = m.normalView(header)242 }243 v := tea.NewView(content)244 v.ReportFocus = true245 if m.height == 0 {246 v.AltScreen = true247 }248 return v249}250251func (m model) reverseView(header string) string {252 view := m.viewport.View()253 if m.header != "" {254 view += "\n" + header255 }256 view += "\n" + m.textinput.View()257 if m.showHelp {258 view += m.helpView()259 }260 return lipgloss.NewStyle().261 Padding(m.padding...).262 Render(view)263}264265func (m model) normalView(header string) string {266 view := m.textinput.View() + "\n" + m.viewport.View()267 if m.showHelp {268 view += m.helpView()269 }
1 unmodified line
271 return lipgloss.NewStyle().272 Padding(m.padding...).273 Render(header + "\n" + view)274 }260275 return lipgloss.NewStyle().276 Padding(m.padding...).277 Render(view)278}
7 unmodified lines
286 m.textinput, icmd = m.textinput.Update(msg)287 switch msg := msg.(type) {288 case tea.WindowSizeMsg:289 if m.height == 0 || m.height > msg.Height {276 m.viewport.Height = msg.Height - lipgloss.Height(m.textinput.View())290 m.viewport.SetHeight(msg.Height - lipgloss.Height(m.textinput.View()))291 }292 // Include the header in the height calculation.293 if m.header != "" {280 m.viewport.Height = m.viewport.Height - lipgloss.Height(m.headerStyle.Render(m.header))294 m.viewport.SetHeight(m.viewport.Height() - lipgloss.Height(m.headerStyle.Render(m.header)))295 }296 // Include the help in the total height calculation.297 if m.showHelp {284 m.viewport.Height = m.viewport.Height - lipgloss.Height(m.helpView())298 m.viewport.SetHeight(m.viewport.Height() - lipgloss.Height(m.helpView()))299 }286 m.viewport.Height = m.viewport.Height - m.padding[0] - m.padding[2]287 m.viewport.Width = msg.Width - m.padding[1] - m.padding[3]288 m.textinput.Width = msg.Width - m.padding[1] - m.padding[3]300 m.viewport.SetHeight(m.viewport.Height() - m.padding[0] - m.padding[2])301 m.viewport.SetWidth(msg.Width - m.padding[1] - m.padding[3])302 m.textinput.SetWidth(msg.Width - m.padding[1] - m.padding[3])303 if m.reverse {290 m.viewport.YOffset = ordered.Clamp(len(m.matches)-m.viewport.Height, 0, len(m.matches))304 m.viewport.SetYOffset(ordered.Clamp(len(m.matches)-m.viewport.Height(), 0, len(m.matches)))305 }292 case tea.KeyMsg:306 case tea.KeyPressMsg:307 km := m.keymap308 switch {309 case key.Matches(msg, km.FocusInSearch):310 m.textinput.Focus()
51 unmodified lines
362 // at a constant position when the number of matches are reduced363 // in the reverse layout.364 var yOffsetFromBottom int365 if m.reverse {352 yOffsetFromBottom = max(0, len(m.matches)-m.viewport.YOffset)366 yOffsetFromBottom = max(0, len(m.matches)-m.viewport.YOffset())367 }368369 // A character was entered, this likely means that the text input has370 // changed. This suggests that the matches are outdated, so update them.
20 unmodified lines
391392 // For reverse layout, we need to offset the viewport so that the393 // it remains at a constant position relative to the cursor.394 if m.reverse {381 maxYOffset := max(0, len(m.matches)-m.viewport.Height)382 m.viewport.YOffset = ordered.Clamp(len(m.matches)-yOffsetFromBottom, 0, maxYOffset)395 maxYOffset := max(0, len(m.matches)-m.viewport.Height())396 m.viewport.SetYOffset(ordered.Clamp(len(m.matches)-yOffsetFromBottom, 0, maxYOffset))397 }398 }399 }400
15 unmodified lines
416 return417 }418 if m.reverse { //nolint:nestif419 m.cursor = (m.cursor + 1) % len(m.matches)406 if len(m.matches)-m.cursor <= m.viewport.YOffset {420 if len(m.matches)-m.cursor <= m.viewport.YOffset() {421 m.viewport.ScrollUp(1)422 }409 if len(m.matches)-m.cursor > m.viewport.Height+m.viewport.YOffset {410 m.viewport.SetYOffset(len(m.matches) - m.viewport.Height)423 if len(m.matches)-m.cursor > m.viewport.Height()+m.viewport.YOffset() {424 m.viewport.SetYOffset(len(m.matches) - m.viewport.Height())425 }426 } else {427 m.cursor = (m.cursor - 1 + len(m.matches)) % len(m.matches)414 if m.cursor < m.viewport.YOffset {428 if m.cursor < m.viewport.YOffset() {429 m.viewport.ScrollUp(1)430 }417 if m.cursor >= m.viewport.YOffset+m.viewport.Height {418 m.viewport.SetYOffset(len(m.matches) - m.viewport.Height)431 if m.cursor >= m.viewport.YOffset()+m.viewport.Height() {432 m.viewport.SetYOffset(len(m.matches) - m.viewport.Height())433 }434 }435}436
2 unmodified lines
439 return440 }441 if m.reverse { //nolint:nestif442 m.cursor = (m.cursor - 1 + len(m.matches)) % len(m.matches)429 if len(m.matches)-m.cursor > m.viewport.Height+m.viewport.YOffset {443 if len(m.matches)-m.cursor > m.viewport.Height()+m.viewport.YOffset() {444 m.viewport.ScrollDown(1)445 }432 if len(m.matches)-m.cursor <= m.viewport.YOffset {446 if len(m.matches)-m.cursor <= m.viewport.YOffset() {447 m.viewport.GotoTop()448 }449 } else {450 m.cursor = (m.cursor + 1) % len(m.matches)437 if m.cursor >= m.viewport.YOffset+m.viewport.Height {451 if m.cursor >= m.viewport.YOffset()+m.viewport.Height() {452 m.viewport.ScrollDown(1)453 }440 if m.cursor < m.viewport.YOffset {454 if m.cursor < m.viewport.YOffset() {455 m.viewport.GotoTop()456 }457 }458}
105 unmodified lines
modified:format/command.go+4 added-1 removed
13 unmodified lines
14 "fmt"15 "strings"1617 "github.com/charmbracelet/gum/internal/stdin"18 "github.com/charmbracelet/gum/internal/tty"19)2021// Run runs the format command.22func (o Options) Run() error {
18 unmodified lines
41 if err != nil {42 return err43 }4444 fmt.Print(output)45 if _, err := fmt.Fprint(tty.Writer(), output); err != nil {46 return fmt.Errorf("unable to write output: %w", err)47 }48 return nil49}
modified:format/formats.go+50 added-5 removed
4 unmodified lines
5 "bytes"6 "fmt"7 tpl "text/template"89 "github.com/charmbracelet/glamour"10 "github.com/muesli/termenv"9 "charm.land/glamour/v2"10 "charm.land/lipgloss/v2"11)1213func code(input, language string) (string, error) {14 renderer, err := glamour.NewTermRenderer(15 glamour.WithAutoStyle(),15 glamour.WithEnvironmentConfig(),16 glamour.WithWordWrap(0),17 )18 if err != nil {19 return "", fmt.Errorf("unable to create renderer: %w", err)
34 unmodified lines
54 return output, nil55}5657func template(input string) (string, error) {58 f := termenv.TemplateFuncs(termenv.ANSI256)59 t, err := tpl.New("tpl").Funcs(f).Parse(input)58 t, err := tpl.New("tpl").Funcs(templateFuncs()).Parse(input)59 if err != nil {60 return "", fmt.Errorf("unable to parse template: %w", err)61 }6263 var buf bytes.Buffer64 err = t.Execute(&buf, nil)65 return buf.String(), err66}6768// templateFuncs returns a few useful template helpers for styling text.69func templateFuncs() tpl.FuncMap {70 return tpl.FuncMap{71 "Color": func(values ...any) string {72 s := lipgloss.NewStyle()73 switch len(values) {74 case 2:75 s = s.Foreground(lipgloss.Color(values[0].(string)))76 case 3:77 s = s.78 Foreground(lipgloss.Color(values[0].(string))).79 Background(lipgloss.Color(values[1].(string)))80 }81 return s.Render(values[len(values)-1].(string))82 },83 "Foreground": func(values ...any) string {84 s := lipgloss.NewStyle()85 if len(values) == 2 {86 s = s.Foreground(lipgloss.Color(values[0].(string)))87 }88 return s.Render(values[len(values)-1].(string))89 },90 "Background": func(values ...any) string {91 s := lipgloss.NewStyle()92 if len(values) == 2 {93 s = s.Background(lipgloss.Color(values[0].(string)))94 }95 return s.Render(values[len(values)-1].(string))96 },97 "Bold": styleFunc(func(s lipgloss.Style) lipgloss.Style { return s.Bold(true) }),98 "Faint": styleFunc(func(s lipgloss.Style) lipgloss.Style { return s.Faint(true) }),99 "Italic": styleFunc(func(s lipgloss.Style) lipgloss.Style { return s.Italic(true) }),100 "Underline": styleFunc(func(s lipgloss.Style) lipgloss.Style { return s.Underline(true) }),101 "Overline": styleFunc(func(s lipgloss.Style) lipgloss.Style { return s }),102 "Blink": styleFunc(func(s lipgloss.Style) lipgloss.Style { return s.Blink(true) }),103 "Reverse": styleFunc(func(s lipgloss.Style) lipgloss.Style { return s.Reverse(true) }),104 "CrossOut": styleFunc(func(s lipgloss.Style) lipgloss.Style { return s.Strikethrough(true) }),105 }106}107108func styleFunc(f func(lipgloss.Style) lipgloss.Style) func(...any) string {109 return func(values ...any) string {110 return f(lipgloss.NewStyle()).Render(values[0].(string))111 }112}
modified:input/command.go+11 added-9 removed
3 unmodified lines
4 "errors"5 "fmt"6 "os"78 "github.com/charmbracelet/bubbles/help"9 "github.com/charmbracelet/bubbles/textinput"10 tea "github.com/charmbracelet/bubbletea"8 "charm.land/bubbles/v2/help"9 "charm.land/bubbles/v2/textinput"10 tea "charm.land/bubbletea/v2"11 "github.com/charmbracelet/gum/cursor"12 "github.com/charmbracelet/gum/internal/stdin"13 "github.com/charmbracelet/gum/internal/timeout"14 "github.com/charmbracelet/gum/style"
16 unmodified lines
31 }32 i.Focus()33 i.Prompt = o.Prompt34 i.Placeholder = o.Placeholder35 i.Width = o.Width36 i.PromptStyle = o.PromptStyle.ToLipgloss()37 i.PlaceholderStyle = o.PlaceholderStyle.ToLipgloss()38 i.Cursor.Style = o.CursorStyle.ToLipgloss()39 i.Cursor.SetMode(cursor.Modes[o.CursorMode])35 i.SetWidth(o.Width)36 styles := i.Styles()37 styles.Focused.Prompt = o.PromptStyle.ToLipgloss()38 styles.Blurred.Prompt = o.PromptStyle.ToLipgloss()39 styles.Focused.Placeholder = o.PlaceholderStyle.ToLipgloss()40 styles.Blurred.Placeholder = o.PlaceholderStyle.ToLipgloss()41 i.SetStyles(styles)42 cursor.TextInput(&i, o.CursorMode, o.CursorStyle)43 i.CharLimit = o.CharLimit4445 if o.Password {46 i.EchoMode = textinput.EchoPassword
17 unmodified lines
6465 p := tea.NewProgram(66 m,67 tea.WithOutput(os.Stderr),65 tea.WithReportFocus(),68 tea.WithContext(ctx),69 )70 tm, err := p.Run()71 if err != nil {
10 unmodified lines
modified:input/input.go+15 added-13 removed
6 unmodified lines
7// $ gum input --placeholder "What's your favorite gum?" > answer.text8package input910import (11 "github.com/charmbracelet/bubbles/help"12 "github.com/charmbracelet/bubbles/key"13 "github.com/charmbracelet/bubbles/textinput"14 tea "github.com/charmbracelet/bubbletea"15 "github.com/charmbracelet/lipgloss"11 "charm.land/bubbles/v2/help"12 "charm.land/bubbles/v2/key"13 "charm.land/bubbles/v2/textinput"14 tea "charm.land/bubbletea/v2"15 "charm.land/lipgloss/v2"16)1718type keymap textinput.KeyMap1920func defaultKeymap() keymap {21 k := textinput.DefaultKeyMap21 k := textinput.DefaultKeyMap()22 return keymap(k)23}2425// FullHelp implements help.KeyMap.
23 unmodified lines
49}5051func (m model) Init() tea.Cmd { return textinput.Blink }5253func (m model) View() string {53func (m model) View() tea.View {54 if m.quitting {55 return ""55 return tea.NewView("")56 }57 var parts []string58 if m.header != "" {59 parts = append(parts, m.headerStyle.Render(m.header))
2 unmodified lines
62 parts = append(parts, m.textinput.View())63 if m.showHelp {64 parts = append(parts, "", m.help.View(m.keymap))65 }66 return lipgloss.NewStyle().66 v := tea.NewView(lipgloss.NewStyle().67 Padding(m.padding...).68 Render(lipgloss.JoinVertical(69 lipgloss.Top,70 parts...,71 ))71 )))72 v.ReportFocus = true73 return v74}7576func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {77 switch msg := msg.(type) {78 case tea.WindowSizeMsg:79 if m.autoWidth {78 m.textinput.Width = msg.Width - 1 -80 m.textinput.SetWidth(msg.Width - 1 -81 lipgloss.Width(m.textinput.Prompt) -80 m.padding[1] - m.padding[3]82 m.padding[1] - m.padding[3])83 }82 case tea.KeyMsg:84 case tea.KeyPressMsg:85 switch msg.String() {86 case "ctrl+c":87 m.quitting = true88 return m, tea.Interrupt
14 unmodified lines
modified:internal/decode/align.go+1 added-1 removed
1// Package decode position strings to lipgloss.2package decode34import "github.com/charmbracelet/lipgloss"4import "charm.land/lipgloss/v2"56// Align maps strings to `lipgloss.Position`s.7var Align = map[string]lipgloss.Position{8 "center": lipgloss.Center,
5 unmodified lines
modified:internal/tty/tty.go+12 added-9 removed
1 unmodified line
2package tty34import (5 "fmt"6 "io"7 "os"8 "sync"99 "github.com/charmbracelet/x/ansi"10 "github.com/charmbracelet/x/term"10 "github.com/charmbracelet/colorprofile"11)1213var isTTY = sync.OnceValue(func() bool {14 return term.IsTerminal(os.Stdout.Fd())13var stdout = sync.OnceValue(func() io.Writer {14 return colorprofile.NewWriter(os.Stdout, os.Environ())15})1617// Writer returns a writer to stdout that downgrades or strips ansi18// sequences according to the environment (NO_COLOR, CLICOLOR, CLICOLOR_FORCE)19// and the capabilities of the terminal.20func Writer() io.Writer {21 return stdout()22}2324// Println handles println, striping ansi sequences if stdout is not a tty.25func Println(s string) {19 if isTTY() {20 fmt.Println(s)21 return22 }23 fmt.Println(ansi.Strip(s))26 _, _ = fmt.Fprintln(stdout(), s)27}
modified:join/command.go+3 added-4 removed
14 unmodified lines
15// ╚══════════════════════╝╚═════════════╝16package join1718import (19 "fmt"19 "charm.land/lipgloss/v2"2021 "github.com/charmbracelet/lipgloss"2221 "github.com/charmbracelet/gum/internal/decode"22 "github.com/charmbracelet/gum/internal/tty"23)2425// Run is the command-line interface for the joining strings through lipgloss.26func (o Options) Run() error {27 join := lipgloss.JoinHorizontal28 if o.Vertical {29 join = lipgloss.JoinVertical30 }32 fmt.Println(join(decode.Align[o.Align], o.Text...))31 tty.Println(join(decode.Align[o.Align], o.Text...))32 return nil33}
modified:log/command.go+7 added-7 removed
6 unmodified lines
7 "os"8 "strings"9 "time"1011 "github.com/charmbracelet/lipgloss"12 "github.com/charmbracelet/log"11 "charm.land/lipgloss/v2"12 log "charm.land/log/v2"13)1415// Run is the command-line interface for logging text.16func (o Options) Run() error {
51 unmodified lines
6869 st := log.DefaultStyles()70 lvl := levelToLog[o.Level]71 lvlStyle := o.LevelStyle.ToLipgloss()72 if lvlStyle.GetForeground() == lipgloss.Color("") {72 if fg := lvlStyle.GetForeground(); fg == nil || fg == lipgloss.Color("") {73 lvlStyle = lvlStyle.Foreground(st.Levels[lvl].GetForeground())74 }7576 st.Levels[lvl] = lvlStyle.
24 unmodified lines
101 l.SetFormatter(log.TextFormatter)102 }103104 var arg0 string105 var args []interface{}105 var args []any106 if len(o.Text) > 0 {107 arg0 = o.Text[0]108 }109110 if len(o.Text) > 1 {111 args = make([]interface{}, len(o.Text[1:]))111 args = make([]any, len(o.Text[1:]))112 for i, arg := range o.Text[1:] {113 args[i] = arg114 }115 }
18 unmodified lines
134 return nil135}136137type logger struct {138 printf func(string, ...interface{})139 print func(interface{}, ...interface{})138 printf func(string, ...any)139 print func(any, ...any)140}141142var levelToLog = map[string]log.Level{143 "none": log.Level(math.MaxInt32),
6 unmodified lines
modified:pager/command.go+4 added-6 removed
2 unmodified lines
3import (4 "fmt"5 "regexp"67 "github.com/charmbracelet/bubbles/help"8 "github.com/charmbracelet/bubbles/viewport"9 tea "github.com/charmbracelet/bubbletea"7 "charm.land/bubbles/v2/help"8 "charm.land/bubbles/v2/viewport"9 tea "charm.land/bubbletea/v2"10 "github.com/charmbracelet/gum/internal/stdin"11 "github.com/charmbracelet/gum/internal/timeout"12)1314// Run provides a shell script interface for the viewport bubble.15// https://github.com/charmbracelet/bubbles/viewport16func (o Options) Run() error {17 vp := viewport.New(o.Style.Width, o.Style.Height)17 vp := viewport.New(viewport.WithWidth(o.Style.Width), viewport.WithHeight(o.Style.Height))18 vp.Style = o.Style.ToLipgloss()1920 if o.Content == "" {21 stdin, err := stdin.Read()
26 unmodified lines
48 defer cancel()4950 _, err := tea.NewProgram(51 m,52 tea.WithAltScreen(),53 tea.WithReportFocus(),52 tea.WithContext(ctx),53 ).Run()54 if err != nil {55 return fmt.Errorf("unable to start program: %w", err)
4 unmodified lines
modified:pager/pager.go+24 added-19 removed
5 unmodified lines
6import (7 "fmt"8 "strings"910 "github.com/charmbracelet/bubbles/help"11 "github.com/charmbracelet/bubbles/key"12 "github.com/charmbracelet/bubbles/textinput"13 "github.com/charmbracelet/bubbles/viewport"14 tea "github.com/charmbracelet/bubbletea"15 "github.com/charmbracelet/lipgloss"10 "charm.land/bubbles/v2/help"11 "charm.land/bubbles/v2/key"12 "charm.land/bubbles/v2/textinput"13 "charm.land/bubbles/v2/viewport"14 tea "charm.land/bubbletea/v2"15 "charm.land/lipgloss/v2"16 "github.com/charmbracelet/x/ansi"17)1819type keymap struct {
88 unmodified lines
108func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {109 switch msg := msg.(type) {110 case tea.WindowSizeMsg:111 m.processText(msg)112 case tea.KeyMsg:112 case tea.KeyPressMsg:113 return m.keyHandler(msg)114 }115116 m.keymap.PrevMatch.SetEnabled(m.search.query != nil)
8 unmodified lines
125 return m.help.View(m.keymap)126}127128func (m *model) processText(msg tea.WindowSizeMsg) {129 m.viewport.Height = msg.Height - lipgloss.Height(m.helpView())130 m.viewport.Width = msg.Width131 textStyle := lipgloss.NewStyle().Width(m.viewport.Width)129 m.viewport.SetHeight(msg.Height - lipgloss.Height(m.helpView()))130 m.viewport.SetWidth(msg.Width)131 textStyle := lipgloss.NewStyle().Width(m.viewport.Width())132 var text strings.Builder133134 // Determine max width of a line.135 m.maxWidth = m.viewport.Width135 m.maxWidth = m.viewport.Width()136 if m.softWrap {137 vpStyle := m.viewport.Style138 m.maxWidth -= vpStyle.GetHorizontalBorderSize() + vpStyle.GetHorizontalMargins() + vpStyle.GetHorizontalPadding()139 if m.showLineNumbers {
22 unmodified lines
162 text.WriteString("\n")163 }164 }165166 diffHeight := m.viewport.Height - lipgloss.Height(text.String())166 diffHeight := m.viewport.Height() - lipgloss.Height(text.String())167 if diffHeight > 0 && m.showLineNumbers {168 remainingLines := " ~ │ " + strings.Repeat("\n ~ │ ", diffHeight-1)169 text.WriteString(m.lineNumberStyle.Render(remainingLines))170 }
1 unmodified line
172}173174const heightOffset = 2175176func (m model) keyHandler(msg tea.KeyMsg) (model, tea.Cmd) {176func (m model) keyHandler(msg tea.KeyPressMsg) (model, tea.Cmd) {177 km := m.keymap178 var cmd tea.Cmd179 if m.search.active {180 switch {
3 unmodified lines
184 m.search.Execute(&m)185186 // Trigger a view update to highlight the found matches.187 m.search.NextMatch(&m)188 m.processText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width})188 m.processText(tea.WindowSizeMsg{Height: m.viewport.Height() + heightOffset, Width: m.viewport.Width()})189 } else {190 m.search.Done()191 }192 case key.Matches(msg, km.CancelSearch):
11 unmodified lines
204 m.search.Begin()205 return m, textinput.Blink206 case key.Matches(msg, km.PrevMatch):207 m.search.PrevMatch(&m)208 m.processText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width})208 m.processText(tea.WindowSizeMsg{Height: m.viewport.Height() + heightOffset, Width: m.viewport.Width()})209 case key.Matches(msg, km.NextMatch):210 m.search.NextMatch(&m)211 m.processText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width})211 m.processText(tea.WindowSizeMsg{Height: m.viewport.Height() + heightOffset, Width: m.viewport.Width()})212 case key.Matches(msg, km.Quit):213 return m, tea.Quit214 case key.Matches(msg, km.Abort):215 return m, tea.Interrupt
3 unmodified lines
219220 return m, cmd221}222223func (m model) View() string {223func (m model) View() tea.View {224 v := tea.NewView("")225 v.AltScreen = true226 v.ReportFocus = true227 if m.search.active {225 return m.viewport.View() + "\n " + m.search.input.View()228 v.SetContent(m.viewport.View() + "\n " + m.search.input.View())229 return v230 }231228 return m.viewport.View() + "\n" + m.helpView()232 v.SetContent(m.viewport.View() + "\n" + m.helpView())233 return v234}
modified:pager/search.go+8 added-5 removed
3 unmodified lines
4 "fmt"5 "regexp"6 "strings"78 "github.com/charmbracelet/bubbles/textinput"9 "github.com/charmbracelet/lipgloss"8 "charm.land/bubbles/v2/textinput"9 "charm.land/lipgloss/v2"10 "github.com/charmbracelet/x/ansi"11)1213type search struct {
8 unmodified lines
22func (s *search) new() {23 input := textinput.New()24 input.Placeholder = "search"25 input.Prompt = "/"26 styles := input.Styles()26 input.PromptStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("240"))27 styles.Focused.Prompt = lipgloss.NewStyle().Foreground(lipgloss.Color("240"))28 styles.Blurred.Prompt = lipgloss.NewStyle().Foreground(lipgloss.Color("240"))29 input.SetStyles(styles)30 s.input = input31}3233func (s *search) Begin() {
67 unmodified lines
101 line = strings.Count(formatStr[:index], "\n")102 }103104 // Only update if the match is not within the viewport.102 if index != -1 && (line > m.viewport.YOffset-1+m.viewport.VisibleLineCount()-1 || line < m.viewport.YOffset) {105 if index != -1 && (line > m.viewport.YOffset()-1+m.viewport.VisibleLineCount()-1 || line < m.viewport.YOffset()) {106 m.viewport.SetYOffset(line)107 }108}109
33 unmodified lines
143 line = strings.Count(formatStr[:index], "\n")144 }145146 // Only update if the match is not within the viewport.144 if index != -1 && (line > m.viewport.YOffset-1+m.viewport.VisibleLineCount()-1 || line < m.viewport.YOffset) {147 if index != -1 && (line > m.viewport.YOffset()-1+m.viewport.VisibleLineCount()-1 || line < m.viewport.YOffset()) {148 m.viewport.SetYOffset(line)149 }150}151
27 unmodified lines
modified:spin/command.go+2 added-2 removed
2 unmodified lines
3import (4 "fmt"5 "os"67 "github.com/charmbracelet/bubbles/spinner"8 tea "github.com/charmbracelet/bubbletea"7 "charm.land/bubbles/v2/spinner"8 tea "charm.land/bubbletea/v2"9 "github.com/charmbracelet/gum/internal/exit"10 "github.com/charmbracelet/gum/internal/timeout"11 "github.com/charmbracelet/gum/style"12 "github.com/charmbracelet/x/term"
70 unmodified lines
modified:spin/spin.go+9 added-9 removed
21 unmodified lines
22 "os/exec"23 "runtime"24 "syscall"2526 "github.com/charmbracelet/bubbles/spinner"27 tea "github.com/charmbracelet/bubbletea"28 "github.com/charmbracelet/lipgloss"26 "charm.land/bubbles/v2/spinner"27 tea "charm.land/bubbletea/v2"28 "charm.land/lipgloss/v2"29 "github.com/charmbracelet/x/term"30 "github.com/charmbracelet/x/xpty"31)32
112 unmodified lines
145 commandStart(m.command),146 )147}148149func (m model) View() string {149func (m model) View() tea.View {150 if m.quitting {151 return ""151 return tea.NewView("")152 }153154 var out string155 if m.showStderr {
3 unmodified lines
159 out += outbuf.String()160 }161162 if !m.isTTY {163 return m.title163 return tea.NewView(m.title)164 }165166 var header string167 if m.align == "left" {168 header = m.spinner.View() + " " + m.title169 } else {170 header = m.title + " " + m.spinner.View()171 }172 return lipgloss.NewStyle().172 return tea.NewView(lipgloss.NewStyle().173 Padding(m.padding...).174 Render(header, "", out)174 Render(header, "", out))175}176177func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {178 switch msg := msg.(type) {
3 unmodified lines
182 m.output = msg.output183 m.status = msg.status184 m.quitting = true185 return m, tea.Quit186 case tea.KeyMsg:186 case tea.KeyPressMsg:187 switch msg.String() {188 case "ctrl+c":189 return m, commandAbort190 }
10 unmodified lines
modified:spin/spinners.go+1 added-1 removed
1package spin23import "github.com/charmbracelet/bubbles/spinner"3import "charm.land/bubbles/v2/spinner"45var spinnerMap = map[string]spinner.Spinner{6 "line": spinner.Line,7 "dot": spinner.Dot,
10 unmodified lines
modified:style/borders.go+1 added-1 removed
1package style23import "github.com/charmbracelet/lipgloss"3import "charm.land/lipgloss/v2"45// Border maps strings to `lipgloss.Border`s.6var Border map[string]lipgloss.Border = map[string]lipgloss.Border{7 "double": lipgloss.DoubleBorder(),
6 unmodified lines
modified:style/command.go+2 added-2 removed
5 unmodified lines
6package style78import (9 "errors"10 "fmt"10 "strings"1112 "github.com/charmbracelet/gum/internal/stdin"13 "github.com/charmbracelet/gum/internal/tty"14)1516// Run provides a shell script interface for the Lip Gloss styling.17// https://github.com/charmbracelet/lipgloss
13 unmodified lines
31 lines = append(lines, strings.TrimSpace(line))32 }33 text = strings.Join(lines, "\n")34 }35 fmt.Println(o.Style.ToLipgloss().Render(text))35 tty.Println(o.Style.ToLipgloss().Render(text))36 return nil37}
modified:style/lipgloss.go+1 added-1 removed
1package style23import (4 "github.com/charmbracelet/lipgloss"4 "charm.land/lipgloss/v2"56 "github.com/charmbracelet/gum/internal/decode"7)8
41 unmodified lines
modified:table/command.go+7 added-6 removed
3 unmodified lines
4 "encoding/csv"5 "fmt"6 "os"78 "github.com/charmbracelet/bubbles/help"9 "github.com/charmbracelet/bubbles/table"10 tea "github.com/charmbracelet/bubbletea"8 "charm.land/bubbles/v2/help"9 "charm.land/bubbles/v2/table"10 tea "charm.land/bubbletea/v2"11 "charm.land/lipgloss/v2"12 ltable "charm.land/lipgloss/v2/table"13 "github.com/charmbracelet/gum/internal/stdin"14 "github.com/charmbracelet/gum/internal/timeout"15 "github.com/charmbracelet/gum/internal/tty"16 "github.com/charmbracelet/gum/style"14 "github.com/charmbracelet/lipgloss"15 ltable "github.com/charmbracelet/lipgloss/table"17 "golang.org/x/text/encoding"18 "golang.org/x/text/encoding/unicode"19 "golang.org/x/text/transform"20)
102 unmodified lines
123 }124 return styles.Cell125 })126126 fmt.Println(table.Render())127 tty.Println(table.Render())128 return nil129 }130131 opts := []table.Option{
50 unmodified lines
modified:table/table.go+10 added-10 removed
16 unmodified lines
17import (18 "fmt"19 "strconv"2021 "github.com/charmbracelet/bubbles/help"22 "github.com/charmbracelet/bubbles/key"23 "github.com/charmbracelet/bubbles/table"24 tea "github.com/charmbracelet/bubbletea"25 "github.com/charmbracelet/lipgloss"21 "charm.land/bubbles/v2/help"22 "charm.land/bubbles/v2/key"23 "charm.land/bubbles/v2/table"24 tea "charm.land/bubbletea/v2"25 "charm.land/lipgloss/v2"26)2728type keymap struct {29 Navigate,
65 unmodified lines
95func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {96 var cmd tea.Cmd9798 switch msg := msg.(type) {99 case tea.KeyMsg:99 case tea.KeyPressMsg:100 km := m.keymap101 switch {102 case key.Matches(msg, km.Select):103 m.selected = m.table.SelectedRow()
11 unmodified lines
115 m.table, cmd = m.table.Update(msg)116 return m, cmd117}118119func (m model) View() string {119func (m model) View() tea.View {120 if m.quitting {121 return ""121 return tea.NewView("")122 }123 s := m.table.View()124 if m.showHelp {125 s += "\n" + m.countView() + m.help.View(m.keymap)126 }127 return lipgloss.NewStyle().127 return tea.NewView(lipgloss.NewStyle().128 Padding(m.padding...).129 Render(s)129 Render(s))130}131132func numLen(i int) int {133 if i == 0 {
9 unmodified lines
modified:write/command.go+9 added-9 removed
4 unmodified lines
5 "fmt"6 "os"7 "strings"89 "github.com/charmbracelet/bubbles/help"10 "github.com/charmbracelet/bubbles/textarea"11 tea "github.com/charmbracelet/bubbletea"9 "charm.land/bubbles/v2/help"10 "charm.land/bubbles/v2/textarea"11 tea "charm.land/bubbletea/v2"12 "github.com/charmbracelet/gum/cursor"13 "github.com/charmbracelet/gum/internal/stdin"14 "github.com/charmbracelet/gum/internal/timeout"15 "github.com/charmbracelet/gum/style"
16 unmodified lines
32 a.CharLimit = o.CharLimit33 a.MaxHeight = o.MaxLines34 top, right, bottom, left := style.ParsePadding(o.Padding)3536 style := textarea.Style{36 taStyles := textarea.StyleState{37 Base: o.BaseStyle.ToLipgloss(),38 Placeholder: o.PlaceholderStyle.ToLipgloss(),39 CursorLine: o.CursorLineStyle.ToLipgloss(),40 CursorLineNumber: o.CursorLineNumberStyle.ToLipgloss(),
1 unmodified line
42 LineNumber: o.LineNumberStyle.ToLipgloss(),43 Prompt: o.PromptStyle.ToLipgloss(),44 }4546 a.BlurredStyle = style47 a.FocusedStyle = style48 a.Cursor.Style = o.CursorStyle.ToLipgloss()49 a.Cursor.SetMode(cursor.Modes[o.CursorMode])46 styles := a.Styles()47 styles.Focused = taStyles48 styles.Blurred = taStyles49 a.SetStyles(styles)50 cursor.TextArea(&a, o.CursorMode, o.CursorStyle)5152 a.SetWidth(max(0, o.Width-left-right))53 a.SetHeight(max(0, o.Height-top-bottom))54 a.SetValue(o.Value)
16 unmodified lines
7172 p := tea.NewProgram(73 m,74 tea.WithOutput(os.Stderr),74 tea.WithReportFocus(),75 tea.WithContext(ctx),76 )77 tm, err := p.Run()78 if err != nil {
9 unmodified lines
modified:write/write.go+13 added-11 removed
10 unmodified lines
11import (12 "io"13 "os"1415 "github.com/charmbracelet/bubbles/help"16 "github.com/charmbracelet/bubbles/key"17 "github.com/charmbracelet/bubbles/textarea"18 tea "github.com/charmbracelet/bubbletea"19 "github.com/charmbracelet/lipgloss"15 "charm.land/bubbles/v2/help"16 "charm.land/bubbles/v2/key"17 "charm.land/bubbles/v2/textarea"18 tea "charm.land/bubbletea/v2"19 "charm.land/lipgloss/v2"20 "github.com/charmbracelet/x/editor"21)2223type keymap struct {
16 unmodified lines
40 }41}4243func defaultKeymap() keymap {44 km := textarea.DefaultKeyMap44 km := textarea.DefaultKeyMap()45 km.InsertNewline = key.NewBinding(46 key.WithKeys("ctrl+j"),47 key.WithHelp("ctrl+j", "insert newline"),48 )
32 unmodified lines
81}8283func (m model) Init() tea.Cmd { return textarea.Blink }8485func (m model) View() string {85func (m model) View() tea.View {86 if m.quitting {87 return ""87 return tea.NewView("")88 }8990 var parts []string91
4 unmodified lines
96 parts = append(parts, m.textarea.View())97 if m.showHelp {98 parts = append(parts, "", m.help.View(m.keymap))99 }100 return lipgloss.NewStyle().100 v := tea.NewView(lipgloss.NewStyle().101 Padding(m.padding...).102 Render(lipgloss.JoinVertical(103 lipgloss.Left,104 parts...,105 ))105 )))106 v.ReportFocus = true107 return v108}109110func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {111 switch msg := msg.(type) {
12 unmodified lines
124 m.quitting = true125 return m, tea.Interrupt126 }127 m.textarea.SetValue(msg.content)126 case tea.KeyMsg:128 case tea.KeyPressMsg:129 km := m.keymap130 switch {131 case key.Matches(msg, km.Abort):132 m.quitting = true
72 unmodified lines
modified:go.mod+14 added-19 removed
1 unmodified line
23go 1.25.845require (6 charm.land/bubbles/v2 v2.1.17 charm.land/bubbletea/v2 v2.0.88 charm.land/glamour/v2 v2.0.19 charm.land/lipgloss/v2 v2.0.510 charm.land/log/v2 v2.0.011 github.com/Masterminds/semver/v3 v3.5.012 github.com/alecthomas/kong v1.15.013 github.com/alecthomas/mango-kong v0.1.09 github.com/charmbracelet/bubbles v1.0.010 github.com/charmbracelet/bubbletea v1.3.1011 github.com/charmbracelet/glamour v1.0.012 github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c66083413 github.com/charmbracelet/log v1.0.014 github.com/charmbracelet/colorprofile v0.4.315 github.com/charmbracelet/x/ansi v0.11.716 github.com/charmbracelet/x/editor v0.2.017 github.com/charmbracelet/x/exp/ordered v0.1.018 github.com/charmbracelet/x/term v0.2.219 github.com/charmbracelet/x/xpty v0.1.320 github.com/muesli/roff v0.1.020 github.com/muesli/termenv v0.16.021 github.com/rivo/uniseg v0.4.722 github.com/sahilm/fuzzy v0.1.323 golang.org/x/text v0.38.023 golang.org/x/text v0.39.024)2526require (27 github.com/alecthomas/chroma/v2 v2.20.0 // indirect28 github.com/atotto/clipboard v0.1.4 // indirect29 github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect29 github.com/aymerick/douceur v0.2.0 // indirect31 github.com/charmbracelet/colorprofile v0.4.1 // indirect32 github.com/charmbracelet/x/cellbuf v0.0.15 // indirect30 github.com/charmbracelet/ultraviolet v0.0.0-20260703014108-f5a850f9c2b7 // indirect31 github.com/charmbracelet/x/conpty v0.1.1 // indirect32 github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 // indirect33 github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf // indirect34 github.com/charmbracelet/x/termios v0.1.1 // indirect35 github.com/charmbracelet/x/windows v0.2.2 // indirect36 github.com/clipperhouse/displaywidth v0.11.0 // indirect37 github.com/clipperhouse/uax29/v2 v2.7.0 // indirect38 github.com/creack/pty v1.1.24 // indirect39 github.com/dlclark/regexp2 v1.11.5 // indirect40 github.com/dustin/go-humanize v1.0.1 // indirect42 github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect41 github.com/go-logfmt/logfmt v0.6.1 // indirect42 github.com/gorilla/css v1.0.1 // indirect43 github.com/lucasb-eyer/go-colorful v1.4.0 // indirect46 github.com/mattn/go-isatty v0.0.20 // indirect47 github.com/mattn/go-localereader v0.0.1 // indirect48 github.com/mattn/go-runewidth v0.0.23 // indirect44 github.com/mattn/go-runewidth v0.0.24 // indirect45 github.com/microcosm-cc/bluemonday v1.0.27 // indirect50 github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect46 github.com/muesli/cancelreader v0.2.2 // indirect47 github.com/muesli/mango v0.2.0 // indirect53 github.com/muesli/reflow v0.3.0 // indirect48 github.com/stretchr/testify v1.11.1 // indirect49 github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect55 github.com/yuin/goldmark v1.7.13 // indirect50 github.com/yuin/goldmark v1.7.17 // indirect51 github.com/yuin/goldmark-emoji v1.0.6 // indirect52 golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect53 golang.org/x/net v0.40.0 // indirect59 golang.org/x/sys v0.38.0 // indirect60 golang.org/x/term v0.36.0 // indirect54 golang.org/x/sync v0.21.0 // indirect55 golang.org/x/sys v0.46.0 // indirect56)
modified:go.sum+30 added-47 removed
1charm.land/bubbles/v2 v2.1.1 h1:7r55WzBxpo/R3z98hGmY7KKPd3ET6vsf0Fb9sDHOV60=2charm.land/bubbles/v2 v2.1.1/go.mod h1:GE6M31gaWZVXzGw73OeuTTgy4lX+OtkH0E5ymnNsHxo=3charm.land/bubbletea/v2 v2.0.8 h1:SxTJMhCAI3lbPmy4SgX5LWZ24AdINr4I6UEqzZvYJuY=4charm.land/bubbletea/v2 v2.0.8/go.mod h1:2SkdgoTXluXJHOUwAoRlRXF/28vklb1rFl6GcgV1/ss=5charm.land/glamour/v2 v2.0.1 h1:xl+r00A4aJWU0z8fgwKd9fQQ4rsphqGUzuEiXZP5n+c=6charm.land/glamour/v2 v2.0.1/go.mod h1:jo9z8XqVKPeEFMVdvCRLGk++RyJ3CdUwgNr7EvXLw3k=7charm.land/lipgloss/v2 v2.0.5 h1:kbNxgeeUOYv5J0YdpxFjfvf3dFvqH8Aci4zB6xqFtrY=8charm.land/lipgloss/v2 v2.0.5/go.mod h1:9oqhxt4yxIMe6q5A4kHr44DremZk7J9UNh74GlWa5nc=9charm.land/log/v2 v2.0.0 h1:SY3Cey7ipx86/MBXQHwsguOT6X1exT94mmJRdzTNs+s=10charm.land/log/v2 v2.0.0/go.mod h1:c3cZSRqm20qUVVAR1WmS/7ab8bgha3C6G7DjPcaVZz0=11github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=12github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=13github.com/Masterminds/semver/v3 v3.5.0 h1:kQceYJfbupGfZOKZQg0kou0DgAKhzDg2NZPAwZ/2OOE=14github.com/Masterminds/semver/v3 v3.5.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
8 unmodified lines
23github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=24github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=25github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=26github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=17github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=18github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=19github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3vj1nolY=20github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E=27github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o=28github.com/aymanbagabas/go-udiff v0.4.1/go.mod h1:0L9PGwj20lrtmEMeyw4WKJ/TMyDtvAoK9bf2u/mNo3w=29github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=30github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=23github.com/charmbracelet/bubbles v1.0.0 h1:12J8/ak/uCZEMQ6KU7pcfwceyjLlWsDLAxB5fXonfvc=24github.com/charmbracelet/bubbles v1.0.0/go.mod h1:9d/Zd5GdnauMI5ivUIVisuEm3ave1XwXtD1ckyV6r3E=25github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw=26github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=27github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk=28github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk=29github.com/charmbracelet/glamour v1.0.0 h1:AWMLOVFHTsysl4WV8T8QgkQ0s/ZNZo7CiE4WKhk8l08=30github.com/charmbracelet/glamour v1.0.0/go.mod h1:DSdohgOBkMr2ZQNhw4LZxSGpx3SvpeujNoXrQyH2hxo=31github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0ro+SZZiIZD7msJyA+NjkCNNavuiPBLgerbOziE=32github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA=33github.com/charmbracelet/log v1.0.0 h1:HVVVMmfOorfj3BA9i8X8UL69Hoz9lI0PYwXfJvOdRc4=34github.com/charmbracelet/log v1.0.0/go.mod h1:uYgY3SmLpwJWxmlrPwXvzVYujxis1vAKRV/0VQB7yWA=31github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q=32github.com/charmbracelet/colorprofile v0.4.3/go.mod h1:/zT4BhpD5aGFpqQQqw7a+VtHCzu+zrQtt1zhMt9mR4Q=33github.com/charmbracelet/ultraviolet v0.0.0-20260703014108-f5a850f9c2b7 h1:3FmWoGNWK4STvqg0O0Aeav2T7rodWJAPeF0QpH+8gFw=34github.com/charmbracelet/ultraviolet v0.0.0-20260703014108-f5a850f9c2b7/go.mod h1:f/jRa757WUmaOZrbPspXymbg/GnbF+rwe4OLsG7aXYo=35github.com/charmbracelet/x/ansi v0.11.7 h1:kzv1kJvjg2S3r9KHo8hDdHFQLEqn4RBCb39dAYC84jI=36github.com/charmbracelet/x/ansi v0.11.7/go.mod h1:9qGpnAVYz+8ACONkZBUWPtL7lulP9No6p1epAihUZwQ=37github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=38github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q=37github.com/charmbracelet/x/conpty v0.1.1 h1:s1bUxjoi7EpqiXysVtC+a8RrvPPNcNvAjfi4jxsAuEs=38github.com/charmbracelet/x/conpty v0.1.1/go.mod h1:OmtR77VODEFbiTzGE9G1XiRJAga6011PIm4u5fTNZpk=39github.com/charmbracelet/x/editor v0.2.0 h1:7XLUKtaRaB8jN7bWU2p2UChiySyaAuIfYiIRg8gGWwk=40github.com/charmbracelet/x/editor v0.2.0/go.mod h1:p3oQ28TSL3YPd+GKJ1fHWcp+7bVGpedHpXmo0D6t1dY=41github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA=42github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0=45github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ=46github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=43github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f h1:pk6gmGpCE7F3FcjaOEKYriCvpmIN4+6OS/RD0vm4uIA=44github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f/go.mod h1:IfZAMTHB6XkZSeXUqriemErjAWCCzT0LwjKFYCZyw0I=45github.com/charmbracelet/x/exp/ordered v0.1.0 h1:55/qLwjIh0gL0Vni+QAWk7T/qRVP6sBf+2agPBgnOFE=46github.com/charmbracelet/x/exp/ordered v0.1.0/go.mod h1:5UHwmG+is5THxMyCJHNPCn2/ecI07aKNrW+LcResjJ8=47github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf h1:rLG0Yb6MQSDKdB52aGX55JT1oi0P0Kuaj7wi1bLUpnI=48github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf/go.mod h1:B3UgsnsBZS/eX42BlaNiJkD1pPOUa+oF1IYC6Yd2CEU=49github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=50github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=51github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=52github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=53github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM=54github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k=55github.com/charmbracelet/x/xpty v0.1.3 h1:eGSitii4suhzrISYH50ZfufV3v085BXQwIytcOdFSsw=56github.com/charmbracelet/x/xpty v0.1.3/go.mod h1:poPYpWuLDBFCKmKLDnhBp51ATa0ooD8FhypRwEFtH3Y=57github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8=58github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
6 unmodified lines
65github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=66github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=67github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=68github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=69github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=70github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=69github.com/go-logfmt/logfmt v0.6.1 h1:4hvbpePJKnIzH1B+8OR/JPbTx37NktoI9LE2QZBBkvE=70github.com/go-logfmt/logfmt v0.6.1/go.mod h1:EV2pOAQoZaT1ZXZbqDl5hrymndi4SY9ED9/z6CO0XAk=71github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=72github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
4 unmodified lines
77github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=78github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=79github.com/lucasb-eyer/go-colorful v1.4.0 h1:UtrWVfLdarDgc44HcS7pYloGHJUjHV/4FwW4TvVgFr4=80github.com/lucasb-eyer/go-colorful v1.4.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=83github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=84github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=85github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=86github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=87github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=88github.com/mattn/go-runewidth v0.0.23 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3RybWcw=89github.com/mattn/go-runewidth v0.0.23/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=81github.com/mattn/go-runewidth v0.0.24 h1:cpokDiIn0MGnhdHwuWnJBITySJ20QyNGnY2kR/ay2DU=82github.com/mattn/go-runewidth v0.0.24/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=83github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=84github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=92github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=93github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=85github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=86github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=87github.com/muesli/mango v0.2.0 h1:iNNc0c5VLQ6fsMgAqGQofByNUBH2Q2nEbD6TaI+5yyQ=88github.com/muesli/mango v0.2.0/go.mod h1:5XFpbC8jY5UUv89YQciiXNlbi+iJgt29VDC5xbzrLL4=98github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=99github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=89github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8=90github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig=102github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=103github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=91github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=92github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=106github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=107github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=93github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=94github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=95github.com/sahilm/fuzzy v0.1.3 h1:juByESSS32nVD81vr6tHmKmA/8zde7gE+x5CLxrzXPU=96github.com/sahilm/fuzzy v0.1.3/go.mod h1:au6//VbVSqu6DFrkL2CfjlJ5iURpNCPeE+1GwY3XsT8=97github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=98github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=99github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=100github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=116github.com/yuin/goldmark v1.7.13 h1:GPddIs617DnBLFFVJFgpo1aBfe/4xcvMc3SB5t/D0pA=117github.com/yuin/goldmark v1.7.13/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=101github.com/yuin/goldmark v1.7.17 h1:p36OVWwRb246iHxA/U4p8OPEpOTESm4n+g+8t0EE5uA=102github.com/yuin/goldmark v1.7.17/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=103github.com/yuin/goldmark-emoji v1.0.6 h1:QWfF2FYaXwL74tfGOW5izeiZepUDroDJfWubQI9HTHs=104github.com/yuin/goldmark-emoji v1.0.6/go.mod h1:ukxJDKFpdFb5x0a5HqbdlcKtebh086iJpI31LTKmWuA=105golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=106golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=107golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=108golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=124golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=125golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=126golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=127golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=128golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q=129golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss=130golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=131golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=109golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=110golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=111golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=112golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=113golang.org/x/text v0.39.0 h1:UbZz4pLOvn600D6Oh6GGEI6VAmndrEBLv8/6BEXzyus=114golang.org/x/text v0.39.0/go.mod h1:3UwRclnC2g0TU9x8PZiyfOajCd1zaUNHF9cvqcQZ+ZM=115gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=116gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modified:main.go+9 added-10 removed
5 unmodified lines
6 "fmt"7 "os"8 "runtime/debug"910 tea "charm.land/bubbletea/v2"11 "charm.land/lipgloss/v2"12 "github.com/alecthomas/kong"11 tea "github.com/charmbracelet/bubbletea"13 "github.com/charmbracelet/gum/internal/exit"13 "github.com/charmbracelet/lipgloss"14 "github.com/muesli/termenv"14)1516const shaLen = 71718const defaultBool = "false"1920var (21 // Version contains the application version number. It's set via ldflags22 // when building.23 Version = ""
5 unmodified lines
2930var bubbleGumPink = lipgloss.NewStyle().Foreground(lipgloss.Color("212"))3132func main() {32 lipgloss.SetColorProfile(termenv.NewOutput(os.Stderr).Profile)3333 if Version == "" {34 if info, ok := debug.ReadBuildInfo(); ok && info.Main.Sum != "" {35 Version = info.Main.Version36 } else {
27 unmodified lines
64 "defaultBackground": "",65 "defaultForeground": "",66 "defaultMargin": "0 0",67 "defaultPadding": "0 0",69 "defaultUnderline": "false",70 "defaultBold": "false",71 "defaultFaint": "false",72 "defaultItalic": "false",73 "defaultStrikethrough": "false",68 "defaultUnderline": defaultBool,69 "defaultBold": defaultBool,70 "defaultFaint": defaultBool,71 "defaultItalic": defaultBool,72 "defaultStrikethrough": defaultBool,73 },74 )75 if err := ctx.Run(); err != nil {76 var ex exit.ErrExit
14 unmodified lines