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

(v2) feat: add compat package #419

Merged
merged 9 commits into from
Nov 12, 2024
Merged

(v2) feat: add compat package #419

merged 9 commits into from
Nov 12, 2024

Conversation

aymanbagabas
Copy link
Member

@aymanbagabas aymanbagabas commented Oct 31, 2024

This adds a compatibility layer for Lip Gloss that provides a way to continue using AdaptiveColor and CompleteColor. It's impure because it uses global variables, is not thread-safe, and only works with the default standard I/O streams.

Users are encouraged to use the pure API when possible.

Here's an example to use a different output as the default:

import (
	"os"

	"github.com/charmbracelet/colorprofile"
	"github.com/charmbracelet/lipgloss/v2/compat"
)

func init() {
	compat.Profile = colorprofile.Detect(os.Stderr, os.Environ())
	compat.HasDarkBackground, _ = lipgloss.HasDarkBackground(os.Stdin, os.Stderr)
}

@aymanbagabas aymanbagabas force-pushed the v2-impure branch 3 times, most recently from 3302047 to 3b9aaed Compare October 31, 2024 20:07
@aymanbagabas aymanbagabas added the v2 label Nov 1, 2024
@aymanbagabas aymanbagabas added this to the v2.0.0 milestone Nov 1, 2024
@aymanbagabas aymanbagabas changed the title (v2) feat: add impure package (v2) feat: add combat package Nov 4, 2024
@aymanbagabas aymanbagabas changed the title (v2) feat: add combat package (v2) feat: add compat package Nov 4, 2024
examples/go.mod Outdated Show resolved Hide resolved
This adds a compatibility layer for Lip Gloss that provides a way to
continue using `AdaptiveColor` and `CompleteColor`. It's impure because
it uses global variables, is not thread-safe, and only works with the
default standard I/O streams.

Users are encouraged to use the pure API when possible.
@aymanbagabas aymanbagabas merged commit ec86e88 into v2-exp Nov 12, 2024
19 checks passed
@aymanbagabas aymanbagabas deleted the v2-impure branch November 12, 2024 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants