modified dll/win32/kernel32/kernel32.rbuild
[reactos.git] / reactos / base / applications / network / telnet / src / keytrans.h
1 ///////////////////////////////////////////////////////////////////
2 // //
3 // //
4 // Key translations - I.Ioannou (roryt@hol.gr) //
5 // Athens - Greece December 18, 1996 02:56am //
6 // Reads a .cfg file and keeps the key definitions //
7 // for the WIN32 console telnet //
8 // modified for alternate keymap swiching //
9 // by Andrey V. Smilianets (smile@head.aval.kiev.ua) //
10 // Kiev - Ukraine, December 1997. //
11 ///////////////////////////////////////////////////////////////////
12 // //
13 // class KeyTranslator //
14 // //
15 // Load : loads or replaces the keymap //
16 // TranslateKey : returns a char * to the key def //
17 // AddKeyDef : Changes or adds the key translation //
18 // DeleteKeyDef : Deletes a key def from the list //
19 ///////////////////////////////////////////////////////////////////
20
21 #ifndef __KEYTRANS_H
22 #define __KEYTRANS_H
23
24 #include "tkeydef.h"
25 #include "tkeymap.h"
26
27 #define TOKEN_DELIMITERS " +\t" // The word's delimiters
28
29 // Ioannou 2 June 98: Borland needs them - quick hack
30 #ifdef __BORLANDC__
31 #define bool BOOL
32 #define true TRUE
33 #define false FALSE
34 #endif // __BORLANDC__
35
36 // Maybe not portable, but this is for application cursor mode
37 // (Paul Brannan 5/27/98)
38 // Updated for correct precedence in tncon.cpp (Paul Brannan 12/9/98)
39 #define APP4_KEY 0x8000
40 #define APP3_KEY 0x4000
41 #define APP2_KEY 0x2000
42 #define APP_KEY 0x1000
43
44 /////////////////////////////////////////////////////////////
45 // class KeyTranslator //
46 // Load : loads or replaces the keymap //
47 // TranslateKey : returns a sz to the key def //
48 // AddKeyDef : Changes or adds the key translation //
49 // DeleteKeyDef : Deletes a key def from the list //
50 /////////////////////////////////////////////////////////////
51
52 class KeyTranslator {
53 friend class TMapLoader; // FIX ME!! This isn't the best solution
54 public:
55 KeyTranslator();
56 ~KeyTranslator() { DeleteAllDefs(); }
57
58 int SwitchTo(int); // switch to selected keymap
59 int switchMap(TKeyDef& tk);
60
61 // Returns a pointer to the string that should be printed.
62 // Should return NULL if there is no translation for the key.
63 const char *TranslateKey(WORD wVirtualKeyCode, DWORD dwControlKeyState);
64
65 // Changes or adds the key translation associated with
66 // wVirtualScanCode and dwControlKeyState.
67 // Return 1 on success.
68 int AddKeyDef(WORD wVirtualKeyCode, DWORD dwControlKeyState, char *lpzKeyDef);
69 int AddKeyDef(WORD wVirtualKeyCode, DWORD dwControlKeyState, tn_ops op);
70
71 // Delete a key translation
72 int DeleteKeyDef(WORD wVirtualKeyCode, DWORD dwControlKeyState);
73
74 // Paul Brannan 8/28/98
75 void set_ext_mode(DWORD mode) {ext_mode |= mode;}
76 void unset_ext_mode(DWORD mode) {ext_mode &= ~mode;}
77 void clear_ext_mode() {ext_mode = 0;}
78 DWORD get_ext_mode() {return ext_mode;}
79
80 private:
81 DWORD Fix_ControlKeyState(char *);
82 char* Fix_Tok(char *);
83 DWORD ext_mode; // Paul Brannan 8/28/98
84
85 TArrayAsVector<KeyMap> mapArray;
86 TArrayAsVector<TKeyDef> globals;
87
88 void DeleteAllDefs(void);
89 int AddGlobalDef(WORD wVirtualKeyCode, char*lpzKeyDef);
90 int LookOnGlobal(char* vkey);
91 DWORD GetGlobalCode(int i) {return globals[i].GetCodeKey();}
92
93 int currentKeyMap, mainKeyMap; // AVS
94
95 };
96
97 #endif // __KEYTRANS_H