Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LineOffset ¶
LineOffset represents a half-open interval [Start, End) that describes either the byte offset or rune offset range of a wrapped segment in the original unwrapped string.
type WrappedString ¶
type WrappedString struct {
// The current wrapped line number (after wrapping).
CurLineNum int
// The original unwrapped line number this segment came
// from.
OrigLineNum int
// The byte start and end offsets of this segment in the
// original unwrapped string.
OrigByteOffset LineOffset
// The rune start and end offsets of this segment in the
// original unwrapped string.
OrigRuneOffset LineOffset
// Which segment number this is within the original line
// (first, second, etc.).
SegmentInOrig int
// Whether the segment fits entirely within the wrapping
// limit.
NotWithinLimit bool
// Whether the wrap was due to a hard break (newline)
// instead of word wrapping.
IsHardBreak bool
// The viewable width of the wrapped string.
Width int
// Whether this wrapped segment ends with a split word due
// to reaching the wrapping limit
// (e.g., a hyphen may be added).
EndsWithSplitWord bool
}
type WrappedStringSeq ¶
type WrappedStringSeq struct {
// WrappedLines is the list of individual wrapped segments with
// metadata.
WrappedLines []WrappedString
// WordSplitAllowed indicates whether splitting words across
// lines is permitted.
WordSplitAllowed bool
// TabSize defines how many spaces a tab character expands to.
TabSize int
// Limit is the maximum viewable width allowed per line.
Limit int
}
WrappedStringSeq holds the sequence of wrapped lines produced by the string wrapping process, along with the configuration used.
func StringWrap ¶
StringWrap wraps the input string to the specified viewable width limit, expanding tabs using the given tab size. It preserves word boundaries and does not split words across lines.
ANSI escape sequences are preserved without contributing to visual width. returns the wrapped string and a metadata sequence describing each wrapped line.
func StringWrapSplit ¶
StringWrapSplit wraps the input string to the specified viewable width limit, expanding tabs using the given tab size. Unlike StringWrap, this function allows words to be split across lines if they exceed the wrapping limit.
ANSI escape sequences are preserved without contributing to visual width. returns the wrapped string and a metadata sequence describing each wrapped line.