trait DrawsScrollbars

Traits

Methods

int
longest(array $lines, int $padding = 0)

Get the length of the longest line.

string
pad(string $text, int $length, string $char = ' ')

Pad text ignoring ANSI escape sequences.

string
replaceLastVisibleGrapheme(string $line, string $replacement)

Replace the last visible grapheme while preserving trailing formatting.

string
stripEscapeSequences(string $text)

Strip ANSI escape sequences from the given text.

string
mbWordwrap(string $string, int $width = 75, string $break = "\n", bool $cut_long_words = false)

Multi-byte version of wordwrap.

array
ansiWordwrap(string $text, int $width, bool $cutLongWords = false)

Word wrap text while preserving ANSI escape sequences.

array
parseAnsiText(string $text)

Parse text into segments with their associated ANSI codes.

void
updateSgrState(array $activeSgr, string $escape)

Update the bounded set of active SGR attributes.

array|Collection
scrollbar(array|Collection $visible, int $firstVisible, int $height, int $total, int $width, string $color = 'cyan')

Render a scrollbar beside the visible items.

int
scrollPosition(int $firstVisible, int $height, int $total)

Return the position where the scrollbar "handle" should be rendered.

Details

protected int longest(array $lines, int $padding = 0)

Get the length of the longest line.

Parameters

array $lines
int $padding

Return Value

int

protected string pad(string $text, int $length, string $char = ' ')

Pad text ignoring ANSI escape sequences.

Parameters

string $text
int $length
string $char

Return Value

string

protected string replaceLastVisibleGrapheme(string $line, string $replacement)

Replace the last visible grapheme while preserving trailing formatting.

Parameters

string $line
string $replacement

Return Value

string

protected string stripEscapeSequences(string $text)

Strip ANSI escape sequences from the given text.

Parameters

string $text

Return Value

string

protected string mbWordwrap(string $string, int $width = 75, string $break = "\n", bool $cut_long_words = false)

Multi-byte version of wordwrap.

Parameters

string $string
int $width
string $break
bool $cut_long_words

Return Value

string

in InteractsWithStrings at line 172
protected array ansiWordwrap(string $text, int $width, bool $cutLongWords = false)

Word wrap text while preserving ANSI escape sequences.

Parameters

string $text
int $width
bool $cutLongWords

Return Value

array

in InteractsWithStrings at line 267
protected array parseAnsiText(string $text)

Parse text into segments with their associated ANSI codes.

Parameters

string $text

Return Value

array

in InteractsWithStrings at line 379
protected void updateSgrState(array $activeSgr, string $escape)

Update the bounded set of active SGR attributes.

Parameters

array $activeSgr
string $escape

Return Value

void

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.

Parameters

array|Collection $visible
int $firstVisible
int $height
int $total
int $width
string $color

Return Value

array|Collection

at line 42
protected int scrollPosition(int $firstVisible, int $height, int $total)

Return the position where the scrollbar "handle" should be rendered.

Parameters

int $firstVisible
int $height
int $total

Return Value

int