Pseudo functions has irritated me for a long, long time, so I thought
I should see how easy it would be to get rid of them. My thought was
that it would be easier now, since we have this FuncRequest thingie.

Enclosed is a patch that gets rid of the peudo stuff, but it is not
really functional, but shows what kind of changes that will be needed.

Espesially work on the toolbar and the Menubar is needed. (that is the
non-functional bits.)

So if others think this worthwile, I'll continue and fix the remaining
problems, if not I'll just ditch it.

Comments?

18 files changed, 109 insertions(+), 235 deletions(-)

? pseudo.diff
Index: src/LyXAction.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v
retrieving revision 1.182
diff -u -p -r1.182 LyXAction.C
--- src/LyXAction.C	9 Sep 2003 22:13:22 -0000	1.182
+++ src/LyXAction.C	10 Sep 2003 18:05:56 -0000
@@ -344,83 +344,8 @@ LyXAction::LyXAction()
 }
 
 
-int LyXAction::searchActionArg(kb_action action, string const & arg) const
-{
-	arg_map::const_iterator pit = lyx_arg_map.find(action);
-
-	if (pit == lyx_arg_map.end()) {
-		lyxerr[Debug::ACTION] << "Action " << action
-				      << " does not have any pseudo actions."
-				      << endl;
-		return LFUN_UNKNOWN_ACTION;
-	}
-
-	arg_item::const_iterator aci = pit->second.find(arg);
-
-	if (aci == pit->second.end()) {
-		lyxerr[Debug::ACTION]
-			<< "Action " << action
-			<< "does not have any pseudoactions with arg "
-			<< arg << endl;
-		return LFUN_UNKNOWN_ACTION;
-	}
-
-	lyxerr[Debug::ACTION] << "Pseudoaction exists["
-			      << action << '|'
-			      << arg << "] = " << aci->second << endl;
-
-	return aci->second;
-}
-
-
-int LyXAction::getPseudoAction(kb_action action, string const & arg)
-{
-	int const psdaction = searchActionArg(action, arg);
-
-	if (isPseudoAction(psdaction)) return psdaction;
-
-	static unsigned int pseudo_counter = LFUN_LASTACTION;
-
-	// Create new pseudo action.
-	lyx_pseudo_map[++pseudo_counter] = FuncRequest(0, action, arg);
-
-	// First ensure that the action is in lyx_arg_map;
-	lyx_arg_map[action];
-	// get the arg_item map
-	arg_map::iterator ami = lyx_arg_map.find(action);
-	// put the new pseudo function in it
-	ami->second[arg] = pseudo_counter;
-
-	lyxerr[Debug::ACTION] << "Creating new pseudoaction "
-			      << pseudo_counter << " for [" << action
-			      << '|' << arg << "]\n";
-
-	return pseudo_counter;
-}
-
-
-FuncRequest LyXAction::retrieveActionArg(int pseudo) const
-{
-	if (!isPseudoAction(pseudo))
-		return FuncRequest(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.argument << "]" << endl;
-		return pit->second;
-	} else {
-		lyxerr << "Lyx Error: Unrecognized pseudo-action "
-			<< pseudo << endl;
-		return FuncRequest(LFUN_UNKNOWN_ACTION);
-	}
-}
-
-
 // Returns an action tag from a string.
