Documentation
¶
Index ¶
- func AnsiParse(input string) string
- func ClearTemplateConfigCache(userId int)
- func DynamicList(itmNames []NameDescription, colWidth, sw, numWidth, longestName int) string
- func Exists(name string) bool
- func GetMemoryUsage() map[string]util.MemoryResult
- func LoadAliases(f ...fileloader.ReadableGroupFS)
- func PreviewPanelLayout(yamlData string, stripAnsi bool) (string, error)
- func Process(fname string, data any, receivingUserId ...int) (string, error)
- func ProcessText(text string, data any, ansiFlags ...AnsiFlag) (string, error)
- func RegisterFS(f fs.ReadFileFS)
- func SavePanelLayout(name, yamlData string) error
- func SetAnsiFlag(flag AnsiFlag)
- func TNL(userId int) string
- func TplAnsiParse(input string) string
- type AnsiFlag
- type LayoutSlot
- type NameDescription
- type Panel
- func (p *Panel) Add(fullLabel, shortLabel, value string) *Panel
- func (p *Panel) AddBlank() *Panel
- func (p *Panel) AddWithWrapWidth(fullLabel, shortLabel, value string, wrapWidth int) *Panel
- func (p *Panel) SetCharset(name string) *Panel
- func (p *Panel) SetColumnGap(n int) *Panel
- func (p *Panel) SetColumns(n int) *Panel
- func (p *Panel) SetLabelWidth(w int) *Panel
- func (p *Panel) SetTitle(title string) *Panel
- func (p *Panel) SetWidth(w int) *Panel
- type PanelLayout
- type PanelLayoutInfo
- type PanelRow
- type PanelValidationIssue
- type TemplateTable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearTemplateConfigCache ¶
func ClearTemplateConfigCache(userId int)
func DynamicList ¶
func DynamicList(itmNames []NameDescription, colWidth, sw, numWidth, longestName int) string
DynamicList takes a slice of NameDescription items and formats them into a string NOTE: This is a first step to moving dynamic lists into a common function.
func GetMemoryUsage ¶ added in v0.9.8
func GetMemoryUsage() map[string]util.MemoryResult
func LoadAliases ¶
func LoadAliases(f ...fileloader.ReadableGroupFS)
Loads the ansi aliases from the config file Only if the file has been modified since the last load
func PreviewPanelLayout ¶ added in v0.9.8
PreviewPanelLayout parses the given YAML definition and renders a text preview by filling every panel with at least two dummy rows. When stripAnsi is true the output is plain ASCII (ANSI tags removed from titles). When false, titles are kept verbatim so the caller can render the ANSI tags with a client-side library.
func RegisterFS ¶
func RegisterFS(f fs.ReadFileFS)
func SavePanelLayout ¶ added in v0.9.8
SavePanelLayout writes yamlData to the panel layout file for the given name. name is relative to panel-layouts/ without the .yaml extension. The file must already exist; this function does not create new layout files.
func TplAnsiParse ¶
Types ¶
type AnsiFlag ¶
type AnsiFlag uint8
const ( AnsiTagsDefault AnsiFlag = iota // Do not parse tags AnsiTagsParse // Parse ansi tags before returning contents of template AnsiTagsStrip // strip out all ansi tags and leave text plain AnsiTagsMono // Parse ansi tags, but strip out all color information AnsiTagsNone = AnsiTagsDefault // alias to default ForceScreenReaderUserId = -1 )
type LayoutSlot ¶ added in v0.9.8
type LayoutSlot = layoutSlot
LayoutSlot is the exported handle for a slot, used by the scripting layer.
type NameDescription ¶
type NameDescription struct {
Id any // optional identifier.
Marked bool // mark in some way?
Name string
Description string
}
A common structure used in templating
type Panel ¶ added in v0.9.8
type Panel struct {
// contains filtered or unexported fields
}
Panel holds the rows for one titled box. Obtain via PanelLayout.Panel(id). width is the total border-inclusive panel width (border chars + padding + content). When width > 0, the panel targets that exact outer width and wraps values to fit; it will expand beyond width only when a label+value pair cannot fit otherwise.
func (*Panel) Add ¶ added in v0.9.8
Add appends a label+value row and returns the panel for chaining. When the panel has a non-zero width, values are wrapped to fit within the panel.
func (*Panel) AddBlank ¶ added in v0.9.8
AddBlank appends an empty spacer row and returns the panel for chaining.
func (*Panel) AddWithWrapWidth ¶ added in v0.9.8
AddWithWrapWidth appends a label+value row with an explicit value wrap width. When the value's visual width exceeds wrapWidth, it is wrapped onto continuation lines indented to align with the value column of the first line. Pass -1 to disable wrapping entirely for this row, even when the panel has a fixed width that would otherwise trigger automatic wrapping.
func (*Panel) SetCharset ¶ added in v0.9.8
SetCharset sets the border character set for this panel, overriding the layout-level charset. Accepts a named preset ("single", "double", "rounded") or a 7-rune literal string in the order: TopLeft, Horizontal, TopRight, VerticalLeft, VerticalRight, BottomLeft, BottomRight. Example literal: "╔═╗║║╚╝". An unrecognised value falls back to "single".
func (*Panel) SetColumnGap ¶ added in v0.9.8
SetColumnGap sets the spaces between columns when columns > 1.
func (*Panel) SetColumns ¶ added in v0.9.8
SetColumns sets the number of label+value pairs per rendered line (1 or 2).
func (*Panel) SetLabelWidth ¶ added in v0.9.8
SetLabelWidth sets a fixed visual width that all labels are padded to. When non-zero, every label is right-padded with spaces to this width before rendering, so values always start at the same column regardless of label length. ANSI tags in labels are accounted for correctly.
type PanelLayout ¶ added in v0.9.8
type PanelLayout struct {
// contains filtered or unexported fields
}
PanelLayout is a loaded layout skeleton populated with data and ready to render.
func LoadPanelLayout ¶ added in v0.9.8
func LoadPanelLayout(name string) (*PanelLayout, error)
LoadPanelLayout loads a panel layout definition from the datafiles directory. name is relative to the panel-layouts/ subdirectory and has no extension. Example: LoadPanelLayout("character/status")
func NewPanelLayout ¶ added in v0.9.8
func NewPanelLayout(border, charset string, gap, margin int) *PanelLayout
NewPanelLayout creates a PanelLayout programmatically without loading a YAML file.
func (*PanelLayout) AddPanelsToSlot ¶ added in v0.9.8
func (l *PanelLayout) AddPanelsToSlot(slot *LayoutSlot, ids ...string)
AddPanelsToSlot appends a new row of panels (one per id) to the given slot. Panels are created with default settings. Use Panel(id) to configure them further.
func (*PanelLayout) AddSlot ¶ added in v0.9.8
func (l *PanelLayout) AddSlot() *LayoutSlot
AddSlot appends a new empty slot to the layout and returns it.
func (*PanelLayout) Panel ¶ added in v0.9.8
func (l *PanelLayout) Panel(id string) *Panel
Panel returns the named panel for data population. If the id is not defined in the layout, a no-op panel is returned and an error is logged so the caller continues without panicking.
func (*PanelLayout) Render ¶ added in v0.9.8
func (l *PanelLayout) Render() string
Render synthesizes all slots into a single terminal string.
type PanelLayoutInfo ¶ added in v0.9.8
type PanelLayoutInfo struct {
// Name is the relative path under panel-layouts/ without the .yaml extension.
// Example: "character/status"
Name string
// YAML is the raw file content.
YAML string
}
PanelLayoutInfo holds metadata about a discovered panel layout file.
func ListPanelLayouts ¶ added in v0.9.8
func ListPanelLayouts() ([]PanelLayoutInfo, error)
ListPanelLayouts returns all panel layout files found under the panel-layouts/ subdirectory of the data files directory. Each entry's Name is the relative path without the .yaml extension (e.g. "character/status").
type PanelRow ¶ added in v0.9.8
PanelRow is one label+value line inside a panel. The renderer uses FullLabel when it fits the panel width, ShortLabel otherwise. Set Blank to true to insert an empty spacer line; label and value are ignored. When WrapWidth > 0, the value is word-wrapped at that visual width; continuation lines are indented to align with the value column of the first line.
type PanelValidationIssue ¶ added in v0.9.8
type PanelValidationIssue struct {
Message string `json:"message"`
}
PanelValidationIssue describes a single problem found during layout validation.
func ValidatePanelLayout ¶ added in v0.9.8
func ValidatePanelLayout(yamlData string) ([]PanelValidationIssue, error)
ValidatePanelLayout parses the given YAML and returns a list of structural issues. An empty slice means the layout is valid. A non-nil error means the YAML itself could not be parsed.
type TemplateTable ¶
type TemplateTable struct {
Title string
Header []string
Rows [][]string
TrueHeaderCellSize []int
TrueCellSize [][]int
ColumnCount int
ColumnWidths []int
Formatting [][]string
// contains filtered or unexported fields
}
func GetTable ¶
func GetTable(title string, headers []string, rows [][]string, formatting ...[]string) TemplateTable
func (TemplateTable) GetHeaderCell ¶
func (t TemplateTable) GetHeaderCell(column int) string