2002-06-12 03:16:41 +00:00
|
|
|
|
/**
|
2007-04-27 08:05:58 +00:00
|
|
|
|
* \file KeyMap.cpp
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-11-30 13:25:38 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-12 03:16:41 +00:00
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
2007-04-27 08:05:58 +00:00
|
|
|
|
#include "KeyMap.h"
|
2003-09-06 20:08:10 +00:00
|
|
|
|
|
|
|
|
|
#include "debug.h"
|
2007-04-27 08:19:12 +00:00
|
|
|
|
#include "KeySequence.h"
|
2003-07-26 23:04:39 +00:00
|
|
|
|
#include "LyXAction.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
|
#include "Lexer.h"
|
2003-09-06 20:08:10 +00:00
|
|
|
|
|
|
|
|
|
#include "support/filetools.h"
|
2004-07-24 10:55:30 +00:00
|
|
|
|
|
|
|
|
|
#include <sstream>
|
2007-10-18 15:48:51 +00:00
|
|
|
|
#include <utility>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-07-17 17:46:54 +00:00
|
|
|
|
using std::endl;
|
|
|
|
|
using std::string;
|
2007-10-18 15:48:51 +00:00
|
|
|
|
using std::make_pair;
|
2007-07-17 17:46:54 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2006-11-26 21:30:39 +00:00
|
|
|
|
using support::FileName;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
using support::i18nLibFileSearch;
|
2000-03-28 02:18:55 +00:00
|
|
|
|
|
2003-09-21 23:00:47 +00:00
|
|
|
|
|
2007-10-02 21:51:54 +00:00
|
|
|
|
string const KeyMap::printKeySym(KeySymbol const & key, KeyModifier mod)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-11-30 13:25:38 +00:00
|
|
|
|
string buf;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2004-03-26 15:12:35 +00:00
|
|
|
|
string const s = key.getSymbolName();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2007-10-02 21:51:54 +00:00
|
|
|
|
if (mod & ShiftModifier)
|
2003-06-18 13:47:11 +00:00
|
|
|
|
buf += "S-";
|
2007-10-02 21:51:54 +00:00
|
|
|
|
if (mod & ControlModifier)
|
2003-06-18 13:47:11 +00:00
|
|
|
|
buf += "C-";
|
2007-10-02 21:51:54 +00:00
|
|
|
|
if (mod & AltModifier)
|
2003-06-18 13:47:11 +00:00
|
|
|
|
buf += "M-";
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
buf += s;
|
2001-11-30 13:25:38 +00:00
|
|
|
|
return buf;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-18 13:47:11 +00:00
|
|
|
|
|
2007-04-27 08:05:58 +00:00
|
|
|
|
size_t KeyMap::bind(string const & seq, FuncRequest const & func)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2007-04-01 14:51:13 +00:00
|
|
|
|
LYXERR(Debug::KBMAP) << "BIND: Sequence `"
|
|
|
|
|
<< seq << "' Action `"
|
|
|
|
|
<< func.action << '\'' << endl;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2007-04-27 08:19:12 +00:00
|
|
|
|
KeySequence k(0, 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-10-01 15:31:59 +00:00
|
|
|
|
string::size_type const res = k.parse(seq);
|
2001-11-14 11:31:14 +00:00
|
|
|
|
if (res == string::npos) {
|
2003-09-21 23:00:47 +00:00
|
|
|
|
defkey(&k, func);
|
2001-11-30 13:25:38 +00:00
|
|
|
|
} else {
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KBMAP) << "Parse error at position " << res
|
1999-10-07 18:44:17 +00:00
|
|
|
|
<< " in key sequence '" << seq << "'."
|
|
|
|
|
<< endl;
|
2001-11-30 13:25:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-26 23:04:39 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
enum BindTags {
|
|
|
|
|
BN_BIND,
|
|
|
|
|
BN_BINDFILE
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
keyword_item bindTags[] = {
|
|
|
|
|
{ "\\bind", BN_BIND },
|
|
|
|
|
{ "\\bind_file", BN_BINDFILE }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-27 08:05:58 +00:00
|
|
|
|
bool KeyMap::read(string const & bind_file)
|
2003-07-26 23:04:39 +00:00
|
|
|
|
{
|
|
|
|
|
const int bindCount = sizeof(bindTags) / sizeof(keyword_item);
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
Lexer lexrc(bindTags, bindCount);
|
2003-07-26 23:04:39 +00:00
|
|
|
|
if (lyxerr.debugging(Debug::PARSER))
|
|
|
|
|
lexrc.printTable(lyxerr);
|
|
|
|
|
|
2006-11-26 21:30:39 +00:00
|
|
|
|
FileName const tmp(i18nLibFileSearch("bind", bind_file, "bind"));
|
2003-07-26 23:04:39 +00:00
|
|
|
|
lexrc.setFile(tmp);
|
2003-07-29 09:43:15 +00:00
|
|
|
|
if (!lexrc.isOK()) {
|
2007-04-27 08:05:58 +00:00
|
|
|
|
lyxerr << "KeyMap::read: cannot open bind file:"
|
2003-07-29 09:43:15 +00:00
|
|
|
|
<< tmp << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2003-07-26 23:04:39 +00:00
|
|
|
|
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KBMAP) << "Reading bind file:" << tmp << endl;
|
2003-07-26 23:04:39 +00:00
|
|
|
|
|
|
|
|
|
bool error = false;
|
2004-04-29 15:25:56 +00:00
|
|
|
|
while (lexrc.isOK()) {
|
2003-07-26 23:04:39 +00:00
|
|
|
|
switch (lexrc.lex()) {
|
2007-04-26 11:30:54 +00:00
|
|
|
|
case Lexer::LEX_UNDEF:
|
2003-07-26 23:04:39 +00:00
|
|
|
|
lexrc.printError("Unknown tag `$$Token'");
|
2003-07-29 09:43:15 +00:00
|
|
|
|
error = true;
|
2003-07-26 23:04:39 +00:00
|
|
|
|
continue;
|
2007-04-26 11:30:54 +00:00
|
|
|
|
case Lexer::LEX_FEOF:
|
2003-07-26 23:04:39 +00:00
|
|
|
|
continue;
|
|
|
|
|
case BN_BIND:
|
|
|
|
|
{
|
|
|
|
|
string seq, cmd;
|
2003-09-09 18:27:24 +00:00
|
|
|
|
|
2003-07-26 23:04:39 +00:00
|
|
|
|
if (lexrc.next()) {
|
|
|
|
|
seq = lexrc.getString();
|
|
|
|
|
} else {
|
|
|
|
|
lexrc.printError("BN_BIND: Missing key sequence");
|
2003-07-29 09:43:15 +00:00
|
|
|
|
error = true;
|
2003-07-26 23:04:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2003-09-09 18:27:24 +00:00
|
|
|
|
|
2003-07-26 23:04:39 +00:00
|
|
|
|
if (lexrc.next(true)) {
|
|
|
|
|
cmd = lexrc.getString();
|
|
|
|
|
} else {
|
|
|
|
|
lexrc.printError("BN_BIND: missing command");
|
2003-07-29 09:43:15 +00:00
|
|
|
|
error = true;
|
2003-07-26 23:04:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2003-09-09 18:27:24 +00:00
|
|
|
|
|
2003-09-21 23:00:47 +00:00
|
|
|
|
FuncRequest func = lyxaction.lookupFunc(cmd);
|
|
|
|
|
if (func. action == LFUN_UNKNOWN_ACTION) {
|
2003-07-26 23:04:39 +00:00
|
|
|
|
lexrc.printError("BN_BIND: Unknown LyX"
|
|
|
|
|
" function `$$Token'");
|
2003-07-29 09:43:15 +00:00
|
|
|
|
error = true;
|
2003-07-26 23:04:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2003-09-09 18:27:24 +00:00
|
|
|
|
|
2003-09-21 23:00:47 +00:00
|
|
|
|
bind(seq, func);
|
2003-07-26 23:04:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case BN_BINDFILE:
|
|
|
|
|
if (lexrc.next()) {
|
|
|
|
|
string const tmp(lexrc.getString());
|
2004-04-29 15:25:56 +00:00
|
|
|
|
error |= !read(tmp);
|
2003-07-26 23:04:39 +00:00
|
|
|
|
} else {
|
|
|
|
|
lexrc.printError("BN_BINDFILE: Missing file name");
|
|
|
|
|
error = true;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-29 09:43:15 +00:00
|
|
|
|
if (error)
|
2007-04-27 08:05:58 +00:00
|
|
|
|
lyxerr << "KeyMap::read: error while reading bind file:"
|
2003-07-29 09:43:15 +00:00
|
|
|
|
<< tmp << endl;
|
|
|
|
|
return !error;
|
2003-07-26 23:04:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-17 18:41:03 +00:00
|
|
|
|
FuncRequest const & KeyMap::lookup(KeySymbol const &key,
|
2007-10-02 21:51:54 +00:00
|
|
|
|
KeyModifier mod, KeySequence * seq) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-09-21 23:00:47 +00:00
|
|
|
|
static FuncRequest const unknown(LFUN_UNKNOWN_ACTION);
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
if (table.empty()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
seq->curmap = seq->stdmap;
|
2001-11-30 13:25:38 +00:00
|
|
|
|
seq->mark_deleted();
|
2003-09-21 23:00:47 +00:00
|
|
|
|
return unknown;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-18 13:47:11 +00:00
|
|
|
|
Table::const_iterator end = table.end();
|
|
|
|
|
for (Table::const_iterator cit = table.begin(); cit != end; ++cit) {
|
2007-10-02 21:51:54 +00:00
|
|
|
|
KeyModifier mask = cit->mod.second;
|
|
|
|
|
KeyModifier check = static_cast<KeyModifier>(mod & ~mask);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
2007-09-17 18:41:03 +00:00
|
|
|
|
if (cit->code == key && cit->mod.first == check) {
|
2001-11-30 13:25:38 +00:00
|
|
|
|
// match found
|
2001-07-12 11:11:10 +00:00
|
|
|
|
if (cit->table.get()) {
|
1999-12-16 06:43:25 +00:00
|
|
|
|
// this is a prefix key - set new map
|
2001-07-12 11:11:10 +00:00
|
|
|
|
seq->curmap = cit->table.get();
|
2006-05-05 20:23:12 +00:00
|
|
|
|
static FuncRequest prefix(LFUN_COMMAND_PREFIX);
|
2003-09-21 23:00:47 +00:00
|
|
|
|
return prefix;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
} else {
|
1999-12-16 06:43:25 +00:00
|
|
|
|
// final key - reset map
|
1999-09-27 18:44:28 +00:00
|
|
|
|
seq->curmap = seq->stdmap;
|
2001-11-30 13:25:38 +00:00
|
|
|
|
seq->mark_deleted();
|
2003-09-21 23:00:47 +00:00
|
|
|
|
return cit->func;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// error - key not found:
|
|
|
|
|
seq->curmap = seq->stdmap;
|
2001-11-30 13:25:38 +00:00
|
|
|
|
seq->mark_deleted();
|
2003-09-21 23:00:47 +00:00
|
|
|
|
|
|
|
|
|
return unknown;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-27 08:05:58 +00:00
|
|
|
|
docstring const KeyMap::print(bool forgui) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2006-12-13 14:13:01 +00:00
|
|
|
|
docstring buf;
|
2003-06-18 13:47:11 +00:00
|
|
|
|
Table::const_iterator end = table.end();
|
|
|
|
|
for (Table::const_iterator cit = table.begin(); cit != end; ++cit) {
|
2007-09-17 18:41:03 +00:00
|
|
|
|
buf += cit->code.print(cit->mod.first, forgui);
|
2000-02-04 09:38:32 +00:00
|
|
|
|
buf += ' ';
|
|
|
|
|
}
|
2001-11-30 13:25:38 +00:00
|
|
|
|
return buf;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-27 08:19:12 +00:00
|
|
|
|
void KeyMap::defkey(KeySequence * seq, FuncRequest const & func, unsigned int r)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2007-09-17 18:41:03 +00:00
|
|
|
|
KeySymbol code = seq->sequence[r];
|
|
|
|
|
if (!code.isOK())
|
2002-08-06 00:54:20 +00:00
|
|
|
|
return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-10-02 21:51:54 +00:00
|
|
|
|
KeyModifier const mod1 = seq->modifiers[r].first;
|
|
|
|
|
KeyModifier const mod2 = seq->modifiers[r].second;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
|
// check if key is already there
|
2003-06-18 13:47:11 +00:00
|
|
|
|
Table::iterator end = table.end();
|
|
|
|
|
for (Table::iterator it = table.begin(); it != end; ++it) {
|
2007-09-17 18:41:03 +00:00
|
|
|
|
if (code == it->code
|
2002-06-18 15:44:30 +00:00
|
|
|
|
&& mod1 == it->mod.first
|
|
|
|
|
&& mod2 == it->mod.second) {
|
2000-02-04 09:38:32 +00:00
|
|
|
|
// overwrite binding
|
2001-11-30 13:25:38 +00:00
|
|
|
|
if (r + 1 == seq->length()) {
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KBMAP)
|
1999-10-07 18:44:17 +00:00
|
|
|
|
<< "Warning: New binding for '"
|
2007-01-04 17:10:24 +00:00
|
|
|
|
<< to_utf8(seq->print(false))
|
1999-10-07 18:44:17 +00:00
|
|
|
|
<< "' is overriding old binding..."
|
|
|
|
|
<< endl;
|
2002-05-21 23:50:36 +00:00
|
|
|
|
if (it->table.get()) {
|
|
|
|
|
it->table.reset();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2003-09-21 23:00:47 +00:00
|
|
|
|
it->func = func;
|
2004-11-08 10:54:29 +00:00
|
|
|
|
it->func.origin = FuncRequest::KEYBOARD;
|
2001-11-30 13:25:38 +00:00
|
|
|
|
return;
|
2001-07-12 11:11:10 +00:00
|
|
|
|
} else if (!it->table.get()) {
|
2007-05-28 22:27:45 +00:00
|
|
|
|
lyxerr << "Error: New binding for '"
|
2007-01-04 17:10:24 +00:00
|
|
|
|
<< to_utf8(seq->print(false))
|
1999-10-07 18:44:17 +00:00
|
|
|
|
<< "' is overriding old binding..."
|
2001-11-30 13:25:38 +00:00
|
|
|
|
<< endl;
|
|
|
|
|
return;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
} else {
|
2003-09-21 23:00:47 +00:00
|
|
|
|
it->table->defkey(seq, func, r + 1);
|
2001-11-30 13:25:38 +00:00
|
|
|
|
return;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2007-04-27 08:05:58 +00:00
|
|
|
|
Table::iterator newone = table.insert(table.end(), Key());
|
2001-07-12 11:11:10 +00:00
|
|
|
|
newone->code = code;
|
2002-05-26 17:33:14 +00:00
|
|
|
|
newone->mod = seq->modifiers[r];
|
2001-11-30 13:25:38 +00:00
|
|
|
|
if (r + 1 == seq->length()) {
|
2003-09-21 23:00:47 +00:00
|
|
|
|
newone->func = func;
|
2006-01-18 17:44:01 +00:00
|
|
|
|
newone->func.origin = FuncRequest::KEYBOARD;
|
2002-05-21 23:50:36 +00:00
|
|
|
|
newone->table.reset();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
} else {
|
2007-04-27 08:05:58 +00:00
|
|
|
|
newone->table.reset(new KeyMap);
|
2003-09-21 23:00:47 +00:00
|
|
|
|
newone->table->defkey(seq, func, r + 1);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-27 08:05:58 +00:00
|
|
|
|
docstring const KeyMap::printbindings(FuncRequest const & func) const
|
1999-12-16 06:43:25 +00:00
|
|
|
|
{
|
2004-07-02 10:03:22 +00:00
|
|
|
|
Bindings bindings = findbindings(func);
|
2007-10-11 16:03:21 +00:00
|
|
|
|
if (bindings.empty())
|
|
|
|
|
return docstring();
|
|
|
|
|
|
|
|
|
|
odocstringstream res;
|
|
|
|
|
Bindings::const_iterator cit = bindings.begin();
|
|
|
|
|
Bindings::const_iterator cit_end = bindings.end();
|
|
|
|
|
// prin the first item
|
|
|
|
|
res << cit->print(true);
|
|
|
|
|
// more than one shortcuts?
|
|
|
|
|
for (++cit; cit != cit_end; ++cit)
|
|
|
|
|
res << ", " << cit->print(true);
|
2004-07-02 10:03:22 +00:00
|
|
|
|
return res.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-27 08:05:58 +00:00
|
|
|
|
KeyMap::Bindings KeyMap::findbindings(FuncRequest const & func) const
|
2004-07-02 10:03:22 +00:00
|
|
|
|
{
|
2007-04-27 08:19:12 +00:00
|
|
|
|
return findbindings(func, KeySequence(0, 0));
|
2004-07-02 10:03:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-27 08:05:58 +00:00
|
|
|
|
KeyMap::Bindings KeyMap::findbindings(FuncRequest const & func,
|
2007-04-27 08:19:12 +00:00
|
|
|
|
KeySequence const & prefix) const
|
2004-07-02 10:03:22 +00:00
|
|
|
|
{
|
|
|
|
|
Bindings res;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
if (table.empty()) return res;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-08-03 21:17:52 +00:00
|
|
|
|
Table::const_iterator end = table.end();
|
2000-10-11 21:06:43 +00:00
|
|
|
|
for (Table::const_iterator cit = table.begin();
|
2000-08-03 21:17:52 +00:00
|
|
|
|
cit != end; ++cit) {
|
2001-07-12 11:11:10 +00:00
|
|
|
|
if (cit->table.get()) {
|
2007-04-27 08:19:12 +00:00
|
|
|
|
KeySequence seq = prefix;
|
2004-07-02 10:03:22 +00:00
|
|
|
|
seq.addkey(cit->code, cit->mod.first);
|
2004-07-24 10:55:30 +00:00
|
|
|
|
Bindings res2 =
|
2004-07-02 10:03:22 +00:00
|
|
|
|
cit->table->findbindings(func, seq);
|
|
|
|
|
res.insert(res.end(), res2.begin(), res2.end());
|
2003-09-21 23:00:47 +00:00
|
|
|
|
} else if (cit->func == func) {
|
2007-04-27 08:19:12 +00:00
|
|
|
|
KeySequence seq = prefix;
|
2004-07-02 10:03:22 +00:00
|
|
|
|
seq.addkey(cit->code, cit->mod.first);
|
|
|
|
|
res.push_back(seq);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-09-21 23:00:47 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return res;
|
|
|
|
|
}
|
2004-07-07 09:32:19 +00:00
|
|
|
|
|
|
|
|
|
|
2007-10-18 15:48:51 +00:00
|
|
|
|
KeyMap::BindingList const KeyMap::listBindings(bool unbound) const
|
|
|
|
|
{
|
|
|
|
|
BindingList list;
|
|
|
|
|
listBindings(list, KeySequence(0, 0));
|
|
|
|
|
if (unbound) {
|
|
|
|
|
LyXAction::const_func_iterator fit = lyxaction.func_begin();
|
|
|
|
|
LyXAction::const_func_iterator fit_end = lyxaction.func_end();
|
|
|
|
|
for (; fit != fit_end; ++fit) {
|
|
|
|
|
kb_action action = fit->second;
|
|
|
|
|
bool has_action = false;
|
|
|
|
|
BindingList::const_iterator it = list.begin();
|
|
|
|
|
BindingList::const_iterator it_end = list.end();
|
|
|
|
|
for (; it != it_end; ++it)
|
|
|
|
|
if (it->first.action == action) {
|
|
|
|
|
has_action = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (!has_action)
|
|
|
|
|
list.push_back(make_pair(action, KeySequence(0, 0)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeyMap::listBindings(BindingList & list,
|
|
|
|
|
KeySequence const & prefix) const
|
|
|
|
|
{
|
|
|
|
|
Table::const_iterator it = table.begin();
|
|
|
|
|
Table::const_iterator it_end = table.end();
|
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
|
// a LFUN_COMMAND_PREFIX
|
|
|
|
|
if (it->table.get()) {
|
|
|
|
|
KeySequence seq = prefix;
|
|
|
|
|
seq.addkey(it->code, it->mod.first);
|
|
|
|
|
it->table->listBindings(list, seq);
|
|
|
|
|
} else {
|
|
|
|
|
KeySequence seq = prefix;
|
|
|
|
|
seq.addkey(it->code, it->mod.first);
|
|
|
|
|
list.push_back(make_pair(it->func, seq));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|