Skip to content

WithProfile not respected in custom rendered #267

@goyapara-deshaw

Description

@goyapara-deshaw

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions