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

Add content style for controlling colors within viewport #445

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Rydez
Copy link

@Rydez Rydez commented Dec 8, 2023

There's a weird issue when attempting to change the colors within the viewport when the using reflow/wrap.

Here's a code example:

var c1 = lipgloss.Color("111")
var c2 = lipgloss.Color("123")
var c3 = lipgloss.Color("239")

func main() {
	const name = "somebody"
	const msg = "a nice message about some things."

	const limit = 20

	nameStyle := lipgloss.NewStyle().Foreground(c1).Background(c3)
	msgStyle := lipgloss.NewStyle().Foreground(c2).Background(c3)
	wrapped := wrap.String(nameStyle.Render(name+": ")+msgStyle.Render(msg), limit)

	vp := viewport.New(20, 5)

	vpStyle := lipgloss.NewStyle().Foreground(c2).Background(c3)
	vp.Style = vpStyle

	vp.SetContent(wrapped)

	fmt.Println(vp.View())
}

which results in:
pr-screen-cap

However, with this PR and changing the code above like so:

-	vp.Style = vpStyle
+	vp.ContentStyle = vpStyl

the result is:
fixed

I struggled to find a way to get this result without changing viewport.go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant