/** * Application class constructor * * @param int $bufferMode The desired ncurses buffer mode */ public function __construct($bufferMode = null) { // Buffer mode muse be an integer if (isset($bufferMode) && !is_int($bufferMode)) { throw new Exception("Buffer mode must be an integer"); } // Initialize ncurses & save terminal state ncurses_init(); ncurses_savetty(); // Initialize buffer mode switch ($bufferMode) { case self::BUFFER_CBREAK: ncurses_cbreak(); break; default: if (isset($bufferMode) && $bufferMode !== self::BUFFER_RAW) { throw new Exception("Invalid buffer mode"); } ncurses_raw(); } // Do not echo characters ncurses_noecho(); // Create an instance of the terminal $this->terminal = new Terminal(); // Initialize colors for capable terminals if ($this->terminal->hasColor()) { ncurses_start_color(); } // Create the events manager $this->eventsMananager = new EventsManager(); // Create the states manager $this->statesManager = new StatesManager(); // The application has been initialized $this->initialized = true; }
public function __construct() { ncurses_init(); ncurses_savetty(); }