mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-24 06:28:13 +01:00
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.6.8 to 6.7.7. - [Release notes](https://github.com/jedib0t/go-pretty/releases) - [Commits](https://github.com/jedib0t/go-pretty/compare/v6.6.8...v6.7.7) --- updated-dependencies: - dependency-name: github.com/jedib0t/go-pretty/v6 dependency-version: 6.7.7 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Text
Package with utility functions to manipulate strings/text with full support for ANSI escape sequences (colors, formatting, etc.).
Used heavily in the other packages in this repo (list, progress, and table).
Features
Colors & Formatting
- ANSI Color Support - Full support for terminal colors and formatting
- Foreground colors (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White)
- Background colors (matching foreground set)
- Hi-intensity variants for both foreground and background
- 256-color palette support - Extended color support for terminals
- Standard 16 colors (0-15)
- RGB cube colors (16-231) - 216 colors organized in a 6x6x6 cube
- Grayscale colors (232-255) - 24 shades of gray
- Helper functions:
Fg256Color(index),Bg256Color(index),Fg256RGB(r, g, b),Bg256RGB(r, g, b)
- Text attributes (Bold, Faint, Italic, Underline, Blink, Reverse, Concealed, CrossedOut)
- Automatic color detection based on environment variables (
NO_COLOR,FORCE_COLOR,TERM) - Global enable/disable functions for colors
- Cached escape sequences for performance
- Text Formatting - Transform text while preserving escape sequences
FormatDefault- No transformationFormatLower- Convert to lowercaseFormatTitle- Convert to title caseFormatUpper- Convert to uppercase
- HTML Support - Generate HTML class attributes for colors
- Color Combinations - Combine multiple colors and attributes
Alignment
- Horizontal Alignment
AlignDefault/AlignLeft- Left-align textAlignCenter- Center-align textAlignRight- Right-align textAlignJustify- Justify text (distribute spaces between words)AlignAuto- Auto-detect: right-align numbers, left-align text- HTML and Markdown property generation for alignment
- Vertical Alignment
VAlignTop- Align to topVAlignMiddle- Align to middleVAlignBottom- Align to bottom- Works with both string arrays and multi-line strings
- HTML property generation for vertical alignment
Text Wrapping
- WrapHard - Hard wrap at specified length, breaks words if needed
- Handles ANSI escape sequences without breaking formatting
- Preserves paragraph breaks
- WrapSoft - Soft wrap at specified length, tries to keep words intact
- Handles ANSI escape sequences without breaking formatting
- Preserves paragraph breaks
- WrapText - Similar to WrapHard but also respects line breaks
- Handles ANSI escape sequences without breaking formatting
String Utilities
- Width Calculation
StringWidth- Calculate display width of string (including escape sequences)StringWidthWithoutEscSequences- Calculate display width ignoring escape sequencesRuneWidth- Calculate display width of a single rune (handles East Asian characters)LongestLineLen- Find the longest line in a multi-line string
- String Manipulation
Trim- Trim string to specified length while preserving escape sequencesPad- Pad string to specified length with a characterSnip- Snip string to specified length with an indicator (e.g., "~")RepeatAndTrim- Repeat string until it reaches specified lengthInsertEveryN- Insert a character every N charactersProcessCRLF- Process carriage returns and line feeds correctlyWiden- Convert half-width characters to full-width
- Escape Sequence Handling
- All functions properly handle ANSI escape sequences
- Escape sequences are preserved during transformations
- Width calculations ignore escape sequences
EscSeqParser- Parser for advanced escape sequence parsing and tracking- Supports both CSI (Control Sequence Introducer) and OSI (Operating System Command) formats
- Tracks active formatting codes and can generate consolidated escape sequences
- Full support for 256-color escape sequences (
\x1b[38;5;nmand\x1b[48;5;nm)
Cursor Control
- Move cursor in all directions
CursorUp- Move cursor up N linesCursorDown- Move cursor down N linesCursorLeft- Move cursor left N charactersCursorRight- Move cursor right N charactersEraseLine- Erase all characters to the right of cursor
- Generate ANSI escape sequences for terminal cursor manipulation
Hyperlinks
- Terminal Hyperlinks - Create clickable hyperlinks in supported terminals
- Uses OSC 8 escape sequences
- Format:
Hyperlink(url, text) - Falls back to plain text in unsupported terminals
Transformers
- Number Transformer - Format numbers with colors
- Positive numbers colored green
- Negative numbers colored red
- Custom format string support (e.g.,
%.2f) - Supports all numeric types (int, uint, float)
- JSON Transformer - Pretty-print JSON strings or objects
- Customizable indentation (prefix and indent string)
- Validates JSON before formatting
- Time Transformer - Format time.Time objects
- Custom layout support (e.g.,
time.RFC3339) - Timezone localization support
- Auto-detects common time formats from strings
- Custom layout support (e.g.,
- Unix Time Transformer - Format Unix timestamps
- Handles seconds, milliseconds, microseconds, and nanoseconds
- Auto-detects timestamp unit based on value
- Timezone localization support
- URL Transformer - Format URLs with styling
- Underlined and colored blue by default
- Custom color support
Text Direction
- Bidirectional Text Support
LeftToRight- Force left-to-right text directionRightToLeft- Force right-to-left text direction- Uses Unicode directional markers
Filtering
- String Filtering - Filter string slices with custom functions
Filter(slice, predicate)- Returns filtered slice
East Asian Character Support
- Proper width calculation for East Asian characters (full-width, half-width)
- Configurable East Asian width handling via
OverrideRuneWidthEastAsianWidth() - Handles mixed character sets correctly