This moves the world along (according to me...) IMHO things are beginning to look a bit better, but there are still several functions that can be removed and simplified.
Also I found some strange differences between XForms and Qt. In XForms the command bindings are present in the menus, in qt noe. (gtk does not matter since that does not even try to put bindings in the menus).
? action-1.diff ? pseudo-2.diff Index: src/BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.438 diff -u -p -r1.438 BufferView_pimpl.C --- src/BufferView_pimpl.C 17 Sep 2003 16:44:51 -0000 1.438 +++ src/BufferView_pimpl.C 21 Sep 2003 22:39:47 -0000 @@ -1324,7 +1324,7 @@ bool BufferView::Pimpl::dispatch(FuncReq ev.errorMessage(N_("Unknown function!")); break; - default: + default: return bv_->getLyXText()->dispatch(FuncRequest(ev, bv_)); } // end of switch Index: src/LyXAction.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v retrieving revision 1.183 diff -u -p -r1.183 LyXAction.C --- src/LyXAction.C 21 Sep 2003 18:57:13 -0000 1.183 +++ src/LyXAction.C 21 Sep 2003 22:39:47 -0000 @@ -20,6 +20,8 @@ #include "support/lstrings.h" +#include <boost/assert.hpp> + using lyx::support::split; using lyx::support::trim; @@ -47,16 +49,6 @@ using std::ostream; LyXAction lyxaction; -namespace { - -/// return true if the given action is a pseudo-action -inline bool isPseudoAction(int a) -{ - return a > int(LFUN_LASTACTION); -} - -} - void LyXAction::newFunc(kb_action action, string const & name, unsigned int attrib) @@ -345,29 +337,27 @@ LyXAction::LyXAction() // Returns an action tag from a string. -kb_action LyXAction::LookupFunc(string const & func) +FuncRequest LyXAction::lookupFunc(string const & func) const { string const func2 = trim(func); - if (func2.empty()) return LFUN_NOACTION; - // split action and arg - string actstr; - string const argstr = split(func2, actstr, ' '); - lyxerr[Debug::ACTION] << "Action: " << actstr << '\n' - << "Arg : " << argstr << endl; + if (func2.empty()) { + return FuncRequest(LFUN_NOACTION); + } + + string cmd; + string const arg = split(func2, cmd, ' '); - func_map::const_iterator fit = lyx_func_map.find(actstr); + func_map::const_iterator fit = lyx_func_map.find(cmd); - return fit != lyx_func_map.end() ? fit->second : LFUN_UNKNOWN_ACTION; + return fit != lyx_func_map.end() ? FuncRequest(fit->second, arg) : FuncRequest(LFUN_UNKNOWN_ACTION); } -string const LyXAction::getActionName(int action) const +string const LyXAction::getActionName(kb_action action) const { - info_map::const_iterator const it = lyx_info_map.find(kb_action(action)); - if (it != lyx_info_map.end()) - return it->second.name; - return string(); + info_map::const_iterator const it = lyx_info_map.find(action); + return it != lyx_info_map.end() ? it->second.name : string(); } @@ -376,14 +366,9 @@ bool LyXAction::funcHasFlag(kb_action ac { info_map::const_iterator ici = lyx_info_map.find(action); - if (ici != lyx_info_map.end()) { - return ici->second.attrib & flag; - } else { - // it really should exist, but... - lyxerr << "LyXAction::funcHasFlag: " - "No info about kb_action: " << action << '\n'; - return false; - } + BOOST_ASSERT(ici != lyx_info_map.end()); + + return ici->second.attrib & flag; } Index: src/LyXAction.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.h,v retrieving revision 1.26 diff -u -p -r1.26 LyXAction.h --- src/LyXAction.h 21 Sep 2003 18:57:13 -0000 1.26 +++ src/LyXAction.h 21 Sep 2003 22:39:47 -0000 @@ -60,10 +60,10 @@ public: * If you include arguments in func_name, a new pseudoaction * will be created if needed. */ - kb_action LookupFunc(string const & func_name); + FuncRequest lookupFunc(string const & func_name) const; /// Return the name (and argument) associated with the given (pseudo) action - string const getActionName(int action) const; + string const getActionName(kb_action action) const; /// True if the command has `flag' set bool funcHasFlag(kb_action action, func_attrib flag) const; Index: src/MenuBackend.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/MenuBackend.C,v retrieving revision 1.87 diff -u -p -r1.87 MenuBackend.C --- src/MenuBackend.C 21 Sep 2003 18:57:13 -0000 1.87 +++ src/MenuBackend.C 21 Sep 2003 22:39:47 -0000 @@ -115,12 +115,17 @@ string const MenuItem::binding() const // Get the keys bound to this action, but keep only the // first one later - string bindings = toplevel_keymap->findbinding(func_.action); + string bindings = toplevel_keymap->findbinding(func_); if (!bindings.empty()) { return bindings.substr(1, bindings.find(']') - 1); - } else + } else { + lyxerr << "No bindings for " + << lyxaction.getActionName(func_.action) + << '(' << func_.argument << ')' << endl; return string(); + } + } @@ -238,20 +243,8 @@ Menu & Menu::read(LyXLex & lex) string const name = _(lex.getString()); lex.next(true); string const command = lex.getString(); - string::size_type sp = command.find(' '); - if (sp != string::npos) { - string const cmd = command.substr(0, sp); - string const arg =command.substr(sp + 1, - string::npos); - kb_action act = lyxaction.LookupFunc(cmd); - add(MenuItem(MenuItem::Command, name, - FuncRequest(act, arg), optional)); - } else { - kb_action act = lyxaction.LookupFunc(command); - add(MenuItem(MenuItem::Command, name, - FuncRequest(act), optional)); - } - + FuncRequest func = lyxaction.lookupFunc(command); + add(MenuItem(MenuItem::Command, name, func, optional)); optional = false; break; } @@ -620,7 +613,8 @@ void expandToc(Menu & tomenu, LyXView co cit = toc_list.find("TOC"); if (cit == end) { tomenu.add(MenuItem(MenuItem::Command, - _("No Table of contents")), + _("No Table of contents"), + FuncRequest()), view); } else { expandToc2(tomenu, cit->second, 0, cit->second.size(), 0); Index: src/ToolbarBackend.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ToolbarBackend.C,v retrieving revision 1.19 diff -u -p -r1.19 ToolbarBackend.C --- src/ToolbarBackend.C 21 Sep 2003 18:57:13 -0000 1.19 +++ src/ToolbarBackend.C 21 Sep 2003 22:39:47 -0000 @@ -93,26 +93,10 @@ void ToolbarBackend::read(LyXLex & lex) lyxerr[Debug::PARSER] << "ToolbarBackend::read TO_ADD func: `" << func_arg << '\'' << endl; - // Split func_arg in function and arg. - string::size_type sp = func_arg.find(' '); - if (sp != string::npos) { - - string const func = - func_arg.substr(0, sp); - string const arg = - func_arg.substr(sp + 1, - string::npos); - - kb_action const tf = - lyxaction.LookupFunc(func); - - add(tb, FuncRequest(tf, arg), tooltip); - } else { - kb_action const tf = lyxaction.LookupFunc(func_arg); - add(tb, FuncRequest(tf), tooltip); - - } + FuncRequest func = + lyxaction.lookupFunc(func_arg); + add(tb, func, tooltip); } break; Index: src/boost.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/boost.C,v retrieving revision 1.5 diff -u -p -r1.5 boost.C --- src/boost.C 10 Sep 2003 13:39:38 -0000 1.5 +++ src/boost.C 21 Sep 2003 22:39:47 -0000 @@ -49,8 +49,9 @@ void emergencyCleanup() void assertion_failed(char const * expr, char const * function, char const * file, long line) { - lyxerr << "Assertion triggered in " << function << " by \"" << - expr << " in file " << file << ":" << line << endl; + lyxerr << "Assertion triggered in " << function + << " by failing check \"" << expr << "\"" + << " in file " << file << ":" << line << endl; emergencyCleanup(); lyx::support::abort(); } Index: src/buffer.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v retrieving revision 1.529 diff -u -p -r1.529 buffer.C --- src/buffer.C 18 Sep 2003 20:18:36 -0000 1.529 +++ src/buffer.C 21 Sep 2003 22:39:48 -0000 @@ -22,6 +22,7 @@ #include "errorlist.h" #include "exporter.h" #include "format.h" +#include "funcrequest.h" #include "gettext.h" #include "iterators.h" #include "language.h" @@ -2199,22 +2200,17 @@ void Buffer::markDepClean(string const & bool Buffer::dispatch(string const & command, bool * result) { - // Split command string into command and argument - string cmd; - string line = ltrim(command); - string const arg = trim(split(line, cmd, ' ')); - - return dispatch(lyxaction.LookupFunc(cmd), arg, result); + return dispatch(lyxaction.lookupFunc(command), result); } -bool Buffer::dispatch(int action, string const & argument, bool * result) +bool Buffer::dispatch(FuncRequest const & func, bool * result) { bool dispatched = true; - switch (action) { + switch (func.action) { case LFUN_EXPORT: { - bool const tmp = Exporter::Export(this, argument, false); + bool const tmp = Exporter::Export(this, func.argument, false); if (result) *result = tmp; break; Index: src/buffer.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.h,v retrieving revision 1.164 diff -u -p -r1.164 buffer.h --- src/buffer.h 9 Sep 2003 17:00:07 -0000 1.164 +++ src/buffer.h 21 Sep 2003 22:39:48 -0000 @@ -31,6 +31,7 @@ class BufferParams; class ErrorItem; +class FuncRequest; class LyXFont; class LyXLex; class LyXRC; @@ -75,7 +76,7 @@ public: bool dispatch(string const & command, bool * result = 0); /// Maybe we know the function already by number... - bool dispatch(int ac, string const & argument, bool * result = 0); + bool dispatch(FuncRequest const & func, bool * result = 0); /// Load the autosaved file. void loadAutoSaveFile(); Index: src/cursor.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v retrieving revision 1.2 diff -u -p -r1.2 cursor.C --- src/cursor.C 18 Sep 2003 11:21:53 -0000 1.2 +++ src/cursor.C 21 Sep 2003 22:39:48 -0000 @@ -38,7 +38,7 @@ void buildCursor(Cursor & cursor, Buffer lyxerr << "\nbuildCursor: " << inset << std::endl; if (!inset) return; - + inset = inset->getLockingInset(); bool ok = false; @@ -47,7 +47,7 @@ void buildCursor(Cursor & cursor, Buffer for ( ; pit != end && !ok; ++pit) { InsetList::iterator it = pit->insetlist.begin(); InsetList::iterator iend = pit->insetlist.end(); - for ( ; it != iend && !ok; ++it) + for ( ; it != iend && !ok; ++it) if (it->inset == inset || it->inset == inset->owner()) ok = true; } @@ -57,7 +57,7 @@ void buildCursor(Cursor & cursor, Buffer return; } - vector<ParagraphList::iterator> pits; + vector<ParagraphList::iterator> pits; vector<ParagraphList const *> plists; vector<LyXText *> texts; /* Index: src/funcrequest.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/funcrequest.C,v retrieving revision 1.17 diff -u -p -r1.17 funcrequest.C --- src/funcrequest.C 21 Sep 2003 18:57:13 -0000 1.17 +++ src/funcrequest.C 21 Sep 2003 22:39:48 -0000 @@ -25,7 +25,7 @@ using std::vector; FuncRequest::FuncRequest() - : view_(0), action(LFUN_UNKNOWN_ACTION), x(0), y(0), button_(mouse_button::none) + : view_(0), action(LFUN_NOACTION), x(0), y(0), button_(mouse_button::none) {} Index: src/funcrequest.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/funcrequest.h,v retrieving revision 1.13 diff -u -p -r1.13 funcrequest.h --- src/funcrequest.h 21 Sep 2003 18:57:13 -0000 1.13 +++ src/funcrequest.h 21 Sep 2003 22:39:48 -0000 @@ -75,4 +75,11 @@ public: // should be private, too... mouse_button::state button_; }; + +inline +bool operator==(FuncRequest const & lhs, FuncRequest const & rhs) +{ + return lhs.action == rhs.action && lhs.argument == rhs.argument; +} + #endif // FUNCREQUEST_H Index: src/kbmap.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/kbmap.C,v retrieving revision 1.49 diff -u -p -r1.49 kbmap.C --- src/kbmap.C 9 Sep 2003 18:27:21 -0000 1.49 +++ src/kbmap.C 21 Sep 2003 22:39:48 -0000 @@ -27,6 +27,7 @@ using std::endl; using lyx::support::i18nLibFileSearch; + string const kb_keymap::printKeysym(LyXKeySymPtr key, key_modifier::state mod) { @@ -52,19 +53,19 @@ string const kb_keymap::printKey(kb_key } -string::size_type kb_keymap::bind(string const & seq, int action) +string::size_type kb_keymap::bind(string const & seq, FuncRequest const & func) { if (lyxerr.debugging(Debug::KBMAP)) { lyxerr << "BIND: Sequence `" << seq << "' Action `" - << action << '\'' << endl; + << func.action << '\'' << endl; } kb_sequence k(0, 0); string::size_type const res = k.parse(seq); if (res == string::npos) { - defkey(&k, action); + defkey(&k, func); } else { lyxerr[Debug::KBMAP] << "Parse error at position " << res << " in key sequence '" << seq << "'." @@ -137,15 +138,15 @@ bool kb_keymap::read(string const & bind break; } - int action = lyxaction.LookupFunc(cmd); - if (!action == LFUN_UNKNOWN_ACTION) { + FuncRequest func = lyxaction.lookupFunc(cmd); + if (func. action == LFUN_UNKNOWN_ACTION) { lexrc.printError("BN_BIND: Unknown LyX" " function `$$Token'"); error = true; break; } - bind(seq, kb_action(action)); + bind(seq, func); break; } case BN_BINDFILE: @@ -169,13 +170,16 @@ bool kb_keymap::read(string const & bind } -int kb_keymap::lookup(LyXKeySymPtr key, - key_modifier::state mod, kb_sequence * seq) const +FuncRequest const & +kb_keymap::lookup(LyXKeySymPtr key, + key_modifier::state mod, kb_sequence * seq) const { + static FuncRequest const unknown(LFUN_UNKNOWN_ACTION); + if (table.empty()) { seq->curmap = seq->stdmap; seq->mark_deleted(); - return LFUN_UNKNOWN_ACTION; + return unknown; } Table::const_iterator end = table.end(); @@ -189,12 +193,13 @@ int kb_keymap::lookup(LyXKeySymPtr key, if (cit->table.get()) { // this is a prefix key - set new map seq->curmap = cit->table.get(); - return LFUN_PREFIX; + static FuncRequest prefix(LFUN_PREFIX); + return prefix; } else { // final key - reset map seq->curmap = seq->stdmap; seq->mark_deleted(); - return cit->action; + return cit->func; } } } @@ -202,7 +207,8 @@ int kb_keymap::lookup(LyXKeySymPtr key, // error - key not found: seq->curmap = seq->stdmap; seq->mark_deleted(); - return LFUN_UNKNOWN_ACTION; + + return unknown; } @@ -218,7 +224,8 @@ string const kb_keymap::print() const } -void kb_keymap::defkey(kb_sequence * seq, int action, unsigned int r) +void kb_keymap::defkey(kb_sequence * seq, + FuncRequest const & func, unsigned int r) { LyXKeySymPtr code = seq->sequence[r]; if (!code->isOK()) @@ -243,7 +250,7 @@ void kb_keymap::defkey(kb_sequence * seq if (it->table.get()) { it->table.reset(); } - it->action = action; + it->func = func; return; } else if (!it->table.get()) { lyxerr << "Error: New binding for '" << seq->print() @@ -251,7 +258,7 @@ void kb_keymap::defkey(kb_sequence * seq << endl; return; } else { - it->table->defkey(seq, action, r + 1); + it->table->defkey(seq, func, r + 1); return; } } @@ -261,18 +268,19 @@ void kb_keymap::defkey(kb_sequence * seq newone->code = code; newone->mod = seq->modifiers[r]; if (r + 1 == seq->length()) { - newone->action = action; + newone->func = func; newone->table.reset(); return; } else { newone->table.reset(new kb_keymap); - newone->table->defkey(seq, action, r + 1); + newone->table->defkey(seq, func, r + 1); return; } } -string const kb_keymap::findbinding(int act, string const & prefix) const +string const kb_keymap::findbinding(FuncRequest const & func, + string const & prefix) const { string res; if (table.empty()) return res; @@ -281,15 +289,23 @@ string const kb_keymap::findbinding(int for (Table::const_iterator cit = table.begin(); cit != end; ++cit) { if (cit->table.get()) { - res += cit->table->findbinding(act, + res += cit->table->findbinding(func, prefix + printKey((*cit)) + ' '); - } else if (cit->action == act) { + } else if (cit->func == func) { res += '['; res += prefix + printKey((*cit)); res += "] "; } } + if (lyxerr.debugging(Debug::GUI)) { + if (res.empty()) { + lyxerr << "No bindings found for " + << lyxaction.getActionName(func.action) + << '(' << func.argument << ')' << endl; + } + } + return res; } Index: src/kbmap.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/kbmap.h,v retrieving revision 1.30 diff -u -p -r1.30 kbmap.h --- src/kbmap.h 7 Sep 2003 01:45:37 -0000 1.30 +++ src/kbmap.h 21 Sep 2003 22:39:48 -0000 @@ -14,6 +14,8 @@ #ifndef KBMAP_H #define KBMAP_H +#include "funcrequest.h" + #include "frontends/key_state.h" #include <boost/shared_ptr.hpp> @@ -33,10 +35,10 @@ public: * occurs. * See kb_sequence::parse for the syntax of the seq string */ - string::size_type bind(string const & seq, int action); + string::size_type bind(string const & seq, FuncRequest const & func); // Parse a bind file - bool kb_keymap::read(string const & bind_file); + bool read(string const & bind_file); /// print all available keysyms string const print() const; @@ -50,11 +52,12 @@ public: * @param seq the current key sequence so far * @return the action / LFUN_PREFIX / LFUN_UNKNOWN_ACTION */ - int lookup(LyXKeySymPtr key, - key_modifier::state mod, kb_sequence * seq) const; + FuncRequest const & + lookup(LyXKeySymPtr key, + key_modifier::state mod, kb_sequence * seq) const; /// Given an action, find all keybindings. - string const findbinding(int action, + string const findbinding(FuncRequest const & func, string const & prefix = string()) const; /** @@ -80,14 +83,15 @@ private: boost::shared_ptr<kb_keymap> table; /// Action for !prefix keys - int action; + FuncRequest func; }; /** * Define an action for a key sequence. * @param r internal recursion level */ - void defkey(kb_sequence * seq, int action, unsigned int r = 0); + void defkey(kb_sequence * seq, FuncRequest const & func, + unsigned int r = 0); /// Returns a string of the given key string const printKey(kb_key const & key) const; Index: src/kbsequence.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/kbsequence.C,v retrieving revision 1.34 diff -u -p -r1.34 kbsequence.C --- src/kbsequence.C 6 Sep 2003 20:08:09 -0000 1.34 +++ src/kbsequence.C 21 Sep 2003 22:39:48 -0000 @@ -24,8 +24,9 @@ using std::make_pair; -int kb_sequence::addkey(LyXKeySymPtr key, - key_modifier::state mod, key_modifier::state nmod) +FuncRequest const & +kb_sequence::addkey(LyXKeySymPtr key, + key_modifier::state mod, key_modifier::state nmod) { // adding a key to a deleted sequence // starts a new sequence @@ -42,7 +43,8 @@ int kb_sequence::addkey(LyXKeySymPtr key return curmap->lookup(key, mod, this); } - return LFUN_UNKNOWN_ACTION; + static FuncRequest unknown(LFUN_UNKNOWN_ACTION); + return unknown; } Index: src/kbsequence.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/kbsequence.h,v retrieving revision 1.18 diff -u -p -r1.18 kbsequence.h --- src/kbsequence.h 6 Sep 2003 20:08:09 -0000 1.18 +++ src/kbsequence.h 21 Sep 2003 22:39:48 -0000 @@ -22,6 +22,7 @@ class kb_keymap; class LyXKeySym; +class FuncRequest; /// Holds a key sequence and the current and standard keymaps class kb_sequence { @@ -43,8 +44,9 @@ public: * @param nmod which modifiers to mask out for equality test * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION */ - int addkey(LyXKeySymPtr keysym, key_modifier::state mod, - key_modifier::state nmod = key_modifier::none); + FuncRequest const & + addkey(LyXKeySymPtr keysym, key_modifier::state mod, + key_modifier::state nmod = key_modifier::none); /** * Add a sequence of keys from a string to the sequence Index: src/lyx_main.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_main.C,v retrieving revision 1.175 diff -u -p -r1.175 lyx_main.C --- src/lyx_main.C 16 Sep 2003 11:03:17 -0000 1.175 +++ src/lyx_main.C 21 Sep 2003 22:39:49 -0000 @@ -333,59 +333,59 @@ void LyX::init(bool gui) void LyX::defaultKeyBindings(kb_keymap * kbmap) { - kbmap->bind("Right", LFUN_RIGHT); - kbmap->bind("Left", LFUN_LEFT); - kbmap->bind("Up", LFUN_UP); - kbmap->bind("Down", LFUN_DOWN); - - kbmap->bind("Tab", LFUN_CELL_FORWARD); - kbmap->bind("ISO_Left_Tab", LFUN_CELL_FORWARD); // jbl 2001-23-02 - - kbmap->bind("Home", LFUN_HOME); - kbmap->bind("End", LFUN_END); - kbmap->bind("Prior", LFUN_PRIOR); - kbmap->bind("Next", LFUN_NEXT); + kbmap->bind("Right", FuncRequest(LFUN_RIGHT)); + kbmap->bind("Left", FuncRequest(LFUN_LEFT)); + kbmap->bind("Up", FuncRequest(LFUN_UP)); + kbmap->bind("Down", FuncRequest(LFUN_DOWN)); + + kbmap->bind("Tab", FuncRequest(LFUN_CELL_FORWARD)); + kbmap->bind("ISO_Left_Tab", FuncRequest(LFUN_CELL_FORWARD)); + + kbmap->bind("Home", FuncRequest(LFUN_HOME)); + kbmap->bind("End", FuncRequest(LFUN_END)); + kbmap->bind("Prior", FuncRequest(LFUN_PRIOR)); + kbmap->bind("Next", FuncRequest(LFUN_NEXT)); - kbmap->bind("Return", LFUN_BREAKPARAGRAPH); - //kbmap->bind("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE); + kbmap->bind("Return", FuncRequest(LFUN_BREAKPARAGRAPH)); + //kbmap->bind("~C-~S-~M-nobreakspace", FuncRequest(LFUN_PROTECTEDSPACE)); - kbmap->bind("Delete", LFUN_DELETE); - kbmap->bind("BackSpace", LFUN_BACKSPACE); + kbmap->bind("Delete", FuncRequest(LFUN_DELETE)); + kbmap->bind("BackSpace", FuncRequest(LFUN_BACKSPACE)); // sub- and superscript -MV - kbmap->bind("~S-underscore", LFUN_SUBSCRIPT); - kbmap->bind("~S-asciicircum", LFUN_SUPERSCRIPT); + kbmap->bind("~S-underscore", FuncRequest(LFUN_SUBSCRIPT)); + kbmap->bind("~S-asciicircum", FuncRequest(LFUN_SUPERSCRIPT)); // kbmap->bindings to enable the use of the numeric keypad // e.g. Num Lock set - //kbmap->bind("KP_0", LFUN_SELFINSERT); - //kbmap->bind("KP_Decimal", LFUN_SELFINSERT); - kbmap->bind("KP_Enter", LFUN_BREAKPARAGRAPH); - //kbmap->bind("KP_1", LFUN_SELFINSERT); - //kbmap->bind("KP_2", LFUN_SELFINSERT); - //kbmap->bind("KP_3", LFUN_SELFINSERT); - //kbmap->bind("KP_4", LFUN_SELFINSERT); - //kbmap->bind("KP_5", LFUN_SELFINSERT); - //kbmap->bind("KP_6", LFUN_SELFINSERT); - //kbmap->bind("KP_Add", LFUN_SELFINSERT); - //kbmap->bind("KP_7", LFUN_SELFINSERT); - //kbmap->bind("KP_8", LFUN_SELFINSERT); - //kbmap->bind("KP_9", LFUN_SELFINSERT); - //kbmap->bind("KP_Divide", LFUN_SELFINSERT); - //kbmap->bind("KP_Multiply", LFUN_SELFINSERT); - //kbmap->bind("KP_Subtract", LFUN_SELFINSERT); - kbmap->bind("KP_Right", LFUN_RIGHT); - kbmap->bind("KP_Left", LFUN_LEFT); - kbmap->bind("KP_Up", LFUN_UP); - kbmap->bind("KP_Down", LFUN_DOWN); - kbmap->bind("KP_Home", LFUN_HOME); - kbmap->bind("KP_End", LFUN_END); - kbmap->bind("KP_Prior", LFUN_PRIOR); - kbmap->bind("KP_Next", LFUN_NEXT); - - kbmap->bind("C-Tab", LFUN_CELL_SPLIT); // ale970515 - kbmap->bind("S-Tab", LFUN_CELL_BACKWARD); // jug20000522 - kbmap->bind("S-ISO_Left_Tab", LFUN_CELL_BACKWARD); // jbl 2001-23-02 + //kbmap->bind("KP_0", FuncRequest(LFUN_SELFINSERT)); + //kbmap->bind("KP_Decimal", FuncRequest(LFUN_SELFINSERT)); + kbmap->bind("KP_Enter", FuncRequest(LFUN_BREAKPARAGRAPH)); + //kbmap->bind("KP_1", FuncRequest(LFUN_SELFINSERT)); + //kbmap->bind("KP_2", FuncRequest(LFUN_SELFINSERT)); + //kbmap->bind("KP_3", FuncRequest(LFUN_SELFINSERT)); + //kbmap->bind("KP_4", FuncRequest(LFUN_SELFINSERT)); + //kbmap->bind("KP_5", FuncRequest(LFUN_SELFINSERT)); + //kbmap->bind("KP_6", FuncRequest(LFUN_SELFINSERT)); + //kbmap->bind("KP_Add", FuncRequest(LFUN_SELFINSERT)); + //kbmap->bind("KP_7", FuncRequest(LFUN_SELFINSERT)); + //kbmap->bind("KP_8", FuncRequest(LFUN_SELFINSERT)); + //kbmap->bind("KP_9", FuncRequest(LFUN_SELFINSERT)); + //kbmap->bind("KP_Divide", FuncRequest(LFUN_SELFINSERT)); + //kbmap->bind("KP_Multiply", FuncRequest(LFUN_SELFINSERT)); + //kbmap->bind("KP_Subtract", FuncRequest(LFUN_SELFINSERT)); + kbmap->bind("KP_Right", FuncRequest(LFUN_RIGHT)); + kbmap->bind("KP_Left", FuncRequest(LFUN_LEFT)); + kbmap->bind("KP_Up", FuncRequest(LFUN_UP)); + kbmap->bind("KP_Down", FuncRequest(LFUN_DOWN)); + kbmap->bind("KP_Home", FuncRequest(LFUN_HOME)); + kbmap->bind("KP_End", FuncRequest(LFUN_END)); + kbmap->bind("KP_Prior", FuncRequest(LFUN_PRIOR)); + kbmap->bind("KP_Next", FuncRequest(LFUN_NEXT)); + + kbmap->bind("C-Tab", FuncRequest(LFUN_CELL_SPLIT)); + kbmap->bind("S-Tab", FuncRequest(LFUN_CELL_BACKWARD)); + kbmap->bind("S-ISO_Left_Tab", FuncRequest(LFUN_CELL_BACKWARD)); } @@ -406,25 +406,25 @@ void LyX::deadKeyBindings(kb_keymap * kb { // bindKeyings for transparent handling of deadkeys // The keysyms are gotten from XFree86 X11R6 - kbmap->bind("~C-~S-~M-dead_acute", LFUN_ACUTE); - kbmap->bind("~C-~S-~M-dead_breve", LFUN_BREVE); - kbmap->bind("~C-~S-~M-dead_caron", LFUN_CARON); - kbmap->bind("~C-~S-~M-dead_cedilla", LFUN_CEDILLA); - kbmap->bind("~C-~S-~M-dead_abovering", LFUN_CIRCLE); - kbmap->bind("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX); - kbmap->bind("~C-~S-~M-dead_abovedot", LFUN_DOT); - kbmap->bind("~C-~S-~M-dead_grave", LFUN_GRAVE); - kbmap->bind("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT); - kbmap->bind("~C-~S-~M-dead_macron", LFUN_MACRON); + kbmap->bind("~C-~S-~M-dead_acute", FuncRequest(LFUN_ACUTE)); + kbmap->bind("~C-~S-~M-dead_breve", FuncRequest(LFUN_BREVE)); + kbmap->bind("~C-~S-~M-dead_caron", FuncRequest(LFUN_CARON)); + kbmap->bind("~C-~S-~M-dead_cedilla", FuncRequest(LFUN_CEDILLA)); + kbmap->bind("~C-~S-~M-dead_abovering", FuncRequest(LFUN_CIRCLE)); + kbmap->bind("~C-~S-~M-dead_circumflex", FuncRequest(LFUN_CIRCUMFLEX)); + kbmap->bind("~C-~S-~M-dead_abovedot", FuncRequest(LFUN_DOT)); + kbmap->bind("~C-~S-~M-dead_grave", FuncRequest(LFUN_GRAVE)); + kbmap->bind("~C-~S-~M-dead_doubleacute", FuncRequest(LFUN_HUNG_UMLAUT)); + kbmap->bind("~C-~S-~M-dead_macron", FuncRequest(LFUN_MACRON)); // nothing with this name // kbmap->bind("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON); - kbmap->bind("~C-~S-~M-dead_tilde", LFUN_TILDE); - kbmap->bind("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT); + kbmap->bind("~C-~S-~M-dead_tilde", FuncRequest(LFUN_TILDE)); + kbmap->bind("~C-~S-~M-dead_diaeresis", FuncRequest(LFUN_UMLAUT)); // nothing with this name either... - //kbmap->bind("~C-~S-~M-dead_underbar", LFUN_UNDERBAR); - kbmap->bind("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT); - kbmap->bind("~C-~S-~M-dead_tie", LFUN_TIE); - kbmap->bind("~C-~S-~M-dead_ogonek", LFUN_OGONEK); + //kbmap->bind("~C-~S-~M-dead_underbar", FuncRequest(LFUN_UNDERBAR)); + kbmap->bind("~C-~S-~M-dead_belowdot", FuncRequest(LFUN_UNDERDOT)); + kbmap->bind("~C-~S-~M-dead_tie", FuncRequest(LFUN_TIE)); + kbmap->bind("~C-~S-~M-dead_ogonek",FuncRequest(LFUN_OGONEK)); } Index: src/lyxfunc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v retrieving revision 1.505 diff -u -p -r1.505 lyxfunc.C --- src/lyxfunc.C 21 Sep 2003 18:57:13 -0000 1.505 +++ src/lyxfunc.C 21 Sep 2003 22:39:49 -0000 @@ -194,30 +194,30 @@ void LyXFunc::processKeySym(LyXKeySymPtr // cancel and meta-fake keys. RVDK_PATCH_5 cancel_meta_seq.reset(); - int action = cancel_meta_seq.addkey(keysym, state); - lyxerr[Debug::KEY] << "action first set to [" << action << ']' << endl; + FuncRequest func = cancel_meta_seq.addkey(keysym, state); + lyxerr[Debug::KEY] << "action first set to [" << func.action << ']' << endl; // When not cancel or meta-fake, do the normal lookup. // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards. // Mostly, meta_fake_bit = key_modifier::none. RVDK_PATCH_5. - if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) { + if ((func.action != LFUN_CANCEL) && (func.action != LFUN_META_FAKE)) { // remove Caps Lock and Mod2 as a modifiers - action = keyseq.addkey(keysym, (state | meta_fake_bit)); + func = keyseq.addkey(keysym, (state | meta_fake_bit)); lyxerr[Debug::KEY] << "action now set to [" - << action << ']' << endl; + << func.action << ']' << endl; } // Dont remove this unless you know what you are doing. meta_fake_bit = key_modifier::none; // can this happen now ? - if (action == LFUN_NOACTION) { - action = LFUN_PREFIX; + if (func.action == LFUN_NOACTION) { + func = FuncRequest(LFUN_PREFIX); } if (lyxerr.debugging(Debug::KEY)) { lyxerr << "Key [action=" - << action << "][" + << func.action << "][" << keyseq.print() << ']' << endl; } @@ -233,19 +233,20 @@ void LyXFunc::processKeySym(LyXKeySymPtr // Maybe user can only reach the key via holding down shift. // Let's see. But only if shift is the only modifier - if (action == LFUN_UNKNOWN_ACTION && state == key_modifier::shift) { + if (func.action == LFUN_UNKNOWN_ACTION && + state == key_modifier::shift) { lyxerr[Debug::KEY] << "Trying without shift" << endl; - action = keyseq.addkey(keysym, key_modifier::none); - lyxerr[Debug::KEY] << "Action now " << action << endl; + func = keyseq.addkey(keysym, key_modifier::none); + lyxerr[Debug::KEY] << "Action now " << func.action << endl; } - if (action == LFUN_UNKNOWN_ACTION) { + if (func.action == LFUN_UNKNOWN_ACTION) { // Hmm, we didn't match any of the keysequences. See // if it's normal insertable text not already covered // by a binding if (keysym->isText() && keyseq.length() == 1) { lyxerr[Debug::KEY] << "isText() is true, inserting." << endl; - action = LFUN_SELFINSERT; + func = FuncRequest(LFUN_SELFINSERT); } else { lyxerr[Debug::KEY] << "Unknown, !isText() - giving up" << endl; owner->message(_("Unknown function.")); @@ -253,7 +254,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr } } - if (action == LFUN_SELFINSERT) { + if (func.action == LFUN_SELFINSERT) { if (encoded_last_key != 0) { string arg; arg += encoded_last_key; @@ -264,7 +265,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr << argument << "']" << endl; } } else { - dispatch(FuncRequest(kb_action(action))); + dispatch(func); } } @@ -803,7 +804,8 @@ FuncStatus LyXFunc::getStatus(FuncReques // solution, we consider only the first action of the sequence if (ev.action == LFUN_SEQUENCE) { // argument contains ';'-terminated commands - flag = getStatus(FuncRequest(lyxaction.LookupFunc(token(ev.argument, ';', 0)))); +#warning LyXAction arguements not handled here. + flag = getStatus(FuncRequest(lyxaction.lookupFunc(token(ev.argument, ';', 0)))); } return flag; @@ -812,14 +814,14 @@ FuncStatus LyXFunc::getStatus(FuncReques void LyXFunc::dispatch(string const & s, bool verbose) { - int const action = lyxaction.LookupFunc(s); + FuncRequest func = lyxaction.lookupFunc(s); - if (action == LFUN_UNKNOWN_ACTION) { + if (func.action == LFUN_UNKNOWN_ACTION) { owner->message(bformat(_("Unknown function (%1$s)"), s)); return; } - dispatch(FuncRequest(kb_action(action)), verbose); + dispatch(func, verbose); } @@ -847,10 +849,13 @@ namespace { } //namespace anon -void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) +void LyXFunc::dispatch(FuncRequest const & func, bool verbose) { - lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << ev.action - <<"] arg[" << ev.argument << ']' << endl; + string argument = func.argument; + kb_action action = func.action; + + lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << action + <<"] arg[" << argument << ']' << endl; // we have not done anything wrong yet. errorstat = false; @@ -865,11 +870,8 @@ void LyXFunc::dispatch(FuncRequest const selection_possible = false; - string argument = ev.argument; - kb_action action = ev.action; - // We cannot use this function here - if (getStatus(ev).disabled()) { + if (getStatus(func).disabled()) { lyxerr[Debug::ACTION] << "LyXFunc::dispatch: " << lyxaction.getActionName(action) << " [" << action << "] is disabled at this location" @@ -885,7 +887,7 @@ void LyXFunc::dispatch(FuncRequest const { Cursor cursor; buildCursor(cursor, *view()); - if (cursor.dispatch(FuncRequest(ev, view())) == DISPATCHED) { + if (cursor.dispatch(FuncRequest(func, view())) == DISPATCHED) { lyxerr << "dispatched by Cursor::dispatch()\n"; goto exit_with_message; } @@ -917,7 +919,7 @@ void LyXFunc::dispatch(FuncRequest const // if we've just done LFUN_ESCAPE (which // injects an LFUN_PARAGRAPH_UPDATE) if (action == LFUN_PARAGRAPH_UPDATE) { - view()->dispatch(ev); + view()->dispatch(func); goto exit_with_message; } @@ -1439,8 +1441,8 @@ void LyXFunc::dispatch(FuncRequest const break; case LFUN_DIALOG_SHOW: { - string const name = ev.getArg(0); - string data = trim(ev.argument.substr(name.size())); + string const name = func.getArg(0); + string data = trim(func.argument.substr(name.size())); if (name == "character") { data = freefont2string(); @@ -1505,7 +1507,7 @@ void LyXFunc::dispatch(FuncRequest const InsetBase * inset = owner->getDialogs().getOpenInset(name); if (inset) { FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE, - ev.argument); + func.argument); inset->localDispatch(fr); } else if (name == "paragraph") { dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE)); @@ -1658,9 +1660,9 @@ void LyXFunc::dispatch(FuncRequest const default: // Then if it was none of the above // Trying the BufferView::pimpl dispatch: - if (!view()->dispatch(ev)) + if (!view()->dispatch(func)) lyxerr << "A truly unknown func [" - << lyxaction.getActionName(ev.action) << "]!" + << lyxaction.getActionName(func.action) << "]!" << endl; break; } // end of switch @@ -1676,22 +1678,23 @@ exit_with_message: } // If we executed a mutating lfun, mark the buffer as dirty - if (!getStatus(ev).disabled() - && !lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer) - && !lyxaction.funcHasFlag(ev.action, LyXAction::ReadOnly)) + if (!getStatus(func).disabled() + && !lyxaction.funcHasFlag(func.action, LyXAction::NoBuffer) + && !lyxaction.funcHasFlag(func.action, LyXAction::ReadOnly)) view()->buffer()->markDirty(); } - sendDispatchMessage(getMessage(), ev, verbose); + sendDispatchMessage(getMessage(), func, verbose); } -void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & ev, bool verbose) +void LyXFunc::sendDispatchMessage(string const & msg, + FuncRequest const & func, bool verbose) { owner->updateMenubar(); owner->updateToolbar(); - if (ev.action == LFUN_SELFINSERT || !verbose) { + if (func.action == LFUN_SELFINSERT || !verbose) { lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl; if (!msg.empty()) owner->message(msg); @@ -1702,23 +1705,23 @@ void LyXFunc::sendDispatchMessage(string if (!dispatch_msg.empty()) dispatch_msg += ' '; - string comname = lyxaction.getActionName(ev.action); + string comname = lyxaction.getActionName(func.action); bool argsadded = false; - if (!ev.argument.empty()) { - if (ev.action != LFUN_UNKNOWN_ACTION) { - comname += ' ' + ev.argument; + if (!func.argument.empty()) { + if (func.action != LFUN_UNKNOWN_ACTION) { + comname += ' ' + func.argument; argsadded = true; } } - string const shortcuts = toplevel_keymap->findbinding(ev.action); + string const shortcuts = toplevel_keymap->findbinding(func); if (!shortcuts.empty()) { comname += ": " + shortcuts; - } else if (!argsadded && !ev.argument.empty()) { - comname += ' ' + ev.argument; + } else if (!argsadded && !func.argument.empty()) { + comname += ' ' + func.argument; } if (!comname.empty()) { Index: src/paragraph.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v retrieving revision 1.325 diff -u -p -r1.325 paragraph.C --- src/paragraph.C 19 Sep 2003 07:25:36 -0000 1.325 +++ src/paragraph.C 21 Sep 2003 22:39:49 -0000 @@ -726,7 +726,7 @@ string const corrected_env(string const output += env; return output + "}"; } - + } // namespace anon Index: src/frontends/LyXView.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/LyXView.C,v retrieving revision 1.34 diff -u -p -r1.34 LyXView.C --- src/frontends/LyXView.C 21 Sep 2003 18:57:14 -0000 1.34 +++ src/frontends/LyXView.C 21 Sep 2003 22:39:50 -0000 @@ -191,4 +191,3 @@ void LyXView::dispatch(FuncRequest const r.setView(view().get()); getLyXFunc().dispatch(r); } -10 Index: src/frontends/gtk/GMenubar.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/GMenubar.C,v retrieving revision 1.4 diff -u -p -r1.4 GMenubar.C --- src/frontends/gtk/GMenubar.C 21 Sep 2003 18:57:14 -0000 1.4 +++ src/frontends/gtk/GMenubar.C 21 Sep 2003 22:39:50 -0000 @@ -179,11 +179,11 @@ void GMenubar::onSubMenuActivate(MenuIte break; case MenuItem::Command: { + #warning Bindings are not inserted into the menu labels here. (Lgb) FuncStatus const flag = view_->getLyXFunc().getStatus(i->func()); - bool on, off; - on = flag.onoff(true); - off = flag.onoff(false); + bool on = flag.onoff(true); + bool off = flag.onoff(false); if (on || off) { gmenu->items().push_back( Index: src/frontends/qt2/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ChangeLog,v retrieving revision 1.585 diff -u -p -r1.585 ChangeLog --- src/frontends/qt2/ChangeLog 21 Sep 2003 18:57:14 -0000 1.585 +++ src/frontends/qt2/ChangeLog 21 Sep 2003 22:39:51 -0000 @@ -1,7 +1,7 @@ 2003-09-21 Lars Gullik Bjønnes <[EMAIL PROTECTED]> * QtView.C (activated): change to take a FuncRequest, not a slot - anymore. + anymore. * QLToolbar.C (update): adjust (add): change to take a FuncRequest Index: src/frontends/qt2/QLPopupMenu.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLPopupMenu.C,v retrieving revision 1.25 diff -u -p -r1.25 QLPopupMenu.C --- src/frontends/qt2/QLPopupMenu.C 21 Sep 2003 18:57:14 -0000 1.25 +++ src/frontends/qt2/QLPopupMenu.C 21 Sep 2003 22:39:51 -0000 @@ -34,21 +34,19 @@ string const getLabel(MenuItem const & m string const shortcut = mi.shortcut(); string label = subst(mi.label(), "&", "&&"); - if (shortcut.empty()) - return label; - - string::size_type pos = label.find(shortcut); - if (pos == string::npos) - return label; - label.insert(pos, 1, '&'); - + if (!shortcut.empty()) { + string::size_type pos = label.find(shortcut); + if (pos != string::npos) + label.insert(pos, 1, '&'); + } + if (mi.kind() == MenuItem::Command) { string const binding(mi.binding()); if (!binding.empty()) { label += '\t' + binding; } } - + return label; }
-- Lgb