Guest User

Untitled

a guest
Apr 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. static meUShort
  2. tgetc(void)
  3. {
  4. meUShort cc ; /* fetched character */
  5.  
  6. /* if we are playing a keyboard macro back, */
  7. if (kbdmode == mePLAY)
  8. {
  9. kbd_rep:
  10. /* if there is some left... */
  11. if(kbdoff < kbdlen)
  12. {
  13. cc = (meUShort) kbdptr[kbdoff++] ;
  14. if(cc == meCHAR_LEADER)
  15. {
  16. cc = kbdptr[kbdoff++] ;
  17. if(cc == meCHAR_TRAIL_SPECIAL)
  18. {
  19. meUByte dd ; /* fetched character */
  20. cc = ((meUShort) kbdptr[kbdoff++]) << 8 ;
  21. if(((dd = kbdptr[kbdoff++]) != meCHAR_LEADER) ||
  22. ((dd = kbdptr[kbdoff++]) != meCHAR_TRAIL_NULL))
  23. cc |= dd ;
  24. }
  25. else if(cc == meCHAR_TRAIL_NULL)
  26. cc = 0 ;
  27. else if(cc == meCHAR_TRAIL_LEADER)
  28. /* special '\?' key (e.g. OSD hot key) - ignore */
  29. goto kbd_rep ;
  30. }
  31. return cc ;
  32. }
  33. /* at the end of last repitition? */
  34. if (--kbdrep > 0)
  35. {
  36. /* reset the macro to the begining for the next rep */
  37. kbdoff = 0 ;
  38. goto kbd_rep ;
  39. }
  40. kbdmode = meSTOP;
  41. #if MEOPT_UNDO
  42. undoContFlag++ ;
  43. #endif
  44. /* force a screen update after all is done */
  45. update(meFALSE);
  46. }
  47.  
  48. if(kbdmode == meRECORD)
  49. {
  50. #if MEOPT_MOUSE
  51. /* get and save a key */
  52. /* ignore mouse keys while recording a macro - get another */
  53. do {
  54. /* fetch a character from the terminal driver */
  55. cc = TTgetc();
  56. } while(((cc & (ME_SPECIAL|0x00ff)) >= (ME_SPECIAL|SKEY_mouse_drop_1)) &&
  57. ((cc & (ME_SPECIAL|0x00ff)) <= (ME_SPECIAL|SKEY_mouse_time_3))) ;
  58. #else
  59. cc = TTgetc();
  60. #endif
  61. /* Each 'key' could take 5 chars to store - if we haven't got room
  62. * stop so we don't overrun the buffer */
  63. if(kbdlen > meBUF_SIZE_MAX - 5)
  64. {
  65. kbdmode = meSTOP;
  66. TTbell();
  67. }
  68. else
  69. {
  70. meUByte dd ;
  71. /* must store 0xaabb as ff,2,aa,bb
  72. * also must store 0x00ff as ff,ff & 0x0000 as 0xff01
  73. * Also 0x??00 stored as ff,2,??,ff,01
  74. */
  75. if(cc > 0xff)
  76. {
  77. kbdptr[kbdlen++] = meCHAR_LEADER ;
  78. kbdptr[kbdlen++] = meCHAR_TRAIL_SPECIAL ;
  79. kbdptr[kbdlen++] = cc >> 8 ;
  80. }
  81. dd = (cc & 0xff) ;
  82. if(dd == meCHAR_LEADER)
  83. {
  84. kbdptr[kbdlen++] = meCHAR_LEADER ;
  85. kbdptr[kbdlen++] = meCHAR_TRAIL_LEADER ;
  86. }
  87. else if(dd == 0x0)
  88. {
  89. kbdptr[kbdlen++] = meCHAR_LEADER ;
  90. kbdptr[kbdlen++] = meCHAR_TRAIL_NULL ;
  91. }
  92. else
  93. kbdptr[kbdlen++] = dd ;
  94. }
  95. }
  96. else
  97. cc = TTgetc();
  98.  
  99. /* and finally give the char back */
  100. return cc ;
  101. }
Add Comment
Please, Sign In to add comment