aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-08-09 08:05:23 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-11-01 10:04:02 (GMT)
commitfd902cc2c9c6c06a0d6ea30fd00652814af91013 (patch)
treef3c598a68544c298d3c6c3f47953bfd78ae32836
parenta858a60ea60eb5e3f601256b403843761c1ae42a (diff)
downloadfluxbox_pavel-fd902cc2c9c6c06a0d6ea30fd00652814af91013.zip
fluxbox_pavel-fd902cc2c9c6c06a0d6ea30fd00652814af91013.tar.bz2
Add a :clear() method for removing keybindings
-rw-r--r--src/Keys.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Keys.cc b/src/Keys.cc
index 92b8718..4d366e5 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
@@ -196,8 +197,7 @@ public:
196 static FbTk::Lua::RegisterInitFunction registerInitKeys; 197 static FbTk::Lua::RegisterInitFunction registerInitKeys;
197}; 198};
198 199
199int Keys::t_key::newindex(lua::state *l) 200int Keys::t_key::newindex(lua::state *l) {
200{
201 l->checkstack(2); 201 l->checkstack(2);
202 202
203 try { 203 try {
@@ -269,6 +269,8 @@ int Keys::t_key::index(lua::state *l) {
269 269
270 if(str == "activate") 270 if(str == "activate")
271 l->pushfunction(&setKeyModeWrapper); 271 l->pushfunction(&setKeyModeWrapper);
272 else if(str == "clear")
273 l->pushfunction(&clear);
272 else { 274 else {
273 vector<string> val; 275 vector<string> val;
274 FbTk::StringUtil::stringtok(val, str.c_str()); 276 FbTk::StringUtil::stringtok(val, str.c_str());
@@ -293,6 +295,21 @@ int Keys::t_key::index(lua::state *l) {
293 return 1; 295 return 1;
294} 296}
295 297
298int Keys::t_key::clear(lua::state *l) {
299 try {
300 l->checkargno(1);
301 const RefKey &k = *l->checkudata<RefKey>(1, keymode_metatable);
302
303 k->keylist.clear();
304 k->m_command.reset();
305 }
306 catch(std::runtime_error &e) {
307 cerr << "clear: " << e.what() << endl;
308 }
309 return 0;
310
311}
312
296void Keys::t_key::initKeys(FbTk::Lua &l) { 313void Keys::t_key::initKeys(FbTk::Lua &l) {
297 l.checkstack(3); 314 l.checkstack(3);
298 lua::stack_sentry s(l); 315 lua::stack_sentry s(l);