editor

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConst

func AddConst(doc *psrt.Document, name, value string) error

AddConst registers a constant and replaces literal value occurrences with @name@.

func AddFont

func AddFont(doc *psrt.Document, url string) error

AddFont appends a font URL if not already present.

func AddMask

func AddMask(doc *psrt.Document, pageName string, mask psrt.Mask, beforeIndex, afterIndex int) error

AddMask inserts a mask block on a page.

func AddPage

func AddPage(doc *psrt.Document, page psrt.Page, before, after string) error

AddPage inserts a new page (append, or before/after another page by name).

func AddPathMask

func AddPathMask(doc *psrt.Document, pageName string, mask psrt.PathMask, beforeIndex, afterIndex int) error

AddPathMask inserts a path mask block on a page.

func AddText

func AddText(doc *psrt.Document, pageName string, text psrt.Text, beforeIndex, afterIndex int) error

AddText inserts a new text block on a page.

func FindMaskByIndex

func FindMaskByIndex(page *psrt.Page, index int) (*psrt.Mask, int, error)

FindMaskByIndex delegates to psrt.FindMaskByIndex.

func FindPage

func FindPage(doc *psrt.Document, name string) (*psrt.Page, error)

FindPage returns the page with the given name.

func FindPageIndex

func FindPageIndex(doc *psrt.Document, name string) (int, error)

FindPageIndex returns the slice index of a page by name.

func FindPathMaskByIndex

func FindPathMaskByIndex(page *psrt.Page, index int) (*psrt.PathMask, int, error)

FindPathMaskByIndex delegates to psrt.FindPathMaskByIndex.

func FindTextByIndex

func FindTextByIndex(page *psrt.Page, index int) (*psrt.Text, int, error)

FindTextByIndex returns the text block with the given Index field on a page.

func FormatDocument

func FormatDocument(doc *psrt.Document) ([]byte, error)

FormatDocument serialises a document to PSRT bytes.

func LoadDocument

func LoadDocument(path string) (psrt.Document, error)

LoadDocument parses a PSRT file from path.

func MergeStyle

func MergeStyle(style psrt.Style, partial json.RawMessage) (psrt.Style, error)

MergeStyle shallow-merges partial JSON into the existing style.

func MovePage

func MovePage(doc *psrt.Document, pageName, before, after string) error

MovePage reorders a page before or after another page.

func NudgeTextPosition

func NudgeTextPosition(doc *psrt.Document, pageName string, textIndex int, delta PositionFields) error

NudgeTextPosition adds deltas to X, Y, Width and/or TextSize. Only non-nil fields in delta are applied.

func ParseTextIndex

func ParseTextIndex(s string) (int, error)

ParseTextIndex parses --index flag value.

func RemoveConst

func RemoveConst(doc *psrt.Document, name string) error

RemoveConst reverts @name@ to the stored value, then deletes the constant.

func RemoveFont

func RemoveFont(doc *psrt.Document, url string) error

RemoveFont removes a font URL.

func RemoveMask

func RemoveMask(doc *psrt.Document, pageName string, maskIndex int) error

RemoveMask deletes a mask by index field.

func RemoveMaskStyleKey

func RemoveMaskStyleKey(doc *psrt.Document, pageName string, maskIndex int, key string) error

RemoveMaskStyleKey removes a style property from a mask block.

func RemovePage

func RemovePage(doc *psrt.Document, name string) error

RemovePage deletes a page by name.

func RemovePageStyleKey

func RemovePageStyleKey(doc *psrt.Document, pageName, key string) error

RemovePageStyleKey removes a style property from a page.

func RemovePathMask

func RemovePathMask(doc *psrt.Document, pageName string, maskIndex int) error

RemovePathMask deletes a path mask by index field.

func RemovePathMaskStyleKey

func RemovePathMaskStyleKey(doc *psrt.Document, pageName string, maskIndex int, key string) error

RemovePathMaskStyleKey removes a style property from a path mask block.

func RemoveStyleKey

func RemoveStyleKey(style psrt.Style, key string) (psrt.Style, error)

RemoveStyleKey removes a property from a style JSON object.

func RemoveText

func RemoveText(doc *psrt.Document, pageName string, textIndex int) error

RemoveText removes a text block by Index field.

func RemoveTextStyleKey

func RemoveTextStyleKey(doc *psrt.Document, pageName string, textIndex int, key string) error

