using std::sort;
using std::string;
using std::vector;
-
+using std::stack;
namespace {
}
+bool Menu::searchFunc(FuncRequest & func, stack<docstring> & names)
+{
+ const_iterator m = begin();
+ const_iterator m_end = end();
+ for (; m != m_end; ++m) {
+ if (m->kind() == MenuItem::Command && m->func() == func) {
+ names.push(m->label());
+ return true;
+ } else if (m->kind() == MenuItem::Submenu) {
+ names.push(m->label());
+ Menu submenu = menubackend.getMenu(m->submenuname());
+ if (submenu.searchFunc(func, names))
+ return true;
+ else
+ names.pop();
+ }
+ }
+ return false;
+}
+
+
void MenuBackend::specialMenu(Menu const & menu)
{
specialmenu_ = menu;
#include <boost/shared_ptr.hpp>
#include <vector>
+#include <stack>
namespace lyx {
// Check whether the menu shortcuts are unique
void checkShortcuts() const;
+
+ // search for func in this menu iteratively, and put menu
+ // names in a stack.
+ bool searchFunc(FuncRequest & func, std::stack<docstring> & names);
private:
friend class MenuBackend;
#include "LaTeXFeatures.h"
#include "LyXAction.h"
#include "Lexer.h"
+#include "MenuBackend.h"
#include "MetricsInfo.h"
#include "ParagraphParameters.h"
#include "TextClassList.h"
translator.addPair(InsetInfo::SHORTCUT_INFO, "shortcut");
translator.addPair(InsetInfo::PACKAGE_INFO, "package");
translator.addPair(InsetInfo::TEXTCLASS_INFO, "textclass");
+ translator.addPair(InsetInfo::MENU_INFO, "menu");
return translator;
}
bp_.getFont(), false);
break;
}
+ case MENU_INFO: {
+ stack<docstring> names;
+ FuncRequest func = lyxaction.lookupFunc(name_);
+ if (func.action == LFUN_UNKNOWN_ACTION) {
+ setText(_("No menu entry for "), bp_.getFont(), false);
+ break;
+ }
+ // iterate through the menubackend to find it
+ Menu menu = menubackend.getMenubar();
+ if (!menu.searchFunc(func, names)) {
+ setText(_("No menu entry for "), bp_.getFont(), false);
+ break;
+ }
+ // if find, return its path.
+ InsetText::clear();
+ Paragraph & info = paragraphs().front();
+ unsigned int i = 0;
+ while (!names.empty()) {
+ // do not insert > for the top level menu item
+ if (i != 0)
+ info.insertInset(0, new InsetSpecialChar(InsetSpecialChar::MENU_SEPARATOR),
+ Change(Change::UNCHANGED));
+ for (i = 0; i < names.top().length(); ++i)
+ info.insertChar(i, names.top()[i], bp_.getFont(), false);
+ names.pop();
+ }
+ break;
+ }
}
// remove indent
paragraphs().begin()->params().noindent(true);