Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(v2) tidiness and consistency changes #646

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a9b780a
feat(deps): bump github.com/charmbracelet/lipgloss from 0.13.0 to 0.13.1
dependabot[bot] Oct 23, 2024
0892f86
chore(filepicker): use Lip Gloss v2
meowgorithm Oct 23, 2024
3fc226c
feat(filepicker): make symlink symbol customizable
meowgorithm Oct 23, 2024
7d60fd1
chore(help): update for Lip Gloss v2
meowgorithm Oct 23, 2024
95e716e
docs(cursor): fix typo in comment
meowgorithm Oct 23, 2024
49c9aca
chore(list): update for Lip Gloss v2
meowgorithm Oct 23, 2024
aa1fe05
chore(textinput): DefaultKeyMap is now a func that returns a KeyMap
meowgorithm Oct 23, 2024
17533b1
chore(textinput): use getter and setter for width
meowgorithm Oct 23, 2024
30d7e7b
chore(textinput): use a getter and setter for width
meowgorithm Oct 23, 2024
432972a
feat(textinput): add styles for focused and blurred states
meowgorithm Oct 23, 2024
1b34148
fix(textinput): return a pointer to StyleState
aymanbagabas Oct 23, 2024
a7b0c79
chore(textarea): update for Lip Gloss v2
meowgorithm Oct 23, 2024
f6eb948
chore(textarea): focused/blurred styles now belong to one style struct
meowgorithm Oct 23, 2024
c4f0400
chore(textarea): remove keymap global in favor of a function
meowgorithm Oct 23, 2024
d487f78
chore(runeutil): make package internal
meowgorithm Oct 23, 2024
d514f3d
chore(runeutil): improve package description
meowgorithm Oct 23, 2024
39fb58b
chore(progress): use getters/setters for width
meowgorithm Oct 23, 2024
e1d891b
chore(deps): use current v2-exp Bubble Tea
meowgorithm Oct 24, 2024
d05ec83
docs(textarea): add simple GoDoc for memo package
meowgorithm Oct 24, 2024
4b2f72b
chore(help): fix help test errors
meowgorithm Oct 24, 2024
89f2eef
fix(help): fix test by downsampling color to NoTTY
meowgorithm Oct 24, 2024
c0611f6
chore(list): fix v2 errors
meowgorithm Oct 24, 2024
812b71c
chore(textarea): make memoizer internal
meowgorithm Oct 24, 2024
5d1f237
chore(help): simplify ansi stripping in test
meowgorithm Oct 24, 2024
0e006c7
fix(textarea): fix tests
meowgorithm Oct 24, 2024
7525b8c
Merge pull request #645 from charmbracelet/dependabot/go_modules/gith…
dependabot[bot] Oct 24, 2024
358a6c5
chore(lint): fix and suppress all soft lint issues; update directives
meowgorithm Oct 24, 2024
8827e48
chore(merge): branch 'master' into v2-tidy
meowgorithm Oct 24, 2024
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
4 changes: 3 additions & 1 deletion cursor/cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ func (c Mode) String() string {
// Model is the Bubble Tea model for this cursor element.
type Model struct {
BlinkSpeed time.Duration

// Style for styling the cursor block.
Style lipgloss.Style

// TextStyle is the style used for the cursor when it is hidden (when blinking).
// I.e. displaying normal text.
// i.e. displaying normal text.
TextStyle lipgloss.Style

// char is the character under the cursor
Expand Down
60 changes: 35 additions & 25 deletions filepicker/filepicker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func New() Model {
return Model{
id: nextID(),
CurrentDirectory: ".",
Cursor: ">",
AllowedTypes: []string{},
selected: 0,
ShowPermissions: true,
Expand All @@ -43,6 +42,10 @@ func New() Model {
maxStack: newStack(),
KeyMap: DefaultKeyMap(),
Styles: DefaultStyles(),

Cursor: ">",
DisabledCursor: ">",
Symlink: "→",
}
}

Expand Down Expand Up @@ -91,8 +94,8 @@ func DefaultKeyMap() KeyMap {

// Styles defines the possible customizations for styles in the file picker.
type Styles struct {
DisabledCursor lipgloss.Style
Cursor lipgloss.Style
DisabledCursor lipgloss.Style
Symlink lipgloss.Style
Directory lipgloss.Style
File lipgloss.Style
Expand All @@ -106,24 +109,18 @@ type Styles struct {

// DefaultStyles defines the default styling for the file picker.
func DefaultStyles() Styles {
return DefaultStylesWithRenderer(lipgloss.DefaultRenderer())
}

// DefaultStylesWithRenderer defines the default styling for the file picker,
// with a given Lip Gloss renderer.
func DefaultStylesWithRenderer(r *lipgloss.Renderer) Styles {
return Styles{
DisabledCursor: r.NewStyle().Foreground(lipgloss.Color("247")),
Cursor: r.NewStyle().Foreground(lipgloss.Color("212")),
Symlink: r.NewStyle().Foreground(lipgloss.Color("36")),
Directory: r.NewStyle().Foreground(lipgloss.Color("99")),
File: r.NewStyle(),
DisabledFile: r.NewStyle().Foreground(lipgloss.Color("243")),
DisabledSelected: r.NewStyle().Foreground(lipgloss.Color("247")),
Permission: r.NewStyle().Foreground(lipgloss.Color("244")),
Selected: r.NewStyle().Foreground(lipgloss.Color("212")).Bold(true),
FileSize: r.NewStyle().Foreground(lipgloss.Color("240")).Width(fileSizeWidth).Align(lipgloss.Right),
EmptyDirectory: r.NewStyle().Foreground(lipgloss.Color("240")).PaddingLeft(paddingLeft).SetString("Bummer. No Files Found."),
Cursor: lipgloss.NewStyle().Foreground(lipgloss.Color("212")),
DisabledCursor: lipgloss.NewStyle().Foreground(lipgloss.Color("247")),
Symlink: lipgloss.NewStyle().Foreground(lipgloss.Color("36")),
Directory: lipgloss.NewStyle().Foreground(lipgloss.Color("99")),
File: lipgloss.NewStyle(),
DisabledFile: lipgloss.NewStyle().Foreground(lipgloss.Color("243")),
DisabledSelected: lipgloss.NewStyle().Foreground(lipgloss.Color("247")),
Permission: lipgloss.NewStyle().Foreground(lipgloss.Color("244")),
Selected: lipgloss.NewStyle().Foreground(lipgloss.Color("212")).Bold(true),
FileSize: lipgloss.NewStyle().Foreground(lipgloss.Color("240")).Width(fileSizeWidth).Align(lipgloss.Right),
EmptyDirectory: lipgloss.NewStyle().Foreground(lipgloss.Color("240")).PaddingLeft(paddingLeft).SetString("Bummer. No Files Found."),
}
}

Expand All @@ -141,6 +138,11 @@ type Model struct {
// If empty the user may select any file.
AllowedTypes []string

// Various characters used in rendering the UI.
Cursor string
DisabledCursor string
Symlink string

KeyMap KeyMap
files []os.DirEntry
ShowPermissions bool
Expand All @@ -161,7 +163,6 @@ type Model struct {
Height int
AutoHeight bool

Cursor string
Styles Styles
}

Expand Down Expand Up @@ -379,7 +380,12 @@ func (m Model) View() string {

disabled := !m.canSelect(name) && !f.IsDir()

if m.selected == i {
cursor := m.Styles.Cursor.Render(m.Cursor)
if disabled {
cursor = m.Styles.DisabledCursor.Render(m.DisabledCursor)
}

if m.selected == i { //nolint:nestif
selected := ""
if m.ShowPermissions {
selected += " " + info.Mode().String()
Expand All @@ -389,12 +395,12 @@ func (m Model) View() string {
}
selected += " " + name
if isSymlink {
selected += " → " + symlinkPath
selected += fmt.Sprintf(" %s %s", m.Symlink, symlinkPath)
}
if disabled {
s.WriteString(m.Styles.DisabledSelected.Render(m.Cursor) + m.Styles.DisabledSelected.Render(selected))
s.WriteString(cursor + m.Styles.DisabledSelected.Render(selected))
} else {
s.WriteString(m.Styles.Cursor.Render(m.Cursor) + m.Styles.Selected.Render(selected))
s.WriteString(cursor + m.Styles.Selected.Render(selected))
}
s.WriteRune('\n')
continue
Expand All @@ -410,7 +416,11 @@ func (m Model) View() string {
}

fileName := style.Render(name)
s.WriteString(m.Styles.Cursor.Render(" "))

// Replace the cursor with an empty space.
gap := strings.Repeat(" ", lipgloss.Width(cursor))
s.WriteString(gap)

if isSymlink {
fileName += " → " + symlinkPath
}
Expand Down
9 changes: 6 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ require (
github.com/MakeNowJust/heredoc v1.0.0
github.com/atotto/clipboard v0.1.4
github.com/charmbracelet/bubbles v0.20.0
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.1.0.20240919172237-265996c29bea
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.1.0.20241023203658-f182f1686950
github.com/charmbracelet/harmonica v0.2.0
github.com/charmbracelet/lipgloss v0.13.0
github.com/charmbracelet/lipgloss v0.13.2-0.20241021214538-5ea375b95bbe
github.com/charmbracelet/x/ansi v0.3.2
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91
github.com/dustin/go-humanize v1.0.1
Expand All @@ -22,11 +22,14 @@ require (
require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymanbagabas/go-udiff v0.2.0 // indirect
github.com/charmbracelet/colorprofile v0.1.2 // indirect
github.com/charmbracelet/x/input v0.2.0 // indirect
github.com/charmbracelet/x/term v0.2.0 // indirect
github.com/charmbracelet/x/windows v0.2.0 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/sys v0.26.0 // indirect
)
21 changes: 14 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,28 @@ github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWp
github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA=
github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE=
github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU=
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.1.0.20240919172237-265996c29bea h1:i32Z8pIQujNjR2BffDviAnai2L9oLMW7jMd7aCD8Jqg=
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.1.0.20240919172237-265996c29bea/go.mod h1:j0gn4ft5CE7NDYNZjAA3hBM8t2OPjI8urxuAD0oR4w8=
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.1.0.20241023203658-f182f1686950 h1:gMikaO49+8jDZ04/gO5jrLNnrmpayxnzj4Gp+ACCHyI=
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.1.0.20241023203658-f182f1686950/go.mod h1:8vhUTCIihfP3GfyyfznbOU7XyFe/ID1n7pdh/uT5Rug=
github.com/charmbracelet/colorprofile v0.1.2 h1:nuB1bd/yAExT4fkcZvpqtQ2N5/8cJHSRIKb6CzT7lAM=
github.com/charmbracelet/colorprofile v0.1.2/go.mod h1:1htIKZYeI4TQs+OykPvpuBTUbUJxBYeSYBDIZuejMj0=
github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw=
github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY=
github.com/charmbracelet/lipgloss v0.13.2-0.20241021214538-5ea375b95bbe h1:THq8diW6MTHOC13UAOxKFVBL/MD437HyTmS0g54vxsk=
github.com/charmbracelet/lipgloss v0.13.2-0.20241021214538-5ea375b95bbe/go.mod h1:S+zi6HCChYq08TKQZpf3KEi7D/RO62JjxwNXbv6KVxA=
github.com/charmbracelet/x/ansi v0.3.2 h1:wsEwgAN+C9U06l9dCVMX0/L3x7ptvY1qmjMwyfE6USY=
github.com/charmbracelet/x/ansi v0.3.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ=
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
github.com/charmbracelet/x/input v0.2.0 h1:1Sv+y/flcqUfUH2PXNIDKDIdT2G8smOnGOgawqhwy8A=
github.com/charmbracelet/x/input v0.2.0/go.mod h1:KUSFIS6uQymtnr5lHVSOK9j8RvwTD4YHnWnzJUYnd/M=
github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0=
github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0=
github.com/charmbracelet/x/windows v0.2.0 h1:ilXA1GJjTNkgOm94CLPeSz7rar54jtFatdmoiONPuEw=
github.com/charmbracelet/x/windows v0.2.0/go.mod h1:ZibNFR49ZFqCXgP76sYanisxRyC+EYrBE7TTknD8s1s=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
Expand All @@ -42,9 +48,10 @@ github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA=
github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
91 changes: 52 additions & 39 deletions help/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type KeyMap interface {

// Styles is a set of available style definitions for the Help bubble.
type Styles struct {
// The symbol we use in the short help when help items have been truncated
// due to width. Periods of ellipsis by default.
Ellipsis lipgloss.Style

// Styling for the short help
Expand All @@ -41,51 +43,62 @@ type Styles struct {
FullSeparator lipgloss.Style
}

// BaseStyles returns a set of styles with layouts, but no colors.
func BaseStyles() Styles {
return Styles{
Ellipsis: lipgloss.NewStyle().SetString("…"),
ShortSeparator: lipgloss.NewStyle().SetString(" • "),
FullSeparator: lipgloss.NewStyle().SetString(" "),
}
}

// DefaultStylesDark returns a set of dark background styles for help.
func DefaultStylesDark() Styles {
var (
s = BaseStyles()
keyColor = lipgloss.Color("#626262")
descColor = lipgloss.Color("#4A4A4A")
sepColor = lipgloss.Color("#3C3C3C")
)

s.ShortKey = s.ShortKey.Foreground(keyColor)
s.ShortDesc = s.ShortDesc.Foreground(descColor)
s.ShortSeparator = s.ShortSeparator.Foreground(sepColor)
s.FullKey = s.FullKey.Foreground(keyColor)
s.FullDesc = s.FullDesc.Foreground(descColor)
s.FullSeparator = s.FullSeparator.Foreground(sepColor)
return s
}

// DefaultStylesLight returns a set of light background styles for help.
func DefaultStylesLight() Styles {
var (
s = BaseStyles()
keyColor = lipgloss.Color("#909090")
descColor = lipgloss.Color("#B2B2B2")
sepColor = lipgloss.Color("#DDDADA")
)

s.ShortKey = s.ShortKey.Foreground(keyColor)
s.ShortDesc = s.ShortDesc.Foreground(descColor)
s.ShortSeparator = s.ShortSeparator.Foreground(sepColor)
s.FullKey = s.FullKey.Foreground(keyColor)
s.FullDesc = s.FullDesc.Foreground(descColor)
s.FullSeparator = s.FullSeparator.Foreground(sepColor)
return s
}

// Model contains the state of the help view.
type Model struct {
Width int
ShowAll bool // if true, render the "full" help menu

ShortSeparator string
FullSeparator string

// The symbol we use in the short help when help items have been truncated
// due to width. Periods of ellipsis by default.
Ellipsis string

Styles Styles
Styles Styles
}

// New creates a new help view with some useful defaults.
func New() Model {
keyStyle := lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{
Light: "#909090",
Dark: "#626262",
})

descStyle := lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{
Light: "#B2B2B2",
Dark: "#4A4A4A",
})

sepStyle := lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{
Light: "#DDDADA",
Dark: "#3C3C3C",
})

return Model{
ShortSeparator: " • ",
FullSeparator: " ",
Ellipsis: "…",
Styles: Styles{
ShortKey: keyStyle,
ShortDesc: descStyle,
ShortSeparator: sepStyle,
Ellipsis: sepStyle,
FullKey: keyStyle,
FullDesc: descStyle,
FullSeparator: sepStyle,
},
Styles: DefaultStylesDark(),
}
}

Expand All @@ -112,7 +125,7 @@ func (m Model) ShortHelpView(bindings []key.Binding) string {

var b strings.Builder
var totalWidth int
separator := m.Styles.ShortSeparator.Inline(true).Render(m.ShortSeparator)
separator := m.Styles.ShortSeparator.Inline(true).String()

for i, kb := range bindings {
if !kb.Enabled() {
Expand Down Expand Up @@ -160,7 +173,7 @@ func (m Model) FullHelpView(groups [][]key.Binding) string {
out []string

totalWidth int
separator = m.Styles.FullSeparator.Inline(true).Render(m.FullSeparator)
separator = m.Styles.FullSeparator.Inline(true).String()
)

// Iterate over groups to build columns
Expand Down Expand Up @@ -215,7 +228,7 @@ func (m Model) FullHelpView(groups [][]key.Binding) string {
func (m Model) shouldAddItem(totalWidth, width int) (tail string, ok bool) {
// If there's room for an ellipsis, print that.
if m.Width > 0 && totalWidth+width > m.Width {
tail = " " + m.Styles.Ellipsis.Inline(true).Render(m.Ellipsis)
tail = " " + m.Styles.Ellipsis.Inline(true).String()

if totalWidth+lipgloss.Width(tail) < m.Width {
return tail, false
Expand Down
6 changes: 4 additions & 2 deletions help/help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"fmt"
"testing"

"github.com/charmbracelet/x/ansi"
"github.com/charmbracelet/x/exp/golden"

"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/v2/key"
)

func TestFullHelp(t *testing.T) {
m := New()
m.FullSeparator = " | "
m.Styles.FullSeparator = m.Styles.FullSeparator.SetString(" | ")
k := key.WithKeys("x")
kb := [][]key.Binding{
{
Expand All @@ -32,6 +33,7 @@ func TestFullHelp(t *testing.T) {
t.Run(fmt.Sprintf("full help %d width", w), func(t *testing.T) {
m.Width = w
s := m.FullHelpView(kb)
s = ansi.Strip(s)
golden.RequireEqual(t, []byte(s))
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package memoization implement a simple memoization cache. It's designed to
// improve performance in textarea.
package memoization

import (
Expand Down
4 changes: 2 additions & 2 deletions runeutil/runeutil.go → internal/runeutil/runeutil.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package runeutil provides a utility function for use in Bubbles
// that can process Key messages containing runes.
// Package runeutil provides utility functions for tidying up incoming runes
// from Key messages.
package runeutil

import (
Expand Down
File renamed without changes.
Loading
Loading