-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetting.h
192 lines (159 loc) · 6.34 KB
/
setting.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// setting.h
#ifndef _SETTING_H
# define _SETTING_H
# include "keymap.h"
# include "parser.h"
# include "multithread.h"
# include <set>
/// this class contains all of loaded settings
class Setting
{
public:
typedef std::set<tstringi> Symbols; ///
typedef std::list<Modifier> Modifiers; ///
public:
Keyboard m_keyboard; ///
Keymaps m_keymaps; ///
KeySeqs m_keySeqs; ///
Symbols m_symbols; ///
bool m_correctKanaLockHandling; ///
bool m_sts4mayu; ///
bool m_cts4mayu; ///
bool m_mouseEvent; ///
LONG m_dragThreshold; ///
unsigned int m_oneShotRepeatableDelay; ///
public:
Setting()
: m_correctKanaLockHandling(false),
m_sts4mayu(false),
m_cts4mayu(false),
m_mouseEvent(false),
m_dragThreshold(0),
m_oneShotRepeatableDelay(0) { }
};
///
namespace Event
{
///
extern Key prefixed;
///
extern Key before_key_down;
///
extern Key after_key_up;
///
extern Key *events[];
}
///
class SettingLoader
{
# define FUNCTION_FRIEND
# include "functions.h"
# undef FUNCTION_FRIEND
public:
///
class FunctionCreator
{
public:
const _TCHAR *m_name; ///
FunctionData *m_creator; ///
};
private:
typedef std::vector<Token> Tokens; ///
typedef std::vector<tstringi> Prefixes; ///
typedef std::vector<bool> CanReadStack; ///
private:
Setting *m_setting; /// loaded setting
bool m_isThereAnyError; /// is there any error ?
SyncObject *m_soLog; /// guard log output stream
tostream *m_log; /// log output stream
tstringi m_currentFilename; /// current filename
Tokens m_tokens; /// tokens for current line
Tokens::iterator m_ti; /// current processing token
static Prefixes *m_prefixes; /// prefix terminal symbol
static size_t m_prefixesRefCcount; /// reference count of prefix
Keymap *m_currentKeymap; /// current keymap
CanReadStack m_canReadStack; /// for <COND_SYMBOL>
Modifier m_defaultAssignModifier; /** default
<ASSIGN_MODIFIER> */
Modifier m_defaultKeySeqModifier; /** default
<KEYSEQ_MODIFIER> */
private:
bool isEOL(); /// is there no more tokens ?
Token *getToken(); /// get next token
Token *lookToken(); /// look next token
bool getOpenParen(bool i_doesThrow, const _TCHAR *i_name); /// argument "("
bool getCloseParen(bool i_doesThrow, const _TCHAR *i_name); /// argument ")"
bool getComma(bool i_doesThrow, const _TCHAR *i_name); /// argument ","
void load_LINE(); /// <LINE>
void load_DEFINE(); /// <DEFINE>
void load_IF(); /// <IF>
void load_ELSE(bool i_isElseIf, const tstringi &i_token);
/// <ELSE> <ELSEIF>
bool load_ENDIF(const tstringi &i_token); /// <ENDIF>
void load_INCLUDE(); /// <INCLUDE>
void load_SCAN_CODES(Key *o_key); /// <SCAN_CODES>
void load_DEFINE_KEY(); /// <DEFINE_KEY>
void load_DEFINE_MODIFIER(); /// <DEFINE_MODIFIER>
void load_DEFINE_SYNC_KEY(); /// <DEFINE_SYNC_KEY>
void load_DEFINE_ALIAS(); /// <DEFINE_ALIAS>
void load_DEFINE_SUBSTITUTE(); /// <DEFINE_SUBSTITUTE>
void load_DEFINE_OPTION(); /// <DEFINE_OPTION>
void load_KEYBOARD_DEFINITION(); /// <KEYBOARD_DEFINITION>
Modifier load_MODIFIER(Modifier::Type i_mode, Modifier i_modifier,
Modifier::Type *o_mode = NULL);
/// <..._MODIFIER>
Key *load_KEY_NAME(); /// <KEY_NAME>
void load_KEYMAP_DEFINITION(const Token *i_which);
/// <KEYMAP_DEFINITION>
void load_ARGUMENT(bool *o_arg); /// <ARGUMENT>
void load_ARGUMENT(int *o_arg); /// <ARGUMENT>
void load_ARGUMENT(unsigned int *o_arg); /// <ARGUMENT>
void load_ARGUMENT(long *o_arg); /// <ARGUMENT>
void load_ARGUMENT(unsigned __int64 *o_arg); /// <ARGUMENT>
void load_ARGUMENT(__int64 *o_arg); /// <ARGUMENT>
void load_ARGUMENT(tstringq *o_arg); /// <ARGUMENT>
void load_ARGUMENT(std::list<tstringq> *o_arg); /// <ARGUMENT>
void load_ARGUMENT(tregex *o_arg); /// <ARGUMENT>
void load_ARGUMENT(VKey *o_arg); /// <ARGUMENT_VK>
void load_ARGUMENT(ToWindowType *o_arg); /// <ARGUMENT_WINDOW>
void load_ARGUMENT(GravityType *o_arg); /// <ARGUMENT>
void load_ARGUMENT(MouseHookType *o_arg); /// <ARGUMENT>
void load_ARGUMENT(MayuDialogType *o_arg); /// <ARGUMENT>
void load_ARGUMENT(ModifierLockType *o_arg); /// <ARGUMENT_LOCK>
void load_ARGUMENT(ToggleType *o_arg); /// <ARGUMENT>
void load_ARGUMENT(ShowCommandType *o_arg); ///<ARGUMENT_SHOW_WINDOW>
void load_ARGUMENT(TargetWindowType *o_arg);
/// <ARGUMENT_TARGET_WINDOW_TYPE>
void load_ARGUMENT(BooleanType *o_arg); /// <bool>
void load_ARGUMENT(LogicalOperatorType *o_arg);/// <ARGUMENT>
void load_ARGUMENT(Modifier *o_arg); /// <ARGUMENT>
void load_ARGUMENT(const Keymap **o_arg); /// <ARGUMENT>
void load_ARGUMENT(const KeySeq **o_arg); /// <ARGUMENT>
void load_ARGUMENT(StrExprArg *o_arg); /// <ARGUMENT>
void load_ARGUMENT(WindowMonitorFromType *o_arg); /// <ARGUMENT>
KeySeq *load_KEY_SEQUENCE(
const tstringi &i_name = _T(""), bool i_isInParen = false,
Modifier::Type i_mode = Modifier::Type_KEYSEQ); /// <KEY_SEQUENCE>
void load_KEY_ASSIGN(); /// <KEY_ASSIGN>
void load_EVENT_ASSIGN(); /// <EVENT_ASSIGN>
void load_MODIFIER_ASSIGNMENT(); /// <MODIFIER_ASSIGN>
void load_LOCK_ASSIGNMENT(); /// <LOCK_ASSIGN>
void load_KEYSEQ_DEFINITION(); /// <KEYSEQ_DEFINITION>
/// load
void load(const tstringi &i_filename);
/// is the filename readable ?
bool isReadable(const tstringi &i_filename, int i_debugLevel = 1) const;
/// get filename
bool getFilename(const tstringi &i_name,
tstringi *o_path, int i_debugLevel = 1) const;
public:
///
SettingLoader(SyncObject *i_soLog, tostream *i_log);
/// load setting
bool load(Setting *o_setting, const tstringi &i_filename = _T(""));
};
/// get home directory path
typedef std::list<tstringi> HomeDirectories;
extern void getHomeDirectories(HomeDirectories *o_path);
#endif // !_SETTING_H