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
Provenance
- Commit
f6dd28e- Tree
778cd0a- Author
Drew Smirnoff <drew@charm.land>- Committer
GitHub <noreply@github.com>- Parent
7423ddf
33 files changed+383 added−315 removed
modified:choose/choose.go+20 added-11 removed
11 unmodified lines12 13 import (14 "strings"15 16- "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 )23 24 func defaultKeymap() keymap {86 unmodified lines111 limit int112 numSelected int113 currentOrder int114 paginator paginator.Model115+ hasDarkBG bool116 showHelp bool117 help help.Model118 keymap keymap119 9 unmodified lines129 selected bool130 order int131 }132 132-func (m model) Init() tea.Cmd { return nil }133+func (m model) Init() tea.Cmd { return tea.RequestBackgroundColor }134 135 func (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, nil142 139- 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 lines243 m.currentOrder = 0244 return m245 }246 243-func (m model) View() string {247+func (m model) View() tea.View {248 if m.quitting {245- return ""249+ return tea.NewView("")250 }251 252 var s strings.Builder253 17 unmodified lines271 }272 }273 274 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 lines291 parts = append(parts, "", m.help.View(m.keymap))292 }293 294 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 lines7 "slices"8 "sort"9 "strings"10 11- "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 )19 20 // Run provides a shell script interface for choosing between different through21 // options.22 func (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- )28-23 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 lines106 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.Height112 113 km := defaultKeymap()61 unmodified linesmodified:confirm/command.go+2 added-2 removed
3 unmodified lines4 "context"5 "fmt"6 "os"7 8- "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 linesmodified:confirm/confirm.go+9 added-9 removed
9 unmodified lines10 // $ gum confirm "Are you sure?" && rm file.txt11 package confirm12 13 import (14- "github.com/charmbracelet/bubbles/help"15- "github.com/charmbracelet/bubbles/key"14+ "charm.land/bubbles/v2/help"15+ "charm.land/bubbles/v2/key"16 17- tea "github.com/charmbracelet/bubbletea"18- "github.com/charmbracelet/lipgloss"17+ tea "charm.land/bubbletea/v2"18+ "charm.land/lipgloss/v2"19 )20 21 func defaultKeymap(affirmative, negative string) keymap {22 return keymap{76 unmodified lines99 func (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.Interrupt21 unmodified lines129 }130 return m, nil131 }132 133-func (m model) View() string {133+func (m model) View() tea.View {134 if m.quitting {135- return ""135+ return tea.NewView("")136 }137 138 var aff, neg string139 18 unmodified lines158 if m.showHelp {159 parts = append(parts, "", m.help.View(m.keys))160 }161 162- 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.2 package cursor3 4 import (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 )9 8-// Modes maps strings to cursor modes.9-var 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.11+func 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 }18+19+// TextArea applies the given cursor mode and style to the text area.20+func 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 lines5 "fmt"6 "os"7 "path/filepath"8 9- "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 lines61 ctx, cancel := timeout.Context(o.Timeout)62 defer cancel()63 64 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 linesmodified:file/file.go+10 added-10 removed
11 unmodified lines12 // $ gum file $HOME13 package file14 15 import (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 )22 23 type keymap filepicker.KeyMap24 48 unmodified lines73 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.Interrupt11 unmodified lines93 }94 return m, cmd95 }96 97-func (m model) View() string {97+func (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 line105 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 }116 117 func (m model) helpView() string {118 return m.help.View(m.keymap)1 unmodified linemodified:filter/command.go+12 added-12 removed
5 unmodified lines6 "os"7 "slices"8 "strings"9 10- "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 lines26 i := textinput.New()27 i.Focus()28 29 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)38 35- v := viewport.New(o.Width, o.Height)39+ v := viewport.New(viewport.WithWidth(o.Width), viewport.WithHeight(o.Height))40 41 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 lines54 defer cancel()55 56 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- }60 61 var matches []fuzzy.Match62 if o.Value != "" {63 i.SetValue(o.Value)111 unmodified linesmodified:filter/filter.go+57 added-43 removed
11 unmodified lines12 13 import (14 "strings"15 16- "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 lines158 }159 160 func (m model) Init() tea.Cmd { return textinput.Blink }161 162-func (m model) View() string {162+func (m model) View() tea.View {163 if m.quitting {164- return ""164+ return tea.NewView("")165 }166 167 var s strings.Builder168 var lineTextStyle lipgloss.Style169 170 // 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 }176 177 // Since there are matches, display them so that the user can see, in real178 // time, what they are searching for.54 unmodified lines233 m.viewport.SetContent(s.String())234 235 // 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+}250 251+func (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+}264+265+func (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 line271 return lipgloss.NewStyle().272 Padding(m.padding...).273 Render(header + "\n" + view)274 }260-275 return lipgloss.NewStyle().276 Padding(m.padding...).277 Render(view)278 }7 unmodified lines286 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 lines362 // 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 }368 369 // 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 lines391 392 // 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 lines416 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 lines439 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 linesmodified:format/command.go+4 added-1 removed
13 unmodified lines14 "fmt"15 "strings"16 17 "github.com/charmbracelet/gum/internal/stdin"18+ "github.com/charmbracelet/gum/internal/tty"19 )20 21 // Run runs the format command.22 func (o Options) Run() error {18 unmodified lines41 if err != nil {42 return err43 }44 44- 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 lines5 "bytes"6 "fmt"7 tpl "text/template"8 9- "github.com/charmbracelet/glamour"10- "github.com/muesli/termenv"9+ "charm.land/glamour/v2"10+ "charm.land/lipgloss/v2"11 )12 13 func 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 lines54 return output, nil55 }56 57 func 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 }62 63 var buf bytes.Buffer64 err = t.Execute(&buf, nil)65 return buf.String(), err66 }67+68+// templateFuncs returns a few useful template helpers for styling text.69+func 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+}107+108+func 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 lines4 "errors"5 "fmt"6 "os"7 8- "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 lines31 }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.CharLimit44 45 if o.Password {46 i.EchoMode = textinput.EchoPassword17 unmodified lines64 65 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 linesmodified:input/input.go+15 added-13 removed
6 unmodified lines7 // $ gum input --placeholder "What's your favorite gum?" > answer.text8 package input9 10 import (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 )17 18 type keymap textinput.KeyMap19 20 func defaultKeymap() keymap {21- k := textinput.DefaultKeyMap21+ k := textinput.DefaultKeyMap()22 return keymap(k)23 }24 25 // FullHelp implements help.KeyMap.23 unmodified lines49 }50 51 func (m model) Init() tea.Cmd { return textinput.Blink }52 53-func (m model) View() string {53+func (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 lines62 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 }75 76 func (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.Interrupt14 unmodified linesmodified:internal/decode/align.go+1 added-1 removed
1 // Package decode position strings to lipgloss.2 package decode3 4-import "github.com/charmbracelet/lipgloss"4+import "charm.land/lipgloss/v2"5 6 // Align maps strings to `lipgloss.Position`s.7 var Align = map[string]lipgloss.Position{8 "center": lipgloss.Center,5 unmodified linesmodified:internal/tty/tty.go+12 added-9 removed
1 unmodified line2 package tty3 4 import (5 "fmt"6+ "io"7 "os"8 "sync"9 9- "github.com/charmbracelet/x/ansi"10- "github.com/charmbracelet/x/term"10+ "github.com/charmbracelet/colorprofile"11 )12 13-var isTTY = sync.OnceValue(func() bool {14- return term.IsTerminal(os.Stdout.Fd())13+var stdout = sync.OnceValue(func() io.Writer {14+ return colorprofile.NewWriter(os.Stdout, os.Environ())15 })16 17+// 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.20+func Writer() io.Writer {21+ return stdout()22+}23+24 // Println handles println, striping ansi sequences if stdout is not a tty.25 func 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 lines15 // ╚══════════════════════╝╚═════════════╝16 package join17 18 import (19- "fmt"19+ "charm.land/lipgloss/v2"20 21- "github.com/charmbracelet/lipgloss"22-21 "github.com/charmbracelet/gum/internal/decode"22+ "github.com/charmbracelet/gum/internal/tty"23 )24 25 // Run is the command-line interface for the joining strings through lipgloss.26 func (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 lines7 "os"8 "strings"9 "time"10 11- "github.com/charmbracelet/lipgloss"12- "github.com/charmbracelet/log"11+ "charm.land/lipgloss/v2"12+ log "charm.land/log/v2"13 )14 15 // Run is the command-line interface for logging text.16 func (o Options) Run() error {51 unmodified lines68 69 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 }75 76 st.Levels[lvl] = lvlStyle.24 unmodified lines101 l.SetFormatter(log.TextFormatter)102 }103 104 var arg0 string105- var args []interface{}105+ var args []any106 if len(o.Text) > 0 {107 arg0 = o.Text[0]108 }109 110 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 lines134 return nil135 }136 137 type logger struct {138- printf func(string, ...interface{})139- print func(interface{}, ...interface{})138+ printf func(string, ...any)139+ print func(any, ...any)140 }141 142 var levelToLog = map[string]log.Level{143 "none": log.Level(math.MaxInt32),6 unmodified linesmodified:pager/command.go+4 added-6 removed
2 unmodified lines3 import (4 "fmt"5 "regexp"6 7- "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 )13 14 // Run provides a shell script interface for the viewport bubble.15 // https://github.com/charmbracelet/bubbles/viewport16 func (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()19 20 if o.Content == "" {21 stdin, err := stdin.Read()26 unmodified lines48 defer cancel()49 50 _, 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 linesmodified:pager/pager.go+24 added-19 removed
5 unmodified lines6 import (7 "fmt"8 "strings"9 10- "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 )18 19 type keymap struct {88 unmodified lines108 func (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 }115 116 m.keymap.PrevMatch.SetEnabled(m.search.query != nil)8 unmodified lines125 return m.help.View(m.keymap)126 }127 128 func (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.Builder133 134 // 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 lines162 text.WriteString("\n")163 }164 }165 166- 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 line172 }173 174 const heightOffset = 2175 176-func (m model) keyHandler(msg tea.KeyMsg) (model, tea.Cmd) {176+func (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 lines184 m.search.Execute(&m)185 186 // 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 lines204 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.Interrupt3 unmodified lines219 220 return m, cmd221 }222 223-func (m model) View() string {223+func (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 }231 228- 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 lines4 "fmt"5 "regexp"6 "strings"7 8- "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 )12 13 type search struct {8 unmodified lines22 func (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 }32 33 func (s *search) Begin() {67 unmodified lines101 line = strings.Count(formatStr[:index], "\n")102 }103 104 // 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 lines143 line = strings.Count(formatStr[:index], "\n")144 }145 146 // 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 linesmodified:spin/command.go+2 added-2 removed
2 unmodified lines3 import (4 "fmt"5 "os"6 7- "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 linesmodified:spin/spin.go+9 added-9 removed
21 unmodified lines22 "os/exec"23 "runtime"24 "syscall"25 26- "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 lines145 commandStart(m.command),146 )147 }148 149-func (m model) View() string {149+func (m model) View() tea.View {150 if m.quitting {151- return ""151+ return tea.NewView("")152 }153 154 var out string155 if m.showStderr {3 unmodified lines159 out += outbuf.String()160 }161 162 if !m.isTTY {163- return m.title163+ return tea.NewView(m.title)164 }165 166 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 }176 177 func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {178 switch msg := msg.(type) {3 unmodified lines182 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 linesmodified:spin/spinners.go+1 added-1 removed
1 package spin2 3-import "github.com/charmbracelet/bubbles/spinner"3+import "charm.land/bubbles/v2/spinner"4 5 var spinnerMap = map[string]spinner.Spinner{6 "line": spinner.Line,7 "dot": spinner.Dot,10 unmodified linesmodified:style/borders.go+1 added-1 removed
1 package style2 3-import "github.com/charmbracelet/lipgloss"3+import "charm.land/lipgloss/v2"4 5 // Border maps strings to `lipgloss.Border`s.6 var Border map[string]lipgloss.Border = map[string]lipgloss.Border{7 "double": lipgloss.DoubleBorder(),6 unmodified linesmodified:style/command.go+2 added-2 removed
5 unmodified lines6 package style7 8 import (9 "errors"10- "fmt"10 "strings"11 12 "github.com/charmbracelet/gum/internal/stdin"13+ "github.com/charmbracelet/gum/internal/tty"14 )15 16 // Run provides a shell script interface for the Lip Gloss styling.17 // https://github.com/charmbracelet/lipgloss13 unmodified lines31 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
1 package style2 3 import (4- "github.com/charmbracelet/lipgloss"4+ "charm.land/lipgloss/v2"5 6 "github.com/charmbracelet/gum/internal/decode"7 )8 41 unmodified linesmodified:table/command.go+7 added-6 removed
3 unmodified lines4 "encoding/csv"5 "fmt"6 "os"7 8- "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 lines123 }124 return styles.Cell125 })126 126- fmt.Println(table.Render())127+ tty.Println(table.Render())128 return nil129 }130 131 opts := []table.Option{50 unmodified linesmodified:table/table.go+10 added-10 removed
16 unmodified lines17 import (18 "fmt"19 "strconv"20 21- "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 )27 28 type keymap struct {29 Navigate,65 unmodified lines95 func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {96 var cmd tea.Cmd97 98 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 lines115 m.table, cmd = m.table.Update(msg)116 return m, cmd117 }118 119-func (m model) View() string {119+func (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 }131 132 func numLen(i int) int {133 if i == 0 {9 unmodified linesmodified:write/command.go+9 added-9 removed
4 unmodified lines5 "fmt"6 "os"7 "strings"8 9- "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 lines32 a.CharLimit = o.CharLimit33 a.MaxHeight = o.MaxLines34 top, right, bottom, left := style.ParsePadding(o.Padding)35 36- 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 line42 LineNumber: o.LineNumberStyle.ToLipgloss(),43 Prompt: o.PromptStyle.ToLipgloss(),44 }45 46- 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)51 52 a.SetWidth(max(0, o.Width-left-right))53 a.SetHeight(max(0, o.Height-top-bottom))54 a.SetValue(o.Value)16 unmodified lines71 72 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 linesmodified:write/write.go+13 added-11 removed
10 unmodified lines11 import (12 "io"13 "os"14 15- "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 )22 23 type keymap struct {16 unmodified lines40 }41 }42 43 func 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 lines81 }82 83 func (m model) Init() tea.Cmd { return textarea.Blink }84 85-func (m model) View() string {85+func (m model) View() tea.View {86 if m.quitting {87- return ""87+ return tea.NewView("")88 }89 90 var parts []string91 4 unmodified lines96 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 }109 110 func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {111 switch msg := msg.(type) {12 unmodified lines124 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 = true72 unmodified linesmodified:go.mod+14 added-19 removed
1 unmodified line2 3 go 1.25.84 5 require (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 )25 26 require (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
1+charm.land/bubbles/v2 v2.1.1 h1:7r55WzBxpo/R3z98hGmY7KKPd3ET6vsf0Fb9sDHOV60=2+charm.land/bubbles/v2 v2.1.1/go.mod h1:GE6M31gaWZVXzGw73OeuTTgy4lX+OtkH0E5ymnNsHxo=3+charm.land/bubbletea/v2 v2.0.8 h1:SxTJMhCAI3lbPmy4SgX5LWZ24AdINr4I6UEqzZvYJuY=4+charm.land/bubbletea/v2 v2.0.8/go.mod h1:2SkdgoTXluXJHOUwAoRlRXF/28vklb1rFl6GcgV1/ss=5+charm.land/glamour/v2 v2.0.1 h1:xl+r00A4aJWU0z8fgwKd9fQQ4rsphqGUzuEiXZP5n+c=6+charm.land/glamour/v2 v2.0.1/go.mod h1:jo9z8XqVKPeEFMVdvCRLGk++RyJ3CdUwgNr7EvXLw3k=7+charm.land/lipgloss/v2 v2.0.5 h1:kbNxgeeUOYv5J0YdpxFjfvf3dFvqH8Aci4zB6xqFtrY=8+charm.land/lipgloss/v2 v2.0.5/go.mod h1:9oqhxt4yxIMe6q5A4kHr44DremZk7J9UNh74GlWa5nc=9+charm.land/log/v2 v2.0.0 h1:SY3Cey7ipx86/MBXQHwsguOT6X1exT94mmJRdzTNs+s=10+charm.land/log/v2 v2.0.0/go.mod h1:c3cZSRqm20qUVVAR1WmS/7ab8bgha3C6G7DjPcaVZz0=11 github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=12 github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=13 github.com/Masterminds/semver/v3 v3.5.0 h1:kQceYJfbupGfZOKZQg0kou0DgAKhzDg2NZPAwZ/2OOE=14 github.com/Masterminds/semver/v3 v3.5.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=8 unmodified lines23 github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=24 github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=25 github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=26 github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=17-github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=18-github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=19-github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3vj1nolY=20-github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E=27+github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o=28+github.com/aymanbagabas/go-udiff v0.4.1/go.mod h1:0L9PGwj20lrtmEMeyw4WKJ/TMyDtvAoK9bf2u/mNo3w=29 github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=30 github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=23-github.com/charmbracelet/bubbles v1.0.0 h1:12J8/ak/uCZEMQ6KU7pcfwceyjLlWsDLAxB5fXonfvc=24-github.com/charmbracelet/bubbles v1.0.0/go.mod h1:9d/Zd5GdnauMI5ivUIVisuEm3ave1XwXtD1ckyV6r3E=25-github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw=26-github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=27-github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk=28-github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk=29-github.com/charmbracelet/glamour v1.0.0 h1:AWMLOVFHTsysl4WV8T8QgkQ0s/ZNZo7CiE4WKhk8l08=30-github.com/charmbracelet/glamour v1.0.0/go.mod h1:DSdohgOBkMr2ZQNhw4LZxSGpx3SvpeujNoXrQyH2hxo=31-github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0ro+SZZiIZD7msJyA+NjkCNNavuiPBLgerbOziE=32-github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA=33-github.com/charmbracelet/log v1.0.0 h1:HVVVMmfOorfj3BA9i8X8UL69Hoz9lI0PYwXfJvOdRc4=34-github.com/charmbracelet/log v1.0.0/go.mod h1:uYgY3SmLpwJWxmlrPwXvzVYujxis1vAKRV/0VQB7yWA=31+github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q=32+github.com/charmbracelet/colorprofile v0.4.3/go.mod h1:/zT4BhpD5aGFpqQQqw7a+VtHCzu+zrQtt1zhMt9mR4Q=33+github.com/charmbracelet/ultraviolet v0.0.0-20260703014108-f5a850f9c2b7 h1:3FmWoGNWK4STvqg0O0Aeav2T7rodWJAPeF0QpH+8gFw=34+github.com/charmbracelet/ultraviolet v0.0.0-20260703014108-f5a850f9c2b7/go.mod h1:f/jRa757WUmaOZrbPspXymbg/GnbF+rwe4OLsG7aXYo=35 github.com/charmbracelet/x/ansi v0.11.7 h1:kzv1kJvjg2S3r9KHo8hDdHFQLEqn4RBCb39dAYC84jI=36 github.com/charmbracelet/x/ansi v0.11.7/go.mod h1:9qGpnAVYz+8ACONkZBUWPtL7lulP9No6p1epAihUZwQ=37-github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=38-github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q=37 github.com/charmbracelet/x/conpty v0.1.1 h1:s1bUxjoi7EpqiXysVtC+a8RrvPPNcNvAjfi4jxsAuEs=38 github.com/charmbracelet/x/conpty v0.1.1/go.mod h1:OmtR77VODEFbiTzGE9G1XiRJAga6011PIm4u5fTNZpk=39 github.com/charmbracelet/x/editor v0.2.0 h1:7XLUKtaRaB8jN7bWU2p2UChiySyaAuIfYiIRg8gGWwk=40 github.com/charmbracelet/x/editor v0.2.0/go.mod h1:p3oQ28TSL3YPd+GKJ1fHWcp+7bVGpedHpXmo0D6t1dY=41 github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA=42 github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0=45-github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ=46-github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=43+github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f h1:pk6gmGpCE7F3FcjaOEKYriCvpmIN4+6OS/RD0vm4uIA=44+github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f/go.mod h1:IfZAMTHB6XkZSeXUqriemErjAWCCzT0LwjKFYCZyw0I=45 github.com/charmbracelet/x/exp/ordered v0.1.0 h1:55/qLwjIh0gL0Vni+QAWk7T/qRVP6sBf+2agPBgnOFE=46 github.com/charmbracelet/x/exp/ordered v0.1.0/go.mod h1:5UHwmG+is5THxMyCJHNPCn2/ecI07aKNrW+LcResjJ8=47 github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf h1:rLG0Yb6MQSDKdB52aGX55JT1oi0P0Kuaj7wi1bLUpnI=48 github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf/go.mod h1:B3UgsnsBZS/eX42BlaNiJkD1pPOUa+oF1IYC6Yd2CEU=49 github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=50 github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=51 github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=52 github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=53+github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM=54+github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k=55 github.com/charmbracelet/x/xpty v0.1.3 h1:eGSitii4suhzrISYH50ZfufV3v085BXQwIytcOdFSsw=56 github.com/charmbracelet/x/xpty v0.1.3/go.mod h1:poPYpWuLDBFCKmKLDnhBp51ATa0ooD8FhypRwEFtH3Y=57 github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8=58 github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=6 unmodified lines65 github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=66 github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=67 github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=68 github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=69-github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=70-github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=69 github.com/go-logfmt/logfmt v0.6.1 h1:4hvbpePJKnIzH1B+8OR/JPbTx37NktoI9LE2QZBBkvE=70 github.com/go-logfmt/logfmt v0.6.1/go.mod h1:EV2pOAQoZaT1ZXZbqDl5hrymndi4SY9ED9/z6CO0XAk=71 github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=72 github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=4 unmodified lines77 github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=78 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=79 github.com/lucasb-eyer/go-colorful v1.4.0 h1:UtrWVfLdarDgc44HcS7pYloGHJUjHV/4FwW4TvVgFr4=80 github.com/lucasb-eyer/go-colorful v1.4.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=83-github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=84-github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=85-github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=86-github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=87-github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=88-github.com/mattn/go-runewidth v0.0.23 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3RybWcw=89-github.com/mattn/go-runewidth v0.0.23/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=81+github.com/mattn/go-runewidth v0.0.24 h1:cpokDiIn0MGnhdHwuWnJBITySJ20QyNGnY2kR/ay2DU=82+github.com/mattn/go-runewidth v0.0.24/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=83 github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=84 github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=92-github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=93-github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=85 github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=86 github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=87 github.com/muesli/mango v0.2.0 h1:iNNc0c5VLQ6fsMgAqGQofByNUBH2Q2nEbD6TaI+5yyQ=88 github.com/muesli/mango v0.2.0/go.mod h1:5XFpbC8jY5UUv89YQciiXNlbi+iJgt29VDC5xbzrLL4=98-github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=99-github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=89 github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8=90 github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig=102-github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=103-github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=91 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=92 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=106-github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=107-github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=93 github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=94 github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=95 github.com/sahilm/fuzzy v0.1.3 h1:juByESSS32nVD81vr6tHmKmA/8zde7gE+x5CLxrzXPU=96 github.com/sahilm/fuzzy v0.1.3/go.mod h1:au6//VbVSqu6DFrkL2CfjlJ5iURpNCPeE+1GwY3XsT8=97 github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=98 github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=99 github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=100 github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=116-github.com/yuin/goldmark v1.7.13 h1:GPddIs617DnBLFFVJFgpo1aBfe/4xcvMc3SB5t/D0pA=117-github.com/yuin/goldmark v1.7.13/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=101+github.com/yuin/goldmark v1.7.17 h1:p36OVWwRb246iHxA/U4p8OPEpOTESm4n+g+8t0EE5uA=102+github.com/yuin/goldmark v1.7.17/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=103 github.com/yuin/goldmark-emoji v1.0.6 h1:QWfF2FYaXwL74tfGOW5izeiZepUDroDJfWubQI9HTHs=104 github.com/yuin/goldmark-emoji v1.0.6/go.mod h1:ukxJDKFpdFb5x0a5HqbdlcKtebh086iJpI31LTKmWuA=105 golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=106 golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=107 golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=108 golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=124-golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=125-golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=126-golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=127-golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=128-golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q=129-golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss=130-golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=131-golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=109+golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=110+golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=111+golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=112+golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=113+golang.org/x/text v0.39.0 h1:UbZz4pLOvn600D6Oh6GGEI6VAmndrEBLv8/6BEXzyus=114+golang.org/x/text v0.39.0/go.mod h1:3UwRclnC2g0TU9x8PZiyfOajCd1zaUNHF9cvqcQZ+ZM=115 gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=116 gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=modified:main.go+9 added-10 removed
5 unmodified lines6 "fmt"7 "os"8 "runtime/debug"9 10+ 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 )15 16 const shaLen = 717 18+const defaultBool = "false"19+20 var (21 // Version contains the application version number. It's set via ldflags22 // when building.23 Version = ""5 unmodified lines29 30 var bubbleGumPink = lipgloss.NewStyle().Foreground(lipgloss.Color("212"))31 32 func main() {32- lipgloss.SetColorProfile(termenv.NewOutput(os.Stderr).Profile)33-33 if Version == "" {34 if info, ok := debug.ReadBuildInfo(); ok && info.Main.Sum != "" {35 Version = info.Main.Version36 } else {27 unmodified lines64 "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.ErrExit14 unmodified lines