merged branch jcowgill/console-windows-fix (PR #4594)
Commits -------bb87a71
[Console] Use 'mode' command to detect terminal size on Windows Discussion ---------- [Console] Use 'mode' command to detect terminal size on Windows This PR uses the windows 'mode' command to get the terminal height and width on windows. I've left in the ANSICON stuff but I'm not sure if that's needed after this. --------------------------------------------------------------------------- by travisbot at 2012-06-16T10:37:25Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1634120) (merged a490b6ec intof881d282
). --------------------------------------------------------------------------- by fabpot at 2012-06-16T16:17:24Z ping @Seldaek --------------------------------------------------------------------------- by Seldaek at 2012-06-16T17:03:22Z It's a good addition, but you should still use ANSICON first if it's available. mode returns the buffer size and not the window size, which means the lines are not the real terminal height, but the buffer setting. ANSICON has both informations and hence allows you to be more correct. For columns/width both offer equally good information since the buffer size is not bigger than the window. --------------------------------------------------------------------------- by fabpot at 2012-06-17T10:41:21Z Can you squash your commits before I merge? Thanks. --------------------------------------------------------------------------- by jcowgill at 2012-06-17T13:23:01Z Yes that's fine. --------------------------------------------------------------------------- by fabpot at 2012-06-18T12:04:43Z @jcowgill there are still 3 commits. --------------------------------------------------------------------------- by jcowgill at 2012-06-18T14:59:51Z Woops, it's done now
This commit is contained in:
commit
086ff48228
@ -834,8 +834,15 @@ class Application
|
||||
*/
|
||||
protected function getTerminalWidth()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD') && $ansicon = getenv('ANSICON')) {
|
||||
return preg_replace('{^(\d+)x.*$}', '$1', $ansicon);
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
if ($ansicon = getenv('ANSICON')) {
|
||||
return preg_replace('{^(\d+)x.*$}', '$1', $ansicon);
|
||||
}
|
||||
|
||||
exec('mode CON', $execData);
|
||||
if (preg_match('{columns:\s*(\d+)}i', $execData[4], $matches)) {
|
||||
return $matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match("{rows.(\d+);.columns.(\d+);}i", $this->getSttyColumns(), $match)) {
|
||||
@ -850,8 +857,15 @@ class Application
|
||||
*/
|
||||
protected function getTerminalHeight()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD') && $ansicon = getenv('ANSICON')) {
|
||||
return preg_replace('{^\d+x\d+ \(\d+x(\d+)\)$}', '$1', trim($ansicon));
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
if ($ansicon = getenv('ANSICON')) {
|
||||
return preg_replace('{^\d+x\d+ \(\d+x(\d+)\)$}', '$1', trim($ansicon));
|
||||
}
|
||||
|
||||
exec('mode CON', $execData);
|
||||
if (preg_match('{lines:\s*(\d+)}i', $execData[3], $matches)) {
|
||||
return $matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match("{rows.(\d+);.columns.(\d+);}i", $this->getSttyColumns(), $match)) {
|
||||
|
Reference in New Issue
Block a user