barista.run: barista.run/pango Index | Files | Directories

package pango

import "barista.run/pango"

Package pango provides a type-safe way to construct pango markup. Using nested Span and Text nodes, pango formatted output can be easily constructed with compile-time validation of nesting and automatic escaping.

For example, to construct pango markup for:

<span color="#ff0000">Red <span weight="bold">Bold Text</span></span>

the go code would be:

pango.New(
  pango.Text("Red "),
  pango.Text("Bold Text").Bold()).
Color(colors.Hex("#ff0000"))

or:

pango.Text("Red ").
  Color(colors.Hex("#ff0000")).
  Append(pango.Text("Bold Text").Bold())

Index

Package Files

attrs.go icon.go kwattrs_size.go kwattrs_stretch.go kwattrs_strikethrough.go kwattrs_style.go kwattrs_underline.go kwattrs_variant.go kwattrs_weight.go pango.go

func AddIconProvider Uses

func AddIconProvider(name string, provider IconProvider)

AddIconProvider adds an icon provider for a given prefix. This is intended for use only by the pango/icons package. See "pango/icons".LoadFromFile for more details.

func SetUnitFormatter Uses

func SetUnitFormatter(f func(format.Values) *Node)

SetUnitFormatter sets the formatter to use in pango.Unit.

type IconProvider Uses

type IconProvider func(string) *Node

IconProvider is an interface for providing pango Icons. The function should return a pango node for the given icon name, or nil if an icon could not be found.

type Node Uses

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

Node represents a node in a pango "document".

func Icon Uses

func Icon(ident string) *Node

Icon returns a pango node that displays the given icon. The identifier must be of the form $provider-$name, and the returned node will render the $name icon using $provider. e.g. "fa-add" will render the "add" icon using font awesome.

func New Uses

func New(children ...*Node) *Node

New constructs a markup node that wraps the given Nodes.

func Text Uses

func Text(s string) *Node

Text constructs a text node.

func Textf Uses

func Textf(format string, args ...interface{}) *Node

Textf constructs a text node by interpolating arguments. Note that it will escape both the format string and arguments, so you should use pango constructs to add formatting. i.e.,

Textf("<span color='%s'>%s</span>", "red", "text")

won't give you red text.

func Unit Uses

func Unit(val ...format.Value) *Node

Unit formats a format.Value into a pango.Node.

func (*Node) Alpha Uses

func (n *Node) Alpha(alpha float64) *Node

Alpha applies just a foreground alpha, keeping the default text colour.

func (*Node) Append Uses

func (n *Node) Append(nodes ...*Node) *Node

Append adds one or more nodes as children of the current node. The new nodes will inherit styles by virtue of being descendants, to insert them *adjacent* to the current node, use .Concat(...).

func (*Node) AppendText Uses

func (n *Node) AppendText(texts ...string) *Node

AppendText is a shortcut for Append(pango.Text(...), pango.Text(...), ...)

func (*Node) AppendTextf Uses

func (n *Node) AppendTextf(format string, args ...interface{}) *Node

AppendTextf is a shortcut for Append(pango.Textf(...))

func (*Node) Background Uses

func (n *Node) Background(c color.Color) *Node

Background applies a background color and alpha.

func (*Node) Bold Uses

func (n *Node) Bold() *Node

Bold sets the pango weight to "bold".

func (*Node) Color Uses

func (n *Node) Color(c color.Color) *Node

Color applies a foreground color and alpha.

func (*Node) Concat Uses

func (n *Node) Concat(nodes ...*Node) *Node

Concat adds the given nodes as siblings rather than children of the current node, and returns a wrapping node for further operations.

For example,

Text("c").Condensed().Color(red).Concat(Text("foo")).UnderlineError()

will create

<span underline='error'><span stretch='condensed' color='#ff0000'>c</span>foo</span>

where the appended "foo" is not condensed or red, and everything is underlined.

func (*Node) ConcatText Uses

func (n *Node) ConcatText(texts ...string) *Node

ConcatText is a shortcut for Concat(pango.Text(...), pango.Text(...), ...)

func (*Node) ConcatTextf Uses

func (n *Node) ConcatTextf(format string, args ...interface{}) *Node

ConcatTextf is a shortcut for Append(pango.Textf(...))

func (*Node) Condensed Uses

func (n *Node) Condensed() *Node

Condensed sets the pango stretch to "condensed".

func (*Node) Expanded Uses

func (n *Node) Expanded() *Node

Expanded sets the pango stretch to "expanded".

func (*Node) ExtraCondensed Uses

func (n *Node) ExtraCondensed() *Node

ExtraCondensed sets the pango stretch to "extracondensed".

func (*Node) ExtraExpanded Uses

func (n *Node) ExtraExpanded() *Node

ExtraExpanded sets the pango stretch to "extraexpanded".

func (*Node) Font Uses

func (n *Node) Font(face string) *Node

Font sets the font face.

func (*Node) Heavy Uses

func (n *Node) Heavy() *Node

Heavy sets the pango weight to "heavy".

func (*Node) Italic Uses

func (n *Node) Italic() *Node

Italic sets the pango style to "italic".

func (*Node) Large Uses

func (n *Node) Large() *Node

Large sets the pango size to "large".

func (*Node) Larger Uses

func (n *Node) Larger() *Node

Larger increases the font size of the contents by wrapping them in <big>...</big>

