function __construct(callable $eventCallback) { ncurses_mousemask(NCURSES_ALL_MOUSE_EVENTS, $oldMask); if (!is_callable($eventCallback)) { throw new \Exception("Mouse handler cannot be constructed without a valid callback"); } $this->callback = $eventCallback; }
public function __construct() { self::$instance = $this; ncurses_init(); // Get access to the mouose events $newmask = NCURSES_ALL_MOUSE_EVENTS; $oldmask = null; $mask = ncurses_mousemask($newmask, $oldmask); // Create a new desktop $this->desktop = new NcursesDesktop(); // Hide cursor ncurses_curs_set(0); }
function __construct() { if (!self::$cwt) { self::$cwt = $this; } $this->buffer = new \Data\FifoQueue(50); if (!function_exists('\\ncurses_init')) { die("This application requires ncurses to work."); } \ncurses_init(); if (ncurses_has_colors()) { $this->initColors(); } ncurses_curs_set(0); ncurses_noecho(); ncurses_mousemask(NCURSES_ALL_MOUSE_EVENTS); $oldmask = null; $newmask = NCURSES_BUTTON1_CLICKED | NCURSES_BUTTON1_RELEASED | NCURSES_BUTTON1_PRESSED | NCURSES_BUTTON2_CLICKED | NCURSES_BUTTON2_RELEASED | NCURSES_BUTTON1_PRESSED | NCURSES_BUTTON3_CLICKED | NCURSES_BUTTON3_RELEASED | NCURSES_BUTTON1_PRESSED | NCURSES_BUTTON4_CLICKED | NCURSES_BUTTON4_RELEASED | NCURSES_BUTTON1_PRESSED; $mask = ncurses_mousemask($newmask, $oldmask); $this->fpin = fopen("php://stdin", "r"); //open direct input stream for reading stream_set_blocking($this->fpin, 0); //set non-blocking mode }