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

Provide ability to prevent insertion of Reset sequence #144

Open
dlvhdr opened this issue Oct 9, 2022 · 0 comments
Open

Provide ability to prevent insertion of Reset sequence #144

dlvhdr opened this issue Oct 9, 2022 · 0 comments

Comments

@dlvhdr
Copy link

dlvhdr commented Oct 9, 2022

I want to be able to concatenate two strings with different foreground colors, but not have termenv insert the reset sequence in between.
The reset sequence prevents the ability to set a shared background for the strings without setting a bg on both strings individually.

My use case is a custom table component I implemented.
When a row is selected, I apply a background on the entire row, but the bg is only applied on the first string, because of the reset sequence.

This is the raw string:

'\x1B[41m\x1B[38;5;245m#158\x1B[0m\x1B[38;5;245mDifferentiate draft PRs from open PRs\x1B[0m\x1B[0m'

Which is the result of calling:

	prNumber := lipgloss.NewStyle().Foreground("<some fg>").Render("#158")
	title := lipgloss.NewStyle().Foreground("<some other fg>").Render("Differentiate draft PRs from open PRs")
	lipgloss.NewStyle().Background(lipgloss.Color("1")).
		Render(fmt.Sprintf("%s%s", prNumber, title))

What have I tried

  • Using lipgloss.JoinHorizontal yields the same results
  • I can always do prNumber = strings.Replace(prNumber, "\x1b[0", "", -1) which works but feels hacky as it relies on the escape sequence encoding termenv is using.

Possible solution

Maybe provide a PreventReset() method on the lipgloss.Style?

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

No branches or pull requests

1 participant