aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-08-09 08:05:23 (GMT)
committerPavel Labath <pavelo@centrum.sk>2013-02-18 21:04:26 (GMT)
commit70294ee0bbfde62bedc81363d8895719404a27ca (patch)
treed72533ffe3ceb5ab5bf536f7e096893c5c72c025 /src
parent71d3443597d1b1e95b922070d56daa5c8c4e505d (diff)
downloadfluxbox_pavel-70294ee0bbfde62bedc81363d8895719404a27ca.zip
fluxbox_pavel-70294ee0bbfde62bedc81363d8895719404a27ca.tar.bz2
Add a :clear() method for removing keybindings
Diffstat (limited to 'src')
-rw-r--r--src/Keys.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Keys.cc b/src/Keys.cc
index 2c5f46c..426e43a 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);