You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.6 KiB

8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /* XTerm keyboard handler routines header.
  2. Copyright by Salvador E. Tropea (SET) (2002)
  3. Covered by the GPL license. */
  4. #if defined(TVOS_UNIX) && !defined(TVOSf_QNXRtP) && !defined(XTERMKEY_HEADER_INCLUDED)
  5. #define XTERMKEY_HEADER_INCLUDED
  6. struct TEvent;
  7. struct node;
  8. const int MaxLenEscapeSequence=16;
  9. // A class to encapsulate the globals, all is static!
  10. class TGKeyXTerm : public TGKey
  11. {
  12. public:
  13. TGKeyXTerm() {};
  14. // Function replacements
  15. static void Suspend();
  16. static void Resume();
  17. static int KbHit();
  18. static void Clear();
  19. static ushort GKey();
  20. static unsigned GetShiftState();
  21. static void FillTEvent(TEvent &e);
  22. // Setup the pointers to point our members
  23. static void Init();
  24. friend class TScreenXTerm;
  25. friend class TDisplayXTerm;
  26. protected:
  27. // Specific for this driver
  28. static int InitOnce();
  29. // Low level code to get a key and process it
  30. static int GetRaw();
  31. // A low level helper
  32. static int GetKeyParsed();
  33. // Get a key from the buffer
  34. static int GetKeyFromBuffer();
  35. // Escape sequences parser
  36. static int ProcessEscape();
  37. // Escape sequences tree creation helpers
  38. static node *NewNode();
  39. static node *NewNode(node *p);
  40. static node *SearchInList(node *p, uchar k);
  41. static node *AddKey2List(node *p, uchar k, node **pa);
  42. static void AddKey(const uchar *key, uchar code, uchar modifiers);
  43. // This fills the tree with known combinations
  44. static void PopulateTree();
  45. // File handle for the input
  46. static int hIn;
  47. // Stream for the hIn
  48. static FILE *fIn;
  49. // Old mode of the input file handle
  50. static int oldInFlags;
  51. // New mode of the input file handle
  52. static int newInFlags;
  53. // Termios data of the console before starting
  54. static struct termios inTermiosOrig;
  55. // Our termios settings
  56. static struct termios inTermiosNew;
  57. // Description of the last error
  58. static const char *error;
  59. // Buffer to store a key escape sequence while we analize it.
  60. // If a sequence failed the keys must be returned from here.
  61. static int bufferKeys[MaxLenEscapeSequence];
  62. // How many keys we have in the buffer
  63. static int keysInBuffer;
  64. // The next key to return. It avoids using things like ungetc
  65. static int nextKey;
  66. // Last key code we decoded
  67. static int lastKeyCode;
  68. // Last set of modifiers
  69. static int lastModifiers;
  70. // Modifiers in the TV format
  71. static int translatedModifiers;
  72. // ASCII of the key
  73. static char ascii;
  74. // Keyboard translation tables
  75. static unsigned char kbToName[128];
  76. static unsigned char kbExtraFlags[128];
  77. // Keys tree
  78. static node *Keys;
  79. // Mouse is reported as a escape sequence and hence handled here
  80. static int MouseButtons;
  81. };
  82. #endif // XTERMKEY_HEADER_INCLUDED