stringeditor

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DOSColorStyle

func DOSColorStyle(attr byte) lipgloss.Style

DOSColorStyle returns a lipgloss style for a given DOS color attribute byte. The byte encodes fg (lower 4 bits) and bg (upper 4 bits), matching the Pascal TextAttr format: attr = bg*16 + fg.

func DOSFGStyle

func DOSFGStyle(colorIdx int) lipgloss.Style

DOSFGStyle returns a lipgloss style for a DOS foreground color index (0-15).

func DefaultStrings

func DefaultStrings() map[string]string

DefaultStrings returns the default string values matching the original Pascal FormatStrings() procedure defaults.

func FormatItemNumber

func FormatItemNumber(n, total int) string

FormatItemNumber formats an item number with consistent width for display.

func LoadStrings

func LoadStrings(path string) (map[string]string, error)

LoadStrings reads strings.json and returns a map of key -> value. If the file doesn't exist, it creates it with defaults from metadata.

func PlainTextLength

func PlainTextLength(s string) int

PlainTextLength returns the visible character count of a BBS pipe-coded string, stripping all color codes.

func RenderColorString

func RenderColorString(s string, maxWidth int) string

RenderColorString converts a BBS pipe-coded string into a lipgloss-styled string suitable for TUI display. It parses |XX foreground codes (00-15), |BX background codes (B0-B7), $x/$X dollar-sign color codes, and |CR (converted to space). The maxWidth parameter truncates visible characters (not counting color codes) and adds a "»" overflow indicator.

func SaveStrings

func SaveStrings(path string, strings map[string]string) error

SaveStrings writes the string map back to the JSON file with sorted keys and pretty formatting. It preserves any keys not in the editor metadata.

Types

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the BubbleTea model for the string editor TUI.

func New

func New(filePath string, shippedDefaults map[string]string) (Model, error)

New creates a new string editor model. shippedDefaults, if non-nil, provides factory default values for F4 restore.

func (Model) Init

func (m Model) Init() tea.Cmd

Init implements tea.Model.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model.

func (Model) View

func (m Model) View() string

View implements tea.Model.

type StringEntry

type StringEntry struct {
	Label       string // Display name shown in the editor list
	Key         string // JSON key in strings.json
	Description string // Help text shown in the description bar
}

StringEntry defines the metadata for a single editable string. It maps a JSON key to a human-readable label and description, matching the original Pascal STRINGS.PAS "things" array.

func StringEntries

func StringEntries() []StringEntry

StringEntries returns the ordered list of all editable strings. The first 178 entries match the original Pascal STRINGS.EXE ordering. V3-specific strings follow in logical groups.

Jump to

Keyboard shortcuts

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