From 8b8741cd5d7e960c5663911f8b69972419f6d37b Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Sat, 12 Jan 2002 20:00:47 +0000 Subject: [PATCH] fixes/cleanup to dispatch/getStatus stuff; fixes the bug where unwanted function names appear in minibuffer git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3346 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 13 +- src/ChangeLog | 40 +++++ src/LyXAction.C | 32 ++-- src/LyXAction.h | 21 +-- src/XFormsView.C | 2 +- src/frontends/xforms/ChangeLog | 10 ++ src/frontends/xforms/FormMathsPanel.C | 6 +- src/frontends/xforms/FormMathsPanel.h | 3 +- src/frontends/xforms/FormMathsStyle.C | 2 +- src/frontends/xforms/Menubar_pimpl.C | 2 +- src/frontends/xforms/Toolbar_pimpl.C | 18 +-- src/kbmap.C | 9 +- src/kbmap.h | 14 +- src/kbsequence.C | 3 +- src/kbsequence.h | 4 +- src/lyx_main.C | 2 +- src/lyxfunc.C | 207 ++++++++++++-------------- src/lyxfunc.h | 38 ++--- src/lyxserver.C | 2 +- src/mathed/ChangeLog | 5 + src/mathed/math_support.C | 7 +- src/vc-backend.C | 14 +- 22 files changed, 241 insertions(+), 213 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index ade488ad3a..1efca6de2f 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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; } } diff --git a/src/ChangeLog b/src/ChangeLog index 731201d538..9de7590097 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,43 @@ +2002-01-12 Jean-Marc Lasgouttes + + * 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 + + * 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 + + * 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 * buffer.C (insertErtContents): Fix (partially) the font bug. diff --git a/src/LyXAction.C b/src/LyXAction.C index 26b5459413..1762e55c64 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -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(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(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(pseudoaction); + action = retrieveActionArg(pseudoaction, arg); info_map::const_iterator ici = lyx_info_map.find(action); if (ici != lyx_info_map.end()) { diff --git a/src/LyXAction.h b/src/LyXAction.h index c48d599e22..c5fbf527ce 100644 --- a/src/LyXAction.h +++ b/src/LyXAction.h @@ -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 diff --git a/src/XFormsView.C b/src/XFormsView.C index e331f5dc7d..ee8c67f1ec 100644 --- a/src/XFormsView.C +++ b/src/XFormsView.C @@ -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)); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 5c638d5982..5c57ea32fd 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,13 @@ +2002-01-12 Jean-Marc Lasgouttes + + * Toolbar_pimpl.C (setPixmap): simplify a bit + +2002-01-10 Jean-Marc Lasgouttes + + * Toolbar_pimpl.C (ToolbarCB): + * Menubar_pimpl.C (MenuCallback): use verboseDispatch instead of + dispatch. + 2002-01-12 Allan Rae * FormTabular.C (FormTabular): Fix Purify UMR. diff --git a/src/frontends/xforms/FormMathsPanel.C b/src/frontends/xforms/FormMathsPanel.C index cc44f170b6..9df7700444 100644 --- a/src/frontends/xforms/FormMathsPanel.C +++ b/src/frontends/xforms/FormMathsPanel.C @@ -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); diff --git a/src/frontends/xforms/FormMathsPanel.h b/src/frontends/xforms/FormMathsPanel.h index a6c0d96de0..13614b62a6 100644 --- a/src/frontends/xforms/FormMathsPanel.h +++ b/src/frontends/xforms/FormMathsPanel.h @@ -12,6 +12,7 @@ #ifndef FORM_MATHSPANEL_H #define FORM_MATHSPANEL_H +#include "commandtags.h" #include #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(); diff --git a/src/frontends/xforms/FormMathsStyle.C b/src/frontends/xforms/FormMathsStyle.C index 50ed4959ea..07b28a4c12 100644 --- a/src/frontends/xforms/FormMathsStyle.C +++ b/src/frontends/xforms/FormMathsStyle.C @@ -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) diff --git a/src/frontends/xforms/Menubar_pimpl.C b/src/frontends/xforms/Menubar_pimpl.C index 67a5439767..868554508e 100644 --- a/src/frontends/xforms/Menubar_pimpl.C +++ b/src/frontends/xforms/Menubar_pimpl.C @@ -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 " diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index 5a82a991bc..0440a290ef 100644 --- a/src/frontends/xforms/Toolbar_pimpl.C +++ b/src/frontends/xforms/Toolbar_pimpl.C @@ -302,10 +302,7 @@ void ToolbarCB(FL_OBJECT * ob, long ac) { XFormsView * owner = static_cast(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"); diff --git a/src/kbmap.C b/src/kbmap.C index 7a147621d8..26f7bbe66a 100644 --- a/src/kbmap.C +++ b/src/kbmap.C @@ -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; diff --git a/src/kbmap.h b/src/kbmap.h index 27b62fd1eb..7852e586c5 100644 --- a/src/kbmap.h +++ b/src/kbmap.h @@ -16,8 +16,6 @@ #include #include -#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 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; diff --git a/src/kbsequence.C b/src/kbsequence.C index afb091ee46..db17594898 100644 --- a/src/kbsequence.C +++ b/src/kbsequence.C @@ -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 diff --git a/src/kbsequence.h b/src/kbsequence.h index 255adb2d29..8da2f19e46 100644 --- a/src/kbsequence.h +++ b/src/kbsequence.h @@ -15,8 +15,6 @@ #include #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 diff --git a/src/lyx_main.C b/src/lyx_main.C index 2aac45735e..dae6699254 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -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... } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 3c4bd85c6a..c76ebbdd9c 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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(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(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 (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 - (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(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; } diff --git a/src/lyxfunc.h b/src/lyxfunc.h index 69df71c328..c74eecf984 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -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 diff --git a/src/lyxserver.C b/src/lyxserver.C index d0454ebb61..ba3e085671 100644 --- a/src/lyxserver.C +++ b/src/lyxserver.C @@ -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(lyxaction.LookupFunc(cmd)); //int action = -1; string rval, buf; diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 10b8e7ae89..a5382b8871 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,8 @@ +2002-01-10 Jean-Marc Lasgouttes + + * math_support.C: change latex_mathfontcmds to an array of + kb_action. + 2002-01-11 Angus Leeming * math_exfuncinset.C: remove using std::ostream declaration. diff --git a/src/mathed/math_support.C b/src/mathed/math_support.C index 59daa51286..c76a6dc7d0 100644 --- a/src/mathed/math_support.C +++ b/src/mathed/math_support.C @@ -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 }; diff --git a/src/vc-backend.C b/src/vc-backend.C index 198fc89cf6..794c81fc4a 100644 --- a/src/vc-backend.C +++ b/src/vc-backend.C @@ -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); } -- 2.39.5