internal

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatNRGBA added in v0.22.0

func FormatNRGBA(nrgba color.NRGBA) string

FormatNRGBA formats an NRGBA value into a hex string.

func ParseNRGBA added in v0.22.0

func ParseNRGBA(str string) color.NRGBA

ParseNRGBA parses an NRGBA value from a hex string. It can be of the format:

  • RGB
  • RGBA
  • RRGGBB
  • RRGGBBAA

If none of these are specified, this function will return an opaque black color. Hex digits may either be upper case or lower case.

Types

type History added in v0.24.0

type History[T comparable] struct {
	// contains filtered or unexported fields
}

History stores a stack of items, always keeping the bottom-most one. It must be created using the NewHistory constructor, otherwise it will be invalid.

func NewHistory added in v0.24.0

func NewHistory[T comparable](initial T, max int) *History[T]

NewHistory creates a new History. The initial item will be on the bottom, and it will remain there until the History overflows and chooses the item after it to be the initial item.

func (*History[T]) Clear added in v0.24.0

func (this *History[T]) Clear()

Clear removes all items except for the initial one.

func (*History[T]) Push added in v0.24.0

func (this *History[T]) Push(item T)

Push pushes a new item onto the stack. If the stack overflows (becomes bigger than the specified max value), the initial item is removed and the one on top of it takes its place.

func (*History[T]) PushWeak added in v0.24.0

func (this *History[T]) PushWeak(item T, minAge time.Duration)

PushWeak replaces the most recent item if it was added recently (sooner than specified by minAge), and will otherwise push the item normally. If the history was popped or cleared beforehand, the item will always be pushed normally. This is intended to be used for things such as keystrokes.

func (*History[T]) Redo added in v0.24.0

func (this *History[T]) Redo() T

Redo undoes an Undo operation and returns the resulting top of the stack.

func (*History[T]) Swap added in v0.24.0

func (this *History[T]) Swap(item T)

Swap replaces the most recent item with another.

func (*History[T]) SwapSilently added in v0.24.0

func (this *History[T]) SwapSilently(item T)

SwapSilently replaces the most recent item with another without updating the time.

func (*History[T]) Top added in v0.24.0

func (this *History[T]) Top() T

Top returns the most recent item.

func (*History[T]) Undo added in v0.24.0

func (this *History[T]) Undo() T

Undo removes the most recent item and returns what was under it. If there is only one item (the initial item), it will kept and returned.

Jump to

Keyboard shortcuts

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