aboutsummaryrefslogtreecommitdiff
path: root/src/Keys.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Keys.cc')
-rw-r--r--src/Keys.cc21
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
197int Keys::t_key::newindex(lua::state *l) 198int 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
296int 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
294void Keys::t_key::initKeys(FbTk::Lua &l) { 311void 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);