Exemple #1
0
 public function __construct(EventLoop $loop = null)
 {
     if ($loop === null) {
         $loop = \Kurses\EventLoopFactory::select();
     }
     $this->loop = $loop;
     ncurses_init();
     ncurses_cbreak();
     ncurses_noecho();
     $this->panels = [];
     if (ncurses_has_colors()) {
         ncurses_start_color();
         ncurses_init_pair(1, NCURSES_COLOR_RED, NCURSES_COLOR_BLACK);
     }
     $this->cursor = new Cursor(null, null, false);
     $this->screen = new Screen();
     $onKeyboardEvent = function (KeyboardEvent $keyboardEvent) {
         $this->handleKeyboardEvent($keyboardEvent);
     };
     $onMouseEvent = function (MouseEvent $mouseEvent) {
         $this->handleMouseEvent($mouseEvent);
     };
     $refreshScreen = function () {
         $this->refreshScreen();
     };
     $this->keyboard = new Keyboard($onKeyboardEvent);
     $this->mouse = new Mouse($onMouseEvent);
     $this->loop->every($refreshScreen, 200);
     stream_set_blocking(STDIN, FALSE);
     $this->loop->attachStreamHandler(STDIN, function () {
         $this->handleStdIn();
     });
 }
Exemple #2
0
 public function __construct(EventLoop $loop)
 {
     $this->loop = $loop;
     ncurses_init();
     ncurses_cbreak();
     ncurses_noecho();
     $this->panels = [];
     if (ncurses_has_colors()) {
         ncurses_start_color();
     }
     $this->cursor = new Cursor(null, null, false);
     $this->loop->every([$this, 'refresh'], 200);
     stream_set_blocking(STDIN, FALSE);
     $this->loop->attachStreamHandler(STDIN, [$this, 'handleStdIn']);
 }