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();
/** * Handles the application execution * * @return void */ public function run() { // Fire the before run event if (is_object($this->eventsMananager)) { $this->eventsMananager->fire('app:beforeRun', $this); } // Application is now running $this->isRunning = true; // Application main loop while ($this->isRunning) { if (!is_object($this->statesManager)) { throw new Exception("State manager must be an object"); } // Execute the current state of exit the application if (($currentState = $this->statesManager->getCurrent()) !== null) { if (method_exists($currentState, 'execute')) { $currentState->execute($this); } // Refresh the application after a loop ncurses_refresh(); ncurses_update_panels(); ncurses_doupdate(); } else { $this->quit(); } } // Fire the after run event if (is_object($this->eventsMananager)) { $this->eventsMananager->fire('app:afterRun'); } }
private function refreshScreen() { $this->screen->beforeRefresh(); ncurses_update_panels(); ncurses_doupdate(); }
/** * Refreshes the virtual screen to reflect the relations between panels in the stack * and * Write all prepared refreshes to terminal */ public function updatePanels() { ncurses_update_panels(); ncurses_doupdate(); return $this; }
public function refresh() { foreach ($this->panels as $panel) { $panel->refresh(); } ncurses_update_panels(); ncurses_doupdate(); }