From 6916e64d7bec00bda2ac5dae3214fcc5c7c9d6cc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 22 Aug 2023 22:48:25 +0000 Subject: [PATCH] fix(deps): update module github.com/charmbracelet/log to v0.2.4 --- go.mod | 4 +- go.sum | 4 ++ .../charmbracelet/lipgloss/.gitignore | 2 +- .../github.com/charmbracelet/lipgloss/LICENSE | 2 +- .../charmbracelet/lipgloss/README.md | 53 ++++++++++++++++++ .../charmbracelet/lipgloss/align.go | 7 ++- .../charmbracelet/lipgloss/borders.go | 4 +- .../charmbracelet/lipgloss/color.go | 6 +- .../github.com/charmbracelet/lipgloss/get.go | 24 +++++--- .../github.com/charmbracelet/lipgloss/join.go | 4 +- .../charmbracelet/lipgloss/position.go | 8 +-- .../charmbracelet/lipgloss/renderer.go | 55 ++++++++++++++++--- .../github.com/charmbracelet/lipgloss/set.go | 48 ++++++++++++---- .../charmbracelet/lipgloss/style.go | 32 +++++++++-- .../charmbracelet/lipgloss/unset.go | 10 +++- .../charmbracelet/lipgloss/whitespace.go | 2 +- vendor/modules.txt | 4 +- 17 files changed, 213 insertions(+), 56 deletions(-) diff --git a/go.mod b/go.mod index 5cbc53d..ae0edd0 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/Masterminds/sprig/v3 v3.2.3 - github.com/charmbracelet/log v0.2.3 + github.com/charmbracelet/log v0.2.4 github.com/gomarkdown/markdown v0.0.0-20230716120725-531d2d74bc12 github.com/kataras/i18n v0.0.8 github.com/playwright-community/playwright-go v0.3500.0 @@ -19,7 +19,7 @@ require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.2.0 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/charmbracelet/lipgloss v0.7.1 // indirect + github.com/charmbracelet/lipgloss v0.8.0 // indirect github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-jose/go-jose/v3 v3.0.0 // indirect diff --git a/go.sum b/go.sum index fe715c1..039177f 100644 --- a/go.sum +++ b/go.sum @@ -51,12 +51,16 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/charmbracelet/lipgloss v0.7.1 h1:17WMwi7N1b1rVWOjMT+rCh7sQkvDU75B2hbZpc5Kc1E= github.com/charmbracelet/lipgloss v0.7.1/go.mod h1:yG0k3giv8Qj8edTCbbg6AlQ5e8KNWpFujkNawKNhE2c= +github.com/charmbracelet/lipgloss v0.8.0 h1:IS00fk4XAHcf8uZKc3eHeMUTCxUH6NkaTrdyCQk84RU= +github.com/charmbracelet/lipgloss v0.8.0/go.mod h1:p4eYUZZJ/0oXTuCQKFF8mqyKCz0ja6y+7DniDDw5KKU= github.com/charmbracelet/log v0.2.1 h1:1z7jpkk4yKyjwlmKmKMM5qnEDSpV32E7XtWhuv0mTZE= github.com/charmbracelet/log v0.2.1/go.mod h1:GwFfjewhcVDWLrpAbY5A0Hin9YOlEn40eWT4PNaxFT4= github.com/charmbracelet/log v0.2.2 h1:CaXgos+ikGn5tcws5Cw3paQuk9e/8bIwuYGhnkqQFjo= github.com/charmbracelet/log v0.2.2/go.mod h1:Zs11hKpb8l+UyX4y1srwZIGW+MPCXJHIty3MB9l/sno= github.com/charmbracelet/log v0.2.3 h1:YVmBhJtpGL7nW/nlf5u+SEloU8XYljxozGzZpgwIvhs= github.com/charmbracelet/log v0.2.3/go.mod h1:ZApwwzDbbETVTIRTk7724yQRJAXIktt98yGVMMaa3y8= +github.com/charmbracelet/log v0.2.4 h1:3pKtq5/Y5QMKtcZt7kDqD1p9w7lICzHYQACBFY4ocHA= +github.com/charmbracelet/log v0.2.4/go.mod h1:nQGK8tvc4pS9cvVEH/pWJiZ50eUq1aoXUOjGpXvdD0k= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= diff --git a/vendor/github.com/charmbracelet/lipgloss/.gitignore b/vendor/github.com/charmbracelet/lipgloss/.gitignore index a170af0..53e1c2b 100644 --- a/vendor/github.com/charmbracelet/lipgloss/.gitignore +++ b/vendor/github.com/charmbracelet/lipgloss/.gitignore @@ -1 +1 @@ -ssh_example_ed25519* \ No newline at end of file +ssh_example_ed25519* diff --git a/vendor/github.com/charmbracelet/lipgloss/LICENSE b/vendor/github.com/charmbracelet/lipgloss/LICENSE index ece3536..6f5b1fa 100644 --- a/vendor/github.com/charmbracelet/lipgloss/LICENSE +++ b/vendor/github.com/charmbracelet/lipgloss/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 Charmbracelet, Inc +Copyright (c) 2021-2023 Charmbracelet, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/github.com/charmbracelet/lipgloss/README.md b/vendor/github.com/charmbracelet/lipgloss/README.md index a071564..2ebabc7 100644 --- a/vendor/github.com/charmbracelet/lipgloss/README.md +++ b/vendor/github.com/charmbracelet/lipgloss/README.md @@ -294,6 +294,20 @@ someStyle.Inline(true).MaxWidth(5).Render("yadda yadda") someStyle.MaxWidth(5).MaxHeight(5).Render("yadda yadda") ``` +## Tabs + +The tab character (`\t`) is rendered differently in different terminals (often +as 8 spaces, sometimes 4). Because of this inconsistency, Lip Gloss converts +tabs to 4 spaces at render time. This behavior can be changed on a per-style +basis, however: + +```go +style := lipgloss.NewStyle() // tabs will render as 4 spaces, the default +style = style.TabWidth(2) // render tabs as 2 spaces +style = style.TabWidth(0) // remove tabs entirely +style = style.TabWidth(lipgloss.NoTabConversion) // leave tabs intact +``` + ## Rendering Generally, you just call the `Render(string...)` method on a `lipgloss.Style`: @@ -400,6 +414,45 @@ You can also style the whitespace. For details, see [the docs][docs]. *** +## FAQ + +
+ +Why are things misaligning? Why are borders at the wrong widths? + +

