/** * Sets new-line translation state * @param bool $state True of false * @return Ncurses This object */ public function setNewLineTranslationState($state) { if ($state) { ncurses_nl(); } else { ncurses_nonl(); } return $this; }
public function init($title = 'AcePHProxy') { // начинаем с инициализации библиотеки $ncurse = ncurses_init(); // используем весь экран $this->windows['main'] = ncurses_newwin(0, 0, 0, 0); // рисуем рамку вокруг окна ncurses_border(0, 0, 0, 0, 0, 0, 0, 0); ncurses_getmaxyx($this->windows['main'], $y, $x); // save current main window size $this->cur_x = $x; $this->cur_y = $y; // создаём второе окно для лога $rows = floor($y / 2); $cols = $x; $sy = $y - $rows; $sx = 0; $this->windows['log'] = ncurses_newwin($rows, $cols, $sy, $sx); // и окно для статистики (остальное пространство) $rows = $y - $rows - 1; $cols = $x; $sy = 1; $sx = 0; // еще -1 чтобы границы не перекрывались $this->windows['stat'] = ncurses_newwin($rows, $cols, $sy, $sx); if (ncurses_has_colors()) { ncurses_start_color(); // colors http://php.net/manual/en/ncurses.colorconsts.php ncurses_init_pair(self::CLR_ERROR, NCURSES_COLOR_RED, NCURSES_COLOR_BLACK); ncurses_init_pair(self::CLR_GREEN, NCURSES_COLOR_GREEN, NCURSES_COLOR_BLACK); ncurses_init_pair(self::CLR_YELLOW, NCURSES_COLOR_YELLOW, NCURSES_COLOR_BLACK); ncurses_init_pair(self::CLR_SPEC1, NCURSES_COLOR_RED, NCURSES_COLOR_WHITE); ncurses_init_pair(5, NCURSES_COLOR_MAGENTA, NCURSES_COLOR_BLACK); ncurses_init_pair(6, NCURSES_COLOR_CYAN, NCURSES_COLOR_BLACK); ncurses_init_pair(self::CLR_DEFAULT, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLACK); $this->log('Init colors', self::CLR_GREEN); } // рамка для него ncurses_wborder($this->windows['log'], 0, 0, 0, 0, 0, 0, 0, 0); ncurses_wborder($this->windows['stat'], 0, 0, 0, 0, 0, 0, 0, 0); $this->outputTitle($title); ncurses_nl(); ncurses_curs_set(0); // visibility ncurses_refresh(); // рисуем окна // обновляем маленькое окно для вывода строки ncurses_wrefresh($this->windows['log']); }