예제 #1
0
파일: Termcap.php 프로젝트: alexpw/Console
 /**
  * The entry method.
  *
  * @access  public
  * @return  int
  */
 public function main()
 {
     $tput = \Hoa\Console::getTput();
     while (false !== ($c = $this->getOption($v))) {
         switch ($c) {
             case 't':
                 echo $tput->getTerm();
                 return;
             case 'f':
                 echo $tput->getTerminfo();
                 return;
             case 'H':
                 echo $tput->has($v) ? 1 : 0;
                 return;
             case 'c':
                 echo $tput->count($v);
                 return;
             case 'g':
                 echo $tput->get($v);
                 return;
             case 'b':
                 $informations = $tput->getInformations();
                 static::format($informations['booleans']);
                 return;
             case 'n':
                 $informations = $tput->getInformations();
                 static::format($informations['numbers']);
                 return;
             case 's':
                 $informations = $tput->getInformations();
                 static::format($informations['strings']);
                 return;
             case '__ambiguous':
                 $this->resolveOptionAmbiguity($v);
                 break;
             case 'h':
             case '?':
             default:
                 return $this->usage();
                 break;
         }
     }
     return $this->usage();
 }
예제 #2
0
파일: Window.php 프로젝트: alexpw/Console
 /**
  * Scroll whole page.
  * Directions can be:
  *     • u, up,    ↑ : scroll whole page up;
  *     • d, down,  ↓ : scroll whole page down.
  * Directions can be concatenated by a single space.
  *
  * @access  public
  * @param   string  $directions    Directions.
  * @param   int     $repeat        How many times do we scroll?
  * @reutrn  void
  */
 public static function scroll($directions, $repeat = 1)
 {
     if (OS_WIN) {
         return;
     }
     if (1 > $repeat) {
         return;
     } elseif (1 === $repeat) {
         $handle = explode(' ', $directions);
     } else {
         $handle = explode(' ', $directions, 1);
     }
     $tput = \Hoa\Console::getTput();
     $count = array('up' => 0, 'down' => 0);
     foreach ($handle as $direction) {
         switch ($direction) {
             case 'u':
             case 'up':
             case '↑':
                 ++$count['up'];
                 break;
             case 'd':
             case 'down':
             case '↓':
                 ++$count['down'];
                 break;
         }
     }
     if (0 < $count['up']) {
         echo str_replace('%p1%d', $count['up'] * $repeat, $tput->get('parm_index'));
     }
     if (0 < $count['down']) {
         echo str_replace('%p1%d', $count['down'] * $repeat, $tput->get('parm_rindex'));
     }
     return;
 }
예제 #3
0
파일: Cursor.php 프로젝트: alexpw/Console
 /**
  * Make a stupid “bip”.
  *
  * @access  public
  * @return  void
  */
 public static function bip()
 {
     echo \Hoa\Console::getTput()->get('bell');
     return;
 }