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

freeze issue with lipgloss* colors #117

Open
jkellogg01 opened this issue Jul 25, 2024 · 1 comment
Open

freeze issue with lipgloss* colors #117

jkellogg01 opened this issue Jul 25, 2024 · 1 comment

Comments

@jkellogg01
Copy link

jkellogg01 commented Jul 25, 2024

Describe the bug
freeze appears to be changing the colors of captured terminal output and I'm not sure why.

Reproduction
Here is a minimal reproduction of the issue I'm experiencing:

package main

import (
        "fmt"

        "github.com/charmbracelet/lipgloss"
        "github.com/charmbracelet/lipgloss/list"
)

func main() {
        l := list.New(
                elem("dotstash", "by sowing"),
                elem("other-config", "by joe standard"),
                elem("this one is empty", "by john testman"),
        ).Enumerator(func(items list.Items, index int) string { return "" }).
                ItemStyleFunc(func(items list.Items, index int) lipgloss.Style {
                        def := lipgloss.NewStyle().
                                Padding(0, 1).MarginBottom(1).Border(lipgloss.NormalBorder(), false, false, false, true)
                        if index == 0 {
                                highlight := lipgloss.Color("#F780E2")
                                return def.Foreground(highlight).BorderForeground(highlight)
                        }
                        return def
                })
        fmt.Println(l)
}

func elem(title, desc string) string {
        return lipgloss.JoinVertical(0,
                lipgloss.NewStyle().Bold(true).Render(title),
                lipgloss.NewStyle().Italic(true).Render(desc),
        )
}

When the program is run, the first element will be entirely pink, but when the output is captured by freeze using the -x flag, the left border will remain pink, while the text will have the color removed.

Expected behavior
Commands that output color that is normally entirely colored are instead stripped of their color when the output is captured using freeze -x <command>

Screenshots

first screenshot is captured output from the program I'm working on, second is captured output from the reproduction program above.

output from my actual program

repro output

Desktop (please complete the following information):

  • OS: Pop!_os
  • Terminal: Wezterm
@jkellogg01
Copy link
Author

this also might have something to do with the use of lipgloss.JoinVertical; when I removed it from my reproduction the colors were rendered correctly:

package main

import (
        "fmt"

        "github.com/charmbracelet/lipgloss"
        "github.com/charmbracelet/lipgloss/list"
)

func main() {
        l := list.New(
                "dotstash",
                "other-config",
        ).Enumerator(func(items list.Items, index int) string { return "" }).
                ItemStyleFunc(func(items list.Items, index int) lipgloss.Style {
                        def := lipgloss.NewStyle().
                                Padding(0, 1).MarginBottom(1).Border(lipgloss.NormalBorder(), false, false, false, true)
                        if index == 0 {
                                highlight := lipgloss.Color("#F780E2")
                                return def.Foreground(highlight).BorderForeground(highlight)
                        }
                        return def
                })
        fmt.Println(l)
}

test-smaller

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