Coding standards
Security in ResourceSpace
Developer reference
Database
User api session functions
Geolocation functions
Storage test functions
Cli functions
Lang translation functions

cli_render_status_block()

Description

Redraw a live status block, reserving space for the persistent log.

Parameters

ColumnTypeDefaultDescription
$lines array
&$rendered_rows int
$size: array
string, list style?: string}> $lines Single-line status messages.
$rendered_rows int Number of rows to clear before redraw. Updated for the next call.
int, array{rows: columns: int} $size Terminal dimensions.

Return

void

Location

include/cli_functions.php lines 155 to 175

Definition

 
function cli_render_status_block(array $lines, int &$rendered_rows, array $size): void
{
    if (!
cli_is_interactive() || $lines === []) {
        return;
    }
    
cli_clear_status_block($rendered_rows);
    
$limit = max(2, $size['rows'] - 4);
    if (
count($lines) > $limit) {
        
$hidden = count($lines) - $limit + 1;
        
$lines = array_slice($lines, 0, $limit - 1);
        
$lines[] = ['text' => "  {$hidden} more status rows", 'style' => 'muted'];
    }
    
$output = [];
    foreach (
$lines as $line) {
        
$text = preg_replace('/[\p{Cc}\x{202A}-\x{202E}\x{2066}-\x{2069}]/u', ' ', $line['text']) ?? '';
        
$text = mb_strimwidth($text, 0, max(1, $size['columns'] - 1), '…', 'UTF-8');
        
$output[] = cli_style($text, $line['style'] ?? '');
    }
    
fwrite(STDOUT, "\r" . implode("\033[K\n\r", $output) . "\033[K");
    
$rendered_rows = count($output);
}

This article was last updated 27th November 2026 18:35 Europe/London time based on the source file dated 27th November 2026 17:15 Europe/London time.