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(); }); }
function initColors() { ncurses_start_color(); ncurses_init_pair(1, NCURSES_COLOR_BLACK, NCURSES_COLOR_CYAN); ncurses_init_pair(2, NCURSES_COLOR_BLUE, NCURSES_COLOR_CYAN); ncurses_init_pair(3, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLUE); ncurses_init_pair(4, NCURSES_COLOR_WHITE, NCURSES_COLOR_YELLOW); }
public function __construct($rows, $cols, $y, $x) { parent::__construct($rows, $cols, $y, $x); $mappingColor = $this->getMappingColor(); if (ncurses_has_colors()) { ncurses_start_color(); ncurses_init_pair($mappingColor[MapBuilder::HERBE], NCURSES_COLOR_GREEN, NCURSES_COLOR_GREEN); ncurses_init_pair($mappingColor[MapBuilder::ARBRE], NCURSES_COLOR_BLACK, NCURSES_COLOR_GREEN); ncurses_init_pair($mappingColor[MapBuilder::EAU], NCURSES_COLOR_WHITE, NCURSES_COLOR_CYAN); ncurses_init_pair($mappingColor["P"], NCURSES_COLOR_WHITE, NCURSES_COLOR_BLACK); ncurses_init_pair($mappingColor[MapBuilder::FLEUR], NCURSES_COLOR_RED, NCURSES_COLOR_GREEN); } }
/** * */ function __construct() { ncurses_init(); if (ncurses_has_colors()) { ncurses_start_color(); ncurses_init_pair(NCC_FRAME, NCURSES_COLOR_BLACK, NCURSES_COLOR_BLUE); ncurses_init_pair(NCC_TEXT, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLUE); ncurses_init_pair(NCC_TITLE, NCURSES_COLOR_YELLOW, NCURSES_COLOR_BLUE); ncurses_init_pair(NCC_MORE, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLUE); ncurses_curs_set(0); } $this->workspace = ncurses_newwin(0, 0, 0, 0); }
public function __construct(Linfo $linfo) { $this->linfo = $linfo; // We obviously need this if (!extension_loaded('ncurses')) { $this->loaded = false; throw new FatalException("PHP ncurses extension not loaded.\nRefer to http://php.net/manual/en/ncurses.installation.php for details."); } // Start ncurses ncurses_init(); ncurses_start_color(); ncurses_init_pair(1, NCURSES_COLOR_YELLOW, NCURSES_COLOR_BLUE); ncurses_timeout(0); }
public function init($title = 'AcePHProxy') { // начинаем с инициализации библиотеки $ncurse = ncurses_init(); // используем весь экран $this->windows['main'] = ncurses_newwin(0, 0, 0, 0); // рисуем рамку вокруг окна ncurses_border(0, 0, 0, 0, 0, 0, 0, 0); ncurses_getmaxyx($this->windows['main'], $y, $x); // save current main window size $this->cur_x = $x; $this->cur_y = $y; // создаём второе окно для лога $rows = floor($y / 2); $cols = $x; $sy = $y - $rows; $sx = 0; $this->windows['log'] = ncurses_newwin($rows, $cols, $sy, $sx); // и окно для статистики (остальное пространство) $rows = $y - $rows - 1; $cols = $x; $sy = 1; $sx = 0; // еще -1 чтобы границы не перекрывались $this->windows['stat'] = ncurses_newwin($rows, $cols, $sy, $sx); if (ncurses_has_colors()) { ncurses_start_color(); // colors http://php.net/manual/en/ncurses.colorconsts.php ncurses_init_pair(self::CLR_ERROR, NCURSES_COLOR_RED, NCURSES_COLOR_BLACK); ncurses_init_pair(self::CLR_GREEN, NCURSES_COLOR_GREEN, NCURSES_COLOR_BLACK); ncurses_init_pair(self::CLR_YELLOW, NCURSES_COLOR_YELLOW, NCURSES_COLOR_BLACK); ncurses_init_pair(self::CLR_SPEC1, NCURSES_COLOR_RED, NCURSES_COLOR_WHITE); ncurses_init_pair(5, NCURSES_COLOR_MAGENTA, NCURSES_COLOR_BLACK); ncurses_init_pair(6, NCURSES_COLOR_CYAN, NCURSES_COLOR_BLACK); ncurses_init_pair(self::CLR_DEFAULT, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLACK); $this->log('Init colors', self::CLR_GREEN); } // рамка для него ncurses_wborder($this->windows['log'], 0, 0, 0, 0, 0, 0, 0, 0); ncurses_wborder($this->windows['stat'], 0, 0, 0, 0, 0, 0, 0, 0); $this->outputTitle($title); ncurses_nl(); ncurses_curs_set(0); // visibility ncurses_refresh(); // рисуем окна // обновляем маленькое окно для вывода строки ncurses_wrefresh($this->windows['log']); }
public function __construct() { $this->nc = ncurses_init(); if (!ncurses_has_colors()) { $this->onTerminate(); echo "No color support.\n"; } ncurses_start_color(); $this->screen = ncurses_newwin(0, 0, 0, 0); $this->setCursorVisible(false); assert($this->screen); ncurses_init_pair(Widget\Widget::COLOR_DIALOGBG, NCURSES_COLOR_YELLOW, NCURSES_COLOR_BLUE); ncurses_init_pair(Widget\Widget::COLOR_DIALOGTEXT, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLUE); ncurses_refresh(); }
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']); }
public function InitialiseTerminal() { $this->ncursesess = ncurses_init(); ncurses_noecho(); // turn off echo to screen ncurses_start_color(); // initialise colour //ncurses_cbreak(); // turn off buffering ncurses_curs_set(0); /* * Initialise the colour pairs that we'll use. First param is a define so we don't have to use * magic numbers all through the app. */ ncurses_init_pair(NC_PAIR_IRCOUT, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLACK); ncurses_init_pair(NC_PAIR_INPUT, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLUE); ncurses_init_pair(NC_PAIR_INPUT_ACTIVE, NCURSES_COLOR_RED, NCURSES_COLOR_BLUE); }
/** * Set color * * @param int $pair * @param int $foreground * @param int $background * @return void */ public function setColor($pair, $foreground = 0, $background = 0) { if (ncurses_has_colors()) { ncurses_start_color(); ncurses_init_pair($pair, $foreground, $background); ncurses_wcolor_set($this->getWindow(), $pair); } $this->setChanged(true); return $pair; }
<?php $n = 0; ncurses_init(); if (ncurses_has_colors()) { ncurses_start_color(); ncurses_init_pair(1, NCURSES_COLOR_RED, NCURSES_COLOR_BLACK); ncurses_init_pair(2, NCURSES_COLOR_GREEN, NCURSES_COLOR_BLACK); ncurses_init_pair(3, NCURSES_COLOR_YELLOW, NCURSES_COLOR_BLACK); ncurses_init_pair(4, NCURSES_COLOR_BLUE, NCURSES_COLOR_BLACK); ncurses_init_pair(5, NCURSES_COLOR_MAGENTA, NCURSES_COLOR_BLACK); ncurses_init_pair(6, NCURSES_COLOR_CYAN, NCURSES_COLOR_BLACK); ncurses_init_pair(7, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLACK); } while (1) { for ($x = 0; $x < 80; $x++) { for ($y = 0; $y < 24; $y++) { $n++; ncurses_move($y, $x); ncurses_addch($n + 64); ncurses_color_set($n % 8); ncurses_refresh(); if ($n > 26) { $n = 0; } } } ncurses_getch(); } ?>
/** * 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; }
function _init_screen() { ncurses_curs_set(0); ncurses_noecho(); $fullscreen = ncurses_newwin(0, 0, 0, 0); ncurses_getmaxyx($fullscreen, $this->_screen_max_height, $this->_screen_max_width); ncurses_delwin($fullscreen); ncurses_start_color(); ncurses_init_pair(1, NCURSES_COLOR_WHITE, NCURSES_COLOR_RED); ncurses_init_pair(4, NCURSES_COLOR_BLACK, NCURSES_COLOR_RED); ncurses_init_pair(2, NCURSES_COLOR_BLACK, NCURSES_COLOR_WHITE); ncurses_init_pair(3, NCURSES_COLOR_WHITE, NCURSES_COLOR_WHITE); ncurses_init_pair(5, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLUE); ncurses_init_pair(6, NCURSES_COLOR_YELLOW, NCURSES_COLOR_BLUE); ncurses_init_pair(7, NCURSES_COLOR_YELLOW, NCURSES_COLOR_WHITE); ncurses_color_set(1); ncurses_erase(); ncurses_mvhline(0, 0, 0, $this->_screen_max_width); ncurses_attron(NCURSES_A_BOLD); ncurses_mvaddstr(0, 1, $this->title_page_header); ncurses_attroff(NCURSES_A_BOLD); for ($y = 1; $y < $this->_screen_max_height; $y++) { ncurses_mvhline($y, 0, 32, $this->_screen_max_width); } ncurses_refresh(); }
/** * Renders the dump */ public function render() { // initialize ncurses window ncurses_init(); ncurses_curs_set(0); ncurses_noecho(); ncurses_cbreak(); ncurses_start_color(); ncurses_use_default_colors(); ncurses_init_pair(self::COLOR_RED, NCURSES_COLOR_RED, -1); ncurses_init_pair(self::COLOR_GREEN, NCURSES_COLOR_GREEN, -1); ncurses_init_pair(self::COLOR_YELLOW, NCURSES_COLOR_YELLOW, -1); ncurses_init_pair(self::COLOR_BLUE, NCURSES_COLOR_BLUE, -1); ncurses_init_pair(self::COLOR_MAGENTA, NCURSES_COLOR_MAGENTA, -1); ncurses_init_pair(self::COLOR_CYAN, NCURSES_COLOR_CYAN, -1); ncurses_init_pair(self::COLOR_WHITE, NCURSES_COLOR_WHITE, -1); ncurses_init_pair(self::COLOR_HIGHLIGHTED_DEFAULT, 0, NCURSES_COLOR_WHITE); ncurses_init_pair(self::COLOR_HIGHLIGHTED_RED, NCURSES_COLOR_RED, NCURSES_COLOR_WHITE); ncurses_init_pair(self::COLOR_HIGHLIGHTED_GREEN, NCURSES_COLOR_GREEN, NCURSES_COLOR_WHITE); ncurses_init_pair(self::COLOR_HIGHLIGHTED_YELLOW, NCURSES_COLOR_YELLOW, NCURSES_COLOR_WHITE); ncurses_init_pair(self::COLOR_HIGHLIGHTED_BLUE, NCURSES_COLOR_BLUE, NCURSES_COLOR_WHITE); ncurses_init_pair(self::COLOR_HIGHLIGHTED_MAGENTA, NCURSES_COLOR_MAGENTA, NCURSES_COLOR_WHITE); ncurses_init_pair(self::COLOR_HIGHLIGHTED_CYAN, NCURSES_COLOR_CYAN, NCURSES_COLOR_WHITE); ncurses_init_pair(self::COLOR_HIGHLIGHTED_WHITE, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLACK); // create a dummy pad which will receive user inputs $this->windowDummy = ncurses_newpad(1, 1); ncurses_keypad($this->windowDummy, true); // run interface $continue = true; $this->currentRenderer = $this->rendererVarDump; $this->createTitleWindow(); $this->createFooterWindow(); $this->refreshTitle(); $this->refreshFooter(); while ($continue) { $this->currentRenderer->refresh(); $key = ncurses_wgetch($this->windowDummy); $continue = $this->onKeypress($key); } ncurses_end(); }
protected function initScreen() { ncurses_curs_set(0); ncurses_noecho(); $fullscreen = ncurses_newwin(0, 0, 0, 0); ncurses_getmaxyx($fullscreen, $this->screenMaxHeight, $this->screenMaxWidth); ncurses_delwin($fullscreen); //COLOR SCHEMES ncurses_start_color(); // text color, background color /* COLOR_BLACK 0 COLOR_RED 1 COLOR_GREEN 2 COLOR_YELLOW 3 COLOR_BLUE 4 COLOR_MAGENTA 5 COLOR_CYAN 6 COLOR_WHITE 7 */ ncurses_init_pair(1, NCURSES_COLOR_WHITE, NCURSES_COLOR_RED); ncurses_init_pair(2, NCURSES_COLOR_BLACK, NCURSES_COLOR_WHITE); ncurses_init_pair(3, NCURSES_COLOR_WHITE, NCURSES_COLOR_WHITE); ncurses_init_pair(4, NCURSES_COLOR_BLACK, NCURSES_COLOR_RED); ncurses_init_pair(5, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLUE); ncurses_init_pair(6, NCURSES_COLOR_YELLOW, NCURSES_COLOR_BLUE); ncurses_init_pair(7, NCURSES_COLOR_BLUE, NCURSES_COLOR_WHITE); ncurses_color_set(5); ncurses_erase(); ncurses_mvhline(0, 0, 0, $this->screenMaxWidth); ncurses_attron(NCURSES_A_BOLD); ncurses_mvaddstr(0, 1, $this->titlePageHeader); ncurses_attroff(NCURSES_A_BOLD); for ($y = 1; $y < $this->screenMaxHeight; $y++) { ncurses_mvhline($y, 0, 32, $this->screenMaxWidth); } ncurses_refresh(); }