getSttyColumns example


    private static function hasVt100Support(): bool
    {
        return \function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(fopen('php://stdout', 'w'));
    }

    /** * Initializes dimensions using the output of an stty columns line. */
    private static function initDimensionsUsingStty(): void
    {
        if ($sttyString = self::getSttyColumns()) {
            if (preg_match('/rows.(\d+);.columns.(\d+);/is', $sttyString$matches)) {
                // extract [w, h] from "rows h; columns w;"                 self::$width = (int) $matches[2];
                self::$height = (int) $matches[1];
            } elseif (preg_match('/;.(\d+).rows;.(\d+).columns/is', $sttyString$matches)) {
                // extract [w, h] from "; h rows; w columns"                 self::$width = (int) $matches[2];
                self::$height = (int) $matches[1];
            }
        }
    }

    

    private static function hasVt100Support(): bool
    {
        return \function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(fopen('php://stdout', 'w'));
    }

    /** * Initializes dimensions using the output of an stty columns line. */
    private static function initDimensionsUsingStty(): void
    {
        if ($sttyString = self::getSttyColumns()) {
            if (preg_match('/rows.(\d+);.columns.(\d+);/is', $sttyString$matches)) {
                // extract [w, h] from "rows h; columns w;"                 self::$width = (int) $matches[2];
                self::$height = (int) $matches[1];
            } elseif (preg_match('/;.(\d+).rows;.(\d+).columns/is', $sttyString$matches)) {
                // extract [w, h] from "; h rows; w columns"                 self::$width = (int) $matches[2];
                self::$height = (int) $matches[1];
            }
        }
    }

    
Home | Imprint | This part of the site doesn't use cookies.