示例#1
0
文件: Sprite.php 项目: glial/glial
 public function __construct($sprite)
 {
     $lines = explode("\n", $sprite);
     foreach ($lines as $line) {
         $len = mb_strlen(Color::strip($line), "utf8");
         if ($len > $this->width) {
             $this->width = $len;
         }
     }
     foreach ($lines as $line) {
         $this->sprite[] = String::str_pad_unicode($line, $this->width);
         $this->height++;
     }
     return $this;
 }
示例#2
0
文件: Window.php 项目: glial/glial
 public function windows($title, $msg)
 {
     if (strpos($title, "\n")) {
         throw new Exception("GLI-020 : The title must be on one line", 20);
     }
     $this->title_length = mb_strlen($title, "utf-8");
     //$this->msg = wordwrap($msg, $this->max_default, "\n", true);
     $this->msg = $msg;
     $lines = explode("\n", $this->msg);
     $this->msg_height = count($lines);
     foreach ($lines as $line) {
         $len = mb_strlen($line, "utf-8");
         if ($len > $this->msg_width) {
             $this->msg_width = $len;
         }
     }
     $this->msg_width += 6;
     $this->borderTop($title);
     $i = 0;
     foreach ($lines as $line) {
         $this->borderLeft();
         if ($line === "[[INPUT]]") {
             $cursor = array();
             $cursor['x'] = ($this->max_width - $this->msg_width) / 2 + 4;
             $cursor['y'] = ceil(($this->max_height - $this->msg_height) / 2) + $i;
             $this->cursor_position_input[] = $cursor;
             $this->windows .= Color::getColoredString(str_pad(" ", $this->msg_width - 6), $this->color_foreground_msg, $this->color_cursor);
             //$this->position_input = $i;
         } else {
             $this->windows .= Color::getColoredString(String::str_pad_unicode($line, Color::strip($this->msg_width) - 6), $this->color_foreground_msg, $this->color_window);
             //$this->windows .= Color::getColoredString(str_pad($line, mb_strlen(Color::strip($this->msg_width) - 6)-strlen($this->msg_width) ), $this->color_foreground_msg, $this->color_window);
         }
         $this->borderRight();
         $i++;
     }
     $this->position_input2 = $i - $this->position_input;
     $this->borderBottom();
     debug($this);
     return $this->encapsulate();
 }
示例#3
0
 public function out($msg, $type)
 {
     switch ($type) {
         case 'OK':
         case 'true':
             $status = Color::getColoredString("OK", "green");
             break;
         case 'KO':
         case 'false':
             $status = Color::getColoredString("KO", "red");
             break;
         case 'NA':
             $status = Color::getColoredString("!!", "blue");
             break;
     }
     $ret = $msg . str_repeat(".", 73 - strlen(Color::strip($msg))) . " [ " . $status . " ]" . PHP_EOL;
     /*
      if (!empty($err)) {
      echo $ret;
      $this->onError();
      }
     */
     return $ret;
 }
示例#4
0
文件: Install.php 项目: glial/glial
 public function out($msg, $type)
 {
     switch ($type) {
         case 'OK':
             $status = Color::getColoredString("OK", "green");
             break;
         case 'KO':
             $status = Color::getColoredString("KO", "red");
             $msg = Color::getColoredString($msg, "red");
             $err = true;
             break;
         case 'NA':
             $status = Color::getColoredString("!!", "blue");
             break;
         default:
             throw new \Exception("GLI-024 : Arguement '" . $msg . $type . "' not valid {OK|KO|NA}", 21);
     }
     $msg .= " ";
     $size = strlen(Color::strip($msg));
     if ($size < 0) {
         $size = 0;
     }
     $ret = $msg . str_repeat(".", 80 - $size) . " [ " . $status . " ]" . PHP_EOL;
     if (!empty($err)) {
         echo $ret;
         $this->onError();
     }
     return $ret;
 }