Documentation
¶
Index ¶
- Variables
- func DoubleBorder() lipgloss.Border
- func HiddenBorder() lipgloss.Border
- func NormalBorder() lipgloss.Border
- func RoundedBorder() lipgloss.Border
- func ThickBorder() lipgloss.Border
- type Style
- func (s *Style) Bg(color lipgloss.TerminalColor) *Style
- func (s *Style) Blink() *Style
- func (s *Style) Bold() *Style
- func (s *Style) Border(b lipgloss.Border, sides ...bool) *Style
- func (s *Style) BorderBackground(colors ...lipgloss.TerminalColor) *Style
- func (s *Style) BorderBottom(b bool) *Style
- func (s *Style) BorderBottomBackground(color lipgloss.TerminalColor) *Style
- func (s *Style) BorderBottomForeground(color lipgloss.TerminalColor) *Style
- func (s *Style) BorderForeground(colors ...lipgloss.TerminalColor) *Style
- func (s *Style) BorderLeft(b bool) *Style
- func (s *Style) BorderLeftBackground(color lipgloss.TerminalColor) *Style
- func (s *Style) BorderLeftForeground(color lipgloss.TerminalColor) *Style
- func (s *Style) BorderRight(b bool) *Style
- func (s *Style) BorderRightBackground(color lipgloss.TerminalColor) *Style
- func (s *Style) BorderRightForeground(color lipgloss.TerminalColor) *Style
- func (s *Style) BorderStyle(b lipgloss.Border) *Style
- func (s *Style) BorderTop(b bool) *Style
- func (s *Style) BorderTopBackground(color lipgloss.TerminalColor) *Style
- func (s *Style) BorderTopForeground(color lipgloss.TerminalColor) *Style
- func (s *Style) Bottom() *Style
- func (s *Style) Center() *Style
- func (s *Style) ColorWhitespace(b bool) *Style
- func (s *Style) Faint() *Style
- func (s *Style) Fg(color lipgloss.TerminalColor) *Style
- func (s *Style) Height(i int) *Style
- func (s *Style) Inline() *Style
- func (s *Style) Inner() lipgloss.Style
- func (s *Style) Italic() *Style
- func (s *Style) Left() *Style
- func (s *Style) Margin(i ...int) *Style
- func (s *Style) MarginBackground(color lipgloss.TerminalColor) *Style
- func (s *Style) MarginBottom(i int) *Style
- func (s *Style) MarginLeft(i int) *Style
- func (s *Style) MarginRight(i int) *Style
- func (s *Style) MarginTop(i int) *Style
- func (s *Style) MaxHeight(i int) *Style
- func (s *Style) MaxWidth(i int) *Style
- func (s *Style) Padding(i ...int) *Style
- func (s *Style) PaddingBottom(i int) *Style
- func (s *Style) PaddingLeft(i int) *Style
- func (s *Style) PaddingRight(i int) *Style
- func (s *Style) PaddingTop(i int) *Style
- func (s *Style) Render(str string) string
- func (s *Style) Reverse() *Style
- func (s *Style) Right() *Style
- func (s *Style) Strikethrough() *Style
- func (s *Style) StrikethroughSpaces(b bool) *Style
- func (s *Style) Top() *Style
- func (s *Style) Underline() *Style
- func (s *Style) UnderlineSpaces(b bool) *Style
- func (s *Style) Width(i int) *Style
Constants ¶
This section is empty.
Variables ¶
var Empty = New()
Functions ¶
func DoubleBorder ¶ added in v0.5.4
DoubleBorder returns a border comprised of two thin strokes.
func HiddenBorder ¶ added in v0.5.4
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
NormalBorder returns a standard-type border with a normal weight and 90 degree corners.
func RoundedBorder ¶ added in v0.5.4
RoundedBorder returns a border with rounded corners.
func ThickBorder ¶ added in v0.5.4
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 (*Style) Bg ¶
func (s *Style) Bg(color lipgloss.TerminalColor) *Style
Bg sets a background color.
func (*Style) Border ¶ added in v0.5.4
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
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
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
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
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) 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) ColorWhitespace ¶ added in v0.5.4
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
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
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 ¶
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) Italic ¶
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) Margin ¶ added in v0.5.4
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
MarginBottom sets the value of the bottom margin.
func (*Style) MarginLeft ¶ added in v0.5.4
MarginLeft sets the value of the left margin.
func (*Style) MarginRight ¶ added in v0.5.4
MarginRight sets the value of the right margin.
func (*Style) MaxHeight ¶ added in v0.5.4
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
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
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
PaddingBottom adds padding to the bottom of the block.
func (*Style) PaddingLeft ¶ added in v0.5.4
PaddingLeft adds padding on the left.
func (*Style) PaddingRight ¶ added in v0.5.4
PaddingRight adds padding on the right.
func (*Style) PaddingTop ¶ added in v0.5.4
PaddingTop adds padding to the top of the block.
func (*Style) Reverse ¶ added in v0.5.4
Reverse sets a rule for inverting foreground and background colors.
func (*Style) Strikethrough ¶ added in v0.7.5
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
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) Underline ¶ added in v0.5.4
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
UnderlineSpaces determines whether to underline spaces between words. By default this is true. Spaces can also be underlined without underlining the text itself.