aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-08-09 08:05:23 (GMT)
committerPaul Tagliamonte <paultag@fluxbox.org>2012-04-07 02:13:13 (GMT)
commitbc41a7240a53f0c5e0a1a5715ab703689280a0e2 (patch)
tree9e33727d1ba81757dd852f80e281f5538cb2ed32
parent588afe41b08df6aa5e8f2f2d92431ad600ecc7db (diff)
downloadfluxbox_paul-bc41a7240a53f0c5e0a1a5715ab703689280a0e2.zip
fluxbox_paul-bc41a7240a53f0c5e0a1a5715ab703689280a0e2.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 2fb11f9..db60649 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);