This is most likely due to your locale and encoding, particularly with +regard to Chinese, Japanese, and Korean (for example, zh_CN.UTF-8 +or ja_JP.UTF-8). The most direct way to fix this is to set +RUNEWIDTH_EASTASIAN=0 in your environment.

+ +

For details see https://github.com/charmbracelet/lipgloss/issues/40.

+
+ +
+ +Why isn't Lip Gloss displaying colors? + +

Lip Gloss automatically degrades colors to the best available option in the +given terminal, and if output's not a TTY it will remove color output entirely. +This is common when running tests, CI, or when piping output elsewhere.

+ +

If necessary, you can force a color profile in your tests with +SetColorProfile.

+ +```go +import ( + "github.com/charmbracelet/lipgloss" + "github.com/muesli/termenv" +) + +lipgloss.SetColorProfile(termenv.TrueColor) +``` + +*Note:* this option limits the flexibility of your application and can cause +ANSI escape codes to be output in cases where that might not be desired. Take +careful note of your use case and environment before choosing to force a color +profile. +
## What about [Bubble Tea][tea]? diff --git a/vendor/github.com/charmbracelet/lipgloss/align.go b/vendor/github.com/charmbracelet/lipgloss/align.go index c399703..6c0fb2d 100644 --- a/vendor/github.com/charmbracelet/lipgloss/align.go +++ b/vendor/github.com/charmbracelet/lipgloss/align.go @@ -21,7 +21,7 @@ func alignTextHorizontal(str string, pos Position, width int, style *termenv.Sty shortAmount += max(0, width-(shortAmount+lineWidth)) // difference from the total width, if set if shortAmount > 0 { - switch pos { + switch pos { //nolint:exhaustive case Right: s := strings.Repeat(" ", shortAmount) if style != nil { @@ -29,8 +29,9 @@ func alignTextHorizontal(str string, pos Position, width int, style *termenv.Sty } l = s + l case Center: - left := shortAmount / 2 - right := left + shortAmount%2 // note that we put the remainder on the right + // Note: remainder goes on the right. + left := shortAmount / 2 //nolint:gomnd + right := left + shortAmount%2 //nolint:gomnd leftSpaces := strings.Repeat(" ", left) rightSpaces := strings.Repeat(" ", right) diff --git a/vendor/github.com/charmbracelet/lipgloss/borders.go b/vendor/github.com/charmbracelet/lipgloss/borders.go index 1896422..2c49316 100644 --- a/vendor/github.com/charmbracelet/lipgloss/borders.go +++ b/vendor/github.com/charmbracelet/lipgloss/borders.go @@ -32,7 +32,7 @@ func (b Border) GetTopSize() int { // runes of varying widths, the widest rune is returned. If no border exists on // the right edge, 0 is returned. func (b Border) GetRightSize() int { - return getBorderEdgeWidth(b.TopRight, b.Top, b.BottomRight) + return getBorderEdgeWidth(b.TopRight, b.Right, b.BottomRight) } // GetBottomSize returns the width of the bottom border. If borders contain @@ -46,7 +46,7 @@ func (b Border) GetBottomSize() int { // of varying widths, the widest rune is returned. If no border exists on the // left edge, 0 is returned. func (b Border) GetLeftSize() int { - return getBorderEdgeWidth(b.TopLeft, b.Left, b.TopRight) + return getBorderEdgeWidth(b.TopLeft, b.Left, b.BottomLeft) } func getBorderEdgeWidth(borderParts ...string) (maxWidth int) { diff --git a/vendor/github.com/charmbracelet/lipgloss/color.go b/vendor/github.com/charmbracelet/lipgloss/color.go index ef7fd27..43f5b43 100644 --- a/vendor/github.com/charmbracelet/lipgloss/color.go +++ b/vendor/github.com/charmbracelet/lipgloss/color.go @@ -35,7 +35,7 @@ func (NoColor) color(*Renderer) termenv.Color { // // Deprecated. func (n NoColor) RGBA() (r, g, b, a uint32) { - return 0x0, 0x0, 0x0, 0xFFFF + return 0x0, 0x0, 0x0, 0xFFFF //nolint:gomnd } // Color specifies a color by hex or ANSI value. For example: @@ -123,7 +123,7 @@ type CompleteColor struct { func (c CompleteColor) color(r *Renderer) termenv.Color { p := r.ColorProfile() - switch p { + switch p { //nolint:exhaustive case termenv.TrueColor: return p.Color(c.TrueColor) case termenv.ANSI256: @@ -146,7 +146,7 @@ func (c CompleteColor) RGBA() (r, g, b, a uint32) { return termenv.ConvertToRGB(c.color(renderer)).RGBA() } -// CompleteColor specifies exact values for truecolor, ANSI256, and ANSI color +// CompleteAdaptiveColor specifies exact values for truecolor, ANSI256, and ANSI color // profiles, with separate options for light and dark backgrounds. Automatic // color degradation will not be performed. type CompleteAdaptiveColor struct { diff --git a/vendor/github.com/charmbracelet/lipgloss/get.go b/vendor/github.com/charmbracelet/lipgloss/get.go index eb24a4e..d0f0826 100644 --- a/vendor/github.com/charmbracelet/lipgloss/get.go +++ b/vendor/github.com/charmbracelet/lipgloss/get.go @@ -53,7 +53,7 @@ func (s Style) GetForeground() TerminalColor { return s.getAsColor(foregroundKey) } -// GetBackground returns the style's back color. If no value is set +// GetBackground returns the style's background color. If no value is set // NoColor{} is returned. func (s Style) GetBackground() TerminalColor { return s.getAsColor(backgroundKey) @@ -191,7 +191,7 @@ func (s Style) GetHorizontalMargins() int { return s.getAsInt(marginLeftKey) + s.getAsInt(marginRightKey) } -// GetVerticalMargins returns the style's top and bottom padding. Unset values +// GetVerticalMargins returns the style's top and bottom margins. Unset values // are measured as 0. func (s Style) GetVerticalMargins() int { return s.getAsInt(marginTopKey) + s.getAsInt(marginBottomKey) @@ -257,7 +257,7 @@ func (s Style) GetBorderBottomForeground() TerminalColor { return s.getAsColor(borderBottomForegroundKey) } -// GetBorderLeftForeground returns the style's border bottom foreground +// GetBorderLeftForeground returns the style's border left foreground // color. If no value is set NoColor{} is returned. func (s Style) GetBorderLeftForeground() TerminalColor { return s.getAsColor(borderLeftForegroundKey) @@ -281,7 +281,7 @@ func (s Style) GetBorderBottomBackground() TerminalColor { return s.getAsColor(borderBottomBackgroundKey) } -// GetBorderLeftBackground returns the style's border bottom background +// GetBorderLeftBackground returns the style's border left background // color. If no value is set NoColor{} is returned. func (s Style) GetBorderLeftBackground() TerminalColor { return s.getAsColor(borderLeftBackgroundKey) @@ -344,9 +344,9 @@ func (s Style) GetHorizontalBorderSize() int { return b.GetLeftSize() + b.GetRightSize() } -// GetVerticalBorderSize returns the width of the horizontal borders. If +// GetVerticalBorderSize returns the width of the vertical borders. If // borders contain runes of varying widths, the widest rune is returned. If no -// border exists on the horizontal edges, 0 is returned. +// border exists on the vertical edges, 0 is returned. func (s Style) GetVerticalBorderSize() int { b := s.getBorderStyle() return b.GetTopSize() + b.GetBottomSize() @@ -364,19 +364,25 @@ func (s Style) GetMaxWidth() int { return s.getAsInt(maxWidthKey) } -// GetMaxHeight returns the style's max width setting. If no value is set 0 is +// GetMaxHeight returns the style's max height setting. If no value is set 0 is // returned. func (s Style) GetMaxHeight() int { return s.getAsInt(maxHeightKey) } +// GetTabWidth returns the style's tab width setting. If no value is set 4 is +// returned which is the implicit default. +func (s Style) GetTabWidth() int { + return s.getAsInt(tabWidthKey) +} + // GetUnderlineSpaces returns whether or not the style is set to underline // spaces. If not value is set false is returned. func (s Style) GetUnderlineSpaces() bool { return s.getAsBool(underlineSpacesKey, false) } -// GetStrikethroughSpaces returns whether or not the style is set to underline +// GetStrikethroughSpaces returns whether or not the style is set to strikethrough // spaces. If not value is set false is returned. func (s Style) GetStrikethroughSpaces() bool { return s.getAsBool(strikethroughSpacesKey, false) @@ -390,7 +396,7 @@ func (s Style) GetHorizontalFrameSize() int { return s.GetHorizontalMargins() + s.GetHorizontalPadding() + s.GetHorizontalBorderSize() } -// GetVerticalFrameSize returns the sum of the style's horizontal margins, padding +// GetVerticalFrameSize returns the sum of the style's vertical margins, padding // and border widths. // // Provisional: this method may be renamed. diff --git a/vendor/github.com/charmbracelet/lipgloss/join.go b/vendor/github.com/charmbracelet/lipgloss/join.go index cc16600..f265976 100644 --- a/vendor/github.com/charmbracelet/lipgloss/join.go +++ b/vendor/github.com/charmbracelet/lipgloss/join.go @@ -60,7 +60,7 @@ func JoinHorizontal(pos Position, strs ...string) string { extraLines := make([]string, maxHeight-len(blocks[i])) - switch pos { + switch pos { //nolint:exhaustive case Top: blocks[i] = append(blocks[i], extraLines...) @@ -139,7 +139,7 @@ func JoinVertical(pos Position, strs ...string) string { for j, line := range block { w := maxWidth - ansi.PrintableRuneWidth(line) - switch pos { + switch pos { //nolint:exhaustive case Left: b.WriteString(line) b.WriteString(strings.Repeat(" ", w)) diff --git a/vendor/github.com/charmbracelet/lipgloss/position.go b/vendor/github.com/charmbracelet/lipgloss/position.go index 28f5ccb..7d229e0 100644 --- a/vendor/github.com/charmbracelet/lipgloss/position.go +++ b/vendor/github.com/charmbracelet/lipgloss/position.go @@ -52,7 +52,7 @@ func PlaceHorizontal(width int, pos Position, str string, opts ...WhitespaceOpti // PlaceHorizontal places a string or text block horizontally in an unstyled // block of a given width. If the given width is shorter than the max width of -// the string (measured by it's longest line) this will be a noöp. +// the string (measured by its longest line) this will be a noöp. func (r *Renderer) PlaceHorizontal(width int, pos Position, str string, opts ...WhitespaceOption) string { lines, contentWidth := getLines(str) gap := width - contentWidth @@ -68,7 +68,7 @@ func (r *Renderer) PlaceHorizontal(width int, pos Position, str string, opts ... // Is this line shorter than the longest line? short := max(0, contentWidth-ansi.PrintableRuneWidth(l)) - switch pos { + switch pos { //nolint:exhaustive case Left: b.WriteString(l) b.WriteString(ws.render(gap + short)) @@ -106,7 +106,7 @@ func PlaceVertical(height int, pos Position, str string, opts ...WhitespaceOptio // PlaceVertical places a string or text block vertically in an unstyled block // of a given height. If the given height is shorter than the height of the -// string (measured by it's newlines) then this will be a noöp. +// string (measured by its newlines) then this will be a noöp. func (r *Renderer) PlaceVertical(height int, pos Position, str string, opts ...WhitespaceOption) string { contentHeight := strings.Count(str, "\n") + 1 gap := height - contentHeight @@ -121,7 +121,7 @@ func (r *Renderer) PlaceVertical(height int, pos Position, str string, opts ...W emptyLine := ws.render(width) b := strings.Builder{} - switch pos { + switch pos { //nolint:exhaustive case Top: b.WriteString(str) b.WriteRune('\n') diff --git a/vendor/github.com/charmbracelet/lipgloss/renderer.go b/vendor/github.com/charmbracelet/lipgloss/renderer.go index 4bea837..85ffd25 100644 --- a/vendor/github.com/charmbracelet/lipgloss/renderer.go +++ b/vendor/github.com/charmbracelet/lipgloss/renderer.go @@ -2,6 +2,7 @@ package lipgloss import ( "io" + "sync" "github.com/muesli/termenv" ) @@ -15,7 +16,16 @@ var renderer = &Renderer{ // Renderer is a lipgloss terminal renderer. type Renderer struct { output *termenv.Output - hasDarkBackground *bool + colorProfile termenv.Profile + hasDarkBackground bool + + getColorProfile sync.Once + explicitColorProfile bool + + getBackgroundColor sync.Once + explicitBackgroundColor bool + + mtx sync.RWMutex } // RendererOption is a function that can be used to configure a [Renderer]. @@ -43,17 +53,32 @@ func NewRenderer(w io.Writer, opts ...termenv.OutputOption) *Renderer { // Output returns the termenv output. func (r *Renderer) Output() *termenv.Output { + r.mtx.RLock() + defer r.mtx.RUnlock() return r.output } // SetOutput sets the termenv output. func (r *Renderer) SetOutput(o *termenv.Output) { + r.mtx.Lock() + defer r.mtx.Unlock() r.output = o } // ColorProfile returns the detected termenv color profile. func (r *Renderer) ColorProfile() termenv.Profile { - return r.output.Profile + r.mtx.RLock() + defer r.mtx.RUnlock() + + if !r.explicitColorProfile { + r.getColorProfile.Do(func() { + // NOTE: we don't need to lock here because sync.Once provides its + // own locking mechanism. + r.colorProfile = r.output.EnvColorProfile() + }) + } + + return r.colorProfile } // ColorProfile returns the detected termenv color profile. @@ -78,7 +103,11 @@ func ColorProfile() termenv.Profile { // // This function is thread-safe. func (r *Renderer) SetColorProfile(p termenv.Profile) { - r.output.Profile = p + r.mtx.Lock() + defer r.mtx.Unlock() + + r.colorProfile = p + r.explicitColorProfile = true } // SetColorProfile sets the color profile on the default renderer. This @@ -110,10 +139,18 @@ func HasDarkBackground() bool { // background. A dark background can either be auto-detected, or set explicitly // on the renderer. func (r *Renderer) HasDarkBackground() bool { - if r.hasDarkBackground != nil { - return *r.hasDarkBackground + r.mtx.RLock() + defer r.mtx.RUnlock() + + if !r.explicitBackgroundColor { + r.getBackgroundColor.Do(func() { + // NOTE: we don't need to lock here because sync.Once provides its + // own locking mechanism. + r.hasDarkBackground = r.output.HasDarkBackground() + }) } - return r.output.HasDarkBackground() + + return r.hasDarkBackground } // SetHasDarkBackground sets the background color detection value for the @@ -139,5 +176,9 @@ func SetHasDarkBackground(b bool) { // // This function is thread-safe. func (r *Renderer) SetHasDarkBackground(b bool) { - r.hasDarkBackground = &b + r.mtx.Lock() + defer r.mtx.Unlock() + + r.hasDarkBackground = b + r.explicitBackgroundColor = true } diff --git a/vendor/github.com/charmbracelet/lipgloss/set.go b/vendor/github.com/charmbracelet/lipgloss/set.go index f8bf9a2..432eac5 100644 --- a/vendor/github.com/charmbracelet/lipgloss/set.go +++ b/vendor/github.com/charmbracelet/lipgloss/set.go @@ -14,7 +14,14 @@ func (s *Style) set(key propKey, value interface{}) { switch v := value.(type) { case int: - // We don't allow negative integers on any of our values, so just keep + // TabWidth is the only property that may have a negative value (and + // that negative value can be no less than -1). + if key == tabWidthKey { + s.rules[key] = v + break + } + + // We don't allow negative integers on any of our other values, so just keep // them at zero or above. We could use uints instead, but the // conversions are a little tedious, so we're sticking with ints for // sake of usability. @@ -126,7 +133,7 @@ func (s Style) AlignHorizontal(p Position) Style { return s } -// AlignVertical sets a text alignment rule. +// AlignVertical sets a vertical text alignment rule. func (s Style) AlignVertical(p Position) Style { s.set(alignVerticalKey, p) return s @@ -497,13 +504,30 @@ func (s Style) MaxWidth(n int) Style { // styles. // // Because this in intended to be used at the time of render, this method will -// not mutate the style and instead return a copy. +// not mutate the style and instead returns a copy. func (s Style) MaxHeight(n int) Style { o := s.Copy() o.set(maxHeightKey, n) return o } +// NoTabConversion can be passed to [Style.TabWidth] to disable the replacement +// of tabs with spaces at render time. +const NoTabConversion = -1 + +// TabWidth sets the number of spaces that a tab (/t) should be rendered as. +// When set to 0, tabs will be removed. To disable the replacement of tabs with +// spaces entirely, set this to [NoTabConversion]. +// +// By default, tabs will be replaced with 4 spaces. +func (s Style) TabWidth(n int) Style { + if n <= -1 { + n = -1 + } + s.set(tabWidthKey, n) + return s +} + // UnderlineSpaces determines whether to underline spaces between words. By // default, this is true. Spaces can also be underlined without underlining the // text itself. @@ -545,19 +569,19 @@ func whichSidesInt(i ...int) (top, right, bottom, left int, ok bool) { left = i[0] right = i[0] ok = true - case 2: + case 2: //nolint:gomnd top = i[0] bottom = i[0] left = i[1] right = i[1] ok = true - case 3: + case 3: //nolint:gomnd top = i[0] left = i[1] right = i[1] bottom = i[2] ok = true - case 4: + case 4: //nolint:gomnd top = i[0] right = i[1] bottom = i[2] @@ -578,19 +602,19 @@ func whichSidesBool(i ...bool) (top, right, bottom, left bool, ok bool) { left = i[0] right = i[0] ok = true - case 2: + case 2: //nolint:gomnd top = i[0] bottom = i[0] left = i[1] right = i[1] ok = true - case 3: + case 3: //nolint:gomnd top = i[0] left = i[1] right = i[1] bottom = i[2] ok = true - case 4: + case 4: //nolint:gomnd top = i[0] right = i[1] bottom = i[2] @@ -611,19 +635,19 @@ func whichSidesColor(i ...TerminalColor) (top, right, bottom, left TerminalColor left = i[0] right = i[0] ok = true - case 2: + case 2: //nolint:gomnd top = i[0] bottom = i[0] left = i[1] right = i[1] ok = true - case 3: + case 3: //nolint:gomnd top = i[0] left = i[1] right = i[1] bottom = i[2] ok = true - case 4: + case 4: //nolint:gomnd top = i[0] right = i[1] bottom = i[2] diff --git a/vendor/github.com/charmbracelet/lipgloss/style.go b/vendor/github.com/charmbracelet/lipgloss/style.go index e94b867..ee50bcf 100644 --- a/vendor/github.com/charmbracelet/lipgloss/style.go +++ b/vendor/github.com/charmbracelet/lipgloss/style.go @@ -10,6 +10,8 @@ import ( "github.com/muesli/termenv" ) +const tabWidthDefault = 4 + // Property for a key. type propKey int @@ -68,6 +70,7 @@ const ( inlineKey maxWidthKey maxHeightKey + tabWidthKey underlineSpacesKey strikethroughSpacesKey ) @@ -148,7 +151,7 @@ func (s Style) Inherit(i Style) Style { s.init() for k, v := range i.rules { - switch k { + switch k { //nolint:exhaustive case marginTopKey, marginRightKey, marginBottomKey, marginLeftKey: // Margins are not inherited continue @@ -182,9 +185,10 @@ func (s Style) Render(strs ...string) string { var ( str = joinString(strs...) - te = s.r.ColorProfile().String() - teSpace = s.r.ColorProfile().String() - teWhitespace = s.r.ColorProfile().String() + p = s.r.ColorProfile() + te = p.String() + teSpace = p.String() + teWhitespace = p.String() bold = s.getAsBool(boldKey, false) italic = s.getAsBool(italicKey, false) @@ -224,7 +228,7 @@ func (s Style) Render(strs ...string) string { ) if len(s.rules) == 0 { - return str + return s.maybeConvertTabs(str) } // Enable support for ANSI on the legacy Windows cmd.exe console. This is a @@ -287,6 +291,9 @@ func (s Style) Render(strs ...string) string { teSpace = teSpace.CrossOut() } + // Potentially convert tabs to spaces + str = s.maybeConvertTabs(str) + // Strip newlines in single line mode if inline { str = strings.ReplaceAll(str, "\n", "") @@ -397,6 +404,21 @@ func (s Style) Render(strs ...string) string { return str } +func (s Style) maybeConvertTabs(str string) string { + tw := tabWidthDefault + if s.isSet(tabWidthKey) { + tw = s.getAsInt(tabWidthKey) + } + switch tw { + case -1: + return str + case 0: + return strings.ReplaceAll(str, "\t", "") + default: + return strings.ReplaceAll(str, "\t", strings.Repeat(" ", tw)) + } +} + func (s Style) applyMargins(str string, inline bool) string { var ( topMargin = s.getAsInt(marginTopKey) diff --git a/vendor/github.com/charmbracelet/lipgloss/unset.go b/vendor/github.com/charmbracelet/lipgloss/unset.go index a836789..f889f9e 100644 --- a/vendor/github.com/charmbracelet/lipgloss/unset.go +++ b/vendor/github.com/charmbracelet/lipgloss/unset.go @@ -30,7 +30,7 @@ func (s Style) UnsetReverse() Style { return s } -// UnsetBlink removes the bold style rule, if set. +// UnsetBlink removes the blink style rule, if set. func (s Style) UnsetBlink() Style { delete(s.rules, blinkKey) return s @@ -112,7 +112,7 @@ func (s Style) UnsetPaddingTop() Style { return s } -// UnsetPaddingBottom removes the bottom style rule, if set. +// UnsetPaddingBottom removes the bottom padding style rule, if set. func (s Style) UnsetPaddingBottom() Style { delete(s.rules, paddingBottomKey) return s @@ -287,6 +287,12 @@ func (s Style) UnsetMaxHeight() Style { return s } +// UnsetMaxHeight removes the max height style rule, if set. +func (s Style) UnsetTabWidth() Style { + delete(s.rules, tabWidthKey) + return s +} + // UnsetUnderlineSpaces removes the value set by UnderlineSpaces. func (s Style) UnsetUnderlineSpaces() Style { delete(s.rules, underlineSpacesKey) diff --git a/vendor/github.com/charmbracelet/lipgloss/whitespace.go b/vendor/github.com/charmbracelet/lipgloss/whitespace.go index b043e56..78815fe 100644 --- a/vendor/github.com/charmbracelet/lipgloss/whitespace.go +++ b/vendor/github.com/charmbracelet/lipgloss/whitespace.go @@ -15,7 +15,7 @@ type whitespace struct { } // newWhitespace creates a new whitespace renderer. The order of the options -// matters, it you'r using WithWhitespaceRenderer, make sure it comes first as +// matters, if you're using WithWhitespaceRenderer, make sure it comes first as // other options might depend on it. func newWhitespace(r *Renderer, opts ...WhitespaceOption) *whitespace { w := &whitespace{ diff --git a/vendor/modules.txt b/vendor/modules.txt index 3d7671f..654695b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -14,10 +14,10 @@ github.com/Masterminds/sprig/v3 # github.com/aymanbagabas/go-osc52/v2 v2.0.1 ## explicit; go 1.16 github.com/aymanbagabas/go-osc52/v2 -# github.com/charmbracelet/lipgloss v0.7.1 +# github.com/charmbracelet/lipgloss v0.8.0 ## explicit; go 1.17 github.com/charmbracelet/lipgloss -# github.com/charmbracelet/log v0.2.3 +# github.com/charmbracelet/log v0.2.4 ## explicit; go 1.17 github.com/charmbracelet/log # github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964