windows_output = KINT_WIN; } if (!self::$terminal_width) { if (!KINT_WIN && self::$detect_width) { self::$terminal_width = \exec('tput cols'); } if (self::$terminal_width < self::$min_terminal_width) { self::$terminal_width = self::$default_width; } } $this->colors = $this->windows_output ? false : self::$cli_colors; $this->header_width = self::$terminal_width; } public function colorValue($string) { if (!$this->colors) { return $string; } return "\x1b[32m".\str_replace("\n", "\x1b[0m\n\x1b[32m", $string)."\x1b[0m"; } public function colorType($string) { if (!$this->colors) { return $string; } return "\x1b[35;1m".\str_replace("\n", "\x1b[0m\n\x1b[35;1m", $string)."\x1b[0m"; } public function colorTitle($string) { if (!$this->colors) { return $string; } return "\x1b[36m".\str_replace("\n", "\x1b[0m\n\x1b[36m", $string)."\x1b[0m"; } public function renderTitle(BasicObject $o) { if ($this->windows_output) { return $this->utf8ToWindows(parent::renderTitle($o)); } return parent::renderTitle($o); } public function preRender() { return PHP_EOL; } public function postRender() { if ($this->windows_output) { return $this->utf8ToWindows(parent::postRender()); } return parent::postRender(); } public function escape($string, $encoding = false) { return \str_replace("\x1b", '\\x1b', $string); } protected function utf8ToWindows($string) { return \str_replace( array('┌', '═', '┐', '│', '└', '─', '┘'), array("\xda", "\xdc", "\xbf", "\xb3", "\xc0", "\xc4", "\xd9"), $string ); } }