Example #1
0
 /**
  * Determine and return current console width.
  *
  * @return int
  */
 public function getWidth()
 {
     static $width;
     if ($width > 0) {
         return $width;
     }
     // Try to read console size from ANSICON env var
     if (preg_match('/\\((\\d+)x/', getenv('ANSICON'), $matches)) {
         $width = $matches[1];
     } else {
         $width = AbstractAdapter::getWidth();
     }
     return $width;
 }
Example #2
0
 /**
  * Determine and return current console width.
  *
  * @return int
  */
 public function getWidth()
 {
     static $width;
     if ($width > 0) {
         return $width;
     }
     // Try to read console size from "mode" command
     if ($this->modeResult === null) {
         $this->runProbeCommand();
     }
     if (preg_match('/Columns\\:\\s+(\\d+)/', $this->modeResult, $matches)) {
         $width = $matches[1];
     } else {
         $width = parent::getWidth();
     }
     return $width;
 }
Example #3
0
 /**
  * Determine and return current console width.
  *
  * @return int
  */
 public function getWidth()
 {
     static $width;
     if ($width > 0) {
         return $width;
     }
     /**
      * Try to read env variable
      */
     if (($result = getenv('COLUMNS')) !== false) {
         return $width = (int) $result;
     }
     /**
      * Try to read console size from "tput" command
      */
     $result = exec('tput cols', $output, $return);
     if (!$return && is_numeric($result)) {
         return $width = (int) $result;
     }
     return $width = parent::getWidth();
 }