@@ -83,14 +83,24 @@ func New(numChars int, label string, t *styles.Theme) (a Anim) {
83 a.width += labelGapWidth + lipgloss.Width(label)
83 a.width += labelGapWidth + lipgloss.Width(label)
86+ if a.labelWidth > 0 {
86− // Pre-render the label.
87+ // Pre-render the label.
87− // XXX: We should really get the graphemes for the label, not the runes.
88+ // XXX: We should really get the graphemes for the label, not the runes.
88− labelRunes := []rune(label)
89+ labelRunes := []rune(label)
89− a.label = make([]string, len(labelRunes))
90+ a.label = make([]string, len(labelRunes))
90− for i := range a.label {
91+ for i := range a.label {
91− a.label[i] = lipgloss.NewStyle().
92+ a.label[i] = lipgloss.NewStyle().
92− Foreground(t.FgBase).
93+ Foreground(t.FgBase).
93− Render(string(labelRunes[i]))
94+ Render(string(labelRunes[i]))
97+ // Pre-render the ellipsis frames which come after the label.
98+ a.ellipsisFrames = make([]string, len(ellipsisFrames))
99+ for i, frame := range ellipsisFrames {
100+ a.ellipsisFrames[i] = lipgloss.NewStyle().
101+ Foreground(t.FgBase).
96 // Pre-generate gradient.
106 // Pre-generate gradient.
@@ -104,14 +114,6 @@ func New(numChars int, label string, t *styles.Theme) (a Anim) {
104 Render(string(initialChar))
114 Render(string(initialChar))
107− // Pre-render the ellipsis frames.
108− a.ellipsisFrames = make([]string, len(ellipsisFrames))
109− for i, frame := range ellipsisFrames {
110− a.ellipsisFrames[i] = lipgloss.NewStyle().
111− Foreground(t.FgBase).
115 // Prerender scrambled rune frames for the animation.
117 // Prerender scrambled rune frames for the animation.
116 a.cyclingFrames = make([][]string, prerenderedFrames)
118 a.cyclingFrames = make([][]string, prerenderedFrames)
117 for i := range a.cyclingFrames {
119 for i := range a.cyclingFrames {
@@ -154,7 +156,7 @@ func (a Anim) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
154 a.step = 0
156 a.step = 0
157− if a.initialized {
159+ if a.initialized && a.labelWidth > 0 {
158 // Manage the ellipsis animation.
160 // Manage the ellipsis animation.
159 a.ellipsisStep++
161 a.ellipsisStep++
160 if a.ellipsisStep >= ellipsisAnimSpeed*len(ellipsisFrames) {
162 if a.ellipsisStep >= ellipsisAnimSpeed*len(ellipsisFrames) {
@@ -190,7 +192,7 @@ func (a Anim) View() tea.View {
191 // Render animated ellipsis at the end of the label if all characters
193 // Render animated ellipsis at the end of the label if all characters
192 // have been initialized.
194 // have been initialized.
193− if a.initialized {
195+ if a.initialized && a.labelWidth > 0 {
194 b.WriteString(a.ellipsisFrames[a.ellipsisStep/ellipsisAnimSpeed])
196 b.WriteString(a.ellipsisFrames[a.ellipsisStep/ellipsisAnimSpeed])
196 return tea.NewView(b.String())
198 return tea.NewView(b.String())