Allow terminal dimensions to be set to 0 (unbounded)
This commit is contained in:
parent
d41a3a56c2
commit
4c1b001891
@ -23,8 +23,9 @@ class Terminal
|
|||||||
*/
|
*/
|
||||||
public function getWidth()
|
public function getWidth()
|
||||||
{
|
{
|
||||||
if ($width = trim(getenv('COLUMNS'))) {
|
$width = getenv('COLUMNS');
|
||||||
return (int) $width;
|
if (false !== $width) {
|
||||||
|
return (int) trim($width);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === self::$width) {
|
if (null === self::$width) {
|
||||||
@ -41,8 +42,9 @@ class Terminal
|
|||||||
*/
|
*/
|
||||||
public function getHeight()
|
public function getHeight()
|
||||||
{
|
{
|
||||||
if ($height = trim(getenv('LINES'))) {
|
$height = getenv('LINES');
|
||||||
return (int) $height;
|
if (false !== $height) {
|
||||||
|
return (int) trim($height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === self::$height) {
|
if (null === self::$height) {
|
||||||
|
@ -30,4 +30,15 @@ class TerminalTest extends TestCase
|
|||||||
$this->assertSame(120, $terminal->getWidth());
|
$this->assertSame(120, $terminal->getWidth());
|
||||||
$this->assertSame(60, $terminal->getHeight());
|
$this->assertSame(60, $terminal->getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_zero_values()
|
||||||
|
{
|
||||||
|
putenv('COLUMNS=0');
|
||||||
|
putenv('LINES=0');
|
||||||
|
|
||||||
|
$terminal = new Terminal();
|
||||||
|
|
||||||
|
$this->assertSame(0, $terminal->getWidth());
|
||||||
|
$this->assertSame(0, $terminal->getHeight());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user