Page MenuHomeWickedGov Phorge

AnsiTermColorer.php
No OneTemporary

Size
828 B
Referenced Files
None
Subscribers
None

AnsiTermColorer.php

<?php
/**
* @license GPL-2.0-or-later
* @file
*/
namespace MediaWiki\Tests;
/**
* Terminal that supports ANSI escape sequences.
*
* @ingroup Testing
*/
class AnsiTermColorer {
/**
* Return ANSI terminal escape code for changing text attribs/color
*
* @param string|int $color Semicolon-separated list of attribute/color codes, e.g. 4 for
* underline, 30 to 37 for 3-bit foreground colors
* @return string
*/
public function color( string|int $color ): string {
global $wgCommandLineDarkBg;
// 1 for increased intensity, 0 to reset all previous attributes
return "\x1b[" . ( $wgCommandLineDarkBg ? '1' : '0' ) . ";{$color}m";
}
/**
* Return ANSI terminal escape code for restoring default text attributes
*
* @return string
*/
public function reset(): string {
return "\x1b[0m";
}
}

File Metadata

Mime Type
text/x-php
Expires
Oct 5 2026, 05:47 (6 w, 11 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a2/1d/8119071b4e2ab4b53cbb6e4380d5
Default Alt Text
AnsiTermColorer.php (828 B)

Event Timeline