Skip to content

Commit

Permalink
CliRenderer: Automatically detect windows VT100 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jnvsor committed Dec 30, 2021
1 parent 71a80e0 commit 0aa8437
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Binary file modified build/kint.phar
Binary file not shown.
13 changes: 10 additions & 3 deletions src/Renderer/CliRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ class CliRenderer extends TextRenderer
*/
public static $min_terminal_width = 40;

/**
* Which stream to check for VT100 support on windows.
*
* @var resource
*/
public static $windows_stream = STDOUT;

protected static $terminal_width = null;

protected $windows_output = false;
Expand All @@ -69,8 +76,8 @@ public function __construct()
{
parent::__construct();

if (!self::$force_utf8) {
$this->windows_output = KINT_WIN;
if (!self::$force_utf8 && KINT_WIN && (!KINT_PHP72 || !\sapi_windows_vt100_support(self::$windows_stream))) {
$this->windows_output = true;
}

if (!self::$terminal_width) {
Expand Down Expand Up @@ -153,7 +160,7 @@ protected function utf8ToWindows($string)
{
return \str_replace(
['', '', '', '', '', '', ''],
["\xda", "\xdc", "\xbf", "\xb3", "\xc0", "\xc4", "\xd9"],
[' ', '=', ' ', '|', ' ', '-', ' '],
$string
);
}
Expand Down

0 comments on commit 0aa8437

Please sign in to comment.