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

fix(renderer): use termenv default renderer #179

Merged
merged 1 commit into from Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions renderer.go
Expand Up @@ -2,12 +2,15 @@ package lipgloss

import (
"io"
"os"

"github.com/muesli/termenv"
)

var renderer = NewRenderer(os.Stdout)
// We're manually creating the struct here to avoid initializing the output and
// query the terminal multiple times.
var renderer = &Renderer{
output: termenv.DefaultOutput(),
}

// Renderer is a lipgloss terminal renderer.
type Renderer struct {
Expand Down
2 changes: 1 addition & 1 deletion style.go
Expand Up @@ -148,7 +148,7 @@
s.init()

for k, v := range i.rules {
switch k {

Check failure on line 151 in style.go

View workflow job for this annotation

GitHub Actions / lint-soft

missing cases in switch of type lipgloss.propKey: lipgloss.boldKey, lipgloss.italicKey, lipgloss.underlineKey, lipgloss.strikethroughKey, lipgloss.reverseKey, lipgloss.blinkKey, lipgloss.faintKey, lipgloss.foregroundKey, lipgloss.widthKey, lipgloss.heightKey, lipgloss.alignHorizontalKey, lipgloss.alignVerticalKey, lipgloss.colorWhitespaceKey, lipgloss.marginBackgroundKey, lipgloss.borderStyleKey, lipgloss.borderTopKey, lipgloss.borderRightKey, lipgloss.borderBottomKey, lipgloss.borderLeftKey, lipgloss.borderTopForegroundKey, lipgloss.borderRightForegroundKey, lipgloss.borderBottomForegroundKey, lipgloss.borderLeftForegroundKey, lipgloss.borderTopBackgroundKey, lipgloss.borderRightBackgroundKey, lipgloss.borderBottomBackgroundKey, lipgloss.borderLeftBackgroundKey, lipgloss.inlineKey, lipgloss.maxWidthKey, lipgloss.maxHeightKey, lipgloss.underlineSpacesKey, lipgloss.strikethroughSpacesKey (exhaustive)
case marginTopKey, marginRightKey, marginBottomKey, marginLeftKey:
// Margins are not inherited
continue
Expand All @@ -173,7 +173,7 @@
// Render applies the defined style formatting to a given string.
func (s Style) Render(strs ...string) string {
if s.r == nil {
s.r = DefaultRenderer()
s.r = renderer
}
if s.value != "" {
strs = append([]string{s.value}, strs...)
Expand Down Expand Up @@ -326,7 +326,7 @@
}

// Padding
if !inline {

Check failure on line 329 in style.go

View workflow job for this annotation

GitHub Actions / lint-soft

`if !inline` has complex nested blocks (complexity: 8) (nestif)
if leftPadding > 0 {
var st *termenv.Style
if colorWhitespace || styleWhitespace {
Expand Down