tmapldr.h
上传用户:tigerk9
上传日期:2020-03-10
资源大小:237k
文件大小:5k
源码类别:

Telnet客户端

开发平台:

Visual C++

  1. ///////////////////////////////////////////////////////////////////
  2. //                                                               //
  3. // File format :                                                 //
  4. //                                                               //
  5. //  Comments with a ; in column 1                                //
  6. //  Empty Lines ignored                                          //
  7. //  The words are separated by a space, a tab, or a plus ("+")   //
  8. //                                                               //
  9. //  First a [GLOBAL] section :                                   //
  10. //   [GLOBAL]                                                    //
  11. //   VK_F1         112                                           //
  12. //   .                                                           //
  13. //   .                                                           //
  14. //   [END_GLOBAL]                                                //
  15. //                                                               //
  16. //   The GLOBAL section defines the names of the keys            //
  17. //   and the virtual key code they have.                         //
  18. //   If you repeat a name you'll overwrite the code.             //
  19. //   You can name the keys anything you like                     //
  20. //   The Virtual key nymber must be in Decimal                   //
  21. //   After the number you can put anything : it is ignored       //
  22. //   Here you must put ALL the keys you'll use in the            //
  23. //   other sections.                                             //
  24. //                                                               //
  25. //  Then the emulations sections :                               //
  26. //                                                               //
  27. //   [SCO_ANSI]                                                  //
  28. //                                                               //
  29. //   VK_F1                    27[M or                          //
  30. //   VK_F1                    ^[[M   or                          //
  31. //   VK_F1 SHIFT              ^[[W  etc                          //
  32. //   .                                                           //
  33. //   .                                                           //
  34. //   [SCO_ANSI_END]                                              //
  35. //                                                               //
  36. //   There are three parts :                                     //
  37. //      a) the key name                                          //
  38. //      b) the shift state                                       //
  39. //         here you put compination of the words :               //
  40. //                                                               //
  41. //                RIGHT_ALT                                      //
  42. //                LEFT_ALT                                       //
  43. //                RIGHT_CTRL                                     //
  44. //                LEFT_CTRL                                      //
  45. //                SHIFT                                          //
  46. //                NUMLOCK                                        //
  47. //                SCROLLLOCK                                     //
  48. //                CAPSLOCK                                       //
  49. //                ENHANCED                                       //
  50. //                APP_KEY                                        //
  51. //      c) the assigned string :                                 //
  52. //         you can use the ^ for esc (^[ = 0x1b)                 //
  53. //                          and a three digit decimal number    //
  54. //                         (27)                                //
  55. //         You can't use the NULL !!!                            //
  56. //         Also (for the moment) you can't use spaces            //
  57. //         in the string : everything after the 3rd word is      //
  58. //           ignored - use unsderscore instead.                  //
  59. //                                                               //
  60. //   for  example :                                              //
  61. //                                                               //
  62. //         VK_F4  SHIFT+LEFT_ALT  274m^[[M = 0x1b 4 m 0x1b [ M //
  63. //         VK_F1  RIGHT_CTRL      This_is_ctrl_f1                //
  64. //                                                               //
  65. // You may have as many sections as you like                     //
  66. // If you repeat any section (even the GLOBAL) you'll overwrite  //
  67. // the common parts.                                             //
  68. //                                                               //
  69. ///////////////////////////////////////////////////////////////////
  70. #ifndef __TLOADMAP_H
  71. #define __TLOADMAP_H
  72. #include "keytrans.h"
  73. #include "tcharmap.h"
  74. // AVS
  75. typedef TArrayAsVector<string> stringArray;
  76. class TMapLoader {
  77. public:
  78. TMapLoader(KeyTranslator &RefKeyTrans, TCharmap &RefCharmap):
  79.   KeyTrans(RefKeyTrans), Charmap(RefCharmap) {}
  80. ~TMapLoader() {}
  81. // If called more than once the new map replaces the old one.
  82. // load with a different KeysetName to change keysets
  83. // Return 0 on error
  84.     int Load(const char * filename, const char * szKeysetName);
  85. void Display();
  86. private:
  87. KeyTranslator &KeyTrans;
  88. TCharmap &Charmap;
  89. int LookForPart(stringArray& sa, const char* partType, const char* partName);
  90. char* ParseKeyDef(const char* buf, WORD& vk_code, DWORD& control);
  91. int LoadGlobal(string& buf);
  92. int LoadKeyMap(string buf);
  93. int LoadCharMap(string buf);
  94. };
  95. #endif