style

package
v0.7.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2022 License: MIT Imports: 1 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoubleBorder added in v0.5.4

func DoubleBorder() lipgloss.Border

DoubleBorder returns a border comprised of two thin strokes.

func HiddenBorder added in v0.5.4

func HiddenBorder() lipgloss.Border

HiddenBorder returns a border that renders as a series of single-cell spaces. It's useful for cases when you want to remove a standard border but maintain layout positioning. This said, you can still apply a background color to a hidden border.

func NormalBorder added in v0.5.4

func NormalBorder() lipgloss.Border

NormalBorder returns a standard-type border with a normal weight and 90 degree corners.

func RoundedBorder added in v0.5.4

func RoundedBorder() lipgloss.Border

RoundedBorder returns a border with rounded corners.

func ThickBorder added in v0.5.4

func ThickBorder() lipgloss.Border

ThickBorder returns a border that's thicker than the one returned by NormalBorder.

Types

type Style

type Style struct {
	// contains filtered or unexported fields
}

Style wrapper lipgloss.Style

func New

func New() *Style

New style

func (*Style) Bg

func (s *Style) Bg(color lipgloss.TerminalColor) *Style

Bg sets a background color.

func (s *Style) Blink() *Style

Blink sets a rule for blinking foreground text.

func (*Style) Bold

func (s *Style) Bold() *Style

Bold sets a bold formatting rule.

func (*Style) Border added in v0.5.4

func (s *Style) Border(b lipgloss.Border, sides ...bool) *Style

Border is shorthand for setting a the border style and which sides should have a border at once. The variadic argument sides works as follows:

With one value, the value is applied to all sides.

With two values, the values are applied to the vertical and horizontal sides, in that order.

With three values, the values are applied to the top side, the horizontal sides, and the bottom side, in that order.

With four values, the values are applied clockwise starting from the top side, followed by the right side, then the bottom, and finally the left.

With more than four arguments the border will be applied to all sides.

Examples:

 // Applies borders to the top and bottom only
style.New().Border(style.NormalBorder(), true, false)

 // Applies rounded borders to the right and bottom only
style.New().Border(style.RoundedBorder(), false, true, true, false)

func (*Style) BorderBackground added in v0.5.4

func (s *Style) BorderBackground(colors ...lipgloss.TerminalColor) *Style

BorderBackground is a shorthand function for setting all of the background colors of the borders at once. The arguments work as follows:

With one argument, the argument is applied to all sides.

With two arguments, the arguments are applied to the vertical and horizontal sides, in that order.

With three arguments, the arguments are applied to the top side, the horizontal sides, and the bottom side, in that order.

With four arguments, the arguments are applied clockwise starting from the top side, followed by the right side, then the bottom, and finally the left.

With more than four arguments nothing will be set.

func (*Style) BorderBottom added in v0.5.4

func (s *Style) BorderBottom(b bool) *Style

BorderBottom determines whether or not to draw a bottom border.

func (*Style) BorderBottomBackground added in v0.5.4

func (s *Style) BorderBottomBackground(color lipgloss.TerminalColor) *Style

BorderBottomBackground sets the background color of the bottom of the border.

func (*Style) BorderBottomForeground added in v0.5.4

func (s *Style) BorderBottomForeground(color lipgloss.TerminalColor) *Style

BorderBottomForeground sets the foreground color for the bottom of the border.

func (*Style) BorderForeground added in v0.5.4

func (s *Style) BorderForeground(colors ...lipgloss.TerminalColor) *Style

BorderForeground is a shorthand function for setting all of the foreground colors of the borders at once. The arguments work as follows:

With one argument, the argument is applied to all sides.

With two arguments, the arguments are applied to the vertical and horizontal sides, in that order.

With three arguments, the arguments are applied to the top side, the horizontal sides, and the bottom side, in that order.

With four arguments, the arguments are applied clockwise starting from the top side, followed by the right side, then the bottom, and finally the left.

With more than four arguments nothing will be set.

func (*Style) BorderLeft added in v0.5.4

func (s *Style) BorderLeft(b bool) *Style

BorderLeft determines whether or not to draw a left border.

func (*Style) BorderLeftBackground added in v0.5.4

func (s *Style) BorderLeftBackground(color lipgloss.TerminalColor) *Style

