Attempts to determine the Terminal's dimensions based on the 'ANSICON' environmental variables.

@return  array   Either an array containing two keys - 'width' and 'height' or null if the data couldn't
be parsed to retrieve anything useful.
543864
protected function getDimensionsFromAnsicon() : ?array
    {
        if (preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim(getenv('ANSICON')), $matches)) {
            return [
                'width'  => (int) $matches[1],
                'height' => (int) ($matches[4] ?? $matches[2])
            ];
        }

        return null;
    }
502553
def get_width():
    """"""
    # Get terminal size
    ws = struct.pack("HHHH", 0, 0, 0, 0)
    ws = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, ws)
    lines, columns, x, y = struct.unpack("HHHH", ws)
    width = min(columns * 39 // 40, columns - 2)
    return width
957237
protected function getSupportedSizes()
    {
        return [FieldInterface::SIZE_TINY, FieldInterface::SIZE_SMALL, FieldInterface::SIZE_MEDIUM, FieldInterface::SIZE_NORMAL, FieldInterface::SIZE_BIG];
    }
1046102
public static function getScreenWidth() {

        // set a simple error handler that indicates the exec function was disabled
        set_error_handler("self::errorHandler", E_WARNING);

        // initialize the array for the output of the execute
        $output = [];

        // execute the bash command tput cols to determine the screen width
        $width = exec("tput cols 2>&1", $output);

        // if the height is zero, then something went wrong
        if (count($output) == 0 ||$width == 0 || $width == "" || is_null($width)) {

            // use the error handler to raise the exception
            self::errorHandler(null,null);


        }

        // put back the error handler
        restore_error_handler();

        // return the height
        return intval($width);


    }
1001282
public function getDimension() {
        $w = imagefontwidth($this->font) * strlen($this->text);
        $h = imagefontheight($this->font);

        $rotationAngle = $this->getRotationAngle();
        if ($rotationAngle === 90 || $rotationAngle === 270) {
            return array($h, $w);
        } else {
            return array($w, $h);
        }
    }
791878
protected function getSizeInfo()
	{
		$size = array();
		// since we check $i + 1 we need to stop one step earlier
		$this->dataLength = strlen($this->data) - 1;

		$sofStartRead = true;

		// Look through file for SOF marker
		for ($i = 2; $i < $this->dataLength; $i++)
		{
			$marker = $this->getNextMarker($i, $sofStartRead);

			if (in_array($marker, $this->sofMarkers))
			{
				// Extract size info from SOF marker
				return $this->extractSizeInfo($i);
			}
			else
			{
				// Extract length only
				$markerLength = $this->extractMarkerLength($i);

				if ($markerLength < 2)
				{
					return $size;
				}

				$i += $markerLength - 1;
				continue;
			}
		}

		return $size;
	}
502649
public function sizeParameter()
	{
		if (!$this->get('size') || !is_integer($this->get('size')))
		{
			return null;
		}

		return array('s' => (int)$this->get('size'));
	}
1214736
protected function _detectNumberOfTerminalColumns() {
        $terminalCols = null;
        try {
            exec('tput cols 2> /dev/null', $terminalCols, $errorCode);

            if ($errorCode == 0 && $terminalCols && array_key_exists(0, $terminalCols)) {
                return (int)$terminalCols[0];
            }
        } catch (Exception $e) {
        }

        return self::DEFAULT_SCREEN_SIZE;
    }
1282692
def get_terminal_size(fd):
    """"""
    sizebuf = array.array('h', [0, 0])
    fcntl.ioctl(fd, termios.TIOCGWINSZ, sizebuf, True)
    return tuple(reversed(sizebuf))
726795
public function getSize()
    {
        $filePath = $this->getPathname();
        $size = -1;
        $isWin = (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN');
        $execWorks = (function_exists('exec') && !ini_get('safe_mode') && exec('echo EXEC') == 'EXEC');
        if ($isWin) {
            if ($execWorks) {
                $cmd = "for %F in (\"$filePath\") do @echo %~zF";
                exec($cmd, $output);
                if (is_array($output)) {
                    $result = trim(implode("\n", $output));
                    if (ctype_digit($result)) {
                        $size = $result;
                    }
                }
            }
            // try the Windows COM interface if its fails
            if (class_exists('COM') && $size > -1) {
                $fsobj = new \COM('Scripting.FileSystemObject');
                $file = $fsobj->GetFile($filePath);
                $result = $file->Size;
                if (ctype_digit($result)) {
                    $size = $result;
                }
            }
        } else {
            $result = trim("stat -c%s $filePath");
            if (ctype_digit($result)) {
                $size = $result;
            }
        }
        if ($size < 0) {
            $size = filesize($filePath);
        }
        return $size;
    }
278719
public function dimensions() {
        return $this->_cache(__FUNCTION__, function($file) {
            /** @type \Transit\File $file */

            $dims = null;

            if (!$file->isImage()) {
                return $dims;
            }

            $data = @getimagesize($file->path());

            if ($data && is_array($data)) {
                $dims = array(
                    'width' => $data[0],
                    'height' => $data[1]
                );
            }

            if (!$data) {
                $image = @imagecreatefromstring(file_get_contents($file->path()));
                $dims = array(
                    'width' => @imagesx($image),
                    'height' => @imagesy($image)
                );
            }

            return $dims;
        });
    }
141804
public function getSize()
    {
        if (!$this->stream) {
            return null;
        }

        $stats = fstat($this->stream);
        if (isset($stats['size'])) {
            return $stats['size'];
        }

        return null;
    }
1097664
public static function getWidth()
    {
        $width = getenv('COLUMNS');
        if ($width !== false) {
            return (int) trim($width);
        }

        static::updateDimensions();

        return static::$width;
    }
430273
public function getButtonDimensions()
    {
        // Initialise:
        
        $data = [];
        
        // Obtain Dimensions:
        
        $sizes = $this->dbObject('ButtonSize');
        
        // Iterate Size Viewports:
        
        foreach ($sizes->getViewports() as $viewport) {
            
            if ($value = $sizes->getField($viewport)) {
                $data[$viewport]['Size'] = $value;
                $data[$viewport]['Breakpoint'] = $sizes->getBreakpoint($viewport);
            }
            
        }
        
        // Obtain Icon Dimensions:
        
        $iconSizes = $this->dbObject('IconSize');
        
        // Iterate Icon Size Viewports:
        
        foreach ($iconSizes->getViewports() as $viewport) {
            
            if ($value = $iconSizes->getField($viewport)) {
                $data[$viewport]['IconSize'] = $value;
                $data[$viewport]['Breakpoint'] = $iconSizes->getBreakpoint($viewport);
            }
            
        }
        
        // Create Items List:
        
        $items = ArrayList::create();
        
        // Create Data Items:
        
        foreach ($data as $item) {
            $items->push(ArrayData::create($item));
        }
        
        // Answer Items List:
        
        return $items;
    }
237367
public function getWidths(): array
    {
        $columns = $this->getColumns();
        $values  = ['equal', 'variable', 'null'];
        $values  = array_merge($values, range(1, $columns));

        return array_combine($values, $values);
    }
1024708
public function getDimensions(): array
	{
		$dimensions = PHP_OS_FAMILY === 'Windows' ? $this->getDimensionsForWindows() : $this->getDimensionsForUnixLike();

		return $dimensions ?? ['width' => static::DEFAULT_WIDTH, 'height' => static::DEFAULT_HEIGHT];
	}
376476
public function getDimensionValues()
    {
        $values = [];
        
        foreach ($this->fields as $dim => $field) {
            $values[$dim] = is_numeric($field->dataValue()) ? (int) $field->dataValue() : null;
        }
        
        return $values;
    }