Extract segments from a line for overlay compositing.
Returns (before_text, before_width, after_text, after_width).
The “before” segment is columns [0, before_end).
The “after” segment is columns [after_start, total_width).
Matches pi’s extractSegments.
Normalize a terminal output line by appending a reset + hyperlink-close sequence.
This ensures any open ANSI/OSC styles are cleanly terminated.
Matches pi’s normalizeTerminalOutput.
Slice text by visible columns, returning both the extracted text and its width.
Like slice_by_column but also returns the actual visible width of the result.
Matches pi’s sliceWithWidth.
Calculate the visible width of a string in terminal columns.
Strips ANSI escape codes and counts grapheme cluster widths.
Uses a thread-local LRU cache for non-ASCII strings (matching pi).