types

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
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).

View Source
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

This section is empty.

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 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) Full

func (m *Mailbox) Full() bool

Does the mailbox contain a value?

func (*Mailbox) Get

func (m *Mailbox) Get() (any, bool)

Get an element from the mailbox. Defaults to using a context with a deadline of 5 seconds.

func (*Mailbox) GetWithContext

func (m *Mailbox) GetWithContext(ctx context.Context) (any, bool)

Get an element from the mailbox using the provided context.

It is recommended to use a context that has a timeout deadline.

func (*Mailbox) Put

func (m *Mailbox) Put(elem any)

Put an element into the mailbox.

type Pair

type Pair struct {
	First  any
	Second any
}

Pair structure.

This is a cheap implementation of a pair (aka two-value tuple).

func NewEmptyPair

func NewEmptyPair() *Pair

Create a new empty pair.

func NewPair

func NewPair(first any, second any) *Pair

Create a new pair.

func (*Pair) String

func (p *Pair) String() string

Return a string representation of the pair.

type Queue

type Queue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Queue structure.

This is a cheap implementation of a LIFO queue.

func NewBoundedQueue

func NewBoundedQueue(bounds int) *Queue

Create a queue that is bounded to a specific size.

func NewQueue

func NewQueue() *Queue

Create a new empty queue.

func (*Queue) Full

func (q *Queue) Full() bool

Is the queue full?

func (*Queue) Get

func (q *Queue) Get() (any, bool)

Remove an element from the end of the queue and return it.

func (*Queue) Len

func (q *Queue) Len() int

Return the number of elements in the queue.

func (*Queue) Put

func (q *Queue) Put(elem any) bool

Append an element to the queue. Returns `false` if there is no more room in the queue.

Jump to

Keyboard shortcuts

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