styled

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2018 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindTransformer

func FindTransformer(transformerName string) func(Segment) Segment

FindTransformer looks up a transformer name and if successful returns a function that can be used to transform a styled Segment.

Types

type Segment

type Segment struct {
	Style
	Text string
}

Segment is a string that has some style applied to it.

func (Segment) Concat

func (s Segment) Concat(v interface{}) (interface{}, error)

Concat implements Segment+string, Segment+Segment and Segment+Text.

func (Segment) Index

func (s Segment) Index(k interface{}) (v interface{}, ok bool)

Index provides access to the attributes of the Segment.

func (Segment) IterateKeys

func (s Segment) IterateKeys(fn func(v interface{}) bool)

func (Segment) Kind

func (Segment) Kind() string

func (Segment) RConcat

func (s Segment) RConcat(v interface{}) (interface{}, error)

RConcat implements string+Segment.

func (Segment) Repr

func (s Segment) Repr(indent int) string

Repr returns the representation of this Segment. The string can be used to construct an identical Segment. Unset or default attributes are skipped. If the Segment represents an unstyled string only this string is returned.

func (Segment) ToLegacyType

func (s Segment) ToLegacyType() *ui.Styled

type Style

type Style struct {
	Foreground string
	Background string
	Bold       bool
	Dim        bool
	Italic     bool
	Underlined bool
	Blink      bool
	Inverse    bool
}

Style specifies how something (mostly a string) shall be displayed.

func (*Style) ImportFromOptions

func (s *Style) ImportFromOptions(options map[string]interface{}) error

ImportFromOptions assigns all recognized values from a map to the current Style.

type Text

type Text []Segment

Text contains of a list of styled Segments.

func (Text) Concat

func (t Text) Concat(v interface{}) (interface{}, error)

Concat implements Text+string, Text+Segment and Text+Text.

func (Text) Index

func (t Text) Index(k interface{}) (interface{}, error)

Index provides access to the underlying Segments.

func (Text) IterateKeys

func (t Text) IterateKeys(fn func(interface{}) bool)

func (Text) Kind

func (t Text) Kind() string

func (Text) Partition

func (t Text) Partition(indicies ...int) []Text

Partition partitions the Text at n indicies into n+1 Text values.

func (Text) RConcat

func (t Text) RConcat(v interface{}) (interface{}, error)

RConcat implements string+Text.

func (Text) Repr

func (t Text) Repr(indent int) string

Repr returns the representation of the current Text. It is just a wrapper around the containing Segments.

func (Text) String

func (t Text) String() string

todo: Make string conversion variable to environment. E.g. the shell displays colors different than HTML.

func (Text) ToLegacyType

func (t Text) ToLegacyType() []*ui.Styled

Jump to

Keyboard shortcuts

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