Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require (
github.com/dustin/go-humanize v1.0.1
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/mattn/go-runewidth v0.0.15
github.com/muesli/reflow v0.3.0
github.com/muesli/termenv v0.15.2
github.com/rivo/uniseg v0.4.7
github.com/sahilm/fuzzy v0.1.1
Expand All @@ -26,6 +25,7 @@ require (
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/term v0.20.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions list/defaultitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/reflow/truncate"
"github.com/charmbracelet/x/ansi"
)

// DefaultItemStyles defines styling for a default list item.
Expand Down Expand Up @@ -155,15 +155,15 @@ func (d DefaultDelegate) Render(w io.Writer, m Model, index int, item Item) {
}

// Prevent text from exceeding list width
textwidth := uint(m.width - s.NormalTitle.GetPaddingLeft() - s.NormalTitle.GetPaddingRight())
title = truncate.StringWithTail(title, textwidth, ellipsis)
textwidth := m.width - s.NormalTitle.GetPaddingLeft() - s.NormalTitle.GetPaddingRight()
title = ansi.Truncate(title, textwidth, ellipsis)
if d.ShowDescription {
var lines []string
for i, line := range strings.Split(desc, "\n") {
if i >= d.height-1 {
break
}
lines = append(lines, truncate.StringWithTail(line, textwidth, ellipsis))
lines = append(lines, ansi.Truncate(line, textwidth, ellipsis))
}
desc = strings.Join(lines, "\n")
}
Expand Down
9 changes: 4 additions & 5 deletions list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import (
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/reflow/ansi"
"github.com/muesli/reflow/truncate"
"github.com/charmbracelet/x/ansi"
"github.com/sahilm/fuzzy"
)

Expand Down Expand Up @@ -1075,7 +1074,7 @@ func (m Model) titleView() string {
// Status message
if m.filterState != Filtering {
view += " " + m.statusMessage
view = truncate.StringWithTail(view, uint(m.width-spinnerWidth), ellipsis)
view = ansi.Truncate(view, m.width-spinnerWidth, ellipsis)
}
}

Expand Down Expand Up @@ -1126,7 +1125,7 @@ func (m Model) statusView() string {

if filtered {
f := strings.TrimSpace(m.FilterInput.Value())
f = truncate.StringWithTail(f, 10, "…")
f = ansi.Truncate(f, 10, "…")
status += fmt.Sprintf("“%s” ", f)
}

Expand All @@ -1151,7 +1150,7 @@ func (m Model) paginationView() string {

// If the dot pagination is wider than the width of the window
// use the arabic paginator.
if ansi.PrintableRuneWidth(s) > m.width {
if ansi.StringWidth(s) > m.width {
m.Paginator.Type = paginator.Arabic
s = m.Styles.ArabicPagination.Render(m.Paginator.View())
}
Expand Down
4 changes: 2 additions & 2 deletions progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/harmonica"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/x/ansi"
"github.com/lucasb-eyer/go-colorful"
"github.com/muesli/reflow/ansi"
"github.com/muesli/termenv"
)

Expand Down Expand Up @@ -283,7 +283,7 @@ func (m Model) View() string {
func (m Model) ViewAs(percent float64) string {
b := strings.Builder{}
percentView := m.percentageView(percent)
m.barView(&b, percent, ansi.PrintableRuneWidth(percentView))
m.barView(&b, percent, ansi.StringWidth(percentView))
b.WriteString(percentView)
return b.String()
}
Expand Down