screenWidth() публичный статический Метод

public static screenWidth ( )
 public static function render($e)
 {
     $isatty = pakeApp::isTTY();
     $title = '  [' . get_class($e) . ']  ';
     $len = self::strlen($title);
     $lines = array();
     foreach (explode("\n", $e->getMessage()) as $line) {
         if ($isatty) {
             $pieces = explode("\n", wordwrap($line, pakeApp::screenWidth() - 4, "\n", true));
         } else {
             $pieces = array($line);
         }
         foreach ($pieces as $piece) {
             $lines[] = '  ' . $piece . '  ';
             $len = max(self::strlen($piece) + 4, $len);
         }
     }
     if ($isatty) {
         $messages = array(str_repeat(' ', $len), $title . str_repeat(' ', $len - self::strlen($title)));
     } else {
         $messages = array('', $title);
     }
     foreach ($lines as $line) {
         if ($isatty) {
             $messages[] = $line . str_repeat(' ', $len - self::strlen($line));
         } else {
             $messages[] = $line;
         }
     }
     if ($isatty) {
         $messages[] = str_repeat(' ', $len);
     } else {
         $messages[] = '';
     }
     fwrite(STDERR, "\n");
     foreach ($messages as $message) {
         fwrite(STDERR, pakeColor::colorize($message, 'ERROR', STDERR) . "\n");
     }
     fwrite(STDERR, "\n");
     $pake = pakeApp::get_instance();
     if ($pake->get_trace()) {
         fwrite(STDERR, "exception trace:\n");
         $trace = self::trace($e);
         for ($i = 0, $count = count($trace); $i < $count; $i++) {
             $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
             $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
             $function = $trace[$i]['function'];
             $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
             $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
             fwrite(STDERR, pake_sprintf(" %s%s%s at %s:%s\n", $class, $type, $function, pakeColor::colorize($file, 'INFO', STDERR), pakeColor::colorize($line, 'INFO', STDERR)));
         }
     }
     fwrite(STDERR, "\n");
 }
Пример #2
0
function pake_excerpt($text, $size = null)
{
    if (null === $size) {
        $size = pakeApp::screenWidth() - 13;
    }
    if (strlen($text) < $size) {
        return $text;
    }
    $subsize = floor(($size - 3) / 2);
    return substr($text, 0, $subsize) . pakeColor::colorize('...', 'INFO') . substr($text, -$subsize);
}
Пример #3
0
function pake_excerpt($text, $size = null, $offset = 0)
{
    if (null === $size) {
        $size = pakeApp::screenWidth() - $offset;
    }
    if (mb_strlen($text) < $size) {
        return $text;
    }
    $subsize = floor(($size - 1) / 2);
    // "1" for ellipsis
    return mb_substr($text, 0, $subsize) . pakeColor::colorize('…', 'INFO') . mb_substr($text, -$subsize);
}