Documentation ¶
Overview ¶
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 ¶
- func AddIconProvider(name string, provider IconProvider)
- func SetUnitFormatter(f func(format.Values) *Node)
- type IconProvider
- type Node
- func (n *Node) Alpha(alpha float64) *Node
- func (n *Node) Append(nodes ...*Node) *Node
- func (n *Node) AppendText(texts ...string) *Node
- func (n *Node) AppendTextf(format string, args ...interface{}) *Node
- func (n *Node) Background(c color.Color) *Node
- func (n *Node) Bold() *Node
- func (n *Node) Color(c color.Color) *Node
- func (n *Node) Concat(nodes ...*Node) *Node
- func (n *Node) ConcatText(texts ...string) *Node
- func (n *Node) ConcatTextf(format string, args ...interface{}) *Node
- func (n *Node) Condensed() *Node
- func (n *Node) Expanded() *Node
- func (n *Node) ExtraCondensed() *Node
- func (n *Node) ExtraExpanded() *Node
- func (n *Node) Font(face string) *Node
- func (n *Node) Heavy() *Node
- func (n *Node) Italic() *Node
- func (n *Node) Large() *Node
- func (n *Node) Larger() *Node
- func (n *Node) LetterSpacing(spacing float64) *Node
- func (n *Node) Light() *Node
- func (n *Node) Medium() *Node
- func (n *Node) NoStrikethrough() *Node
- func (n *Node) Oblique() *Node
- func (n *Node) Rise(rise int) *Node
- func (n *Node) Segments() []*bar.Segment
- func (n *Node) SemiCondensed() *Node
- func (n *Node) SemiExpanded() *Node
- func (n *Node) Size(size float64) *Node
- func (n *Node) Small() *Node
- func (n *Node) SmallCaps() *Node
- func (n *Node) Smaller() *Node
- func (n *Node) StretchNormal() *Node
- func (n *Node) Strikethrough() *Node
- func (n *Node) StrikethroughColor(c color.Color) *Node
- func (n *Node) String() string
- func (n *Node) StyleNormal() *Node
- func (n *Node) UltraBold() *Node
- func (n *Node) UltraCondensed() *Node
- func (n *Node) UltraExpanded() *Node
- func (n *Node) UltraLight() *Node
- func (n *Node) UnderlineColor(c color.Color) *Node
- func (n *Node) UnderlineDouble() *Node
- func (n *Node) UnderlineError() *Node
- func (n *Node) UnderlineLow() *Node
- func (n *Node) UnderlineNone() *Node
- func (n *Node) UnderlineSingle() *Node
- func (n *Node) VariantNormal() *Node
- func (n *Node) Weight(weight int) *Node
- func (n *Node) WeightNormal() *Node
- func (n *Node) XLarge() *Node
- func (n *Node) XSmall() *Node
- func (n *Node) XXLarge() *Node
- func (n *Node) XXSmall() *Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddIconProvider ¶
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.
Types ¶
type IconProvider ¶
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 ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a node in a pango "document".
func Icon ¶
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 ¶
New constructs a markup node that wraps the given Nodes.
func Textf ¶
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 (*Node) Alpha ¶
Alpha applies just a foreground alpha, keeping the default text colour.
func (*Node) Append ¶
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 ¶
AppendText is a shortcut for Append(pango.Text(...), pango.Text(...), ...)
func (*Node) AppendTextf ¶
AppendTextf is a shortcut for Append(pango.Textf(...))
func (*Node) Background ¶
Background applies a background color and alpha.
func (*Node) Color ¶
Color applies a foreground color and alpha.
func (*Node) Concat ¶
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 ¶
ConcatText is a shortcut for Concat(pango.Text(...), pango.Text(...), ...)
func (*Node) ConcatTextf ¶
ConcatTextf is a shortcut for Append(pango.Textf(...))
func (*Node) Condensed ¶
Condensed sets the pango stretch to "condensed".
func (*Node) Expanded ¶
Expanded sets the pango stretch to "expanded".
func (*Node) ExtraCondensed ¶
ExtraCondensed sets the pango stretch to "extracondensed".
func (*Node) ExtraExpanded ¶
ExtraExpanded sets the pango stretch to "extraexpanded".
func (*Node) Larger ¶
Larger increases the font size of the contents by wrapping them in <big>...</big>
func (*Node) LetterSpacing ¶
LetterSpacing sets the letter spacing, in points.
func (*Node) NoStrikethrough ¶
NoStrikethrough sets the pango strikethrough to "false".
func (*Node) Rise ¶
Rise sets the font "rise" in pango units. Negative for subscript, positive for superscript.
func (*Node) Segments ¶
Segments implements bar.Output for a single pango Node.
func (*Node) SemiCondensed ¶
SemiCondensed sets the pango stretch to "semicondensed".
func (*Node) SemiExpanded ¶
SemiExpanded sets the pango stretch to "semiexpanded".
func (*Node) SmallCaps ¶
SmallCaps sets the pango variant to "smallcaps".
func (*Node) Smaller ¶
Smaller decreases the font size of the contents by wrapping them in <small>...</small>
func (*Node) StretchNormal ¶
StretchNormal sets the pango stretch to "normal".
func (*Node) Strikethrough ¶
Strikethrough sets the pango strikethrough to "true".
func (*Node) StrikethroughColor ¶
StrikethroughColor applies a strikethrough color.
func (*Node) String ¶
Pango returns a pango-formatted version of the node.
func (*Node) StyleNormal ¶
StyleNormal sets the pango style to "normal".
func (*Node) UltraBold ¶
UltraBold sets the pango weight to "ultrabold".
func (*Node) UltraCondensed ¶
UltraCondensed sets the pango stretch to "ultracondensed".
func (*Node) UltraExpanded ¶
UltraExpanded sets the pango stretch to "ultraexpanded".
func (*Node) UltraLight ¶
UltraLight sets the pango weight to "ultralight".
func (*Node) UnderlineColor ¶
UnderlineColor applies an underline color.
func (*Node) UnderlineDouble ¶
UnderlineDouble sets the pango underline to "double".
func (*Node) UnderlineError ¶
UnderlineError sets the pango underline to "error".
func (*Node) UnderlineLow ¶
UnderlineLow sets the pango underline to "low".
func (*Node) UnderlineNone ¶
UnderlineNone sets the pango underline to "none".
func (*Node) UnderlineSingle ¶
UnderlineSingle sets the pango underline to "single".
func (*Node) VariantNormal ¶
VariantNormal sets the pango variant to "normal".
func (*Node) Weight ¶
Weight sets the font weight in numeric form.
func (*Node) WeightNormal ¶
WeightNormal sets the pango weight to "normal".
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package icons provides an interface for using icon fonts in a bar.
|
Package icons provides an interface for using icon fonts in a bar. |
fontawesome
Package fontawesome provides support for FontAwesome Icons from https://github.com/FortAwesome/Font-Awesome
|
Package fontawesome provides support for FontAwesome Icons from https://github.com/FortAwesome/Font-Awesome |
material
Package material provides support for Google's Material Design Icons from https://github.com/google/material-design-icons
|
Package material provides support for Google's Material Design Icons from https://github.com/google/material-design-icons |
mdi
Package mdi provides support for "Material Design Icons" from https://materialdesignicons.com/, a fork and extension of Material.
|
Package mdi provides support for "Material Design Icons" from https://materialdesignicons.com/, a fork and extension of Material. |
typicons
Package typicons provides support for Typicons from https://github.com/stephenhutchings/typicons.font
|
Package typicons provides support for Typicons from https://github.com/stephenhutchings/typicons.font |