author

package
v0.0.0-...-4b8acdf Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package author handles rendering usernames.

Index

Constants

View Source
const ChipAvatarSize = 20 // smaller than usual

Variables

This section is empty.

Functions

func Markup

func Markup(name string, mods ...MarkupMod) string

Markup renders the markup string for the given user inside the given room. The markup format follows the Pango markup format.

If the given room ID string is empty, then certain information are skipped. If it's non-empty, then the state will be used to fetch additional information.

func Text

func Text(iter *gtk.TextIter, name string, mods ...MarkupMod)

Text renders the author's name into a rich text buffer. The written string is always minimal. The inserted tags have the "_mauthor" prefix.

Types

type Chip

type Chip struct {
	*gtk.Box
	Avatar *onlineimage.Avatar
	Name   *gtk.Label
	// contains filtered or unexported fields
}

Chip describes a user chip. It is used for display in messages and for composing messages in the composer bar.

In Material Design, chips are described as "compact elements tha represen an input, attribute, or action." People who have used Google Mail before will have seen it when they input an email address into the "To" field and having it turn into a small box showing the user information in a friendlier way instead of being an email address.

Note that due to how chips are currently implemented, it only works well at certain font scale ranges. Once the font scale is beyond ~1.3, flaws will start to be very apparent. In that case, the user should use proper graphics scaling using Wayland, not using hacks like font scaling.

func NewChip

func NewChip(ctx context.Context, avatarProvider imgutil.Provider) *Chip

NewChip creates a new Chip widget.

func (*Chip) InsertText

func (c *Chip) InsertText(text *gtk.TextView, iter *gtk.TextIter) *gtk.TextChildAnchor

InsertText inserts the chip into the given TextView at the given TextIter. The inserted anchor is returned.

func (*Chip) SetAvatar

func (c *Chip) SetAvatar(url string)

SetAvatar calls c.Avatar.SetFromURL.

func (*Chip) SetColor

func (c *Chip) SetColor(color string)

SetColor sets the chip's color in a hexadecimal string #FFFFFF.

func (*Chip) SetName

func (c *Chip) SetName(label string)

SetName sets the username.

func (*Chip) Unpad

func (c *Chip) Unpad()

Unpad removes the negative margin in the Chip.

type MarkupMod

type MarkupMod func(opts *markupOpts)

MarkupMod is a function type that Markup can take multiples of. It changes subtle behaviors of the Markup function, such as the color hasher used.

func WithColor

func WithColor(color string) MarkupMod

WithColor sets the color of the rendered output.

func WithMention

func WithMention() MarkupMod

WithMention makes the renderer prefix an at ("@") symbol.

func WithMinimal

func WithMinimal() MarkupMod

WithMinimal renders the markup without additional information, such as pronouns.

func WithShade

func WithShade() MarkupMod

WithShade renders the markup with a background shade.

func WithSuffix

func WithSuffix(suffix string) MarkupMod

WithSuffix adds a small grey suffix string into the output string if the Minimal flag is not present.

func WithSuffixMarkup

func WithSuffixMarkup(suffix string) MarkupMod

WithSuffixMarkup is like WithSuffix, except the input is taken as valid markup.

func WithTextTagAttr

func WithTextTagAttr(attr textutil.TextTag) MarkupMod

WithTextTagAttr sets the given attribute into the text tag used for the author. It is only useful for Text.

Jump to

Keyboard shortcuts

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