示例#1
0
 public function __construct(Buffer $buf)
 {
     $this->buf = $buf;
     $this->color = Color::NIL();
 }
示例#2
0
 private function exportRow($row, $x, $w)
 {
     $color = Color::NIL();
     $ret = '';
     $sz = count($this->buf[$row]);
     for ($i = $x; $i < $x + $w and $i < $sz; $i++) {
         if (!isset($this->buf[$row][$i])) {
             echo sprintf("Dump: row = %s, i = %s, x = %s, w = %s\n", $row, $i, $x, $w);
             //echo var_export($this->buf[$row]) . "\n";
             exit(1);
         }
         list($char, $clr) = $this->buf[$row][$i];
         if ($color != $clr) {
             $ret .= $clr->export();
             $color = $clr;
         }
         $ret .= $char;
         if (WString::isWide($char)) {
             $i++;
         }
     }
     if ($x + $w > $sz) {
         if ($color != Color::NIL()) {
             $ret .= Color::NIL()->export();
         }
         $ret .= str_repeat(' ', $x + $w - $sz);
     }
     return $ret;
 }