From add13c8028c4e3f2b4d7ce9677e66465e600065d Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Thu, 2 Sep 2021 16:13:22 -0400 Subject: [PATCH] Add a lipgloss style to the viewport for borders, margins, and padding --- viewport/viewport.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/viewport/viewport.go b/viewport/viewport.go index 48b3c54..d6b07a2 100644 --- a/viewport/viewport.go +++ b/viewport/viewport.go @@ -6,6 +6,7 @@ import ( "github.com/charmbracelet/bubbles/key" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/lipgloss" ) // NewModel returns a new model with the given width and height as well as @@ -40,6 +41,10 @@ type Model struct { // window. It's used in high performance rendering only. YPosition int + // Style applies a lipgloss style to the viewport. Realistically, it's most + // useful for setting borders, margins and padding. + Style lipgloss.Style + // HighPerformanceRendering bypasses the normal Bubble Tea renderer to // provide higher performance rendering. Most of the time the normal Bubble // Tea rendering methods will suffice, but if you're passing content with @@ -340,7 +345,7 @@ func (m Model) View() string { extraLines = strings.Repeat("\n", max(0, m.Height-len(lines))) } - return strings.Join(lines, "\n") + extraLines + return m.Style.Render(strings.Join(lines, "\n") + extraLines) } // ETC