예제 #1
0
파일: Ncurses.php 프로젝트: swos-/ncurses
 public function __construct()
 {
     $ncurse = ncurses_init();
     $this->fullscreen = ncurses_newwin(0, 0, 0, 0);
     ncurses_noecho();
     ncurses_border(0, 0, 0, 0, 0, 0, 0, 0);
     $this->small = ncurses_newwin(10, 30, 7, 25);
     ncurses_wborder($this->small, 0, 0, 0, 0, 0, 0, 0, 0);
     ncurses_refresh();
     ncurses_attron(NCURSES_A_REVERSE);
     ncurses_mvaddstr(0, 10, "---Sample Title---");
     ncurses_attroff(NCURSES_A_REVERSE);
     ncurses_mvwaddstr($this->small, 5, 5, "Initial screen");
     ncurses_wrefresh($this->small);
 }
예제 #2
0
 public function draw()
 {
     ncurses_color_set(1);
     ncurses_mvaddstr($this->top, $this->left, str_repeat(" ", $this->width));
     $yp = 1;
     foreach ($this->menus as $id => $data) {
         $str = ' ' . str_replace('_', '', $data->label) . ' ';
         $ofs = strpos($data->label, '_');
         ncurses_mvaddstr($this->top, $this->left + $yp, $str);
         if ($ofs !== false) {
             ncurses_attron(NCURSES_A_UNDERLINE);
             $hlchar = substr($data->label, $ofs + 1, 1);
             ncurses_mvaddstr($this->top, $this->left + 1 + $yp + $ofs, $hlchar);
             ncurses_attroff(NCURSES_A_UNDERLINE);
         }
         $yp += strlen($data->label) + 2;
     }
     ncurses_color_set(0);
 }
예제 #3
0
function gui()
{
    // we begin by initializing ncurses
    $ncurse = ncurses_init();
    // let ncurses know we wish to use the whole screen
    $fullscreen = ncurses_newwin(0, 0, 0, 0);
    // draw a border around the whole thing.
    ncurses_border(0, 0, 0, 0, 0, 0, 0, 0);
    ncurses_attron(NCURSES_A_REVERSE);
    ncurses_mvaddstr(0, 1, "AEMB2 SIMULATOR OUTPUT TRANSLATOR");
    ncurses_attroff(NCURSES_A_REVERSE);
    // now lets create a small window
    $small = ncurses_newwin(10, 30, 2, 2);
    // border our small window.
    ncurses_wborder($small, 0, 0, 0, 0, 0, 0, 0, 0);
    ncurses_refresh();
    // paint both windows
    // move into the small window and write a string
    ncurses_mvwaddstr($small, 5, 5, "   Test  String   ");
    // show our handiwork and refresh our small window
    ncurses_wrefresh($small);
    $pressed = ncurses_getch();
    // wait for a user keypress
    ncurses_end();
    // clean up our screen
}
예제 #4
0
 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();
 }
예제 #5
0
// define some key constants.
define("ESCAPE_KEY", 27);
define("ENTER_KEY", 13);
// get our initial data
$tr_return = traceroute("www.zend.com");
$ncurses_session = ncurses_init();
$main = ncurses_newwin(0, 0, 0, 0);
// main window
ncurses_getmaxyx($main, $lines, $columns);
ncurses_border(0, 0, 0, 0, 0, 0, 0, 0);
while (1) {
    // border the main window
    ncurses_attron(NCURSES_A_REVERSE);
    ncurses_mvaddstr(0, 1, "Traceroute example");
    ncurses_attroff(NCURSES_A_REVERSE);
    // create a lower window which is dynamically sized...
    $lower_frame_window = ncurses_newwin(10, $columns - 3, $lines - 11, 1);
    ncurses_wborder($lower_frame_window, 0, 0, 0, 0, 0, 0, 0, 0);
    // border it
    $lower_main_window = ncurses_newwin(8, $columns - 5, $lines - 10, 2);
    $main_list_window = ncurses_newwin($lines - 12, $columns - 3, 1, 1);
    ncurses_wborder($main_list_window, 0, 0, 0, 0, 0, 0, 0, 0);
    // border it
    if ($currently_selected == "") {
        $currently_selected = 0;
    }
    for ($a = 0; $a < count($tr_return); $a++) {
        $out = $tr_return[$a];
        if ($currently_selected == intval($a)) {
            ncurses_wattron($main_list_window, NCURSES_A_REVERSE);
예제 #6
0
 protected function outputTitle($title)
 {
     ncurses_attron(NCURSES_A_REVERSE);
     ncurses_mvaddstr(0, 1, $title);
     ncurses_attroff(NCURSES_A_REVERSE);
     ncurses_refresh();
     // рисуем окна
 }
예제 #7
0
 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();
 }