|
@@ -253,136 +253,3 @@ signed int getkey(void) {
|
|
|
}
|
|
|
return c;
|
|
|
}
|
|
|
-
|
|
|
-#ifdef JUNKY_MONKEY
|
|
|
-
|
|
|
-int nogetkey(void) {
|
|
|
- char c;
|
|
|
- if (read(STDIN_FILENO, &c, 1) == 1) {
|
|
|
- std::cout << std::hex << (int)c << ":";
|
|
|
-
|
|
|
- if (c == 0) {
|
|
|
- std::cout << "0x00" CRNL;
|
|
|
- }
|
|
|
- std::cout.flush();
|
|
|
-
|
|
|
- if (c == 0x1b) {
|
|
|
- // Ok, this might be something special...
|
|
|
- char buffer[5] = "";
|
|
|
- int pos = 0;
|
|
|
- while ((pos < sizeof(buffer) - 1) and
|
|
|
- (read(STDIN_FILENO, &buffer[pos], 1) == 1)) {
|
|
|
- std::cout << "~" << std::hex << (int)buffer[pos] << "~";
|
|
|
- std::cout.flush();
|
|
|
-
|
|
|
- pos++;
|
|
|
- buffer[pos] = 0;
|
|
|
- };
|
|
|
-
|
|
|
- if (pos == 0)
|
|
|
- return 0x1b;
|
|
|
-
|
|
|
- // Ok, translate the keys
|
|
|
- if (buffer[0] == '[') {
|
|
|
- switch (buffer[1]) {
|
|
|
- case 'A':
|
|
|
- return XKEY_UP_ARROW;
|
|
|
- case 'B':
|
|
|
- return XKEY_DOWN_ARROW;
|
|
|
- case 'C':
|
|
|
- return XKEY_RIGHT_ARROW;
|
|
|
- case 'D':
|
|
|
- return XKEY_LEFT_ARROW;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- std::cout << CRNL "DEBUG:" CRNL;
|
|
|
- for (int x = 0; x < pos; x++) {
|
|
|
- char z = buffer[x];
|
|
|
- if (iscntrl(z)) {
|
|
|
- std::cout << (int)z << " ";
|
|
|
- } else {
|
|
|
- std::cout << "'" << (char)z << "'"
|
|
|
- << " ";
|
|
|
- };
|
|
|
-
|
|
|
- // std::cout << (int)buffer[x] << ", ";
|
|
|
- };
|
|
|
-
|
|
|
- std::cout << CRNL;
|
|
|
- std::cout.flush();
|
|
|
- return 0x1000;
|
|
|
- };
|
|
|
- return (int)c;
|
|
|
- }
|
|
|
- return -1;
|
|
|
- /*
|
|
|
- if (iscntrl(c)) {
|
|
|
- printf("%d\r\n", c);
|
|
|
- } else {
|
|
|
- printf("%d ('%c')\r\n", c, c);
|
|
|
- }
|
|
|
- */
|
|
|
-}
|
|
|
-
|
|
|
-int main(void) {
|
|
|
- std::cout
|
|
|
- << "\377\375\042\377\373\001"; // "\xff\xfc\x22"; // IAC WONT LINEMODE
|
|
|
- std::cout << "\x1b[2J\x1b[H";
|
|
|
-
|
|
|
- raw();
|
|
|
-
|
|
|
- std::cout << "\u2615"
|
|
|
- << "\x1b[6n";
|
|
|
-
|
|
|
- std::cout << "\x1b[999C\x1b[999B\x1b[6n";
|
|
|
- std::cout.flush();
|
|
|
-
|
|
|
- std::cout << "\x1b[2J\x1b[H";
|
|
|
- std::cout << "isatty = " << isatty(STDIN_FILENO) << CRNL;
|
|
|
-
|
|
|
- // no, I don't get a SIGHUP. Hmm, maybe that's a "terminal" thing,
|
|
|
- // and I'm not in a terminal...
|
|
|
-
|
|
|
- // signal(SIGHUP, done);
|
|
|
-
|
|
|
- // Ok! Great!
|
|
|
- signed int c = 0;
|
|
|
- std::cout << "RAW MODE" CRNL;
|
|
|
- std::cout.flush();
|
|
|
-
|
|
|
- while (c != 'Q') {
|
|
|
- c = getkey();
|
|
|
- if (c >= 0) {
|
|
|
- if (c == 0x1b) {
|
|
|
- // This is ESC, so..
|
|
|
- std::cout << "\x1b[6n";
|
|
|
- std::cout.flush();
|
|
|
- }
|
|
|
- if (c > 256) {
|
|
|
- std::cout << "[" << std::hex << c << "]";
|
|
|
- } else {
|
|
|
- if (iscntrl(c)) {
|
|
|
- std::cout << int(c);
|
|
|
- } else {
|
|
|
- std::cout << int(c) << "('" << (char)c << "')";
|
|
|
- }
|
|
|
- }
|
|
|
- std::cout << " ";
|
|
|
- std::cout.flush();
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
- if (std::cin.eof()) {
|
|
|
- std::cout << "BLARGH" CRNL;
|
|
|
- break;
|
|
|
- }
|
|
|
- */
|
|
|
- };
|
|
|
-
|
|
|
- std::cout << CRNL "DONE" CRNL;
|
|
|
-
|
|
|
- reset();
|
|
|
-}
|
|
|
-
|
|
|
-#endif
|