コード例 #1
0
ファイル: Window.php プロジェクト: Precom/HoaConsole
 /**
  * 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.
  *
  * @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 = Console::getTput();
     $count = ['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;
 }
コード例 #2
0
ファイル: Mouse.php プロジェクト: Precom/HoaConsole
    {
        if (false === static::$_enabled) {
            return;
        }
        echo "[?1003l";
        echo "[?1000l";
        static::$_enabled = false;
        return;
    }
    /**
     * Attach a callable to a listenable component.
     *
     * @param   string  $listenerId    Listener ID.
     * @param   mixed   $callable      Callable.
     * @return  \Hoa\Core\Event\Listenable
     * @throws  \Hoa\Core\Exception
     */
    public function on($listenerId, $callable)
    {
        $this->_on->attach($listenerId, $callable);
        return $this;
    }
}
/**
 * Advanced interaction.
 */
Console::advancedInteraction();
/**
 * Untrack mouse.
 */
Core::registerShutdownFunction('\\Hoa\\Console\\Mouse', 'untrack');
コード例 #3
0
ファイル: Window.php プロジェクト: vcgato29/Console
 /**
  * Set clipboard value.
  *
  * @param   string  $data    Data to copy.
  * @return  void
  */
 public static function copy($data)
 {
     if (OS_WIN) {
         return;
     }
     $out = "]52;;" . base64_encode($data) . "\\";
     if (true === Console::isTmuxRunning()) {
         echo "Ptmux;" . str_replace("", "", $out) . "\\";
         return;
     }
     echo $out;
     return;
 }