internal/tui/components/chat/sidebar/sidebar.go 🔗
@@ -250,6 +250,7 @@ func (m *sidebarCmp) logoBlock() string {
TitleColorB: t.Primary,
CharmColor: t.Secondary,
VersionColor: t.Primary,
+ Width: m.width - 2,
})
}
Kujtim Hoxha created
fix(tui): logo: make sure we truncate the logo if it exceeds the width
internal/tui/components/chat/sidebar/sidebar.go | 1 +
internal/tui/components/logo/logo.go | 11 ++++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
@@ -250,6 +250,7 @@ func (m *sidebarCmp) logoBlock() string {
TitleColorB: t.Primary,
CharmColor: t.Secondary,
VersionColor: t.Primary,
+ Width: m.width - 2,
})
}
@@ -98,7 +98,16 @@ func Render(version string, compact bool, o Opts) string {
// Return the wide version.
const hGap = " "
- return lipgloss.JoinHorizontal(lipgloss.Top, leftField.String(), hGap, crush, hGap, rightField.String())
+ logo := lipgloss.JoinHorizontal(lipgloss.Top, leftField.String(), hGap, crush, hGap, rightField.String())
+ if o.Width > 0 {
+ // Truncate the logo to the specified width.
+ lines := strings.Split(logo, "\n")
+ for i, line := range lines {
+ lines[i] = ansi.Truncate(line, o.Width, "")
+ }
+ logo = strings.Join(lines, "\n")
+ }
+ return logo
}
// renderWord renders letterforms to fork a word.