-int LyXAction::LookupFunc(string const & func)
+kb_action LyXAction::LookupFunc(string const & func)
 {
 	string const func2 = trim(func);
 	if (func2.empty()) return LFUN_NOACTION;
@@ -433,25 +358,15 @@ int LyXAction::LookupFunc(string const &
 
 	func_map::const_iterator fit = lyx_func_map.find(actstr);
 
-	if (!argstr.empty() && fit != lyx_func_map.end()) {
-		// might be pseudo (or create one)
-		return getPseudoAction(fit->second, argstr);
-	}
-
 	return fit != lyx_func_map.end() ? fit->second : LFUN_UNKNOWN_ACTION;
 }
 
 
 string const LyXAction::getActionName(int action) const
 {
-	FuncRequest ev = retrieveActionArg(action);
-	if (!ev.argument.empty())
-		ev.argument.insert(string::size_type(0), 1, ' ');
-
-	info_map::const_iterator const it = lyx_info_map.find(ev.action);
-
+	info_map::const_iterator const it = lyx_info_map.find(kb_action(action));
 	if (it != lyx_info_map.end())
-		return it->second.name + ev.argument;
+		return it->second.name;
 	return string();
 }
 
Index: src/LyXAction.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.h,v
retrieving revision 1.25
diff -u -p -r1.25 LyXAction.h
--- src/LyXAction.h	5 Sep 2003 17:22:47 -0000	1.25
+++ src/LyXAction.h	10 Sep 2003 18:05:56 -0000
@@ -44,12 +44,6 @@ public:
 	typedef std::map<string, kb_action> func_map;
 	/// type for map between an action and its info
 	typedef std::map<kb_action, func_info> info_map;
-	/// type for a map between a pseudo-action and its stored action/arg
-	typedef std::map<unsigned int, FuncRequest> pseudo_map;
-	/// map from argument to pseudo-action
-	typedef std::map<string, unsigned int> arg_item;
-	/// map from an action to all its dependent pseudo-actions
-	typedef std::map<kb_action, arg_item> arg_map;
 
 	/// possible "permissions" for an action
 	enum func_attrib {
@@ -66,19 +60,7 @@ public:
 	 * If you include arguments in func_name, a new pseudoaction
 	 * will be created if needed.
 	 */
-	int LookupFunc(string const & func_name);
-
-	/// Returns a pseudo-action given an action and its argument.
-	int getPseudoAction(kb_action action, string const & arg);
-
-	/**
-	 * Given a pseudo-action, return the real action and
-	 * associated argument
-	 */
-	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;
+	kb_action LookupFunc(string const & func_name);
 
 	/// Return the name (and argument) associated with the given (pseudo) action
 	string const getActionName(int action) const;
@@ -114,18 +96,6 @@ private:
 	 * command attributes (ro)
 	 */
 	info_map lyx_info_map;
-
-	/**
-	 * A mapping from the automatically created pseudo action number
-	 * to the real action and its argument.
-	 */
-	pseudo_map lyx_pseudo_map;
-
-	/**
-	 * A (multi) mapping from the lyx action to all the generated
-	 * pseudofuncs and the arguments the action should use.
-	 */
-	arg_map lyx_arg_map;
 };
 
 /// singleton instance
Index: src/MenuBackend.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/MenuBackend.C,v
retrieving revision 1.86
diff -u -p -r1.86 MenuBackend.C
--- src/MenuBackend.C	9 Sep 2003 22:13:22 -0000	1.86
+++ src/MenuBackend.C	10 Sep 2003 18:05:56 -0000
@@ -67,7 +67,8 @@ MenuBackend menubackend;
 
 
 MenuItem::MenuItem(Kind kind, string const & label,
-		   string const & command, bool optional)
+		   string const & command,
+		   string const & argument, bool optional)
 	: kind_(kind), label_(label), optional_(optional)
 {
 	switch (kind) {
@@ -85,9 +86,9 @@ MenuItem::MenuItem(Kind kind, string con
 	case Branches:
 		break;
 	case Command:
-		action_ = lyxaction.LookupFunc(command);
-
-		if (action_ == LFUN_UNKNOWN_ACTION) {
+		func_.action = lyxaction.LookupFunc(command);
+		func_.argument = argument;
+		if (func_.action == LFUN_UNKNOWN_ACTION) {
 			lyxerr << "MenuItem(): LyX command `"
 			       << command << "' does not exist." << endl;
 		}
@@ -102,8 +103,8 @@ MenuItem::MenuItem(Kind kind, string con
 }
 
 
-MenuItem::MenuItem(Kind kind, string const & label, int action, bool optional)
-	: kind_(kind), label_(label), action_(action), submenuname_(),
+MenuItem::MenuItem(Kind kind, string const & label, FuncRequest const & func, bool optional)
+	: kind_(kind), label_(label), func_(func), submenuname_(),
 	  optional_(optional)
 {}
 
@@ -136,7 +137,7 @@ string const MenuItem::binding() const
 
 	// Get the keys bound to this action, but keep only the
 	// first one later
-	string bindings = toplevel_keymap->findbinding(action_);
+	string bindings = toplevel_keymap->findbinding(func_.action);
 
 	if (!bindings.empty()) {
 		return bindings.substr(1, bindings.find(']') - 1);
@@ -156,7 +157,7 @@ Menu & Menu::add(MenuItem const & i, LyX
 	case MenuItem::Command:
 	{
 		FuncStatus status =
-			view->getLyXFunc().getStatus(i.action());
+			view->getLyXFunc().getStatus(i.func());
 		if (status.unknown()
 		    || (status.disabled() && i.optional()))
 			break;
@@ -260,7 +261,7 @@ Menu & Menu::read(LyXLex & lex)
 			lex.next(true);
 			string const command = lex.getString();
 			add(MenuItem(MenuItem::Command, name,
-				     command, optional));
+				     command, string(), optional));
 			optional = false;
 			break;
 		}
@@ -322,7 +323,7 @@ Menu & Menu::read(LyXLex & lex)
 			lex.next(true);
 			string const mname = lex.getString();
 			add(MenuItem(MenuItem::Submenu, mlabel, mname,
-				     optional));
+				     string(), optional));
 			optional = false;
 			break;
 		}
@@ -398,10 +399,7 @@ void expandLastfiles(Menu & tomenu, LyXV
 		string const label = tostr(ii) + ". "
 			+ MakeDisplayPath((*lfit), 30)
 			+ '|' + tostr(ii);
-		int const action = lyxaction.
-			getPseudoAction(LFUN_FILE_OPEN,
-					(*lfit));
-		tomenu.add(MenuItem(MenuItem::Command, label, action), view);
+		tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FILE_OPEN, (*lfit))), view);
 	}
 }
 
