DrawsScrollbars
trait DrawsScrollbars
Traits
Methods
Get the length of the longest line.
Pad text ignoring ANSI escape sequences.
Replace the last visible grapheme while preserving trailing formatting.
Strip ANSI escape sequences from the given text.
Multi-byte version of wordwrap.
Word wrap text while preserving ANSI escape sequences.
Parse text into segments with their associated ANSI codes.
Update the bounded set of active SGR attributes.
Render a scrollbar beside the visible items.
Return the position where the scrollbar "handle" should be rendered.
Details
in
InteractsWithStrings at line 16
protected int
longest(array $lines, int $padding = 0)
Get the length of the longest line.
in
InteractsWithStrings at line 27
protected string
pad(string $text, int $length, string $char = ' ')
Pad text ignoring ANSI escape sequences.
in
InteractsWithStrings at line 37
protected string
replaceLastVisibleGrapheme(string $line, string $replacement)
Replace the last visible grapheme while preserving trailing formatting.
in
InteractsWithStrings at line 68
protected string
stripEscapeSequences(string $text)
Strip ANSI escape sequences from the given text.
in
InteractsWithStrings at line 79
protected string
mbWordwrap(string $string, int $width = 75, string $break = "\n", bool $cut_long_words = false)
Multi-byte version of wordwrap.
in
InteractsWithStrings at line 172
protected array
ansiWordwrap(string $text, int $width, bool $cutLongWords = false)
Word wrap text while preserving ANSI escape sequences.
in
InteractsWithStrings at line 267
protected array
parseAnsiText(string $text)
Parse text into segments with their associated ANSI codes.
in
InteractsWithStrings at line 379
protected void
updateSgrState(array $activeSgr, string $escape)
Update the bounded set of active SGR attributes.
at line 21
protected array|Collection
scrollbar(array|Collection $visible, int $firstVisible, int $height, int $total, int $width, string $color = 'cyan')
Render a scrollbar beside the visible items.
at line 42
protected int
scrollPosition(int $firstVisible, int $height, int $total)
Return the position where the scrollbar "handle" should be rendered.