Debian Codegraph @

unikey/mactab.h

raw
1 /*
2 * SPDX-FileCopyrightText: 2000-2005 Pham Kim Long <[email protected]>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7 #ifndef __MACRO_TABLE_H
8 #define __MACRO_TABLE_H
9
10 #include "charset.h"
11 #include "keycons.h"
12
13 #if defined(_WIN32)
14 #if defined(UNIKEYHOOK)
15 #define DllInterface __declspec(dllexport)
16 #else
17 #define DllInterface __declspec(dllimport)
18 #endif
19 #else
20 #define DllInterface // not used
21 #define DllExport
22 #define DllImport
23 #endif
24
25 struct MacroDef {
26 int keyOffset;
27 int textOffset;
28 };
29
30 #if !defined(WIN32)
31 typedef char TCHAR;
32 #endif
33
34 class DllInterface CMacroTable {
35 public:
36 void init();
37 int loadFromFile(const char *fname);
38 int writeToFile(const char *fname);
39 int writeToFp(FILE *f);
40
41 const StdVnChar *lookup(StdVnChar *key);
42 const StdVnChar *getKey(int idx) const;
43 const StdVnChar *getText(int idx) const;
44 int getCount() const { return m_count; }
45 void resetContent();
46 int addItem(const char *item, int charset);
47 int addItem(const void *key, const void *text, int charset);
48
49 protected:
50 bool readHeader(FILE *f, int &version);
51 void writeHeader(FILE *f);
52
53 MacroDef m_table[MAX_MACRO_ITEMS];
54 char m_macroMem[MACRO_MEM_SIZE];
55
56 int m_count;
57 int m_memSize, m_occupied;
58 };
59
60 #endif