Utils
class Utils
| internal |
Constants
| MAX_UNBREAKABLE_BYTES |
|
| private OSC8_PATTERN |
|
| TERMINAL_FORMATTING_PATTERN |
The terminal formatting sequences preserved by decorated renderers. |
| private WRITE_CHUNK_BYTES |
The largest chunk offered to a single write attempt. |
| private MEMORY_STREAM_TYPE |
The stream type that always accepts a full write and cannot be selected on. |
Methods
Get the last item from an array or null if it doesn't exist.
Strip terminal escape sequences and Symfony style tags.
Split text into bounded Unicode grapheme units.
Return the byte length when a fragment continues the trailing grapheme.
Remove terminal controls other than SGR and OSC 8 formatting.
Resolve a complete OSC 8 sequence to its active hyperlink state.
Write an entire payload to a stream, waiting up to a timeout for a blocked reader.
Details
at line 39
static bool
allMatch(array $values, Closure $callback)
Determine if all items in an array match a truth test.
at line 55
static mixed
last(array $array)
Get the last item from an array or null if it doesn't exist.
at line 65
static false|int|string
search(array $array, Closure $callback)
Returns the key of the first element in the array that satisfies the callback.
at line 79
static string
stripEscapeSequences(string $text)
Strip terminal escape sequences and Symfony style tags.
at line 96
static array
graphemes(string $text)
Split text into bounded Unicode grapheme units.
at line 125
static int|null
continuedGraphemeBytes(string $text, string $next)
Return the byte length when a fragment continues the trailing grapheme.
at line 139
static string
sanitizeTerminalFormatting(string $text)
Remove terminal controls other than SGR and OSC 8 formatting.
at line 147
static string|null
resolveOsc8Link(string $escape)
Resolve a complete OSC 8 sequence to its active hyperlink state.
at line 172
static void
writeAll(resource $stream, string $payload, float $timeout = 10.0)
Write an entire payload to a stream, waiting up to a timeout for a blocked reader.
The stream is driven in non-blocking mode because stream_set_timeout() only governs reads. A blocking write into a full buffer parks in the underlying send syscall on macOS and BSD, where no timeout applies and no signal can interrupt it, so the caller would wait for the reader forever.