/** * Constructor accepts the placement (x, y, width and height), the title, * the available options, and the currently selected index. * * @param int $x The topmost row * @param int $y The leftmost column * @param int $w The width * @param int $h The height * @param string $title The title * @param array $items The available options * @param int $selected The currently selected index */ function __construct($x, $y, $w, $h, $title, array $items, $selected = 0) { $this->_x = $x; $this->_y = $y; $this->_w = $w; $this->_h = $h; $this->_title = $title; $this->_items = $items; $this->_itemsidx = array_values($items); $this->_selected = $selected; $this->_scroll = 0; // TODO: Calculate from height and selected $this->_wh = ncurses_newwin($this->_h, $this->_w, $this->_y, $this->_x); ncurses_werase($this->_wh); Console::debug("Created window with handle %xd", $this->_wh); }
/** * {@inheritdoc} */ public function refresh() { if (null === $this->pad) { $this->createPad(); } ncurses_werase($this->pad); ncurses_wmove($this->pad, 0, 0); $this->renderStackTrace($this->stackTrace); ncurses_prefresh($this->pad, $this->decY, $this->decX, $this->padPositionY, $this->padPositionX, $this->padHeight + $this->padPositionY - 1, $this->padWidth - 1); }
/** * Clears the window */ public function clear() { $this->isDirty = true; ncurses_werase($this->window); return $this; }
/** * Erases a window * @return Window This object */ public function erase() { ncurses_werase($this->windowResource); return $this; }
/** * Refresh the footer window */ protected function refreshFooter() { $length = 1; $labels = array("F1" => "Help", "F2" => "Var dump", "F3" => "Stack trace", "Q" => "Quit"); if (null === $this->rendererStackTrace) { unset($labels["F3"]); } ncurses_werase($this->windowFooter); // write an empty space ncurses_wattron($this->windowFooter, NCURSES_A_REVERSE); ncurses_wcolor_set($this->windowFooter, NCURSES_COLOR_CYAN); ncurses_waddstr($this->windowFooter, " "); ncurses_wattroff($this->windowFooter, NCURSES_A_REVERSE); // write key/labels foreach ($labels as $key => $label) { ncurses_wcolor_set($this->windowFooter, 0); ncurses_waddstr($this->windowFooter, $key); ncurses_wattron($this->windowFooter, NCURSES_A_REVERSE); ncurses_wcolor_set($this->windowFooter, NCURSES_COLOR_CYAN); ncurses_waddstr($this->windowFooter, "{$label} "); ncurses_wattroff($this->windowFooter, NCURSES_A_REVERSE); $length += strlen($key); $length += strlen($label); $length += 1; } // fill the line $fillStr = str_repeat(" ", $this->windowFooterWidth - $length); ncurses_wattron($this->windowFooter, NCURSES_A_REVERSE); ncurses_wcolor_set($this->windowFooter, NCURSES_COLOR_CYAN); ncurses_waddstr($this->windowFooter, $fillStr); ncurses_wattroff($this->windowFooter, NCURSES_A_REVERSE); ncurses_wrefresh($this->windowFooter); }
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']); }
/** * Refresh search pad content */ protected function refreshSearchPad() { if (!$this->showSearchPad) { return; } $backgroundColor = $this->editSearchPad ? NCURSES_COLOR_YELLOW : NCURSES_COLOR_MAGENTA; $length = 1; if ($this->editSearchPad) { // edit mode $labels = array("ESC" => "Cancel", "ENTER" => "Done"); } else { // not in edit mode $labels = array("F9" => "Edit"); } ncurses_werase($this->padSearch); // write an empty space ncurses_wattron($this->padSearch, NCURSES_A_REVERSE); ncurses_wcolor_set($this->padSearch, $backgroundColor); ncurses_waddstr($this->padSearch, " "); ncurses_wattroff($this->padSearch, NCURSES_A_REVERSE); // write key/labels foreach ($labels as $key => $label) { ncurses_wcolor_set($this->padSearch, 0); ncurses_waddstr($this->padSearch, $key); ncurses_wattron($this->padSearch, NCURSES_A_REVERSE); ncurses_wcolor_set($this->padSearch, $backgroundColor); ncurses_waddstr($this->padSearch, "{$label} "); ncurses_wattroff($this->padSearch, NCURSES_A_REVERSE); $length += strlen($key); $length += strlen($label); $length += 1; } // search box $length += 2; ncurses_wcolor_set($this->padSearch, 0); ncurses_waddstr($this->padSearch, " "); ncurses_wattron($this->padSearch, NCURSES_A_REVERSE); ncurses_wcolor_set($this->padSearch, $backgroundColor); if (!$this->editSearchPad) { // show found occurences $text = " [{$this->searchFoundOccurences} found]"; $length += strlen($text); ncurses_waddstr($this->padSearch, $text); } ncurses_waddstr($this->padSearch, str_pad(" Search: {$this->searchText}", $this->padWidth - $length, " ", STR_PAD_RIGHT)); ncurses_wattroff($this->padSearch, NCURSES_A_REVERSE); // display pad ncurses_prefresh($this->padSearch, 0, 0, $this->padHeight + $this->padPositionY - 1, $this->padPositionX, $this->padHeight + $this->padPositionY - 1, $this->padWidth - 1); }