on main help sign in
fix(tui): logo: make sure we truncate the logo if it exceeds the width
ddeec85Ayman Bagabas
internal/tui/components/chat/sidebar/sidebar.go+1
@@ -250,6 +250,7 @@ func (m *sidebarCmp) logoBlock() string {
250 TitleColorB: t.Primary,
250 TitleColorB: t.Primary,
251 CharmColor: t.Secondary,
251 CharmColor: t.Secondary,
252 VersionColor: t.Primary,
252 VersionColor: t.Primary,
253+ Width: m.width - 2,
253 })
254 })
254}
255}
255
256
internal/tui/components/logo/logo.go+10−1
@@ -98,7 +98,16 @@ func Render(version string, compact bool, o Opts) string {
98
98
99 // Return the wide version.
99 // Return the wide version.
100 const hGap = " "
100 const hGap = " "
101− return lipgloss.JoinHorizontal(lipgloss.Top, leftField.String(), hGap, crush, hGap, rightField.String())
101+ logo := lipgloss.JoinHorizontal(lipgloss.Top, leftField.String(), hGap, crush, hGap, rightField.String())
102+ if o.Width > 0 {
103+ // Truncate the logo to the specified width.
104+ lines := strings.Split(logo, "\n")
105+ for i, line := range lines {
106+ lines[i] = ansi.Truncate(line, o.Width, "")
107+ }
108+ logo = strings.Join(lines, "\n")
109+ }
110+ return logo
102}
111}
103
112
104// renderWord renders letterforms to fork a word.
113// renderWord renders letterforms to fork a word.