@@ -412,7 +410,7 @@ void expandDocuments(Menu & tomenu, LyXV
 
 	if (names.empty()) {
 		tomenu.add(MenuItem(MenuItem::Command, _("No Documents Open!"),
-				    LFUN_NOACTION), view);
+				    FuncRequest(LFUN_NOACTION)), view);
 		return;
 	}
 
@@ -420,12 +418,10 @@ void expandDocuments(Menu & tomenu, LyXV
 	Strings::const_iterator docit = names.begin();
 	Strings::const_iterator end = names.end();
 	for (; docit != end; ++docit, ++ii) {
-		int const action =
-			lyxaction.getPseudoAction(LFUN_SWITCHBUFFER, *docit);
 		string label = MakeDisplayPath(*docit, 20);
 		if (ii < 10)
 			label = tostr(ii) + ". " + label + '|' + tostr(ii);
-		tomenu.add(MenuItem(MenuItem::Command, label, action), view);
+		tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_SWITCHBUFFER, *docit)), view);
 	}
 }
 
@@ -434,7 +430,8 @@ void expandFormats(MenuItem::Kind kind, 
 {
 	if (!view->buffer() && kind != MenuItem::ImportFormats) {
 		tomenu.add(MenuItem(MenuItem::Command,
-				    _("No Documents Open!"), LFUN_NOACTION),
+				    _("No Documents Open!"),
+				    FuncRequest(LFUN_NOACTION)),
 				    view);
 		return;
 	}
@@ -483,9 +480,9 @@ void expandFormats(MenuItem::Kind kind, 
 		}
 		if (!(*fit)->shortcut().empty())
 			label += '|' + (*fit)->shortcut();
-		int const action2 = lyxaction.
-			getPseudoAction(action,	(*fit)->name());
-		tomenu.add(MenuItem(MenuItem::Command, label, action2),
+
+		tomenu.add(MenuItem(MenuItem::Command, label,
+				    FuncRequest(action, (*fit)->name())),
 			   view);
 	}
 }
@@ -495,7 +492,8 @@ void expandFloatListInsert(Menu & tomenu
 {
 	if (!view->buffer()) {
 		tomenu.add(MenuItem(MenuItem::Command,
-				    _("No Documents Open!"), LFUN_NOACTION),
+				    _("No Documents Open!"),
+				    FuncRequest(LFUN_NOACTION)),
 			   view);
 		return;
 	}
@@ -505,10 +503,10 @@ void expandFloatListInsert(Menu & tomenu
 	FloatList::const_iterator cit = floats.begin();
 	FloatList::const_iterator end = floats.end();
 	for (; cit != end; ++cit) {
-		int const action =  lyxaction
-			.getPseudoAction(LFUN_FLOAT_LIST, cit->second.type());
 		tomenu.add(MenuItem(MenuItem::Command,
-				    _(cit->second.listName()), action),
+				    _(cit->second.listName()),
+				    FuncRequest(LFUN_FLOAT_LIST,
+						cit->second.type())),
 			   view);
 	}
 }
