Documentation ¶
Overview ¶
Package mauthor handles rendering Matrix room members' names.
Index ¶
- Variables
- func Markup(c *gotktrix.Client, rID matrix.RoomID, uID matrix.UserID, mods ...MarkupMod) string
- func Name(c *gotktrix.Client, rID matrix.RoomID, uID matrix.UserID, mods ...MarkupMod) string
- func RGBHex(c color.RGBA) string
- func SetDefaultColorHasher(hasher ColorHasher)
- func Text(c *gotktrix.Client, iter *gtk.TextIter, rID matrix.RoomID, uID matrix.UserID, ...)
- func UserColor(uID matrix.UserID, mods ...MarkupMod) string
- type Chip
- type ColorHasher
- type HSVHasher
- type MarkupMod
Constants ¶
This section is empty.
Variables ¶
var ( // FNVHasher is the alternative hasher for color hashing. FNVHasher = func() hash.Hash32 { return fnv.New32a() } // DJB2Hasher is the string hasher used for color hashing. DJB2Hasher = newDJB32 )
Functions ¶
func Markup ¶
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 RGBHex ¶
RGBHex converts the given color to a HTML hex color string. The alpha value is ignored.
func SetDefaultColorHasher ¶
func SetDefaultColorHasher(hasher ColorHasher)
SetDefaultColorHasher sets the default hasher that the package uses.
Types ¶
type Chip ¶
type Chip struct { *gtk.Box // 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 (*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) Invalidate ¶
func (c *Chip) Invalidate()
Invalidate invalidates the state of the chip and asks it to update the name and avatar. The NewChip constructor will automatically call this method, so the user doesn't have to.
type ColorHasher ¶
ColorHasher describes a string hasher that outputs a color.
var ( // LightColorHasher generates a pastel color name for use with a dark // background. LightColorHasher ColorHasher = HSVHasher{ FNVHasher, [2]float64{0.3, 0.4}, [2]float64{0.9, 1.0}, } // DarkColorHasher generates a darker, stronger color name for use with a // light background. DarkColorHasher ColorHasher = HSVHasher{ FNVHasher, [2]float64{0.9, 1.0}, [2]float64{0.6, 0.7}, } )
func DefaultColorHasher ¶
func DefaultColorHasher() ColorHasher
DefaultColorHasher returns the default color hasher.
type HSVHasher ¶
type HSVHasher struct { H func() hash.Hash32 // hashing function S [2]float64 // saturation V [2]float64 // value }
HSVHasher describes a color hasher that accepts saturation and value parameters in the HSV color space.
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 WithColorHasher ¶
func WithColorHasher(hasher ColorHasher) MarkupMod
WithColorHasher uses the given color hasher.
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 WithTextTagAttr ¶
func WithTextTagAttr(attr markuputil.TextTag) MarkupMod
WithTextTagAttr sets the given attribute into the text tag used for the author. It is only useful for Text.
func WithWidgetColor ¶
func WithWidgetColor(w gtk.Widgetter) MarkupMod
WithWidgetColor determines the best hasher from the given widget. The caller should beware to call this function in the main thread to not cause a race condition.