private function drawPrompt($input = null) { $windowSize = $this->getWindowSize(); // Move to the last line ncurses_curs_set(2); ncurses_move($windowSize[1] - 1, 0); // Clear the line ncurses_clrtoeol(); // Write the prompt ncurses_addstr($this->prompt); $this->input = $input; // Reset cursor position ncurses_move($windowSize[1] - 1, strlen($this->prompt)); if ($this->input == null) { // Clear the rest of the line for ($i = 0; $i < $windowSize[0] - strlen($this->prompt); $i++) { ncurses_addstr(' '); } // Reset the cursor again ncurses_move($windowSize[1] - 1, strlen($this->prompt)); } else { ncurses_addstr($this->input); } }
public function log($msg, $color = self::CLR_DEFAULT) { ncurses_getmaxyx($this->windows['log'], $y, $x); ncurses_getyx($this->windows['log'], $cy, $cx); // cursor xy if ($cy > $y - 3) { ncurses_werase($this->windows['log']); ncurses_wborder($this->windows['log'], 0, 0, 0, 0, 0, 0, 0, 0); $cy = 0; } $msg = mb_substr($msg, 0, $x - 2); $color and ncurses_wcolor_set($this->windows['log'], $color); ncurses_mvwaddstr($this->windows['log'], $cy + 1, 1, $msg); ncurses_clrtoeol(); $color and ncurses_wcolor_set($this->windows['log'], self::CLR_DEFAULT); // никак скроллить не выходит #ncurses_insdelln (1); #ncurses_scrl (-2); // вообще 0 реакции #ncurses_insertln (); ncurses_wrefresh($this->windows['log']); }