From 3332e1fbc85ca7e2268da4073b59ad14e948044b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 14 Aug 2002 10:16:05 +0000 Subject: [PATCH] small cleanups git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4963 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 ++++ src/LyXAction.C | 42 +++++++++++----------------- src/LyXAction.h | 2 +- src/frontends/xforms/Toolbar_pimpl.C | 15 ++++------ src/lyxfunc.C | 16 ++--------- 5 files changed, 31 insertions(+), 49 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 1a660f4b0f..5f493709ec 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,9 @@ +2002-08-13 André Pönitz + + * LyXAction.[Ch]: + * lyxfunc.C: further cleaning + 2002-08-13 André Pönitz * funcrequest.h: new constructor diff --git a/src/LyXAction.C b/src/LyXAction.C index 9999d1312b..ba7b6aeae0 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -16,8 +16,6 @@ #include "gettext.h" #include "support/lstrings.h" -#include - using std::ostream; using std::endl; using std::pair; @@ -492,10 +490,10 @@ int LyXAction::getPseudoAction(kb_action action, string const & arg) } -pair LyXAction::retrieveActionArg(int pseudo) const +FuncRequest LyXAction::retrieveActionArg(int pseudo) const { if (!isPseudoAction(pseudo)) - return make_pair(static_cast(pseudo), string()); + return FuncRequest(static_cast(pseudo)); pseudo_map::const_iterator pit = lyx_pseudo_map.find(pseudo); @@ -503,11 +501,11 @@ pair LyXAction::retrieveActionArg(int pseudo) const lyxerr[Debug::ACTION] << "Found the pseudoaction: [" << pit->second.action << '|' << pit->second.argument << "]\n"; - return make_pair(pit->second.action, pit->second.argument); + return pit->second; } else { lyxerr << "Lyx Error: Unrecognized pseudo-action " << pseudo << endl; - return make_pair(LFUN_UNKNOWN_ACTION, string()); + return FuncRequest(LFUN_UNKNOWN_ACTION); } } @@ -537,36 +535,28 @@ int LyXAction::LookupFunc(string const & func) string const LyXAction::getActionName(int action) const { - kb_action ac; - string arg; - boost::tie(ac, arg) = retrieveActionArg(action); - - if (!arg.empty()) - arg.insert(0, " "); + FuncRequest ev = retrieveActionArg(action); + if (!ev.argument.empty()) + ev.argument.insert(0, " "); - info_map::const_iterator iit = lyx_info_map.find(ac); + info_map::const_iterator iit = lyx_info_map.find(ev.action); - if (iit != lyx_info_map.end()) { - string ret(iit->second.name); - ret += arg; - return ret; - } else - return string(); + if (iit != lyx_info_map.end()) + return iit->second.name + ev.argument; + return string(); } string const LyXAction::helpText(int pseudoaction) const { - kb_action action; - string arg; - boost::tie(action, arg) = retrieveActionArg(pseudoaction); + FuncRequest ev = retrieveActionArg(pseudoaction); string help; - info_map::const_iterator ici = lyx_info_map.find(action); + info_map::const_iterator ici = lyx_info_map.find(ev.action); if (ici != lyx_info_map.end()) { if (lyxerr.debugging(Debug::ACTION)) { - lyxerr << "Action: " << action << '\n'; + lyxerr << "Action: " << ev.action << '\n'; lyxerr << " name: " << ici->second.name << '\n'; lyxerr << " attrib: " @@ -581,9 +571,9 @@ string const LyXAction::helpText(int pseudoaction) const if (help.empty()) { help = _("No description available!"); - } else if (!arg.empty()) { + } else if (!ev.argument.empty()) { help += ' '; - help += arg; + help += ev.argument; } return help; diff --git a/src/LyXAction.h b/src/LyXAction.h index a2672a07eb..906a9a4476 100644 --- a/src/LyXAction.h +++ b/src/LyXAction.h @@ -72,7 +72,7 @@ public: * Given a pseudo-action, return the real action and * associated argument */ - std::pair retrieveActionArg(int pseudo) const; + FuncRequest retrieveActionArg(int pseudo) const; /// Search for an existent pseudoaction, return -1 if it doesn't exist. int searchActionArg(kb_action action, string const & arg) const; diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index 582ac897ea..7e14480b9d 100644 --- a/src/frontends/xforms/Toolbar_pimpl.C +++ b/src/frontends/xforms/Toolbar_pimpl.C @@ -251,14 +251,11 @@ extern "C" { void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) { string xpm_name; - - kb_action act; - string arg; - boost::tie(act, arg) = lyxaction.retrieveActionArg(action); + FuncRequest ev = lyxaction.retrieveActionArg(action); - string const name = lyxaction.getActionName(act); - if (!arg.empty()) - xpm_name = subst(name + ' ' + arg, ' ','_'); + string const name = lyxaction.getActionName(ev.action); + if (!ev.argument.empty()) + xpm_name = subst(name + ' ' + ev.argument, ' ','_'); else xpm_name = name; @@ -271,8 +268,8 @@ void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) return; } - if (act == LFUN_INSERT_MATH && !arg.empty()) { - char const ** pixmap = get_pixmap_from_symbol(arg.c_str(), + if (ev.action == LFUN_INSERT_MATH && !ev.argument.empty()) { + char const ** pixmap = get_pixmap_from_symbol(ev.argument.c_str(), buttonwidth, height); if (pixmap) { diff --git a/src/lyxfunc.C b/src/lyxfunc.C index d427716ac5..549018fdda 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -90,8 +90,6 @@ #include "support/path.h" #include "support/lyxfunctional.h" -#include - #include #include #include @@ -120,9 +118,6 @@ extern tex_accent_struct get_accent(kb_action action); extern void ShowLatexLog(); -/* === globals =========================================================== */ - - LyXFunc::LyXFunc(LyXView * o) : owner(o), keyseq(toplevel_keymap.get(), toplevel_keymap.get()), @@ -274,10 +269,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, FuncStatus LyXFunc::getStatus(int ac) const { - kb_action action; - string arg; - boost::tie(action, arg) = lyxaction.retrieveActionArg(ac); - return getStatus(FuncRequest(view(), action, arg)); + return getStatus(lyxaction.retrieveActionArg(ac)); } @@ -703,10 +695,7 @@ void LyXFunc::dispatch(string const & s, bool verbose) void LyXFunc::dispatch(int ac, bool verbose) { - kb_action action; - string arg; - boost::tie(action, arg) = lyxaction.retrieveActionArg(ac); - dispatch(FuncRequest(view(), action, arg), verbose); + dispatch(lyxaction.retrieveActionArg(ac), verbose); } @@ -1872,5 +1861,6 @@ string const LyXFunc::view_status_message() BufferView * LyXFunc::view() const { + lyx::Assert(owner); return owner->view().get(); } -- 2.39.2