PHP 8.3.31
Preview: TextareaPromptRenderer.php Size: 2.52 KB
/home/getspomw/royalsquad.us/vendor/laravel/prompts/src/Themes/Default/TextareaPromptRenderer.php

<?php

namespace Laravel\Prompts\Themes\Default;

use Laravel\Prompts\TextareaPrompt;
use Laravel\Prompts\Themes\Contracts\Scrolling;

class TextareaPromptRenderer extends Renderer implements Scrolling
{
    use Concerns\DrawsBoxes;
    use Concerns\DrawsScrollbars;

    /**
     * Render the textarea prompt.
     */
    public function __invoke(TextareaPrompt $prompt): string
    {
        $prompt->width = $prompt->terminal()->cols() - 8;

        return match ($prompt->state) {
            'submit' => $this
                ->box(
                    $this->dim($this->truncate($prompt->label, $prompt->width)),
                    implode(PHP_EOL, $prompt->lines()),
                ),

            'cancel' => $this
                ->box(
                    $this->truncate($prompt->label, $prompt->width),
                    implode(PHP_EOL, array_map(fn ($line) => $this->strikethrough($this->dim($line)), $prompt->lines())),
                    color: 'red',
                )
                ->error($prompt->cancelMessage),

            'error' => $this
                ->box(
                    $this->truncate($prompt->label, $prompt->width),
                    $this->renderText($prompt),
                    color: 'yellow',
                    info: 'Ctrl+D to submit'
                )
                ->warning($this->truncate($prompt->error, $prompt->terminal()->cols() - 5)),

            default => $this
                ->box(
                    $this->cyan($this->truncate($prompt->label, $prompt->width)),
                    $this->renderText($prompt),
                    info: 'Ctrl+D to submit'
                )
                ->when(
                    $prompt->hint,
                    fn () => $this->hint($prompt->hint),
                    fn () => $this->newLine() // Space for errors
                )
        };
    }

    /**
     * Render the text in the prompt.
     */
    protected function renderText(TextareaPrompt $prompt): string
    {
        $visible = $prompt->visible();

        while (count($visible) < $prompt->scroll) {
            $visible[] = '';
        }

        $longest = $this->longest($prompt->lines()) + 2;

        return implode(PHP_EOL, $this->scrollbar(
            $visible,
            $prompt->firstVisible,
            $prompt->scroll,
            count($prompt->lines()),
            min($longest, $prompt->width + 2),
        ));
    }

    /**
     * The number of lines to reserve outside of the scrollable area.
     */
    public function reservedLines(): int
    {
        return 5;
    }
}

Directory Contents

Dirs: 1 × Files: 17

Name Size Perms Modified Actions
Concerns DIR
- drwxrwxrwx 2026-04-22 16:37:06
Edit Download
216 B lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
2.37 KB lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
16.33 KB lrw-r--r-- 2026-04-26 11:58:05
Edit Download
5.90 KB lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
4.37 KB lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
1.60 KB lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
1.69 KB lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
522 B lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
2.03 KB lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
2.10 KB lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
4.39 KB lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
3.11 KB lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
934 B lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
4.11 KB lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
1.30 KB lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
2.52 KB lrw-rw-rw- 2025-09-17 06:52:54
Edit Download
1.71 KB lrw-rw-rw- 2025-09-17 06:52:54
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).