rich

package
v0.0.0-...-6513b37 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsyncUse

func AsyncUse(r Reuser, fn AsyncUser)

AsyncUse is a handler for structs that implement the Reuser primitive. The passed in function will be called asynchronously, but swap will be called in the Gtk main thread.

func BindRoundImage

func BindRoundImage(img ImageURLSetter, state LabelStateStorer, tooltip bool)

BindRoundImage binds a round image to a rich label state store.

func MakeRed

func MakeRed(content text.Rich) markup.RenderOutput

MakeRed is a renderer that makes the plain text red.

func RenderSkipImages

func RenderSkipImages(rich text.Rich) markup.RenderOutput

RenderSkipImages is a label renderer that skips images.

func Small

func Small(content text.Rich) markup.RenderOutput

Small is a renderer that makes the plain text small.

Types

type AsyncUser

type AsyncUser = func(context.Context) (interface{}, func(), error)

type ImageURLSetter

type ImageURLSetter interface {
	SetImageURL(url string)
}

ImageURLSetter describes an image that can be set a URL.

type Label

type Label struct {
	gtk.Label
	Tooltip bool
	// contains filtered or unexported fields
}

Label provides an abstraction around a regular GTK label that can be self-updated. Widgets that extend off of this (such as ToggleButton) does not need to manually

func NewLabel

func NewLabel(state LabelStateStorer) *Label

NewLabel creates a self-updating label.

func NewLabelWithRenderer

func NewLabelWithRenderer(state LabelStateStorer, r LabelRenderer) *Label

NewLabelWithRenderer creates a self-updating label using the given renderer.

func NewStaticLabel

func NewStaticLabel(rich text.Rich) *Label

NewStaticLabel creates a static, non-updating label.

func (*Label) Output

func (l *Label) Output() markup.RenderOutput

Output returns the rendered output.

func (*Label) SetLabel

func (l *Label) SetLabel(content text.Rich)

SetLabel sets the label in the current thread, meaning it's not thread-safe.

func (*Label) SetRenderer

func (l *Label) SetRenderer(renderer LabelRenderer)

SetRenderer sets a custom renderer. If the given renderer is nil, then the default markup renderer is used instead. The label is automatically updated.

type LabelImage

type LabelImage struct {
	URL    string
	Text   string
	Size   image.Point
	Avatar bool
}

LabelImage is the first image from a label. If

func (LabelImage) HasImage

func (labelImage LabelImage) HasImage() bool

HasImage returns true if the label has an image.

type LabelRenderer

type LabelRenderer = func(text.Rich) markup.RenderOutput

LabelRenderer is the input/output function to render a rich text segment to Pango markup.

type LabelState

type LabelState struct {
	// contains filtered or unexported fields
}

LabelState provides a container for labels that allow other containers to extend upon. A zero-value instance is a valid instance.

func NewLabelState

func NewLabelState(l text.Rich) *LabelState

NewLabelState creates a new label state.

func (*LabelState) Image

func (state *LabelState) Image() LabelImage

Image returns the image, if any. Otherwise, an empty string is returned.

func (*LabelState) Label

func (state *LabelState) Label() text.Rich

Label returns the inside label.

func (*LabelState) OnUpdate

func (state *LabelState) OnUpdate(fn func()) (remove func())

OnUpdate subscribes the given callback. The returned callback removes the given callback from the registry.

func (*LabelState) SetLabel

func (state *LabelState) SetLabel(label text.Rich)

SetLabel is called by cchat to update the state. The internal subscribed callbacks will be called in the main thread.

func (*LabelState) String

func (state *LabelState) String() string

String returns the inside label in plain text.

type LabelStateStorer

type LabelStateStorer interface {
	Label() text.Rich
	Image() LabelImage
	OnUpdate(func()) (remove func())
}

LabelStateStorer is an interface for LabelState.

type NameContainer

type NameContainer struct {
	LabelState
	// contains filtered or unexported fields
}

NameContainer contains a reusable LabelState for cchat.Namer.

func (*NameContainer) BindNamer

func (namec *NameContainer) BindNamer(w primitives.Connector, sig string, namer cchat.Namer)

BindNamer binds a destructor signal to the name container to cancel a context.

func (*NameContainer) QueueNamer

func (namec *NameContainer) QueueNamer(ctx context.Context, namer cchat.Namer)

QueueNamer tries using the namer in the background and queue the setter onto the next GLib loop iteration.

func (*NameContainer) Stop

func (namec *NameContainer) Stop()

Stop stops the name container. Calling Stop twice when no new namers are set will do nothing.

type Reuser

type Reuser interface {
	Context() context.Context
	Acquire() int64
	Validate(int64) bool
	SwapResource(v interface{}, cancel func())
}

Reuser is an interface for structs that inherit Reusable.

Directories

Path Synopsis
parser
hl
Package hl provides a syntax highlighted renderer for the markup API.
Package hl provides a syntax highlighted renderer for the markup API.

Jump to

Keyboard shortcuts

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