RemoveTextStyleKey removes a style property from a text block.

func RenamePage

func RenamePage(doc *psrt.Document, oldName, newName string) error

RenamePage changes a page name.

func ReorderTextByDelta

func ReorderTextByDelta(doc *psrt.Document, pageName string, textIndex, delta int) error

ReorderTextByDelta moves a text block by a delta in slice order.

func ReorderTextRelative

func ReorderTextRelative(doc *psrt.Document, pageName string, textIndex int, beforeIndex, afterIndex int) error

ReorderTextRelative moves a text block before or after another text index in the page slice.

func ReorderTextTo

func ReorderTextTo(doc *psrt.Document, pageName string, textIndex, to int) error

ReorderTextTo moves a text block to an absolute slice position.

func RevertConstReferences

func RevertConstReferences(doc *psrt.Document, name, value string)

RevertConstReferences replaces @name@ with the original value across the document.

func SaveDocument

func SaveDocument(doc *psrt.Document, path string) error

SaveDocument formats and writes a PSRT document to path.

func SetMaskPosition

func SetMaskPosition(doc *psrt.Document, pageName string, maskIndex int, pos MaskPositionFields) error

SetMaskPosition sets mask X, Y, Width and/or Height (percent).

func SetMaskStyle

func SetMaskStyle(doc *psrt.Document, pageName string, maskIndex int, key, value string, partial json.RawMessage) error

SetMaskStyle merges a style property on a mask block.

func SetPagePath

func SetPagePath(doc *psrt.Document, pageName, path string) error

SetPagePath updates the page image URL.

func SetPageStyle

func SetPageStyle(doc *psrt.Document, pageName string, key, value string, partial json.RawMessage) error

SetPageStyle merges style properties on a page.

func SetPathMaskPath

func SetPathMaskPath(doc *psrt.Document, pageName string, maskIndex int, path string) error

SetPathMaskPath replaces the SVG path `d` data of a path mask block. Validation mirrors flushPathMaskBlock's parse-time checks (see psrt/parser.go): the path must be non-empty, syntactically valid SVG path data, and describe a single shape (RF-7).

func SetPathMaskPosition

func SetPathMaskPosition(doc *psrt.Document, pageName string, maskIndex int, pos PathMaskPositionFields) error

SetPathMaskPosition sets path mask X, Y, Width and/or Height (percent).

func SetPathMaskStyle

func SetPathMaskStyle(doc *psrt.Document, pageName string, maskIndex int, key, value string, partial json.RawMessage) error

SetPathMaskStyle merges a style property on a path mask block.

func SetStyleKey

func SetStyleKey(style psrt.Style, key, value string) (psrt.Style, error)

SetStyleKey sets a single property on a style JSON object. value is raw JSON (e.g. "#fff", "\"600\"", "true").

func SetTextContent

func SetTextContent(doc *psrt.Document, pageName string, textIndex int, content string, appendContent bool) error

SetTextContent updates text content (replace or append).

func SetTextPosition

func SetTextPosition(doc *psrt.Document, pageName string, textIndex int, pos PositionFields) error

SetTextPosition sets X, Y, Width and/or TextSize to absolute values. Only non-nil fields in pos are applied.

func SetTextStyle

func SetTextStyle(doc *psrt.Document, pageName string, textIndex int, key, value string, partial json.RawMessage) error

SetTextStyle merges style properties on a text block.

func SubstituteConstReferences

func SubstituteConstReferences(doc *psrt.Document, name, value string)

SubstituteConstReferences replaces literal value with @name@ across the document.

Types

type MaskPositionFields

type MaskPositionFields struct {
	X, Y, Width, Height *float64
}

MaskPositionFields holds optional mask coordinate updates.

func (MaskPositionFields) IsEmpty

func (p MaskPositionFields) IsEmpty() bool

type PathMaskPositionFields

type PathMaskPositionFields struct {
	X, Y, Width, Height *float64
}

PathMaskPositionFields holds optional path mask coordinate updates.

func (PathMaskPositionFields) IsEmpty

func (p PathMaskPositionFields) IsEmpty() bool

type PositionFields

type PositionFields struct {
	X, Y, Width, TextSize *float64
}

PositionFields holds optional coordinate updates (nil = leave unchanged).

Jump to

Keyboard shortcuts

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