Beispiel #1
0
 /**
  * Draws the menu on the workspace.
  *
  * @param int $workspace The workspace window handle for curses
  */
 function draw($workspace)
 {
     $wh = $this->_wh;
     ncurses_wcolor_set($wh, NCC_FRAME);
     ncurses_wborder($wh, 0, 0, 0, 0, 0, 0, 0, 0);
     ncurses_wcolor_set($wh, NCC_TITLE);
     ncurses_wattron($wh, NCURSES_A_BOLD);
     $left = floor(($this->_w - 2) / 2 - (strlen($this->_title) + 2) / 2);
     ncurses_mvwaddstr($wh, 0, $left, ' ' . $this->_title . ' ');
     ncurses_wattroff($wh, NCURSES_A_BOLD);
     ncurses_wcolor_set($wh, NCC_TEXT);
     $i = $this->_scroll;
     $sm = count($this->_items) - ($this->_h - 2);
     if ($sm < 0) {
         $sm = 0;
     }
     for ($n = 0; $n < $this->_h - 2; $n++) {
         if ($n + $i < count($this->_items)) {
             $str = " " . $this->_itemsidx[$n + $i];
         } else {
             $str = "";
         }
         $str .= str_repeat(' ', $this->_w - 2 - strlen($str));
         if ($n + $i == $this->_selected) {
             ncurses_wattron($wh, NCURSES_A_REVERSE);
         }
         $str = substr($str, 0, $this->_w - 2);
         ncurses_mvwaddstr($wh, $n + 1, 1, $str);
         ncurses_wattroff($wh, NCURSES_A_REVERSE);
     }
     ncurses_wcolor_set($wh, NCC_MORE);
     if ($i > 0) {
         ncurses_wmove($wh, 1, $this->_w - 1);
         ncurses_waddch($wh, NCURSES_ACS_UARROW | NCURSES_A_BOLD);
     }
     if ($sm - $i > 0) {
         ncurses_wmove($wh, $this->_h - 2, $this->_w - 1);
         ncurses_waddch($wh, NCURSES_ACS_DARROW | NCURSES_A_BOLD);
     }
     ncurses_wrefresh($wh);
     ncurses_wcolor_set($wh, 0);
     ncurses_move(-1, 1);
     ncurses_refresh();
 }
Beispiel #2
0
 function _strokeAllMenuItems(&$win)
 {
     for ($i = 0; $i < $this->menu_total; $i++) {
         if ($this->menu_cursor == $i) {
             ncurses_wcolor_set($win, 5);
         } else {
             ncurses_wcolor_set($win, 2);
         }
         // output Checkbox -- (optional)
         if ($this->mode == "checklist") {
             $sel = $this->menu_list[$i]['selected'] == true ? "û" : " ";
             ncurses_mvwaddstr($win, $this->menu_list[$i]['y'], $this->menu_list[$i]['x'], "[" . $sel . "]");
             ncurses_mvwaddstr($win, $this->menu_list[$i]['y'], $this->menu_list[$i]['x'] + 4, "");
             $desc_offset = 5;
         } else {
             ncurses_mvwaddstr($win, $this->menu_list[$i]['y'], $this->menu_list[$i]['x'], "");
             $desc_offset = 2;
         }
         // output menu item label
         $len = strlen($this->menu_list[$i]['label']);
         for ($n = 0; $n < $len; $n++) {
             $char = substr($this->menu_list[$i]['label'], $n, 1);
             $ord = ord($char);
             if ($char == $this->menu_list[$i]['hot']) {
                 if ($this->menu_cursor == $i) {
                     ncurses_wcolor_set($win, 6);
                 } else {
                     ncurses_wcolor_set($win, 7);
                 }
                 ncurses_wattron($win, NCURSES_A_BOLD);
                 ncurses_waddch($win, $ord);
                 ncurses_wattroff($win, NCURSES_A_BOLD);
             } else {
                 if ($this->menu_cursor == $i) {
                     ncurses_wcolor_set($win, 5);
                 } else {
                     ncurses_wcolor_set($win, 2);
                 }
                 ncurses_waddch($win, $ord);
             }
         }
         // output menu item description
         if ($this->menu_cursor == $i) {
             ncurses_wcolor_set($win, 5);
         } else {
             ncurses_wcolor_set($win, 2);
         }
         ncurses_mvwaddstr($win, $this->menu_list[$i]['y'], $this->menu_list[$i]['x'] + $this->menu_label_width + $desc_offset, $this->menu_list[$i]['desc']);
     }
 }
Beispiel #3
0
 /**
  * Displays all Menu Items (or Checklist) to screen
  * @param $win
  */
 protected function strokeAllMenuItems(&$win)
 {
     for ($i = 0; $i < $this->menuTotal; $i++) {
         if ($this->menuCursor == $i) {
             ncurses_wcolor_set($win, 5);
         } else {
             ncurses_wcolor_set($win, 2);
         }
         // output Checkbox -- (optional)
         if ($this instanceof NcursesChecklist) {
             // for checklist type menus
             $sel = $this->menuList[$i]['selected'] == true ? 'X' : ' ';
             ncurses_mvwaddstr($win, $this->menuList[$i]['y'], $this->menuList[$i]['x'], '[' . $sel . ']');
             ncurses_mvwaddstr($win, $this->menuList[$i]['y'], $this->menuList[$i]['x'] + 4, '');
             $desc_offset = 5;
         } else {
             ncurses_mvwaddstr($win, $this->menuList[$i]['y'], $this->menuList[$i]['x'], '');
             $desc_offset = 2;
         }
         // output menu item label
         $len = strlen($this->menuList[$i]['label']);
         for ($n = 0; $n < $len; $n++) {
             $char = substr($this->menuList[$i]['label'], $n, 1);
             $ord = ord($char);
             if ($char == $this->menuList[$i]['hot']) {
                 // highlight char that is the hotkey
                 //SET HOTKEY COLOR ON SELECTED ITEM
                 if ($this->menuCursor == $i) {
                     ncurses_wcolor_set($win, 5);
                 } else {
                     ncurses_wcolor_set($win, 7);
                 }
                 ncurses_wattron($win, NCURSES_A_BOLD);
                 ncurses_waddch($win, $ord);
                 ncurses_wattroff($win, NCURSES_A_BOLD);
             } else {
                 if ($this->menuCursor == $i) {
                     ncurses_wcolor_set($win, 5);
                 } else {
                     ncurses_wcolor_set($win, 2);
                 }
                 ncurses_waddch($win, $ord);
             }
         }
         // output menu item description
         if ($this->menuCursor == $i) {
             ncurses_wcolor_set($win, 5);
         } else {
             ncurses_wcolor_set($win, 2);
         }
         ncurses_mvwaddstr($win, $this->menuList[$i]['y'], $this->menuList[$i]['x'] + $this->menuLabelWidth + $desc_offset, $this->menuList[$i]['desc']);
     }
 }