signalfmt

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(ctx context.Context, message string, ranges []*signalpb.BodyRange, params *FormatParams) *event.MessageEventContent

Types

type BodyRange

type BodyRange struct {
	Start  int
	Length int
	Value  BodyRangeValue
}

func (BodyRange) End

func (b BodyRange) End() int

End returns the end index of the range.

func (BodyRange) Offset

func (b BodyRange) Offset(offset int) *BodyRange

Offset changes the start of the range without affecting the length.

func (BodyRange) Proto

func (b BodyRange) Proto() *signalpb.BodyRange

func (BodyRange) String

func (b BodyRange) String() string

func (BodyRange) TruncateEnd

func (b BodyRange) TruncateEnd(maxEnd int) *BodyRange

TruncateEnd changes the length of the range, so it ends at or before the given index and starts at the same index as before.

func (BodyRange) TruncateStart

func (b BodyRange) TruncateStart(startAt int) *BodyRange

TruncateStart changes the length of the range, so it starts at the given index and ends at the same index as before.

type BodyRangeList

type BodyRangeList []BodyRange

func (BodyRangeList) Len

func (b BodyRangeList) Len() int

func (BodyRangeList) Less

func (b BodyRangeList) Less(i, j int) bool

func (BodyRangeList) Swap

func (b BodyRangeList) Swap(i, j int)

type BodyRangeValue

type BodyRangeValue interface {
	String() string
	Format(message string) string
	Proto() signalpb.BodyRangeAssociatedValue
}

type FormatParams

type FormatParams struct {
	GetUserInfo func(ctx context.Context, uuid uuid.UUID) UserInfo
}

type LinkedRangeTree

type LinkedRangeTree struct {
	Node    *BodyRange
	Sibling *LinkedRangeTree
	Child   *LinkedRangeTree
}

LinkedRangeTree is a linked tree of formatting entities.

It's meant to parse a list of Signal body ranges into nodes that either overlap completely or not at all, which enables more natural conversion to HTML.

func (*LinkedRangeTree) Add

func (lrt *LinkedRangeTree) Add(r *BodyRange)

Add adds the given formatting entity to this tree.

func (*LinkedRangeTree) Format

func (lrt *LinkedRangeTree) Format(message UTF16String, ctx formatContext) string

type Mention

type Mention struct {
	UserInfo
	UUID uuid.UUID
}

func (Mention) Format

func (m Mention) Format(message string) string

func (Mention) Proto

func (Mention) String

func (m Mention) String() string

type Style

type Style int
const (
	StyleNone Style = iota
	StyleBold
	StyleItalic
	StyleSpoiler
	StyleStrikethrough
	StyleMonospace
)

func (Style) Format

func (s Style) Format(message string) string

func (Style) Proto

func (Style) String

func (s Style) String() string

type UTF16String

type UTF16String []uint16

func NewUTF16String

func NewUTF16String(s string) UTF16String

func (UTF16String) String

func (u UTF16String) String() string

type UserInfo

type UserInfo struct {
	MXID id.UserID
	Name string
}

Jump to

Keyboard shortcuts

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