Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit620e894

Browse files
bug#34085 [Console] Detect dimensions using mode CON if vt100 is supported (rtek)
This PR was merged into the 4.3 branch.Discussion----------[Console] Detect dimensions using mode CON if vt100 is supported| Q | A| ------------- | ---| Branch? | 4.3| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |Fix#33915| License | MITThis fixes color support detection for users of Win10 + git-bash. If vt100 support is detected, the terminal will not try to use `stty` to test for dimensions. Calling such command implicitly disables vt100 support on STDOUT.Commits-------fdeceff [Console]Fix#33915, Detect dimensions using mode CON if vt100 is supported
2 parentse0c7ab0 +fdeceff commit620e894

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎src/Symfony/Component/Console/Terminal.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ private static function initDimensions()
7979
// or [w, h] from "wxh"
8080
self::$width = (int)$matches[1];
8181
self::$height =isset($matches[4]) ? (int)$matches[4] : (int)$matches[2];
82-
}elseif (self::hasSttyAvailable()) {
82+
}elseif (!self::hasVt100Support() &&self::hasSttyAvailable()) {
83+
// only use stty on Windows if the terminal does not support vt100 (e.g. Windows 7 + git-bash)
84+
// testing for stty in a Windows 10 vt100-enabled console will implicitly disable vt100 support on STDOUT
8385
self::initDimensionsUsingStty();
8486
}elseif (null !==$dimensions =self::getConsoleMode()) {
8587
// extract [w, h] from "wxh"
@@ -91,6 +93,17 @@ private static function initDimensions()
9193
}
9294
}
9395

96+
/**
97+
* Returns whether STDOUT has vt100 support (some Windows 10+ configurations).
98+
*/
99+
privatestaticfunctionhasVt100Support():bool
100+
{
101+
return\function_exists('sapi_windows_vt100_support') &&sapi_windows_vt100_support(STDOUT);
102+
}
103+
104+
/**
105+
* Initializes dimensions using the output of an stty columns line.
106+
*/
94107
privatestaticfunctioninitDimensionsUsingStty()
95108
{
96109
if ($sttyString =self::getSttyColumns()) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp