public function draw() { $start = 3; foreach ($this->tabs as $i => $tab) { $attrs = NCURSES_A_UNDERLINE; ncurses_wmove($this->window, 0, $start); // ncurses_wvline($this->window, NCURSES_A_NORMAL, 1); if ($i === $this->active) { $attrs += NCURSES_A_REVERSE; } if ($tab->hasAlert()) { ncurses_wcolor_set($this->window, 0); } if ($attrs) { ncurses_wattron($this->window, $attrs); } $tabName = sprintf("[F%d] %s", $i + 1, $tab->name); ncurses_mvwaddstr($this->window, 0, $start + 1, $tabName); if ($attrs) { ncurses_wattroff($this->window, $attrs); } // ncurses_wvline($this->window, NCURSES_A_NORMAL, 1); $start += strlen($tabName) + 3; if ($i === $this->active) { $tab->draw(); ncurses_top_panel($tab->panel->panel); } } }
for ($i = 0; $i < $n_lines; $i++) { $window_width = max($window_width, strlen($lines[$i])); } $window_width += 4; $x_coords = array(10, 14, 18); $y_coords = array(10, 12, 8); for ($i = 0; $i < 3; $i++) { $windows[$i] = ncurses_newwin(4 + $n_lines, $window_width, $y_coords[$i], $x_coords[$i]); ncurses_wborder($windows[$i], 0, 0, 0, 0, 0, 0, 0, 0); ncurses_wattron($windows[$i], NCURSES_A_REVERSE); ncurses_mvwaddstr($windows[$i], 0, 2, ' window #' . $i . ' '); ncurses_wattroff($windows[$i], NCURSES_A_REVERSE); for ($j = 0; $j < $n_lines; $j++) { ncurses_mvwaddstr($windows[$i], 2 + $j, 2, $lines[$j]); } ncurses_wrefresh($windows[$i]); $panels[$i] = ncurses_new_panel($windows[$i]); } ncurses_update_panels(); ncurses_curs_set(0); ncurses_noecho(); $i = 0; $k = NULL; while (XCURSES_KEY_ESC != $k) { $k = ncurses_getch(); ncurses_top_panel($panels[$i % 3]); ncurses_update_panels(); ncurses_doupdate(); $i++; } ncurses_end();
/** * Puts a panel on the top * @return Panel This object */ public function putOnTop() { ncurses_top_panel($this->panelResource); return $this; }