compose

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package compose holds the compose window's logic, with no UI: the recipient fields' addresses, Send Later's choices, the attachment reminder, the links the editor keeps and the characters Backspace and Delete take (docs/specs/compose-ui.md). Outgoing mail itself is internal/compose's.

Index

Constants

View Source
const Leaf = "\ufffc"

Leaf is what an inline leaf of the message text, such as an image or a line break, stands for in its block's text: 1 position, a character alone.

Variables

This section is empty.

Functions

func AllowedLink(href string) bool

AllowedLink reports whether the editor keeps a link.

func CharAt added in v0.12.0

func CharAt(text string, offset int) (start, end int)

CharAt is the character of text that holds offset, from start to end in UTF-16 code units: what Delete deletes in the message text. A character is a grapheme cluster of Unicode's text segmentation (UAX #29), counted from the start of each run of text between Leafs, and a Leaf is a character alone. So an offset inside a character, which the caret can reach, gives the whole of it. At or past the end of text, start and end are both offset.

func HTMLText

func HTMLText(src string) string

HTMLText is the text of HTML: blocks and line breaks end a line, then white space is squashed.

func HasAttachment

func HasAttachment(src string, attachments int) bool

HasAttachment reports a chip, or an image outside every quote.

func MentionsAttachment

func MentionsAttachment(text string) bool

MentionsAttachment reports whether text holds an attachment word as a whole word.

func NeedsReminder

func NeedsReminder(src, signatureHTML string, attachments int) bool

NeedsReminder reports whether the user's own text mentions an attachment and none is attached.

func OwnText

func OwnText(src, signatureHTML string) string

OwnText is the text the user wrote: no quotes, no attribution line, no signature (docs/specs/compose-ui.md, Attachment reminder).

func ParseAddresses

func ParseAddresses(text string) (addresses []api.Address, invalid []string)

ParseAddresses splits typed or pasted text into addresses, dropping repeats without regard to case; pieces that do not parse come back as invalid, trimmed.

func RecipientPrefix added in v0.10.0

func RecipientPrefix(text string) (string, string)

RecipientPrefix returns the completed part of a field, including its last separator, and the last unfinished address for completion.

func RuneBefore added in v0.12.0

func RuneBefore(text string, offset int) (start, end int)

RuneBefore is the rune of text that ends at offset, or that holds it, from start to end in UTF-16 code units: what Backspace deletes in the message text. The rich editor counts its positions in UTF-16 code units. At the start of text, start and end are both 0.

Backspace takes 1 rune, not a whole character, because NSGo's rich editor also sends it once for each rune that an input method takes back from the text it typed: a character of several runes would delete more than the input method took.

func Token

func Token(a api.Address) string

Token writes an address as a recipient field's token, which reads back as this one recipient whatever the mail it came from says: the text is untrusted. An address that cannot be written plainly becomes one quoted piece, which is invalid and holds the send back.

func TomorrowMorning

func TomorrowMorning(now time.Time) time.Time

TomorrowMorning is where the Send Later sheet starts.

func ValidAddress

func ValidAddress(text string) bool

ValidAddress reports whether text is a plausible email address.

Types

type Choice

type Choice struct {
	Label string
	At    time.Time
}

Choice is a Send Later choice and its time.

func SendChoices

func SendChoices(now time.Time) []Choice

SendChoices offers tonight at 9 PM while that is ahead, then tomorrow at 8 AM, in now's zone.

Jump to

Keyboard shortcuts

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