func (*Node) LetterSpacing Uses

func (n *Node) LetterSpacing(spacing float64) *Node

LetterSpacing sets the letter spacing, in points.

func (*Node) Light Uses

func (n *Node) Light() *Node

Light sets the pango weight to "light".

func (*Node) Medium Uses

func (n *Node) Medium() *Node

Medium sets the pango size to "medium".

func (*Node) NoStrikethrough Uses

func (n *Node) NoStrikethrough() *Node

NoStrikethrough sets the pango strikethrough to "false".

func (*Node) Oblique Uses

func (n *Node) Oblique() *Node

Oblique sets the pango style to "oblique".

func (*Node) Rise Uses

func (n *Node) Rise(rise int) *Node

Rise sets the font "rise" in pango units. Negative for subscript, positive for superscript.

func (*Node) Segments Uses

func (n *Node) Segments() []*bar.Segment

Segments implements bar.Output for a single pango Node.

func (*Node) SemiCondensed Uses

func (n *Node) SemiCondensed() *Node

SemiCondensed sets the pango stretch to "semicondensed".

func (*Node) SemiExpanded Uses

func (n *Node) SemiExpanded() *Node

SemiExpanded sets the pango stretch to "semiexpanded".

func (*Node) Size Uses

func (n *Node) Size(size float64) *Node

Size sets the font size, in points.

func (*Node) Small Uses

func (n *Node) Small() *Node

Small sets the pango size to "small".

func (*Node) SmallCaps Uses

func (n *Node) SmallCaps() *Node

SmallCaps sets the pango variant to "smallcaps".

func (*Node) Smaller Uses

func (n *Node) Smaller() *Node

Smaller decreases the font size of the contents by wrapping them in <small>...</small>

func (*Node) StretchNormal Uses

func (n *Node) StretchNormal() *Node

StretchNormal sets the pango stretch to "normal".

func (*Node) Strikethrough Uses

func (n *Node) Strikethrough() *Node

Strikethrough sets the pango strikethrough to "true".

func (*Node) StrikethroughColor Uses

func (n *Node) StrikethroughColor(c color.Color) *Node

StrikethroughColor applies a strikethrough color.

func (*Node) String Uses

func (n *Node) String() string

Pango returns a pango-formatted version of the node.

func (*Node) StyleNormal Uses

func (n *Node) StyleNormal() *Node

StyleNormal sets the pango style to "normal".

func (*Node) UltraBold Uses

func (n *Node) UltraBold() *Node

UltraBold sets the pango weight to "ultrabold".

func (*Node) UltraCondensed Uses

func (n *Node) UltraCondensed() *Node

UltraCondensed sets the pango stretch to "ultracondensed".

func (*Node) UltraExpanded Uses

func (n *Node) UltraExpanded() *Node

UltraExpanded sets the pango stretch to "ultraexpanded".

func (*Node) UltraLight Uses

func (n *Node) UltraLight() *Node

UltraLight sets the pango weight to "ultralight".

func (*Node) UnderlineColor Uses

func (n *Node) UnderlineColor(c color.Color) *Node

UnderlineColor applies an underline color.

func (*Node) UnderlineDouble Uses

func (n *Node) UnderlineDouble() *Node

UnderlineDouble sets the pango underline to "double".

func (*Node) UnderlineError Uses

func (n *Node) UnderlineError() *Node

UnderlineError sets the pango underline to "error".

func (*Node) UnderlineLow Uses

func (n *Node) UnderlineLow() *Node

UnderlineLow sets the pango underline to "low".

func (*Node) UnderlineNone Uses

func (n *Node) UnderlineNone() *Node

UnderlineNone sets the pango underline to "none".

func (*Node) UnderlineSingle Uses

func (n *Node) UnderlineSingle() *Node

UnderlineSingle sets the pango underline to "single".

func (*Node) VariantNormal Uses

func (n *Node) VariantNormal() *Node

VariantNormal sets the pango variant to "normal".

func (*Node) Weight Uses

func (n *Node) Weight(weight int) *Node

Weight sets the font weight in numeric form.

func (*Node) WeightNormal Uses

func (n *Node) WeightNormal() *Node

WeightNormal sets the pango weight to "normal".

func (*Node) XLarge Uses

func (n *Node) XLarge() *Node

XLarge sets the pango size to "x-large".

func (*Node) XSmall Uses

func (n *Node) XSmall() *Node

XSmall sets the pango size to "x-small".

func (*Node) XXLarge Uses

func (n *Node) XXLarge() *Node

XXLarge sets the pango size to "xx-large".

func (*Node) XXSmall Uses

func (n *Node) XXSmall() *Node

XXSmall sets the pango size to "xx-small".

Directories

PathSynopsis
iconsPackage icons provides an interface for using icon fonts in a bar.
icons/fontawesomePackage fontawesome provides support for FontAwesome Icons from https://github.com/FortAwesome/Font-Awesome
icons/materialPackage material provides support for Google's Material Design Icons from https://github.com/google/material-design-icons
icons/mdiPackage mdi provides support for "Material Design Icons" from https://materialdesignicons.com/, a fork and extension of Material.
icons/typiconsPackage typicons provides support for Typicons from https://github.com/stephenhutchings/typicons.font

Package pango imports 11 packages (graph) and is imported by 7 packages. Updated 2019-09-24. Refresh now. Tools for package owners.