>>>>> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:
Angus> Jean-Marc Lasgouttes wrote: >> What would be wrong with static std::string const >> printKeysym(LyXKeySym const & key, key_modifier::state mod); Angus> Feels good to me. Go for it. OK, here is the updated patch (with some untested code for gtk). I'll commit it. JMarc
Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.1847 diff -u -p -r1.1847 ChangeLog --- src/ChangeLog 26 Mar 2004 08:27:13 -0000 1.1847 +++ src/ChangeLog 26 Mar 2004 13:54:24 -0000 @@ -1,3 +1,10 @@ +2004-03-26 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * kbsequence.C (print): adjust + + * kbmap.C (printKeySym): rename and change signature + (printKey): use LyXKeySym::print() + 2004-03-26 Martin Vermeer <[EMAIL PROTECTED]> * undo.C: add using std::advance to compile for stlport Index: src/kbmap.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/kbmap.C,v retrieving revision 1.51 diff -u -p -r1.51 kbmap.C --- src/kbmap.C 6 Oct 2003 15:42:15 -0000 1.51 +++ src/kbmap.C 26 Mar 2004 13:54:24 -0000 @@ -30,12 +30,12 @@ using std::endl; using std::string; -string const kb_keymap::printKeysym(LyXKeySymPtr key, +string const kb_keymap::printKeySym(LyXKeySym const & key, key_modifier::state mod) { string buf; - string const s = key->getSymbolName(); + string const s = key.getSymbolName(); if (mod & key_modifier::shift) buf += "S-"; @@ -51,7 +51,7 @@ string const kb_keymap::printKeysym(LyXK string const kb_keymap::printKey(kb_key const & key) const { - return printKeysym(key.code, key.mod.first); + return key.code->print(key.mod.first); } Index: src/kbmap.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/kbmap.h,v retrieving revision 1.32 diff -u -p -r1.32 kbmap.h --- src/kbmap.h 6 Oct 2003 15:42:18 -0000 1.32 +++ src/kbmap.h 26 Mar 2004 13:54:24 -0000 @@ -64,8 +64,8 @@ public: * @param key the key as a keysym * @param mod the modifiers */ - static std::string const printKeysym(LyXKeySymPtr key, - key_modifier::state mod); + static std::string const printKeySym(LyXKeySym const & key, + key_modifier::state mod); typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair; Index: src/kbsequence.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/kbsequence.C,v retrieving revision 1.36 diff -u -p -r1.36 kbsequence.C --- src/kbsequence.C 6 Oct 2003 15:42:18 -0000 1.36 +++ src/kbsequence.C 26 Mar 2004 13:54:24 -0000 @@ -137,7 +137,7 @@ string const kb_sequence::print() const KeySequence::size_type i, length = sequence.size(); for (i = 0; i < length; ++i) { - buf += kb_keymap::printKeysym(sequence[i], modifiers[i].first); + buf += kb_keymap::printKeySym(*sequence[i], modifiers[i].first); // append a blank if (i + 1 < length) { Index: src/frontends/LyXKeySym.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/LyXKeySym.h,v retrieving revision 1.14 diff -u -p -r1.14 LyXKeySym.h --- src/frontends/LyXKeySym.h 6 Oct 2003 15:42:44 -0000 1.14 +++ src/frontends/LyXKeySym.h 26 Mar 2004 13:54:24 -0000 @@ -14,6 +14,8 @@ #include <string> +#include "key_state.h" + /** * This is a base class for representing a keypress. * Each frontend has to implement this to provide @@ -47,6 +49,12 @@ public: * This relies on user to use the right encoding. */ virtual char getISOEncoded(std::string const & encoding) const = 0; + + /** + * Return a string describing the KeySym with modifier mod. + * This should use the native UI format when applicable + */ + virtual std::string const print(key_modifier::state mod) const = 0; }; Index: src/frontends/gtk/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/ChangeLog,v retrieving revision 1.24 diff -u -p -r1.24 ChangeLog --- src/frontends/gtk/ChangeLog 24 Mar 2004 17:03:02 -0000 1.24 +++ src/frontends/gtk/ChangeLog 26 Mar 2004 13:54:24 -0000 @@ -1,3 +1,8 @@ +2004-03-26 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * GLyXKeySym.C (print): new method; print a keysym using + kb_keymap::printKeySym (should use some native gtk method instead) + 2004-03-24 Angus Leeming <[EMAIL PROTECTED]> * GMenubar.C (submenuDisabled, onSubMenuActivate): compile fixes Index: src/frontends/gtk/GLyXKeySym.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/GLyXKeySym.C,v retrieving revision 1.3 diff -u -p -r1.3 GLyXKeySym.C --- src/frontends/gtk/GLyXKeySym.C 6 Oct 2003 15:42:49 -0000 1.3 +++ src/frontends/gtk/GLyXKeySym.C 26 Mar 2004 13:54:24 -0000 @@ -14,6 +14,8 @@ #include <gdk/gdkkeysyms.h> #include "GLyXKeySym.h" +#include "kbmap.h" + using std::string; @@ -89,6 +91,12 @@ char GLyXKeySym::getISOEncoded(string co c = 0; } return c; +} + + +string const GLyXKeySym::print(key_modifier::state mod) const +{ + return kb_keymap::printKeySym(*this, mod); } Index: src/frontends/gtk/GLyXKeySym.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/GLyXKeySym.h,v retrieving revision 1.4 diff -u -p -r1.4 GLyXKeySym.h --- src/frontends/gtk/GLyXKeySym.h 6 Oct 2003 15:42:49 -0000 1.4 +++ src/frontends/gtk/GLyXKeySym.h 26 Mar 2004 13:54:24 -0000 @@ -27,6 +27,7 @@ public: virtual bool isModifier() const; virtual std::string getSymbolName() const; virtual char getISOEncoded(std::string const & encoding) const; + virtual std::string const print(key_modifier::state mod) const; private: unsigned int keyval_; }; Index: src/frontends/qt2/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ChangeLog,v retrieving revision 1.649 diff -u -p -r1.649 ChangeLog --- src/frontends/qt2/ChangeLog 17 Mar 2004 21:21:46 -0000 1.649 +++ src/frontends/qt2/ChangeLog 26 Mar 2004 13:54:24 -0000 @@ -1,3 +1,7 @@ +2004-03-25 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * QLyXKeySym.C (print): new method; print a KeySym using Qt syntax + 2004-03-17 Angus Leeming <[EMAIL PROTECTED]> * Dialogs2.C, lyx_gui.C: remove mention of the forks dialog. Index: src/frontends/qt2/QLyXKeySym.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLyXKeySym.C,v retrieving revision 1.29 diff -u -p -r1.29 QLyXKeySym.C --- src/frontends/qt2/QLyXKeySym.C 6 Oct 2003 15:42:50 -0000 1.29 +++ src/frontends/qt2/QLyXKeySym.C 26 Mar 2004 13:54:24 -0000 @@ -16,6 +16,7 @@ #include "qlkey.h" #include "qt_helpers.h" +#include <qaccel.h> #include <qevent.h> #include <qtextcodec.h> @@ -164,6 +165,22 @@ char QLyXKeySym::getISOEncoded(string co if (lyxerr.debugging()) lyxerr[Debug::KEY] << "ISOEncoded returning value " << int(c) << endl; return c; +} + + +string const QLyXKeySym::print(key_modifier::state mod) const +{ + int tmpkey = key_; + + + if (mod & key_modifier::shift) + tmpkey += Qt::SHIFT; + if (mod & key_modifier::ctrl) + tmpkey += Qt::CTRL; + if (mod & key_modifier::alt) + tmpkey += Qt::ALT; + + return fromqstr(QAccel::keyToString(tmpkey)); } Index: src/frontends/qt2/QLyXKeySym.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLyXKeySym.h,v retrieving revision 1.16 diff -u -p -r1.16 QLyXKeySym.h --- src/frontends/qt2/QLyXKeySym.h 6 Oct 2003 15:42:50 -0000 1.16 +++ src/frontends/qt2/QLyXKeySym.h 26 Mar 2004 13:54:24 -0000 @@ -54,6 +54,10 @@ public: * This relies on user to use the right encoding. */ virtual char getISOEncoded(std::string const & encoding) const; + + /// + virtual std::string const print(key_modifier::state mod) const; + /// int key() const { return key_; Index: src/frontends/xforms/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v retrieving revision 1.883 diff -u -p -r1.883 ChangeLog --- src/frontends/xforms/ChangeLog 17 Mar 2004 21:21:46 -0000 1.883 +++ src/frontends/xforms/ChangeLog 26 Mar 2004 13:54:25 -0000 @@ -1,3 +1,8 @@ +2004-03-26 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * XLyXKeySym.C (print): new method; print a keysym using + kb_keymap::printKeySym. + 2004-03-17 Angus Leeming <[EMAIL PROTECTED]> * Dialogs2.C, FormForks.[Ch], Makefile.am: Index: src/frontends/xforms/XLyXKeySym.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XLyXKeySym.C,v retrieving revision 1.11 diff -u -p -r1.11 XLyXKeySym.C --- src/frontends/xforms/XLyXKeySym.C 6 Oct 2003 15:42:57 -0000 1.11 +++ src/frontends/xforms/XLyXKeySym.C 26 Mar 2004 13:54:25 -0000 @@ -13,6 +13,7 @@ #include "XLyXKeySym.h" #include "debug.h" +#include "kbmap.h" #include <X11/keysym.h> @@ -97,6 +98,12 @@ char XLyXKeySym::getISOEncoded(string co c = 0; } return c; +} + + +string const XLyXKeySym::print(key_modifier::state mod) const +{ + return kb_keymap::printKeySym(*this, mod); } Index: src/frontends/xforms/XLyXKeySym.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XLyXKeySym.h,v retrieving revision 1.11 diff -u -p -r1.11 XLyXKeySym.h --- src/frontends/xforms/XLyXKeySym.h 6 Oct 2003 15:42:57 -0000 1.11 +++ src/frontends/xforms/XLyXKeySym.h 26 Mar 2004 13:54:25 -0000 @@ -45,6 +45,9 @@ public: virtual char getISOEncoded(std::string const & encoding) const; /// + virtual std::string const print(key_modifier::state mod) const; + + /// unsigned int keysym() const { return keysym_; }