]> git.lyx.org Git - lyx.git/commitdiff
fixes/cleanup to dispatch/getStatus stuff; fixes the bug where unwanted function...
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 12 Jan 2002 20:00:47 +0000 (20:00 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 12 Jan 2002 20:00:47 +0000 (20:00 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3346 a592a061-630c-0410-9148-cb99ea01b6c8

22 files changed:
src/BufferView_pimpl.C
src/ChangeLog
src/LyXAction.C
src/LyXAction.h
src/XFormsView.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormMathsPanel.C
src/frontends/xforms/FormMathsPanel.h
src/frontends/xforms/FormMathsStyle.C
src/frontends/xforms/Menubar_pimpl.C
src/frontends/xforms/Toolbar_pimpl.C
src/kbmap.C
src/kbmap.h
src/kbsequence.C
src/kbsequence.h
src/lyx_main.C
src/lyxfunc.C
src/lyxfunc.h
src/lyxserver.C
src/mathed/ChangeLog
src/mathed/math_support.C
src/vc-backend.C

index ade488ad3a8fa5bb5eeb96148af496fdc908daf7..1efca6de2f60ea1bf17e1c460137c80d3a86da9d 100644 (file)
@@ -2624,13 +2624,13 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        if (cursor.par()->params().spaceTop() == VSpace(VSpace::NONE)) {
                                lt->setParagraph
                                        (bv_,
-                                        cursor.par()->params().lineTop(),      
+                                        cursor.par()->params().lineTop(),
                                         cursor.par()->params().lineBottom(),
-                                        cursor.par()->params().pagebreakTop(), 
+                                        cursor.par()->params().pagebreakTop(),
                                         cursor.par()->params().pagebreakBottom(),
                                         VSpace(VSpace::DEFSKIP), cursor.par()->params().spaceBottom(),
-                                        cursor.par()->params().spacing(), 
-                                        cursor.par()->params().align(), 
+                                        cursor.par()->params().spacing(),
+                                        cursor.par()->params().align(),
                                         cursor.par()->params().labelWidthString(), 1);
                                //update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                        } 
@@ -3279,9 +3279,8 @@ void BufferView::Pimpl::specialChar(InsetSpecialChar::Kind kind)
                update(lt, BufferView::SELECT|BufferView::FITCUR);
                InsetSpecialChar * new_inset = 
                        new InsetSpecialChar(kind);
-               insertInset(new_inset);
-               // Ok, what happens here if we are unable to insert
-               // the inset? Leak it?
+               if (!insertInset(new_inset))
+                       delete new_inset;
        }
 }
 
index 731201d5387210f8104fbaeab25d427de9c3cff8..9de7590097096ecda26bb3130c2e31265efb45a5 100644 (file)
@@ -1,3 +1,43 @@
+2002-01-12  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * LyXAction.[Ch]: move isPseudoAction to the C file, since nobody
+       should need to care about that.
+
+       * lyxfunc.C (verboseDispatch): simplify a bit
+       (getStatus): have a version which takes a pseudoaction, and
+       another which requires a (kb_action,string).
+
+       * LyXAction.C (retrieveActionArg): make it work also when action
+       is not a pseudo-action.
+       (getActionName): simplify a bit
+       (helpText): 
+
+2002-01-11  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * lyxfunc.C (verboseDispatch): new families of methods with
+       several ways to specify a command and a bool to indicate whether
+       the command name and shortcut should be displayed in minibuffer
+       (eventually, we could extend that to a finer bitmask like
+       SHORTCUT|CMDNAME|CMDRESULT, or whatever).
+       (dispatch): the pristine dispatch command which just, well,
+       dispatchs! Note it still sets its result to minibuffer; I'm not
+       sure we want that.
+
+       * lyxfunc.h: remove setHintMessage
+
+       * vc-backend.C: use LFUN_MENURELOAD instead of "buffer-reload"
+
+2002-01-10  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * BufferView_pimpl.C (specialChar): delete new inset if we have
+       not been able to insert it.
+
+       * kbmap.C: revert to using int instead of kb_action, since all we
+       are dealing with is pseudo-actions.
+
+       * LyXAction.C (searchActionArg): change to return int instead of
+       kb_action, since the result is a pseudoaction.
+
 2002-01-12  Dekel Tsur  <dekelts@tau.ac.il>
 
        * buffer.C (insertErtContents): Fix (partially) the font bug.
index 26b5459413113f2473bdc5d25a354b81791636b2..1762e55c645554f74b840ec31fdb30fc89441df3 100644 (file)
@@ -42,6 +42,15 @@ using std::endl;
 // These are globals. 
 LyXAction lyxaction;
 
+// Small helper function
+inline
+bool isPseudoAction(int a)
+{ 
+       return a > int(LFUN_LASTACTION); 
+}
+     
+
+
 void LyXAction::newFunc(kb_action action, string const & name,
                        string const & helpText, unsigned int attrib)
 {
@@ -448,7 +457,7 @@ LyXAction::LyXAction()
 
 // Search for an existent pseudoaction, return LFUN_UNKNOWN_ACTION
 // if it doesn't exist.
-kb_action LyXAction::searchActionArg(kb_action action, string const & arg) const
+int LyXAction::searchActionArg(kb_action action, string const & arg) const
 {
        arg_map::const_iterator pit = lyx_arg_map.find(action);
 
@@ -476,7 +485,7 @@ kb_action LyXAction::searchActionArg(kb_action action, string const & arg) const
                              << action << '|' 
                              << arg << "] = " << aci->second << endl;
 
-       return kb_action(aci->second);
+       return aci->second;
 }
 
 
@@ -516,12 +525,15 @@ kb_action LyXAction::retrieveActionArg(int pseudo, string & arg) const
 {
        arg.erase(); // clear it to be sure.
 
+       if (!isPseudoAction(pseudo)) 
+               return static_cast<kb_action>(pseudo);
+       
        pseudo_map::const_iterator pit = lyx_pseudo_map.find(pseudo);
 
        if (pit != lyx_pseudo_map.end()) {
                lyxerr[Debug::ACTION] << "Found the pseudoaction: ["
                                      << pit->second.action << '|'
-                                     << pit->second.arg << '\n';
+                                     << pit->second.arg << "]\n";
                arg = pit->second.arg;
                return pit->second.action;
        } else {
@@ -601,12 +613,11 @@ string const LyXAction::getActionName(int action) const
 {
        kb_action ac;
        string arg;
-       if (isPseudoAction(action)) {
-               ac = retrieveActionArg(action, arg);
-               arg.insert(0, " ");
-       } else
-               ac = static_cast<kb_action>(action);
 
+       ac = retrieveActionArg(action, arg);
+       if (!arg.empty())
+               arg.insert(0, " ");
+       
        info_map::const_iterator iit = lyx_info_map.find(ac);
 
        if (iit != lyx_info_map.end()) {
@@ -625,10 +636,7 @@ string const LyXAction::helpText(int pseudoaction) const
        string help, arg;
        kb_action action;
 
-       if (isPseudoAction(pseudoaction)) 
-               action = retrieveActionArg(pseudoaction, arg);
-       else 
-               action = static_cast<kb_action>(pseudoaction);
+       action = retrieveActionArg(pseudoaction, arg);
 
        info_map::const_iterator ici = lyx_info_map.find(action);
        if (ici != lyx_info_map.end()) {
index c48d599e226be5da25cf891ee0a0b315746c7b16..c5fbf527cea2d1ec638ce5f3ab0655037fb66bd0 100644 (file)
@@ -63,9 +63,9 @@ public:
        ///
        LyXAction();
     
-       /** Returns an action tag from a string. Returns kb_action.
-         Include arguments in func_name ONLY if you
-         want to create new pseudo actions. */
+       /** Returns an pseudoaction from a string
+         If you include arguments in func_name, a new psedoaction will be 
+         created if needed. */
        int LookupFunc(string const & func_name) const; 
 
         /** Returns an action tag which name is the most similar to a string.
@@ -83,11 +83,8 @@ public:
        kb_action retrieveActionArg(int i, string & arg) const;
     
        /// Search for an existent pseudoaction, return -1 if it doesn't exist.
-       kb_action searchActionArg(kb_action action, string const & arg) const;
+       int searchActionArg(kb_action action, string const & arg) const;
 
-       /// Check if a value is a pseudo-action. 
-       bool isPseudoAction(int) const;
-    
        /// Return the name associated with command
        string const getActionName(int action) const;
 
@@ -126,14 +123,4 @@ private:
        mutable arg_map lyx_arg_map;
 };
      
-
-/* --------------------   Inlines  ------------------ */
-    
-     
-inline
-bool LyXAction::isPseudoAction(int a) const
-{ 
-       return a > int(LFUN_LASTACTION); 
-}
-     
 #endif
index e331f5dc7d770902684bbdc2acf1cb4db22a2754..ee8c67f1ece47ac892336ac616fa733a71f8d2e0 100644 (file)
@@ -58,7 +58,7 @@ XFormsView::XFormsView(int width, int height)
 
        // Connect the minibuffer signals
        minibuffer->stringReady.connect(SigC::slot(getLyXFunc(),
-                                                  &LyXFunc::miniDispatch));
+                                               &LyXFunc::miniDispatch));
        minibuffer->timeout.connect(SigC::slot(getLyXFunc(),
                                               &LyXFunc::initMiniBuffer));
        
index 5c638d5982bab102d5125f9cb25d93f4ac06655d..5c57ea32fd6841da380900d4b661fa8d85e7730a 100644 (file)
@@ -1,3 +1,13 @@
+2002-01-12  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * Toolbar_pimpl.C (setPixmap): simplify a bit
+
+2002-01-10  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * Toolbar_pimpl.C (ToolbarCB): 
+       * Menubar_pimpl.C (MenuCallback): use verboseDispatch instead of
+       dispatch.
+
 2002-01-12  Allan Rae  <rae@lyx.org>
 
        * FormTabular.C (FormTabular): Fix Purify UMR.
index cc44f170b62b3fbbd2cc772d61ccaddd8814acb5..9df7700444c742b3d1911ce852bc3274d5424a17 100644 (file)
@@ -301,11 +301,13 @@ void FormMathsPanel::insertSymbol(string const & sym) const
        lv_->getLyXFunc()->dispatch(LFUN_INSERT_MATH, '\\' + sym);
 }
 
-void FormMathsPanel::dispatchFunc(string const & funcode) const
+
+void FormMathsPanel::dispatchFunc(kb_action action) const
 {
-       lv_->getLyXFunc()->dispatch(funcode);
+       lv_->getLyXFunc()->dispatch(action);
 }
 
+
 void FormMathsPanel::mathDisplay() const
 {
        lv_->getLyXFunc()->dispatch(LFUN_MATH_DISPLAY);
index a6c0d96de02ab3a2efad30f198853a259aa08c34..13614b62a60a078431bfbb6f40fb307fec2beeda 100644 (file)
@@ -12,6 +12,7 @@
 #ifndef FORM_MATHSPANEL_H
 #define FORM_MATHSPANEL_H
 
+#include "commandtags.h"
 #include <boost/smart_ptr.hpp>
 
 #ifdef __GNUG_
@@ -64,7 +65,7 @@ public:
        /// dispatch a symbol insert 
        void insertSymbol(string const & sym) const;
        /// dispatch an LFUN:
-       void dispatchFunc(string const & funcode) const;
+       void dispatchFunc(kb_action action) const;
 private:
        /// Pointer to the actual instantiation of the ButtonController.
        virtual xformsBC & bc();
index 50ed4959ea568d353671c3b2df5c52347309bffa..07b28a4c127eb2e94dbc17e9000914f36f503c10 100644 (file)
@@ -20,7 +20,7 @@
 #include "form_maths_style.h"
 
 extern char * latex_mathstyle[];
-extern char * latex_mathfontcmds[];
+extern kb_action latex_mathfontcmds[];
 
 FormMathsStyle::FormMathsStyle(LyXView * lv, Dialogs * d,
                               FormMathsPanel const & p)
index 67a5439767ac3e09f17d8c7ddf3721b5f6396694..868554508e511f3cf729c7cc199e21a89f07920f 100644 (file)
@@ -582,7 +582,7 @@ void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button)
                // If the action value is too low, then it is not a
                // valid action, but something else.
                if (choice >= action_offset + 1) {
-                       view->getLyXFunc()->dispatch(choice - action_offset);
+                       view->getLyXFunc()->verboseDispatch(choice - action_offset, true);
                } else {
                        lyxerr[Debug::GUI]
                                << "MenuCallback: ignoring bogus action "
index 5a82a991bc02b660352a6ff4151eeb02f804683d..0440a290ef6cc697fa81bd133fe1b300fce45188 100644 (file)
@@ -302,10 +302,7 @@ void ToolbarCB(FL_OBJECT * ob, long ac)
 {
        XFormsView * owner = static_cast<XFormsView *>(ob->u_vdata);
        
-       string res = owner->getLyXFunc()->dispatch(int(ac));
-       if (!res.empty())
-               lyxerr[Debug::GUI] << "ToolbarCB: Function returned: " 
-                                  << res << endl;
+       owner->getLyXFunc()->verboseDispatch(int(ac), true);
 }
 
 
@@ -322,20 +319,15 @@ extern "C" {
 
 void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height)
 {
-       string name;
        string arg;
        string xpm_name;
-       kb_action act;
 
-       if (lyxaction.isPseudoAction(action)) {
-               act = lyxaction.retrieveActionArg(action, arg);
-               name = lyxaction.getActionName(act);
+       const kb_action act = lyxaction.retrieveActionArg(action, arg);
+       string const name = lyxaction.getActionName(act);
+       if (!arg.empty())
                xpm_name = subst(name + ' ' + arg, ' ','_');
-       } else {
-               act = (kb_action)action;
-               name = lyxaction.getActionName(action);
+       else 
                xpm_name = name;
-       }
 
        string fullname = LibFileSearch("images", xpm_name, "xpm");
 
index 7a147621d801f04f33d16b91f9968ea751cb8a10..26f7bbe66a13a923b4e0075e1499a9f4bca4b9eb 100644 (file)
@@ -17,6 +17,7 @@
 #endif
 
 #include "kbmap.h"
+#include "commandtags.h"
 #include "kbsequence.h"
 #include "debug.h"
 
@@ -71,7 +72,7 @@ string const kb_keymap::printKey(kb_key const & key) const
 }
 
 
-string::size_type kb_keymap::bind(string const & seq, kb_action action)
+string::size_type kb_keymap::bind(string const & seq, int action)
 {
        if (lyxerr.debugging(Debug::KBMAP)) {
                lyxerr << "BIND: Sequence `"
@@ -94,7 +95,7 @@ string::size_type kb_keymap::bind(string const & seq, kb_action action)
 }
 
 
-kb_action kb_keymap::lookup(unsigned int key,
+int kb_keymap::lookup(unsigned int key,
                      unsigned int mod, kb_sequence * seq) const
 {
        if (table.empty()) {
@@ -144,7 +145,7 @@ string const kb_keymap::print() const
 }
 
 
-void kb_keymap::defkey(kb_sequence * seq, kb_action action, unsigned int r)
+void kb_keymap::defkey(kb_sequence * seq, int action, unsigned int r)
 {
        unsigned int const code = seq->sequence[r];
        if (code == NoSymbol) return;
@@ -193,7 +194,7 @@ void kb_keymap::defkey(kb_sequence * seq, kb_action action, unsigned int r)
 }
 
 
-string const kb_keymap::findbinding(kb_action act, string const & prefix) const
+string const kb_keymap::findbinding(int act, string const & prefix) const
 {
        string res;
        if (table.empty()) return res;
index 27b62fd1eb9dca98bf9ed8a9bb1e38a76c429ce5..7852e586c5e4580c6c8755aff55d88bf6f036fe0 100644 (file)
@@ -16,8 +16,6 @@
 #include <list>
 #include <boost/smart_ptr.hpp>
 
-#include "commandtags.h"
-
 #include "LString.h"
 
 class kb_sequence;
@@ -30,7 +28,7 @@ public:
         * @return 0 on success, or position in string seq where error
         * occurs.
         */
-       string::size_type bind(string const & seq, kb_action action);
+       string::size_type bind(string const & seq, int action);
 
        /// print all available keysyms
        string const print() const;
@@ -42,11 +40,11 @@ public:
         * @param seq the current key sequence so far
         * @return the action / LFUN_PREFIX / LFUN_UNKNOWN_ACTION
         */
-       kb_action lookup(unsigned int key,
-               unsigned int mod, kb_sequence * seq) const;
+       int lookup(unsigned int key,
+                  unsigned int mod, kb_sequence * seq) const;
 
        /// Given an action, find all keybindings.
-       string const findbinding(kb_action action,
+       string const findbinding(int action,
                                 string const & prefix = string()) const;
 
        /**
@@ -72,7 +70,7 @@ private:
                boost::shared_ptr<kb_keymap> table;
                
                /// Action for !prefix keys
-               kb_action action;
+               int action;
        };
 
 
@@ -80,7 +78,7 @@ private:
         * Define an action for a key sequence.
         * @param r internal recursion level
         */
-       void defkey(kb_sequence * seq, kb_action action, unsigned int r = 0);
+       void defkey(kb_sequence * seq, int action, unsigned int r = 0);
        
        ///  Returns a string of the given key
        string const printKey(kb_key const & key) const;
index afb091ee46d62c0593a3983a7e57b80c1acd6752..db1759489895f069edde5cfcf784c1e6a897b0e2 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "kbsequence.h"
 #include "kbmap.h"
+#include "commandtags.h"
 #include "debug.h"
 
 using std::endl;
@@ -29,7 +30,7 @@ using std::endl;
 enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
 
 
-kb_action kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod)
+int kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod)
 {
        // adding a key to a deleted sequence
        // starts a new sequence
index 255adb2d298f7d86f81f70084391fbc4df09b72c..8da2f19e4674e7e5dd054813956328ca73c1e179 100644 (file)
@@ -15,8 +15,6 @@
 #include <vector>
 #include "LString.h"
 
-#include "commandtags.h"
-
 class kb_keymap;
 
 /// Holds a key sequence and the current and standard keymaps
@@ -37,7 +35,7 @@ public:
         * @param nmod which modifiers to mask out for equality test
         * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
         */
-       kb_action addkey(unsigned int key, unsigned int mod, unsigned int nmod = 0);
+       int addkey(unsigned int key, unsigned int mod, unsigned int nmod = 0);
 
        /**
         * Add a sequence of keys from a string to the sequence
index 2aac45735efff5dcd9fc6f005341c115138f12c6..dae669925425512ec5ce4001d353e2d94a709714 100644 (file)
@@ -167,7 +167,7 @@ LyX::LyX(int * argc, char * argv[])
 
                // otherwise, let the GUI handle the batch command
                lyxGUI->regBuf(last_loaded);
-               lyxGUI->getLyXView()->getLyXFunc()->dispatch(batch_command);
+               lyxGUI->getLyXView()->getLyXFunc()->verboseDispatch(batch_command, false);
 
                // fall through...
        }
index 3c4bd85c6aae1cb1e96b801b8f7c0d8e8494dbc8..c76ebbdd9ccf82295d657bb4c23415bf1232df5d 100644 (file)
@@ -158,9 +158,6 @@ MiniBufferController mb_ctrl;
 
 /* === globals =========================================================== */
 
-// Initialization of static member var
-bool LyXFunc::show_sc = true;
-
 
 LyXFunc::LyXFunc(LyXView * o)
        : owner(o),
@@ -325,45 +322,37 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
        if (action == LFUN_SELFINSERT) {
                // This is very X dependent.
                unsigned int c = keysym;
+               string argument;
                
                c = kb_keymap::getiso(c);
 
                if (c > 0)
                        argument = static_cast<char>(c);
+               
+               dispatch(LFUN_SELFINSERT, argument);
                lyxerr[Debug::KEY] << "SelfInsert arg[`"
                                   << argument << "']" << endl;
        }
-       
-        bool tmp_sc = show_sc;
-       show_sc = false;
-       dispatch(action, argument);
-       show_sc = tmp_sc;
-       
-       //return 0;
+       else
+               verboseDispatch(action, false);
 } 
 
 
 FuncStatus LyXFunc::getStatus(int ac) const
 {
-       return getStatus(ac, string());
+       kb_action action;
+       string argument;
+       action = lyxaction.retrieveActionArg(ac, argument);
+       return getStatus(action, argument);
 }
 
-FuncStatus LyXFunc::getStatus(int ac,
-                             string const & not_to_use_arg) const
+
+FuncStatus LyXFunc::getStatus(kb_action action,
+                             string const & argument) const
 {
-       kb_action action;
        FuncStatus flag;
-       string argument;
        Buffer * buf = owner->buffer();
        
-       if (lyxaction.isPseudoAction(ac)) 
-               action = lyxaction.retrieveActionArg(ac, argument);
-       else {
-               action = static_cast<kb_action>(ac);
-               if (!not_to_use_arg.empty())
-                       argument = not_to_use_arg; // except here
-       }
-       
        if (action == LFUN_UNKNOWN_ACTION) {
                setErrorMessage(N_("Unknown action"));
                return flag.unknown(true);
@@ -435,7 +424,7 @@ FuncStatus LyXFunc::getStatus(int ac,
                disable = true;
                if (owner->view()->theLockingInset()) {
                        FuncStatus ret;
-                       ret.disabled(true);
+                       //ret.disabled(true);
                        if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
                                ret = static_cast<InsetTabular *>
                                        (owner->view()->theLockingInset())->
@@ -760,12 +749,12 @@ void LyXFunc::miniDispatch(string const & s)
        string s2(frontStrip(strip(s))); 
  
        if (!s2.empty()) {
-               dispatch(s2);
+               verboseDispatch(s2, true);
        }
 }
 
 
-string const LyXFunc::dispatch(string const & s
+void const LyXFunc::verboseDispatch(string const & s, bool show_sc
 {
        // Split command string into command and argument
        string cmd;
@@ -778,57 +767,107 @@ string const LyXFunc::dispatch(string const & s)
                string const msg = string(_("Unknown function ("))
                        + cmd + ")";
                owner->message(msg);
-               return string();
        } else {
-               return dispatch(action, arg);
+               verboseDispatch(action, show_sc);
        } 
 }
 
 
-string const LyXFunc::dispatch(int ac,
-                              string const & do_not_use_this_arg)
+void const LyXFunc::verboseDispatch(int ac, bool show_sc) 
 {
-       lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
-                             <<"] arg[" << do_not_use_this_arg << "]" << endl;
-       
        string argument;
        kb_action action;
         
-        // we have not done anything wrong yet.
-        errorstat = false;
-       dispatch_buffer.erase();
+       // get the real action and argument
+       action = lyxaction.retrieveActionArg(ac, argument);
+
+       verboseDispatch(action, argument, show_sc);
+}
+
+
+
+void const LyXFunc::verboseDispatch(kb_action action,
+                                   string const & argument, bool show_sc)
+{
+       string res = dispatch(action, argument);
+
+       commandshortcut.erase();
        
-       // if action is a pseudo-action, we need the real action
-       if (lyxaction.isPseudoAction(ac)) {
-               string tmparg;
-               action = static_cast<kb_action>
-                       (lyxaction.retrieveActionArg(ac, tmparg));
-               if (!tmparg.empty())
-                       argument = tmparg;
+       if (lyxrc.display_shortcuts && show_sc) {
+               if (action != LFUN_SELFINSERT) {
+                       // Put name of command and list of shortcuts
+                       // for it in minibuffer
+                       string comname = lyxaction.getActionName(action);
+                       
+                       int pseudoaction = action;
+                       bool argsadded = false;
+                       
+                       if (!argument.empty()) {
+                               // the pseudoaction is useful for the bindings
+                               pseudoaction = 
+                                       lyxaction.searchActionArg(action,
+                                                                 argument);
+
+                               if (pseudoaction == LFUN_UNKNOWN_ACTION) {
+                                       pseudoaction = action;
+                               } else {
+                                       comname += " " + argument;
+                                       argsadded = true;
+                               }
+                       }
+
+                       string const shortcuts =
+                               toplevel_keymap->findbinding(pseudoaction);
+
+                       if (!shortcuts.empty()) {
+                               comname += ": " + shortcuts;
+                       } else if (!argsadded && !argument.empty()) {
+                               comname += " " + argument;
+                       }
+
+                       if (!comname.empty()) {
+                               comname = strip(comname);
+                               commandshortcut = "(" + comname + ')';
+                       }
+               }
+        }
+
+       if (res.empty()) {
+               if (!commandshortcut.empty()) {
+                       owner->getMiniBuffer()->addSet(commandshortcut);
+               }
        } else {
-               action = static_cast<kb_action>(ac);
-               if (!do_not_use_this_arg.empty())
-                       argument = do_not_use_this_arg; // except here
+               owner->getMiniBuffer()->addSet(' ' + commandshortcut);
        }
+}
+
+
+string const LyXFunc::dispatch(kb_action action, string argument)
+{
+       lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << action
+                             <<"] arg[" << argument << "]" << endl;
+
+        // we have not done anything wrong yet.
+        errorstat = false;
+       dispatch_buffer.erase();
 
 #ifdef NEW_DISPATCHER
        // We try do call the most specific dispatcher first:
        //  1. the lockinginset's dispatch
        //  2. the bufferview's dispatch
        //  3. the lyxview's dispatch
 #endif
-       
+
        selection_possible = false;
-       
+
        if (owner->view()->available())
                owner->view()->hideCursor();
 
        // We cannot use this function here
-       if (getStatus(ac, do_not_use_this_arg).disabled()) {
+       if (getStatus(action, argument).disabled()) {
                lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: "
-                      << lyxaction.getActionName(ac)
-                      << " [" << ac << "] is disabled at this location"
+                      << lyxaction.getActionName(action)
+                      << " [" << action << "] is disabled at this location"
                       << endl;
                goto exit_with_message;
        }
@@ -838,7 +877,8 @@ string const LyXFunc::dispatch(int ac,
                if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
                                     (!keyseq.deleted())))
                {
-                       if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){
+                       if ((action == LFUN_UNKNOWN_ACTION)
+                           && argument.empty()){
                                argument = keyseq.getiso();
                        }
                        // Undo/Redo is a bit tricky for insets.
@@ -1509,7 +1549,7 @@ string const LyXFunc::dispatch(int ac,
                while (argument.find(';') != string::npos) {
                        string first;
                        argument = split(argument, first, ';');
-                       dispatch(first);
+                       verboseDispatch(first, false);
                }
        }
        break;
@@ -1588,65 +1628,10 @@ string const LyXFunc::dispatch(int ac,
 
 exit_with_message:
 
-       commandshortcut.erase();
-       
-       if (lyxrc.display_shortcuts && show_sc) {
-               if (action != LFUN_SELFINSERT) {
-                       // Put name of command and list of shortcuts
-                       // for it in minibuffer
-                       string comname = lyxaction.getActionName(action);
-
-                       kb_action pseudoaction = action;
-                       bool argsadded = false;
-
-                       if (!argument.empty()) {
-                               // If we have the command with argument, 
-                               // this is better
-                               pseudoaction = 
-                                       lyxaction.searchActionArg(action,
-                                                                 argument);
-
-                               if (pseudoaction == -1) {
-                                       pseudoaction = action;
-                               } else {
-                                       comname += " " + argument;
-                                       argsadded = true;
-                               }
-                       }
-
-                       string const shortcuts =
-                               toplevel_keymap->findbinding(pseudoaction);
-
-                       if (!shortcuts.empty()) {
-                               comname += ": " + shortcuts;
-                       } else if (!argsadded && !argument.empty()) {
-                               comname += " " + argument;
-                       }
-
-                       if (!comname.empty()) {
-                               comname = strip(comname);
-                               commandshortcut = "(" + comname + ')';
-
-                               // Here we could even add a small pause,
-                               // to annoy the user and make him learn
-                               // the shortcuts.
-                               // No! That will just annoy, not teach
-                               // anything. The user will read the messages
-                               // if they are interested. (Asger)
-                       }
-               }
-        }
-
        string const res = getMessage();
 
-       if (res.empty()) {
-               if (!commandshortcut.empty()) {
-                       owner->getMiniBuffer()->addSet(commandshortcut);
-               }
-       } else {
-               string const msg(_(res) + ' ' + commandshortcut);
-               owner->message(msg);
-       }
+       if (!res.empty())
+               owner->message(_(res));
 
        return res;
 }
index 69df71c3287940b2861ccd1f0443696989aac144..c74eecf984f501baefde589ccfcece36e6231b1a 100644 (file)
@@ -31,13 +31,22 @@ public:
        LyXFunc(LyXView *);
     
        /// LyX dispatcher, executes lyx actions.
-       string const dispatch(int action, string const & arg = string());
-                        
-       /// The same but uses the name of a lyx command.
-       string const dispatch(string const & cmd);
+       string const dispatch(kb_action ac, string argument = string());
 
-       ///
-       void miniDispatch(string const & cmd);
+       /// The same as dispatch, but also shows shortcuts and command
+       /// name in minibuffer if show_sc is true (more to come?) 
+       void const LyXFunc::verboseDispatch(kb_action action,
+                                           string const & argument,
+                                           bool show_sc);
+       
+       /// Same as above, using a pseudoaction as argument
+       void const LyXFunc::verboseDispatch(int ac, bool show_sc);
+
+       /// Same as above, when the command is provided as a string
+       void const LyXFunc::verboseDispatch(string const & s, bool show_sc);
+
+       /// 
+       void LyXFunc::miniDispatch(string const & s);
 
        ///
        void initMiniBuffer();
@@ -45,12 +54,12 @@ public:
        ///
        void processKeySym(KeySym k, unsigned int state);
 
-       /// we need one internall which is called from inside LyXAction and
+       /// we need one internal which is called from inside LyXAction and
        /// can contain the string argument.
        FuncStatus getStatus(int ac) const;
        ///
-       FuncStatus getStatus(int ac
-                            string const & not_to_use_arg) const;
+       FuncStatus getStatus(kb_action action
+                            string const & argument = string()) const;
        
        /// The last key was meta
        bool wasMetaKey() const;
@@ -65,8 +74,7 @@ public:
         string const getMessage() const { return dispatch_buffer; }
        /// Handle a accented char keysequenze
        void handleKeyFunc(kb_action action);
-       /// Should a hint message be displayed?
-       void setHintMessage(bool);
+
 private:
        ///
        LyXView * owner;
@@ -116,8 +124,6 @@ private:
        ///
        LyXText * TEXT(bool) const;
        ///
-       //  This is the same for all lyxfunc objects
-       static bool show_sc;
 };
      
      
@@ -130,10 +136,4 @@ bool LyXFunc::wasMetaKey() const
 }
      
 
-inline
-void LyXFunc::setHintMessage(bool hm) 
-{ 
-       show_sc = hm;
-}
-
 #endif
index d0454ebb61f6aa5579440bc32ed143440c2c5879..ba3e0856713dcda4bff3e9da40c60af9b3295dd4 100644 (file)
@@ -501,7 +501,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
                        // connect to the lyxfunc in the single LyXView we
                        // support currently. (Lgb)
 
-                       int action = lyxaction.LookupFunc(cmd);
+                       kb_action action = static_cast<kb_action>(lyxaction.LookupFunc(cmd));
                        //int action = -1;
                        string rval, buf;
                    
index 10b8e7ae89ef0fbdc1bbfbe21bc1bb631f452b10..a5382b887113e4e2f2ee7a676a551aac10090abb 100644 (file)
@@ -1,3 +1,8 @@
+2002-01-10  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * math_support.C: change latex_mathfontcmds to an array of
+       kb_action. 
+
 2002-01-11  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * math_exfuncinset.C: remove using std::ostream declaration.
index 59daa5128653c05876345cd637219600d2309dc3..c76a6dc7d0f99896e73ab4ed6d17ae92f810911c 100644 (file)
@@ -12,6 +12,7 @@
 #include "math_parser.h"
 #include "Painter.h"
 #include "debug.h"
+#include "commandtags.h"
 
 using std::map;
 using std::endl;
@@ -781,9 +782,9 @@ char const * latex_mathstyle[] = {
        "textstyle", "displaystyle", "scriptstyle", "scriptscriptstyle" 
 };
 
-char const * latex_mathfontcmds[] = {
-       "font-bold", "font-emph", "font-roman", "font-code", "font-sans",
-       "font-ital", "font-noun", "font-frak", "font-free", "font-default"
+kb_action latex_mathfontcmds[] = {
+       LFUN_BOLD, LFUN_EMPH, LFUN_ROMAN, LFUN_CODE, LFUN_SANS,
+       LFUN_ITAL, LFUN_NOUN, LFUN_FRAK, LFUN_FREE, LFUN_DEFAULT
 };
 
 
index 198fc89cf687d564c7dd6c6f16ea110fd8f3b2a0..794c81fc4aec00630a3f1f1b519e73547c2d532e 100644 (file)
@@ -150,7 +150,7 @@ void RCS::registrer(string const & msg)
        cmd += OnlyFilename(owner_->fileName());
        cmd += "\"";
        doVCCommand(cmd, owner_->filepath);
-       owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
+       owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
 }
 
 
@@ -158,7 +158,7 @@ void RCS::checkIn(string const & msg)
 {
        doVCCommand("ci -q -u -m\"" + msg + "\" \""
                    + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
-       owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
+       owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
 }
 
 
@@ -167,7 +167,7 @@ void RCS::checkOut()
        owner_->markLyxClean();
        doVCCommand("co -q -l \""
                    + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
-       owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
+       owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
 }
 
 
@@ -178,7 +178,7 @@ void RCS::revert()
        // We ignore changes and just reload!
        owner_->markLyxClean();
        owner_->getUser()->owner()
-               ->getLyXFunc()->dispatch("buffer-reload");
+               ->getLyXFunc()->dispatch(LFUN_MENURELOAD);
 }
 
 
@@ -280,7 +280,7 @@ void CVS::registrer(string const & msg)
 {
        doVCCommand("cvs -q add -m \"" + msg + "\" \""
                    + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
-       owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
+       owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
 }
 
 
@@ -289,7 +289,7 @@ void CVS::checkIn(string const & msg)
        doVCCommand("cvs -q commit -m \"" + msg + "\" \""
                    + OnlyFilename(owner_->fileName()) + "\"",
                    owner_->filepath);
-       owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
+       owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
 }
 
 
@@ -310,7 +310,7 @@ void CVS::revert()
                    owner_->filepath);
        owner_->markLyxClean();
        owner_->getUser()->owner()
-               ->getLyXFunc()->dispatch("buffer-reload");
+               ->getLyXFunc()->dispatch(LFUN_MENURELOAD);
 }