Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tput cols on Windows #424

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
/.php-cs-fixer.cache
/.phpunit.result.cache
/.idea
/.vscode
npm-debug.log
/tests/phpunit.tmp
Binary file modified build/kint.phar
Binary file not shown.
4 changes: 1 addition & 3 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@
</TypeDoesNotContainType>
</file>
<file src="src/Renderer/CliRenderer.php">
<RedundantCondition>
<code><![CDATA[!KINT_WIN]]></code>
</RedundantCondition>
<TypeDoesNotContainType>
<code><![CDATA[KINT_WIN]]></code>
<code><![CDATA[KINT_WIN]]></code>
</TypeDoesNotContainType>
</file>
<file src="src/Utils.php">
Expand Down
4 changes: 2 additions & 2 deletions src/Renderer/CliRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ public function __construct()
}

if (null === self::$terminal_width) {
if (!KINT_WIN && self::$detect_width) {
if (self::$detect_width) {
Copy link
Member

@jnvsor jnvsor Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be !$this->windows_output && self::$detect_width instead? That'd guard against windows terminals that don't have sapi_windows_vt100_support but I'm not sure that coincides with the presence of tput

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am investigating this. Will run a Windows 7 terminal for testing purposes. While I'm on it, I would like to also address the lack of colors on Windows, it seems to be related to this.

try {
$tput = \exec('tput cols 2>/dev/null');
$tput = KINT_WIN ? \exec('tput cols 2>nul') : \exec('tput cols 2>/dev/null');
if ((bool) $tput) {
/**
* @psalm-suppress InvalidCast
Expand Down