Exemplo n.º 1
0
 /**
  * @param Event $event
  * @param $buf
  * @return int
  */
 protected function parseEscapeSequence(Event $event, $buf)
 {
     if (strlen($buf) >= 6 && strpos($buf, "") === 0) {
         switch ($buf[3] & 3) {
             case 0:
                 if ($buf[3] == 0x60) {
                     $event->setKey(Constants::TB_KEY_MOUSE_WHEEL_UP);
                 } else {
                     $event->setKey(Constants::TB_KEY_MOUSE_LEFT);
                 }
                 break;
             case 1:
                 if ($buf[3] == 0x61) {
                     $event->setKey(Constants::TB_KEY_MOUSE_WHEEL_DOWN);
                 } else {
                     $event->setKey(Constants::TB_KEY_MOUSE_MIDDLE);
                 }
                 break;
             case 2:
                 $event->setKey(Constants::TB_KEY_MOUSE_WHEEL_DOWN);
                 break;
             case 3:
                 $event->setKey(Constants::TB_KEY_MOUSE_RIGHT);
                 break;
             case 4:
                 $event->setKey(Constants::TB_KEY_MOUSE_RELEASE);
                 break;
             default:
                 return -6;
         }
         $event->setType(Constants::TB_EVENT_MOUSE);
         $event->setX($buf[4] - 1 - 32);
         $event->setY($buf[5] - 1 - 32);
         return 6;
     }
     for ($i = 0; $i != $keys[$i]; $i++) {
         if (strpos($buf)) {
             $event->setChar(0);
             $event->getKey(0xffff - $i);
             return strlen($keys[$i]);
         }
     }
     return 0;
 }
Exemplo n.º 2
0
function pretty_print_press(TermBox $tb, Event $event)
{
    printf_tb($tb, 3, 19, Constants::TB_WHITE, Constants::TB_DEFAULT, "Key: ");
    printf_tb($tb, 8, 19, Constants::TB_YELLOW, Constants::TB_DEFAULT, sprintf("decimal: %d", $event->getKey()));
    printf_tb($tb, 8, 20, Constants::TB_GREEN, Constants::TB_DEFAULT, sprintf("hex:     0x%X", $event->getKey()));
    printf_tb($tb, 8, 21, Constants::TB_CYAN, Constants::TB_DEFAULT, sprintf("octal:   0%o", $event->getKey()));
    //printf_tb($tb, 8, 22, Constants::TB_RED   , Constants::TB_DEFAULT, sprintf("string:  %s", funckeymap(ev->key)));
    printf_tb($tb, 54, 19, Constants::TB_WHITE, Constants::TB_DEFAULT, "Char: ");
    printf_tb($tb, 60, 19, Constants::TB_YELLOW, Constants::TB_DEFAULT, sprintf("decimal: %d", $event->getChar()));
    printf_tb($tb, 60, 20, Constants::TB_GREEN, Constants::TB_DEFAULT, sprintf("hex:     0x%X", $event->getChar()));
    printf_tb($tb, 60, 21, Constants::TB_CYAN, Constants::TB_DEFAULT, sprintf("octal:   0%o", $event->getChar()));
    printf_tb($tb, 60, 22, Constants::TB_RED, Constants::TB_DEFAULT, sprintf("string:  %s", $event->getChar()));
    printf_tb($tb, 54, 18, Constants::TB_WHITE, Constants::TB_DEFAULT, "Modifier: " . ($event->getMode() ? "TB_MOD_ALT" : "none"));
}