markuputil

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package markuputil contains utilities for handling Pango markup and TextBuffer shenanigans.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attrs

func Attrs(attrs ...*pango.Attribute) *pango.AttrList

Attrs is a way to declaratively create a pango.AttrList.

func Error

func Error(msg string) string

Error formats the given message red.

func ErrorLabel

func ErrorLabel(markup string) *gtk.Label

ErrorLabel makes a new label with the class `.error'.

func HashTag

func HashTag(table *gtk.TextTagTable, attrs TextTag) *gtk.TextTag

HashTag creates a tag inside the text tag table using the hash of the text tag attributes as the name. If the same tag has already been created, then it is returned.

func IsDarkTheme

func IsDarkTheme(w gtk.Widgetter) bool

IsDarkTheme returns true if the given widget is inside an application with a dark theme. A dark theme implies the background color is dark. The function can be called concurrently, but it shouldn't ever be.

func NewAttrOpacity

func NewAttrOpacity(alpha float64) *pango.Attribute

NewAttrOpacity creates a new AttrForegroundAlpha.

func RGBHex

func RGBHex(c color.RGBA) string

RGBHex converts the given color to a HTML hex color string. The alpha value is ignored.

Types

type TextTag

type TextTag map[string]interface{}

TextTag describes a map of attribute/property name to its value for a TextTag. Attributes that need a -set suffix will be set to true automatically.

func (TextTag) Hash

func (t TextTag) Hash() string

Hash returns a 24-byte string of the text tag hashed.

func (TextTag) Tag

func (t TextTag) Tag(name string) *gtk.TextTag

Tag creates a new text tag from the attributes.

type TextTagsMap

type TextTagsMap map[string]TextTag

TextTagsMap describes a map of tag names to its attributes. It is used to declaratively construct a TextTagTable using NewTextTags.

func LinkTags

func LinkTags() TextTagsMap

LinkTags gets the text tags with colors for a, a:hover and a:visited. The output of the function is cached for a short while, so the user doesn't have to store it. It is concurrently safe to call this function.

func (TextTagsMap) Combine

func (m TextTagsMap) Combine(other TextTagsMap)

Combine adds all tags from other into m. If m already contains a tag that appears in other, then the tag is not overridden.

func (TextTagsMap) FromBuffer

func (m TextTagsMap) FromBuffer(buffer *gtk.TextBuffer, name string) *gtk.TextTag

FromBuffer call FromTable on the buffer's tag table.

func (TextTagsMap) FromTable

func (m TextTagsMap) FromTable(table *gtk.TextTagTable, name string) *gtk.TextTag

FromTable gets the tag with the given name from the given tag table, or if the tag doesn't exist, then a new one is added instead. If the name isn't known in either the table or the map, then the function will panic.

func (TextTagsMap) SetTagAttr

func (m TextTagsMap) SetTagAttr(name, attr string, value interface{})

SetTagAttr sets the attribute/property of the tag with the given name.

Jump to

Keyboard shortcuts

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