Documentation ¶
Index ¶
- type Alignment
- type Bus
- type Event
- type EventHandler
- type EventID
- type FindColorFunc
- type Mask
- type Option
- func FromStyle(clone *Style) Option
- func WithAttrs(mask Mask) Option
- func WithBg(c color.Color) Option
- func WithBlink(on bool) Option
- func WithBold(on bool) Option
- func WithDim(on bool) Option
- func WithFg(c color.Color) Option
- func WithItalic(on bool) Option
- func WithReverse(on bool) Option
- func WithStrikeThrough(on bool) Option
- func WithUnderline(on bool) Option
- type Orientation
- type Publisher
- type Style
- type Subscriber
- type Subscription
- type TermStyle
- type Theme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alignment ¶
type Alignment int
Alignment represents the alignment of an object, and consists of either or both of horizontal and vertical alignment.
const ( NoAlignment Alignment = 1 << iota // NoAlignment indicates missing alignment info. Left // Left indicates alignment on the left edge. HCenter // HCenter indicates horizontally centered. Right // Right indicates alignment on the right edge. Top // Top indicates alignment on the top edge. VCenter // VCenter indicates vertically centered. Bottom // Bottom indicates alignment on the bottom edge. Begin = Left | Top // Begin indicates alignment at the top left corner (default) End = Right | Bottom // End indicates alignment at the bottom right corner. Middle = HCenter | VCenter // Middle indicates full centering. )
type Bus ¶
type Bus interface { Subscriber Publisher }
allows to subscribe/unsubscribe to external events and publish own events
type Event ¶
type Event interface {
EventID() EventID
}
must be implemented by anything that can be published
type EventHandler ¶
type EventHandler func(event Event)
is function that can be subscribed to the event
type Mask ¶
type Mask int
Mask represents a mask of text attributes, apart from color. Note that support for attributes may vary widely across terminals.
type Orientation ¶
type Orientation int
Orientation represents the direction of a widget or layout.
const ( NoOrientation Orientation = 1 << iota // NoOrientation indicates orientation has not been indicated. Horizontal // Horizontal indicates left to right orientation. Vertical // Vertical indicates top to bottom orientation. Absolute = Vertical | Horizontal // Absolute ??? )
type Style ¶
Style represents a complete text style, including both foreground and background color. We encode it in a 64-bit int for efficiency. The coding is (MSB): <7b flags><1b><24b fgcolor><7b attr><1b><24b bgcolor>. The <1b> is set true to indicate that the color is an RGB color, rather than a named index.
This gives 24bit color options, if it ever becomes truly necessary. However, applications must not rely on this encoding.
Note that not all terminals can display all colors or attributes, and many might have specific incompatibilities between specific attributes and color combinations.
The intention is to extend styles to support palette-ing, in which case some flag bit(s) would be set, and the foreground and background colors would be replaced with a palette number and palette index.
To use Style, just declare a variable of its type.
type Subscriber ¶
type Subscriber interface { Subscribe(eventID EventID, cb EventHandler) Subscription Unsubscribe(id Subscription) }
allows to subscribe/unsubscribe own event handlers
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
represents active event subscription
type TermStyle ¶
type TermStyle struct { sync.Mutex // guards other properties // contains filtered or unexported fields }
func NewTermStyle ¶
type Theme ¶
type Theme struct { BorderColor color.Color // Color for borders. MainBackgroundColor color.Color // Main background color for primitives. HoverBackgroundColor color.Color // Background color for hovered elements. SelectedBackgroundColor color.Color // Background color for selected elements. InverseBackgroundColor color.Color // TextColor color.Color // Main text color. HoverTextColor color.Color // Hovered text color. SelectedTextColor color.Color // Selected text color. InverseTextColor color.Color // }
Theme defines the colors used across Applications.