diff options
Diffstat (limited to 'src/Keys.cc')
-rw-r--r-- | src/Keys.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Keys.cc b/src/Keys.cc index 0a3d856..14a5d0f 100644 --- a/src/Keys.cc +++ b/src/Keys.cc | |||
@@ -149,6 +149,7 @@ public: | |||
149 | static int newKeyMode(lua::state *l); | 149 | static int newKeyMode(lua::state *l); |
150 | static int index(lua::state *l); | 150 | static int index(lua::state *l); |
151 | static int newindex(lua::state *l); | 151 | static int newindex(lua::state *l); |
152 | static int clear(lua::state *l); | ||
152 | 153 | ||
153 | bool equalExact(const RefKey &x) { | 154 | bool equalExact(const RefKey &x) { |
154 | return type == x->type && key == x->key && context == x->context | 155 | return type == x->type && key == x->key && context == x->context |
@@ -194,8 +195,7 @@ public: | |||
194 | static FbTk::Lua::RegisterInitFunction registerInitKeys; | 195 | static FbTk::Lua::RegisterInitFunction registerInitKeys; |
195 | }; | 196 | }; |
196 | 197 | ||
197 | int Keys::t_key::newindex(lua::state *l) | 198 | int Keys::t_key::newindex(lua::state *l) { |
198 | { | ||
199 | l->checkstack(2); | 199 | l->checkstack(2); |
200 | 200 | ||
201 | try { | 201 | try { |
@@ -267,6 +267,8 @@ int Keys::t_key::index(lua::state *l) { | |||
267 | 267 | ||
268 | if(str == "activate") | 268 | if(str == "activate") |
269 | l->pushfunction(&setKeyModeWrapper); | 269 | l->pushfunction(&setKeyModeWrapper); |
270 | else if(str == "clear") | ||
271 | l->pushfunction(&clear); | ||
270 | else { | 272 | else { |
271 | vector<string> val; | 273 | vector<string> val; |
272 | FbTk::StringUtil::stringtok(val, str.c_str()); | 274 | FbTk::StringUtil::stringtok(val, str.c_str()); |
@@ -291,6 +293,21 @@ int Keys::t_key::index(lua::state *l) { | |||
291 | return 1; | 293 | return 1; |
292 | } | 294 | } |
293 | 295 | ||
296 | int Keys::t_key::clear(lua::state *l) { | ||
297 | try { | ||
298 | l->checkargno(1); | ||
299 | const RefKey &k = *l->checkudata<RefKey>(1, keymode_metatable); | ||
300 | |||
301 | k->keylist.clear(); | ||
302 | k->m_command.reset(); | ||
303 | } | ||
304 | catch(std::runtime_error &e) { | ||
305 | cerr << "clear: " << e.what() << endl; | ||
306 | } | ||
307 | return 0; | ||
308 | |||
309 | } | ||
310 | |||
294 | void Keys::t_key::initKeys(FbTk::Lua &l) { | 311 | void Keys::t_key::initKeys(FbTk::Lua &l) { |
295 | l.checkstack(3); | 312 | l.checkstack(3); |
296 | lua::stack_sentry s(l); | 313 | lua::stack_sentry s(l); |