Documentation
¶
Index ¶
- Constants
- Variables
- type ColorString
- type Duration
- func (obj Duration) Duration() time.Duration
- func (obj Duration) MarshalJSON() ([]byte, error)
- func (obj Duration) MarshalYAML() (any, error)
- func (obj *Duration) Set(str string) error
- func (obj *Duration) SetYAML(value any) error
- func (obj Duration) String() string
- func (obj Duration) Type() string
- func (obj *Duration) UnmarshalJSON(data []byte) error
- func (obj *Duration) UnmarshalYAML(value *yaml.Node) error
- func (obj Duration) Validate(minDuration, maxDuration time.Duration) error
- type Mailbox
- type Pair
- type Queue
Constants ¶
const ( // Normal (default) attribtues -- VT100. NORMAL = 0 // Bold -- VT100. BOLD = 1 // Faint, decreased intensity -- ECMA-48 2e. FAINT = 2 // Italicizsed -- ECMA-48 2e. ITALICS = 3 // Underlined -- VT100. UNDERLINE = 4 // Blinking -- VT100. BLINK = 5 // Inverse video -- VT100. INVERSE = 7 // Crossed-out characters -- ECMA-48 3e. STRIKETHROUGH = 9 // Black colour -- ANSI. BLACK = 0 // Red colour -- ANSI. RED = 1 // Green colour -- ANSI. GREEN = 2 // Yellow colour -- ANSI. YELLOW = 3 // Blue colour -- ANSI. BLUE = 4 // Magenta colour -- ANSI. MAGENTA = 5 // Cyan colour -- ANSI. CYAN = 6 // White colour -- ANSI. WHITE = 7 // Default colour -- ANSI. DEFAULT = 9 // Offset for foreground colours. FGOFFSET = 30 // Offset for background colours. BGOFFSET = 40 )
CSI Pm [; Pm ...] m -- Character Attributes (SGR).
const ( // Amount of time to delay semaphore acquisition loops. MailboxDelaySleep time.Duration = 50 * time.Millisecond // Default deadline for context timeouts. DefaultCtxDeadline time.Duration = 5 * time.Second )
Variables ¶
var ( // Error condition that signals an invalid time duration of some kind. // // This error is usually wrapped around a descriptive message string. ErrInvalidDuration error = errors.Base("invalid time duration") // Error condition that signals that a duration is not a string value. // // This error is used by `Set` as well as JSON and YAML methods. ErrDurationNotString error = errors.Base("duration must be a string") // Error condition that signals that a duration is out of bounds. // // This is used by `Validate`. ErrOutOfBounds error = errors.Base("duration out of bounds") )
Functions ¶
This section is empty.
Types ¶
type ColorString ¶ added in v0.1.1
type ColorString struct {
// contains filtered or unexported fields
}
Colour string.
Generates a string that, with the right terminal type, display text using various character attributes.
To find out more, consult your nearest DEC VT340 programmer's manual or the latest ECMA-48 standard.
func MakeColorString ¶ added in v0.1.1
func MakeColorString() *ColorString
Make a new coloured string.
func MakeColorStringWithAttrs ¶ added in v0.3.3
func MakeColorStringWithAttrs(data string, attr, foreg, backg int) *ColorString
Make a new coloured string with the given attributes.
func (*ColorString) SetAttr ¶ added in v0.1.1
func (cs *ColorString) SetAttr(attr int)
Set the character attribute.
func (*ColorString) SetBG ¶ added in v0.1.1
func (cs *ColorString) SetBG(col int)
Set the background colour.
func (*ColorString) SetFG ¶ added in v0.1.1
func (cs *ColorString) SetFG(col int)
Set the foreground colour.
func (*ColorString) SetString ¶ added in v0.1.1
func (cs *ColorString) SetString(val string)
Set the string to display.
func (*ColorString) String ¶ added in v0.1.1
func (cs *ColorString) String() string
Convert to a string.
Warning: the resulting string will contain escape sequences for use with a compliant terminal or terminal emulator.
type Duration ¶ added in v0.5.9
Enhanced time duration type.
func (Duration) MarshalJSON ¶ added in v0.5.9
JSON marshalling method.
func (Duration) MarshalYAML ¶ added in v0.5.9
YAML marshalling method.
func (*Duration) Set ¶ added in v0.5.9
Set the duration to that of the given string.
This method uses `time.ParseDuration`, so any string that `time` understands may be used.
If the string value fails parsing, then `ErrInvalidDuration` is returned.
func (*Duration) SetYAML ¶ added in v0.5.9
Set the duration value from a YAML value.
If the passed YAML value is not a string, then `ErrDurationNotString` is returned.
Will also return any error condition from the `Set` method.
func (*Duration) UnmarshalJSON ¶ added in v0.5.9
JSON unmarshalling method.
func (*Duration) UnmarshalYAML ¶ added in v0.5.9
YAML unmarshalling method.
type Mailbox ¶
type Mailbox struct {
// contains filtered or unexported fields
}
Mailbox structure.
This is a cheap implementation of a mailbox.
It uses two semaphores to control read and write access, and contains a single datum.
This is *not* a queue!
func NewMailbox ¶
func NewMailbox() *Mailbox
Create and return a new empty mailbox.
Note: this acquires the `preventRead` semaphore.
func (*Mailbox) Get ¶
Get an element from the mailbox. Defaults to using a context with a deadline of 5 seconds.
func (*Mailbox) GetWithContext ¶
Get an element from the mailbox using the provided context.
It is recommended to use a context that has a timeout deadline.