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

WithProfile not respected in custom rendered #267

Open
goyapara-deshaw opened this issue Mar 12, 2024 · 0 comments
Open

WithProfile not respected in custom rendered #267

goyapara-deshaw opened this issue Mar 12, 2024 · 0 comments

Comments

@goyapara-deshaw
Copy link

goyapara-deshaw commented Mar 12, 2024

Describe the bug
When a custom renderer is defined with the WithProfile method, it is not being respected, when TERM=xterm and COLORTERM is unset.

Setup
Please complete the following information along with version numbers, if applicable.

  • OS Linux
  • Shell bash
  • Terminal Emulator PuTTy

To Reproduce
export TERM=xterm
unset COLORTERM

and run the below code:

package main

import (
        "fmt"
        "os"

        "github.com/charmbracelet/lipgloss"
        "github.com/muesli/termenv"
)

func main() {
        renderer := lipgloss.NewRenderer(os.Stdout, termenv.WithProfile(termenv.TrueColor))
        style := renderer.NewStyle().Foreground(lipgloss.Color("#FF0000")) // bright red
        fmt.Fprint(os.Stdout, style.Render("Hello, World!"))
}

Source Code
We have to explicitly do:

package main

import (
        "fmt"
        "os"

        "github.com/charmbracelet/lipgloss"
        "github.com/muesli/termenv"
)

func main() {
        renderer := lipgloss.NewRenderer(os.Stdout, termenv.WithProfile(termenv.TrueColor))
		renderer.SetColorProfile = termenv.TrueColor
        style := renderer.NewStyle().Foreground(lipgloss.Color("#FF0000")) // bright red
        fmt.Fprint(os.Stdout, style.Render("Hello, World!"))
}

Expected behavior
It should render in color.

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