BorderLeftBackground set the background color of the left side of the border.

func (*Style) BorderLeftForeground added in v0.5.4

func (s *Style) BorderLeftForeground(color lipgloss.TerminalColor) *Style

BorderLeftForeground sets the foreground color for the left side of the border.

func (*Style) BorderRight added in v0.5.4

func (s *Style) BorderRight(b bool) *Style

BorderRight determines whether or not to draw a right border.

func (*Style) BorderRightBackground added in v0.5.4

func (s *Style) BorderRightBackground(color lipgloss.TerminalColor) *Style

BorderRightBackground sets the background color of right side the border.

func (*Style) BorderRightForeground added in v0.5.4

func (s *Style) BorderRightForeground(color lipgloss.TerminalColor) *Style

BorderRightForeground sets the foreground color for the right side of the border.

func (*Style) BorderStyle added in v0.5.4

func (s *Style) BorderStyle(b lipgloss.Border) *Style

BorderStyle defines the Border on a style. A Border contains a series of definitions for the sides and corners of a border.

Note that if border visibility has not been set for any sides when setting the border style, the border will be enabled for all sides during rendering.

You can define border characters as you'd like, though several default styles are included: NormalBorder(), RoundedBorder(), ThickBorder(), and DoubleBorder().

Example:

style.New().BorderStyle(style.ThickBorder())

func (*Style) BorderTop added in v0.5.4

func (s *Style) BorderTop(b bool) *Style

BorderTop determines whether or not to draw a top border.

func (*Style) BorderTopBackground added in v0.5.4

func (s *Style) BorderTopBackground(color lipgloss.TerminalColor) *Style

BorderTopBackground sets the background color of the top of the border.

func (*Style) BorderTopForeground added in v0.5.4

func (s *Style) BorderTopForeground(color lipgloss.TerminalColor) *Style

BorderTopForeground set the foreground color for the top of the border.

func (*Style) Bottom added in v0.5.4

func (s *Style) Bottom() *Style

Bottom set vertical position to bottom

func (*Style) Center added in v0.5.4

func (s *Style) Center() *Style

Center set the horizontal position to the center

func (*Style) ColorWhitespace added in v0.5.4

func (s *Style) ColorWhitespace(b bool) *Style

ColorWhitespace determines whether or not the background color should be applied to the padding. This is true by default as it's more than likely the desired and expected behavior, but it can be disabled for certain graphic effects.

func (*Style) Faint added in v0.5.4

func (s *Style) Faint() *Style

Faint sets a rule for rendering the foreground color in a dimmer shade.

func (*Style) Fg

func (s *Style) Fg(color lipgloss.TerminalColor) *Style

Fg sets a foreground color.

// Sets the foreground to blue
s := New().Fg(color.NewHex("#0000ff"))

// Removes the foreground color
s.Foreground(color.NoColor)

func (*Style) Height added in v0.5.4

func (s *Style) Height(i int) *Style

Height sets the width of the block before applying margins. If the height of the text block is less than this value after applying padding (or not), the block will be set to this height.

func (*Style) Inline

func (s *Style) Inline() *Style

Inline makes rendering output one line and disables the rendering of margins, padding and borders. This is useful when you need a style to apply only to font rendering and don't want it to change any physical dimensions. It works well with Style.MaxWidth.

Because this in intended to be used at the time of render, this method will not mutate the style and instead return a copy.

Example:

var userInput string = "..."
var userStyle = text.Style{ /* ... */ }
fmt.Println(userStyle.Inline(true).Render(userInput))

func (*Style) Inner

func (s *Style) Inner() lipgloss.Style

func (*Style) Italic

func (s *Style) Italic() *Style

Italic sets an italic formatting rule. In some terminal emulators this will render with "reverse" coloring if not italic font variant is available.

func (*Style) Left added in v0.5.4

func (s *Style) Left() *Style

Left set the horizontal position to the left

func (*Style) Margin added in v0.5.4

func (s *Style) Margin(i ...int) *Style

Margin is a shorthand method for setting margins on all sides at once.

With one argument, the value is applied to all sides.

With two arguments, the value is applied to the vertical and horizontal sides, in that order.

With three arguments, the value is applied to the top side, the horizontal sides, and the bottom side, in that order.

With four arguments, the value is applied clockwise starting from the top side, followed by the right side, then the bottom, and finally the left.