@@ -518,7 +516,8 @@ void expandFloatInsert(Menu & tomenu, Ly
 {
 	if (!view->buffer()) {
 		tomenu.add(MenuItem(MenuItem::Command,
-				    _("No Documents Open!"), LFUN_NOACTION),
+				    _("No Documents Open!"),
+				    FuncRequest(LFUN_NOACTION)),
 			   view);
 		return;
 	}
@@ -529,11 +528,10 @@ void expandFloatInsert(Menu & tomenu, Ly
 	FloatList::const_iterator end = floats.end();
 	for (; cit != end; ++cit) {
 		// normal float
-		int const action =
-			lyxaction.getPseudoAction(LFUN_INSET_FLOAT,
-						  cit->second.type());
 		string const label = _(cit->second.name());
-		tomenu.add(MenuItem(MenuItem::Command, label, action),
+		tomenu.add(MenuItem(MenuItem::Command, label,
+				    FuncRequest(LFUN_INSET_FLOAT,
+						cit->second.type())),
 			   view);
 	}
 }
@@ -549,14 +547,14 @@ void expandToc2(Menu & tomenu,
 	int shortcut_count = 0;
 	if (to - from <= max_number_of_items) {
 		for (lyx::toc::Toc::size_type i = from; i < to; ++i) {
-			int const action = toc_list[i].action();
 			string label(4 * max(0, toc_list[i].depth - depth),' ');
 			label += limit_string_length(toc_list[i].str);
 			if (toc_list[i].depth == depth
 			    && ++shortcut_count <= 9) {
 				label += '|' + tostr(shortcut_count);
 			}
-			tomenu.add(MenuItem(MenuItem::Command, label, action));
+			tomenu.add(MenuItem(MenuItem::Command, label,
+					    FuncRequest(toc_list[i].action())));
 		}
 	} else {
 		lyx::toc::Toc::size_type pos = from;
@@ -566,7 +564,6 @@ void expandToc2(Menu & tomenu,
 			       toc_list[new_pos].depth > depth)
 				++new_pos;
 
-			int const action = toc_list[pos].action();
 			string label(4 * max(0, toc_list[pos].depth - depth), ' ');
 			label += limit_string_length(toc_list[pos].str);
 			if (toc_list[pos].depth == depth &&
@@ -575,7 +572,7 @@ void expandToc2(Menu & tomenu,
 
 			if (new_pos == pos + 1) {
 				tomenu.add(MenuItem(MenuItem::Command,
-						    label, action));
+						    label, FuncRequest(toc_list[pos].action())));
 			} else {
 				MenuItem item(MenuItem::Submenu, label);
 				item.submenu(new Menu);
@@ -598,7 +595,8 @@ void expandToc(Menu & tomenu, LyXView co
 
 	if (!view->buffer()) {
 		tomenu.add(MenuItem(MenuItem::Command,
-				    _("No Documents Open!"), LFUN_NOACTION),
+				    _("No Documents Open!"),
+				    FuncRequest(LFUN_NOACTION)),
 			   view);
 		return;
 	}
@@ -618,7 +616,8 @@ void expandToc(Menu & tomenu, LyXView co
 		for (; ccit != eend; ++ccit) {
 			string const label = limit_string_length(ccit->str);
 			menu->add(MenuItem(MenuItem::Command,
-					   label, ccit->action()));
+					   label,
+					   FuncRequest(ccit->action())));
 		}
 		string const & floatName = cit->first;
 		// Is the _(...) really needed here? (Lgb)
@@ -651,9 +650,8 @@ void expandPasteRecent(Menu & tomenu, Ly
 	vector<string>::const_iterator end = selL.end();
 
 	for (unsigned int index = 0; cit != end; ++cit, ++index) {
-		int const action = lyxaction.getPseudoAction(LFUN_PASTE,
-							     tostr(index));
-		tomenu.add(MenuItem(MenuItem::Command, *cit, action));
+		tomenu.add(MenuItem(MenuItem::Command, *cit,
+				    FuncRequest(LFUN_PASTE, tostr(index))));
 	}
 }
 
@@ -670,12 +668,11 @@ void expandBranches(Menu & tomenu, LyXVi
 
 	for (int ii = 1; cit != end; ++cit, ++ii) {
 		string label = cit->getBranch();
-		int const action = lyxaction.
-			getPseudoAction(LFUN_INSERT_BRANCH,
-					(cit->getBranch()));
 		if (ii < 10)
 			label = tostr(ii) + ". " + label + "|" + tostr(ii);
-		tomenu.add(MenuItem(MenuItem::Command, label, action), view);
+		tomenu.add(MenuItem(MenuItem::Command, label,
+				    FuncRequest(LFUN_INSERT_BRANCH,
+						cit->getBranch())), view);
 	}
 }
 
Index: src/MenuBackend.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/MenuBackend.h,v
retrieving revision 1.30
diff -u -p -r1.30 MenuBackend.h
--- src/MenuBackend.h	5 Sep 2003 17:22:47 -0000	1.30
+++ src/MenuBackend.h	10 Sep 2003 18:05:56 -0000
@@ -13,14 +13,15 @@
 #ifndef MENUBACKEND_H
 #define MENUBACKEND_H
 
+#include "FuncStatus.h"
+#include "funcrequest.h"
+
 #include "support/std_string.h"
 
 #include <boost/shared_ptr.hpp>
 
 #include <vector>
 
-#include "FuncStatus.h"
-
 class LyXLex;
 class LyXView;
 class Menu;
@@ -72,10 +73,11 @@ public:
 	MenuItem(Kind kind,
 		 string const & label = string(),
 		 string const & command = string(),
+		 string const & argument = string(),
 		 bool optional = false);
 	MenuItem(Kind kind,
 		 string const & label,
-		 int action,
+		 FuncRequest const & func,
 		 bool optional = false);
 
 	/// This one is just to please boost::shared_ptr<>
@@ -89,7 +91,7 @@ public:
 	/// The kind of entry
 	Kind kind() const { return kind_; }
 	/// the action (if relevant)
-	int action() const { return action_; }
+	FuncRequest const & func() const { return func_; }
 	/// returns true if the entry should be ommited when disabled
 	bool optional() const { return optional_; }
 	/// returns the status of the lfun associated with this entry
@@ -116,7 +118,7 @@ private:
 	///
 	string label_;
 	///
-	int action_;
+	FuncRequest func_;
 	///
 	string submenuname_;
 	///
Index: src/ToolbarBackend.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ToolbarBackend.C,v
retrieving revision 1.18
diff -u -p -r1.18 ToolbarBackend.C
--- src/ToolbarBackend.C	9 Sep 2003 22:13:22 -0000	1.18
+++ src/ToolbarBackend.C	10 Sep 2003 18:05:56 -0000
@@ -98,15 +98,15 @@ void ToolbarBackend::read(LyXLex & lex)
 			break;
 
 		case TO_MINIBUFFER:
-			add(tb, MINIBUFFER);
+			add(tb, FuncRequest(kb_action(MINIBUFFER)));
 			break;
 
 		case TO_SEPARATOR:
-			add(tb, SEPARATOR);
+			add(tb, FuncRequest(kb_action(SEPARATOR)));
 			break;
 
 		case TO_LAYOUTS:
-			add(tb, LAYOUTS);
+			add(tb, FuncRequest(kb_action(LAYOUTS)));
 			break;
 
 		case TO_ENDTOOLBAR:
@@ -193,9 +193,9 @@ void ToolbarBackend::readToolbars(LyXLex
 }
 
 
-void ToolbarBackend::add(Toolbar & tb, int action, string const & tooltip)
+void ToolbarBackend::add(Toolbar & tb, FuncRequest const & func, string const & tooltip)
 {
-	tb.items.push_back(make_pair(action, tooltip));
+	tb.items.push_back(make_pair(func, tooltip));
 }
 
 
@@ -207,15 +207,14 @@ void ToolbarBackend::add(Toolbar & tb, s
 		lyxerr << "ToolbarBackend::add: no LyX command called `"
 		       << func << "' exists!" << endl;
 	} else {
-		add(tb, tf, tooltip);
+		add(tb, FuncRequest(kb_action(tf)), tooltip);
 	}
 }
 
 
-string const ToolbarBackend::getIcon(int action)
+string const ToolbarBackend::getIcon(FuncRequest const & f)
 {
 	string fullname;
-	FuncRequest f = lyxaction.retrieveActionArg(action);
 
 	if (f.action == LFUN_INSERT_MATH) {
 		if (!f.argument.empty())
Index: src/ToolbarBackend.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ToolbarBackend.h,v
retrieving revision 1.9
diff -u -p -r1.9 ToolbarBackend.h
--- src/ToolbarBackend.h	7 Sep 2003 21:25:33 -0000	1.9
+++ src/ToolbarBackend.h	10 Sep 2003 18:05:56 -0000
@@ -13,12 +13,15 @@
 #ifndef TOOLBAR_BACKEND_H
 #define TOOLBAR_BACKEND_H
 
+#include "funcrequest.h"
+
 #include <vector>
 
 #include "support/std_string.h"
 
 class LyXLex;
 
+
 ///
 class ToolbarBackend {
 public:
@@ -33,10 +36,10 @@ public:
 	};
 
 	/// action, tooltip
-	typedef std::pair<int, string> Item;
+	typedef std::pair<FuncRequest, string> Item;
 
 	/// the toolbar items
-	typedef std::vector<std::pair<int, string> > Items;
+	typedef std::vector<Item> Items;
 
 	/// toolbar flags
 	enum Flags {
@@ -82,11 +85,12 @@ public:
 	void readToolbars(LyXLex &);
 
 	/// return a full path of an XPM for the given action
-	static string const getIcon(int action);
+	static string const getIcon(FuncRequest const &);
 
 private:
 	/// add the given lfun with tooltip if relevant
-	void add(Toolbar & tb, int, string const & tooltip = string());
+	void add(Toolbar & tb, FuncRequest const &,
+		 string const & tooltip = string());
 
 	/// add the given lfun with tooltip if relevant
 	void add(Toolbar & tb, string const &, string const & tooltip);
Index: src/funcrequest.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/funcrequest.C,v
retrieving revision 1.15
diff -u -p -r1.15 funcrequest.C
--- src/funcrequest.C	8 Sep 2003 00:33:21 -0000	1.15
+++ src/funcrequest.C	10 Sep 2003 18:05:56 -0000
@@ -127,7 +127,7 @@ void split(vector<string> & args, string
 }
 
 
-string FuncRequest::getArg(int i) const
+string FuncRequest::getArg(unsigned int i) const
 {
 	vector<string> args;
 	split(args, argument);
Index: src/funcrequest.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/funcrequest.h,v
retrieving revision 1.12
diff -u -p -r1.12 funcrequest.h
--- src/funcrequest.h	5 Sep 2003 17:22:48 -0000	1.12
+++ src/funcrequest.h	10 Sep 2003 18:05:56 -0000
@@ -57,7 +57,7 @@ public:
 	void errorMessage(string const & msg) const;
 
 	/// argument parsing, extract argument i as string
-	string getArg(int i) const;
+	string getArg(unsigned int i) const;
 
 private:
 	/// the BufferView we are talking to
Index: src/lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.501
diff -u -p -r1.501 lyxfunc.C
--- src/lyxfunc.C	9 Sep 2003 22:13:25 -0000	1.501
+++ src/lyxfunc.C	10 Sep 2003 18:05:56 -0000
@@ -262,17 +262,11 @@ void LyXFunc::processKeySym(LyXKeySymPtr
 				   << argument << "']" << endl;
 		}
 	} else {
-		dispatch(action);
+		dispatch(FuncRequest(kb_action(action)));
 	}
 }
 
 
-FuncStatus LyXFunc::getStatus(int ac) const
-{
-	return getStatus(lyxaction.retrieveActionArg(ac));
-}
-
-
 FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
 {
 	FuncStatus flag;
@@ -807,7 +801,7 @@ 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(lyxaction.LookupFunc(token(ev.argument, ';', 0)));
+		flag = getStatus(FuncRequest(lyxaction.LookupFunc(token(ev.argument, ';', 0))));
 	}
 
 	return flag;
@@ -823,15 +817,10 @@ void LyXFunc::dispatch(string const & s,
 		return;
 	}
 
-	dispatch(action, verbose);
+	dispatch(FuncRequest(kb_action(action)), verbose);
 }
 
 
-void LyXFunc::dispatch(int ac, bool verbose)
-{
-	dispatch(lyxaction.retrieveActionArg(ac), verbose);
-}
-
 namespace {
 	bool ensureBufferClean(BufferView * bv) {
 
@@ -1079,7 +1068,7 @@ void LyXFunc::dispatch(FuncRequest const
 		meta_fake_bit = key_modifier::none;
 		if (view()->available())
 			// cancel any selection
-			dispatch(LFUN_MARK_OFF);
+			dispatch(FuncRequest(LFUN_MARK_OFF));
 		setMessage(N_("Cancel"));
 		break;
 
@@ -1702,22 +1691,16 @@ void LyXFunc::sendDispatchMessage(string
 
 	string comname = lyxaction.getActionName(ev.action);
 
-	int pseudoaction = ev.action;
 	bool argsadded = false;
 
 	if (!ev.argument.empty()) {
-		// the pseudoaction is useful for the bindings
-		pseudoaction = lyxaction.searchActionArg(ev.action, ev.argument);
-
-		if (pseudoaction == LFUN_UNKNOWN_ACTION) {
-			pseudoaction = ev.action;
-		} else {
+		if (ev.action != LFUN_UNKNOWN_ACTION) {
 			comname += ' ' + ev.argument;
 			argsadded = true;
 		}
 	}
 
-	string const shortcuts = toplevel_keymap->findbinding(pseudoaction);
+	string const shortcuts = toplevel_keymap->findbinding(ev.action);
 
 	if (!shortcuts.empty()) {
 		comname += ": " + shortcuts;
Index: src/lyxfunc.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.h,v
retrieving revision 1.62
diff -u -p -r1.62 lyxfunc.h
--- src/lyxfunc.h	7 Sep 2003 01:45:37 -0000	1.62
+++ src/lyxfunc.h	10 Sep 2003 18:05:56 -0000
@@ -49,9 +49,6 @@ public:
 	/// Dispatch via a string argument
 	void dispatch(string const & s, bool verbose = false);
 
-	/// Dispatch via a pseudo action, also displaying shortcut/command name
-	void dispatch(int ac, bool verbose = false);
-
 	/// return the status bar state string
 	string const view_status_message();
 
@@ -60,9 +57,6 @@ public:
 	///
 	void processKeySym(LyXKeySymPtr key, key_modifier::state state);
 
-	/// we need one internal which is called from inside LyXAction and
-	/// can contain the string argument.
-	FuncStatus getStatus(int ac) const;
 	///
 	FuncStatus getStatus(FuncRequest const & action) const;
 
Index: src/toc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/toc.C,v
retrieving revision 1.32
diff -u -p -r1.32 toc.C
--- src/toc.C	9 Sep 2003 11:24:22 -0000	1.32
+++ src/toc.C	10 Sep 2003 18:05:56 -0000
@@ -47,10 +47,9 @@ void TocItem::goTo(LyXView & lv_) const
 }
 
 
-int TocItem::action() const
+FuncRequest TocItem::action() const
 {
-	return lyxaction.getPseudoAction(LFUN_GOTO_PARAGRAPH,
-					 tostr(id_));
+	return FuncRequest(LFUN_GOTO_PARAGRAPH, tostr(id_));
 }
 
 
Index: src/toc.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/toc.h,v
retrieving revision 1.10
diff -u -p -r1.10 toc.h
--- src/toc.h	7 Sep 2003 21:25:33 -0000	1.10
+++ src/toc.h	10 Sep 2003 18:05:56 -0000
@@ -22,6 +22,7 @@
 class Buffer;
 class LyXView;
 class Paragraph;
+class FuncRequest;
 
 /** Nice functions and objects to handle TOCs
  */
@@ -37,7 +38,7 @@ struct TocItem {
 	/// set cursor in LyXView to this TocItem
 	void goTo(LyXView & lv_) const;
 	/// the action corresponding to the goTo above
-	int action() const;
+	FuncRequest action() const;
 	/// Paragraph ID containing this item
 	int id_;
 	/// nesting depth
Index: src/frontends/LyXView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/LyXView.C,v
retrieving revision 1.33
diff -u -p -r1.33 LyXView.C
--- src/frontends/LyXView.C	9 Sep 2003 22:13:39 -0000	1.33
+++ src/frontends/LyXView.C	10 Sep 2003 18:05:56 -0000
@@ -106,7 +106,7 @@ void LyXView::updateToolbar()
 {
 	bool const math = mathcursor;
 	bool const table =
-		!getLyXFunc().getStatus(LFUN_LAYOUT_TABULAR).disabled();
+		!getLyXFunc().getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).disabled();
 	toolbar_->update(math, table);
 }
 
Index: src/frontends/Toolbar.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/Toolbar.h,v
retrieving revision 1.22
diff -u -p -r1.22 Toolbar.h
--- src/frontends/Toolbar.h	9 Sep 2003 18:27:21 -0000	1.22
+++ src/frontends/Toolbar.h	10 Sep 2003 18:05:56 -0000
@@ -32,7 +32,7 @@ public:
 	virtual ~Toolbar();
 
 	/// Initialize toolbar from backend
- 	void init();
+	void init();
 
 	/// update the state of the toolbars
 	void update(bool in_math, bool in_table);
Index: src/frontends/xforms/XFormsMenubar.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XFormsMenubar.C,v
retrieving revision 1.6
diff -u -p -r1.6 XFormsMenubar.C
--- src/frontends/xforms/XFormsMenubar.C	9 Sep 2003 22:13:41 -0000	1.6
+++ src/frontends/xforms/XFormsMenubar.C	10 Sep 2003 18:05:56 -0000
@@ -194,6 +194,8 @@ string const fixlabel(string const & str
 int XFormsMenubar::create_submenu(Window win, XFormsView * view,
 				   Menu const & menu, vector<int> & smn)
 {
+	funcs_.clear();
+
 	const int menuid = get_new_submenu(smn, win);
 	lyxerr[Debug::GUI] << "XFormsMenubar::create_submenu: creating "
 			   << menu.name() << " as menuid=" << menuid << endl;
@@ -220,7 +222,8 @@ int XFormsMenubar::create_submenu(Window
 
 	size_type count = 0;
 	int curmenuid = menuid;
-	for (Menu::const_iterator i = menu.begin(); i != end; ++i) {
+	int action_count = 0;
+	for (Menu::const_iterator i = menu.begin(); i != end; ++i, ++action_count) {
 		MenuItem const & item = (*i);
 
 		++count;
@@ -292,10 +295,11 @@ int XFormsMenubar::create_submenu(Window
 					<< "), ";
 			} else {
 				// Add the action
-				label += "%x" + tostr(item.action()
-						      + action_offset);
+				label += "%x" + tostr(action_count);
+				funcs_[action_count] = item.func();
+
 				lyxerr[Debug::GUI] << "Action: \""
-						   << item.action() << "\", ";
+						   << item.func().action << "\", ";
 			}
 
 			// Add everything to the menu
@@ -371,7 +375,7 @@ void XFormsMenubar::MenuCallback(FL_OBJE
 		// 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, true);
+			view->getLyXFunc().dispatch(iteminfo->menubar_->funcs_[choice], true);
 		} else {
 			lyxerr[Debug::GUI]
 				<< "MenuCallback: ignoring bogus action "
Index: src/frontends/xforms/XFormsMenubar.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XFormsMenubar.h,v
retrieving revision 1.4
diff -u -p -r1.4 XFormsMenubar.h
--- src/frontends/xforms/XFormsMenubar.h	7 Sep 2003 21:25:34 -0000	1.4
+++ src/frontends/xforms/XFormsMenubar.h	10 Sep 2003 18:05:56 -0000
@@ -12,6 +12,7 @@
 #ifndef XFORMSMENUBAR_H
 #define XFORMSMENUBAR_H
 
+#include "funcrequest.h"
 #include "frontends/Menubar.h"
 
 #include <boost/shared_ptr.hpp>
@@ -21,6 +22,7 @@
 
 #include "support/std_string.h"
 #include <vector>
+#include <map>
 
 class LyXView;
 class XFormsView;
@@ -80,5 +82,9 @@ private:
 	typedef std::vector<boost::shared_ptr<ItemInfo> > ButtonList;
 	///
 	ButtonList buttonlist_;
+	///
+	typedef std::map<int, FuncRequest> Funcs;
+	///
+	Funcs funcs_;
 };
 #endif
Index: src/frontends/xforms/XFormsToolbar.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XFormsToolbar.C,v
retrieving revision 1.7
diff -u -p -r1.7 XFormsToolbar.C
--- src/frontends/xforms/XFormsToolbar.C	9 Sep 2003 11:24:25 -0000	1.7
+++ src/frontends/xforms/XFormsToolbar.C	10 Sep 2003 18:05:56 -0000
@@ -40,7 +40,7 @@ const int buttonwidth = 30; // the stand
 const int height = 30; // the height of all items in the toolbar
 
 XFormsToolbar::toolbarItem::toolbarItem()
-	: action(LFUN_NOACTION), icon(0)
+	: icon(0)
 {}
 
 
@@ -81,7 +81,7 @@ XFormsToolbar::toolbarItem::operator=(to
 	// But we don't copy the icon from ti
 	kill_icon();
 
-	action = ti.action;
+	func = ti.func;
 
 	return *this;
 }
@@ -113,10 +113,10 @@ void XFormsToolbar::update()
 	ToolbarList::const_iterator p = toollist_.begin();
 	ToolbarList::const_iterator end = toollist_.end();
 	for (; p != end; ++p) {
-		if (p->action == ToolbarBackend::LAYOUTS && combox_) {
+		if (p->func.action == ToolbarBackend::LAYOUTS && combox_) {
 			LyXFunc const & lf = owner_->getLyXFunc();
 			bool const disable =
-				lf.getStatus(LFUN_LAYOUT).disabled();
+				lf.getStatus(FuncRequest(LFUN_LAYOUT)).disabled();
 			setEnabled(combox_, !disable);
 			continue;
 		}
@@ -124,7 +124,7 @@ void XFormsToolbar::update()
 		if (!p->icon)
 			continue;
 
-		FuncStatus const status = owner_->getLyXFunc().getStatus(p->action);
+		FuncStatus const status = owner_->getLyXFunc().getStatus(p->func);
 		if (status.onoff(true)) {
 			// I'd like to use a different color
 			// here, but then the problem is to
@@ -251,7 +251,7 @@ void ToolbarCB(FL_OBJECT * ob, long ac)
 {
 	XFormsView * owner = static_cast<XFormsView *>(ob->u_vdata);
 
-	owner->getLyXFunc().dispatch(int(ac), true);
+	owner->getLyXFunc().dispatch(FuncRequest(kb_action(ac)), true);
 }
 
 
@@ -280,12 +280,12 @@ void XFormsToolbar::add(ToolbarBackend::
 }
 
 
-void XFormsToolbar::add(int action, string const & tooltip)
+void XFormsToolbar::add(FuncRequest const & func, string const & tooltip)
 {
 	toolbarItem item;
-	item.action = action;
+	item.func = func;
 
-	switch (action) {
+	switch (func.action) {
 	case ToolbarBackend::SEPARATOR:
 		xpos += sepspace;
 		break;
@@ -323,7 +323,7 @@ void XFormsToolbar::add(int action, stri
 				      NorthWestGravity,
 				      NorthWestGravity);
 		fl_set_object_callback(obj, C_Toolbar_ToolbarCB,
-				       static_cast<long>(action));
+				       static_cast<long>(func.action));
 		// Remove the blue feedback rectangle
 		fl_set_pixmapbutton_focus_outline(obj, 0);
 
@@ -332,7 +332,7 @@ void XFormsToolbar::add(int action, stri
 		// The view that this object belongs to.
 		obj->u_vdata = owner_;
 
-		string const xpm = toolbarbackend.getIcon(action);
+		string const xpm = toolbarbackend.getIcon(func);
 		fl_set_pixmapbutton_file(obj, xpm.c_str());
 
 		// we must remember to update the positions
Index: src/frontends/xforms/XFormsToolbar.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XFormsToolbar.h,v
retrieving revision 1.4
diff -u -p -r1.4 XFormsToolbar.h
--- src/frontends/xforms/XFormsToolbar.h	9 Sep 2003 18:27:22 -0000	1.4
+++ src/frontends/xforms/XFormsToolbar.h	10 Sep 2003 18:05:56 -0000
@@ -36,7 +36,7 @@ public:
 	void add(ToolbarBackend::Toolbar const & tb);
 
 	/// add an item to a toolbar
-	void add(int action, string const & tooltip);
+	void add(FuncRequest const &, string const & tooltip);
 
 	/// display toolbar, not implemented
 	void displayToolbar(ToolbarBackend::Toolbar const & tb, bool show);
@@ -68,7 +68,7 @@ public:
 		void kill_icon();
 
 		/// lyx action number
-		int action;
+		FuncRequest func;
 		/// icon for this item
 		FL_OBJECT * icon;
 	};
-- 
        Lgb

Reply via email to