/** * Renders the var * @param \Bugzorcist\VarDump\Ncurses\VarDump\NcursesVarDumpTypeAbstract $var var to render * @param int $level [optional] depth level */ protected function renderVar(NcursesVarDumpTypeAbstract $var, $level = 0) { $var->setLastPosY($this->posY); // verify if the entire element (string + children) will be printed outside of the viewport $totalHeight = $var->getStringHeight() + $var->getChildrenHeight(); if ($this->isBeingPrintedOutside($totalHeight)) { $this->addPosition(0, $totalHeight); return; } // add var to expandable list if ($var->isExpandable()) { $this->expandableList[$this->posY] = $var; } // render string $strHeight = $var->getStringHeight(); if (!$this->isBeingPrintedOutside($strHeight)) { $strArray = $var->getStringArray(); $color = null; $str = null; $this->printRawText(str_repeat(" ", $level)); foreach ($strArray as $v) { if (null === $color) { $color = $v; continue; } $str = $v; $this->printRawText($str, $color); $str = null; $color = null; } // in case of a multiline string, lines other than the first are marked as unselectable if ($strHeight > 1) { for ($i = $this->posY + 1; $i <= $this->posY + ($strHeight - 1); $i++) { $this->highlightRefYList[$i] = $this->posY; } } } $this->addPosition(0, $var->getStringHeight()); $level++; // render children $children = $var->getChildren(); foreach ($children as $child) { $this->renderVar($child, $level); } }