With more than four arguments no margin will be added.

func (*Style) MarginBackground added in v0.5.4

func (s *Style) MarginBackground(color lipgloss.TerminalColor) *Style

MarginBackground sets the background color of the margin. Note that this is also set when inheriting from a style with a background color. In that case the background color on that style will set the margin color on this style.

func (*Style) MarginBottom added in v0.5.4

func (s *Style) MarginBottom(i int) *Style

MarginBottom sets the value of the bottom margin.

func (*Style) MarginLeft added in v0.5.4

func (s *Style) MarginLeft(i int) *Style

MarginLeft sets the value of the left margin.

func (*Style) MarginRight added in v0.5.4

func (s *Style) MarginRight(i int) *Style

MarginRight sets the value of the right margin.

func (*Style) MarginTop added in v0.5.4

func (s *Style) MarginTop(i int) *Style

MarginTop sets the value of the top margin.

func (*Style) MaxHeight added in v0.5.4

func (s *Style) MaxHeight(i int) *Style

MaxHeight applies a max width to a given style. This is useful in enforcing a certain width at render time, particularly with arbitrary strings and 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.

func (*Style) MaxWidth added in v0.5.4

func (s *Style) MaxWidth(i int) *Style

MaxWidth applies a max width to a given style. This is useful in enforcing a certain width at render time, particularly with arbitrary strings and 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.

Example:

var userInput string = "..."
var userStyle = text.Style{ /* ... */ }
fmt.Println(userStyle.MaxWidth(16).Render(userInput))

func (*Style) Padding added in v0.5.4

func (s *Style) Padding(i ...int) *Style

Padding is a shorthand method for setting padding on all sides at once.

With one argument, the value is applied to all sides.

With two arguments, the value is applied to the vertical and horizontal sides, in that order.

With three arguments, the value is applied to the top side, the horizontal sides, and the bottom side, in that order.

With four arguments, the value is applied clockwise starting from the top side, followed by the right side, then the bottom, and finally the left.

With more than four arguments no padding will be added.

func (*Style) PaddingBottom added in v0.5.4

func (s *Style) PaddingBottom(i int) *Style

PaddingBottom adds padding to the bottom of the block.

func (*Style) PaddingLeft added in v0.5.4

func (s *Style) PaddingLeft(i int) *Style

PaddingLeft adds padding on the left.

func (*Style) PaddingRight added in v0.5.4

func (s *Style) PaddingRight(i int) *Style

PaddingRight adds padding on the right.

func (*Style) PaddingTop added in v0.5.4

func (s *Style) PaddingTop(i int) *Style

PaddingTop adds padding to the top of the block.

func (*Style) Render

func (s *Style) Render(str string) string

Render applies the defined style formatting to a given string.

func (*Style) Reverse added in v0.5.4

func (s *Style) Reverse() *Style

Reverse sets a rule for inverting foreground and background colors.

func (*Style) Right added in v0.5.4

func (s *Style) Right() *Style

Right set the horizontal position to the right

func (*Style) Strikethrough added in v0.7.5

func (s *Style) Strikethrough() *Style

Strikethrough sets a strikethrough rule. By default, strikes will not be drawn on whitespace like margins and padding. To change this behavior set renderStrikethroughOnSpaces.

func (*Style) StrikethroughSpaces added in v0.5.4

func (s *Style) StrikethroughSpaces(b bool) *Style

StrikethroughSpaces determines whether to apply strikethroughs to spaces between words. By default this is true. Spaces can also be struck without underlining the text itself.

func (*Style) Top added in v0.5.4

func (s *Style) Top() *Style

Top set vertical position to top

func (*Style) Underline added in v0.5.4

func (s *Style) Underline() *Style

Underline sets an underline rule. By default, underlines will not be drawn on whitespace like margins and padding. To change this behavior set renderUnderlinesOnSpaces.

func (*Style) UnderlineSpaces added in v0.5.4

func (s *Style) UnderlineSpaces(b bool) *Style

UnderlineSpaces determines whether to underline spaces between words. By default this is true. Spaces can also be underlined without underlining the text itself.

func (*Style) Width added in v0.5.4

func (s *Style) Width(i int) *Style

Width sets the width of the block before applying margins. The width, if set, also determines where text will wrap.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL