2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file MenuBackend.cpp
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Asger Alstrup
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
* \author Dekel Tsur
|
|
|
|
|
* \author Martin Vermeer
|
2000-07-24 13:53:19 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
2000-07-24 13:53:19 +00:00
|
|
|
|
|
2001-05-04 10:36:36 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
#include "MenuBackend.h"
|
2003-09-09 17:00:19 +00:00
|
|
|
|
|
|
|
|
|
#include "BranchList.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Buffer.h"
|
|
|
|
|
#include "BufferList.h"
|
|
|
|
|
#include "BufferParams.h"
|
2003-09-09 17:00:19 +00:00
|
|
|
|
#include "CutAndPaste.h"
|
2000-07-24 13:53:19 +00:00
|
|
|
|
#include "debug.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Exporter.h"
|
2003-09-09 17:00:19 +00:00
|
|
|
|
#include "Floating.h"
|
|
|
|
|
#include "FloatList.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Format.h"
|
2000-07-26 07:09:53 +00:00
|
|
|
|
#include "gettext.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Importer.h"
|
2007-04-27 08:05:58 +00:00
|
|
|
|
#include "KeyMap.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Session.h"
|
2003-09-09 17:00:19 +00:00
|
|
|
|
#include "LyXAction.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyX.h" // for lastfiles
|
|
|
|
|
#include "LyXFunc.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
|
#include "Lexer.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Paragraph.h"
|
2006-11-11 00:35:14 +00:00
|
|
|
|
#include "TocBackend.h"
|
2006-11-02 16:01:36 +00:00
|
|
|
|
#include "ToolbarBackend.h"
|
2003-09-09 17:00:19 +00:00
|
|
|
|
|
2000-10-04 09:54:31 +00:00
|
|
|
|
#include "support/filetools.h"
|
2001-07-29 17:39:01 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2005-01-06 16:39:35 +00:00
|
|
|
|
#include "support/convert.h"
|
2003-05-13 14:36:24 +00:00
|
|
|
|
|
2004-01-31 15:30:24 +00:00
|
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
|
2003-05-13 14:36:24 +00:00
|
|
|
|
#include <algorithm>
|
2000-07-24 13:53:19 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
using support::compare_ascii_no_case;
|
|
|
|
|
using support::contains;
|
|
|
|
|
using support::makeDisplayPath;
|
|
|
|
|
using support::token;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2004-01-31 15:30:24 +00:00
|
|
|
|
using boost::bind;
|
|
|
|
|
|
2003-11-03 17:47:28 +00:00
|
|
|
|
using std::auto_ptr;
|
2000-07-24 13:53:19 +00:00
|
|
|
|
using std::endl;
|
2004-01-31 15:30:24 +00:00
|
|
|
|
using std::equal_to;
|
2000-10-12 15:17:42 +00:00
|
|
|
|
using std::find_if;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
using std::max;
|
2000-10-16 13:27:56 +00:00
|
|
|
|
using std::sort;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
using std::vector;
|
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
|
2004-01-31 15:30:24 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
class MenuNamesEqual : public std::unary_function<Menu, bool> {
|
|
|
|
|
public:
|
2006-09-09 22:27:22 +00:00
|
|
|
|
MenuNamesEqual(docstring const & name)
|
2004-01-31 15:30:24 +00:00
|
|
|
|
: name_(name) {}
|
|
|
|
|
bool operator()(Menu const & menu) const
|
|
|
|
|
{
|
|
|
|
|
return menu.name() == name_;
|
|
|
|
|
}
|
|
|
|
|
private:
|
2006-09-09 22:27:22 +00:00
|
|
|
|
docstring name_;
|
2004-01-31 15:30:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
// This is the global menu definition
|
|
|
|
|
MenuBackend menubackend;
|
|
|
|
|
|
|
|
|
|
|
2003-09-21 18:57:15 +00:00
|
|
|
|
MenuItem::MenuItem(Kind kind)
|
|
|
|
|
: kind_(kind), optional_(false)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2006-09-09 22:27:22 +00:00
|
|
|
|
MenuItem::MenuItem(Kind kind, docstring const & label,
|
|
|
|
|
docstring const & submenu, bool optional)
|
2003-09-21 18:57:15 +00:00
|
|
|
|
: kind_(kind), label_(label),
|
|
|
|
|
submenuname_(submenu), optional_(optional)
|
2000-07-24 13:53:19 +00:00
|
|
|
|
{
|
2003-09-21 18:57:15 +00:00
|
|
|
|
BOOST_ASSERT(kind == Submenu);
|
2000-07-24 13:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-20 17:23:17 +00:00
|
|
|
|
|
2006-09-09 22:27:22 +00:00
|
|
|
|
MenuItem::MenuItem(Kind kind, docstring const & label,
|
2003-09-21 18:57:15 +00:00
|
|
|
|
FuncRequest const & func, bool optional)
|
|
|
|
|
: kind_(kind), label_(label), func_(func), optional_(optional)
|
2004-11-08 10:54:29 +00:00
|
|
|
|
{
|
2006-11-09 14:56:57 +00:00
|
|
|
|
func_.origin = FuncRequest::MENU;
|
2004-11-08 10:54:29 +00:00
|
|
|
|
}
|
2002-08-21 06:32:10 +00:00
|
|
|
|
|
|
|
|
|
|
2002-07-23 22:42:12 +00:00
|
|
|
|
MenuItem::~MenuItem()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2002-08-21 06:39:45 +00:00
|
|
|
|
void MenuItem::submenu(Menu * menu)
|
|
|
|
|
{
|
|
|
|
|
submenu_.reset(menu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-09 22:27:22 +00:00
|
|
|
|
docstring const MenuItem::label() const
|
2002-03-21 17:27:08 +00:00
|
|
|
|
{
|
2006-09-09 22:27:22 +00:00
|
|
|
|
return token(label_, char_type('|'), 0);
|
2001-07-29 17:39:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-20 17:23:17 +00:00
|
|
|
|
|
2006-09-09 22:27:22 +00:00
|
|
|
|
docstring const MenuItem::shortcut() const
|
2002-03-21 17:27:08 +00:00
|
|
|
|
{
|
2006-09-09 22:27:22 +00:00
|
|
|
|
return token(label_, char_type('|'), 1);
|
2001-07-29 17:39:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-21 18:57:15 +00:00
|
|
|
|
|
2007-01-04 17:10:24 +00:00
|
|
|
|
docstring const MenuItem::binding(bool forgui) const
|
2003-02-15 21:03:40 +00:00
|
|
|
|
{
|
|
|
|
|
if (kind_ != Command)
|
2006-09-09 22:27:22 +00:00
|
|
|
|
return docstring();
|
2003-03-04 09:27:27 +00:00
|
|
|
|
|
2003-02-15 21:03:40 +00:00
|
|
|
|
// Get the keys bound to this action, but keep only the
|
|
|
|
|
// first one later
|
2007-04-27 08:05:58 +00:00
|
|
|
|
KeyMap::Bindings bindings = theTopLevelKeymap().findbindings(func_);
|
2003-02-15 21:03:40 +00:00
|
|
|
|
|
2004-07-02 10:03:22 +00:00
|
|
|
|
if (bindings.size()) {
|
2007-01-04 17:10:24 +00:00
|
|
|
|
return bindings.begin()->print(forgui);
|
2003-09-21 23:00:47 +00:00
|
|
|
|
} else {
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KBMAP)
|
2004-07-02 10:03:22 +00:00
|
|
|
|
<< "No binding for "
|
2003-10-09 13:33:19 +00:00
|
|
|
|
<< lyxaction.getActionName(func_.action)
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< '(' << to_utf8(func_.argument()) << ')' << endl;
|
2006-09-09 22:27:22 +00:00
|
|
|
|
return docstring();
|
2003-09-21 23:00:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-15 21:03:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-07-24 21:49:58 +00:00
|
|
|
|
|
2006-09-29 21:40:56 +00:00
|
|
|
|
Menu & Menu::add(MenuItem const & i)
|
2000-07-24 13:53:19 +00:00
|
|
|
|
{
|
2006-09-29 21:40:56 +00:00
|
|
|
|
items_.push_back(i);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2003-03-04 09:27:27 +00:00
|
|
|
|
|
2006-09-29 21:40:56 +00:00
|
|
|
|
|
|
|
|
|
Menu & Menu::addWithStatusCheck(MenuItem const & i)
|
|
|
|
|
{
|
2003-02-15 21:03:40 +00:00
|
|
|
|
switch (i.kind()) {
|
2004-03-18 13:57:20 +00:00
|
|
|
|
|
|
|
|
|
case MenuItem::Command: {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
FuncStatus status = lyx::getStatus(i.func());
|
|
|
|
|
if (status.unknown() || (!status.enabled() && i.optional()))
|
2003-02-15 21:03:40 +00:00
|
|
|
|
break;
|
|
|
|
|
items_.push_back(i);
|
|
|
|
|
items_.back().status(status);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2004-03-18 13:57:20 +00:00
|
|
|
|
|
|
|
|
|
case MenuItem::Submenu: {
|
2003-02-15 21:03:40 +00:00
|
|
|
|
if (i.submenu()) {
|
2004-03-18 13:57:20 +00:00
|
|
|
|
bool enabled = false;
|
2003-02-15 21:03:40 +00:00
|
|
|
|
for (const_iterator cit = i.submenu()->begin();
|
|
|
|
|
cit != i.submenu()->end(); ++cit) {
|
|
|
|
|
if ((cit->kind() == MenuItem::Command
|
|
|
|
|
|| cit->kind() == MenuItem::Submenu)
|
2004-03-18 13:57:20 +00:00
|
|
|
|
&& cit->status().enabled()) {
|
|
|
|
|
enabled = true;
|
2003-02-15 21:03:40 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-03-18 13:57:20 +00:00
|
|
|
|
if (enabled || !i.optional()) {
|
2003-02-15 21:03:40 +00:00
|
|
|
|
items_.push_back(i);
|
2004-03-18 13:57:20 +00:00
|
|
|
|
items_.back().status().enabled(enabled);
|
2003-02-15 21:03:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
items_.push_back(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2004-03-18 13:57:20 +00:00
|
|
|
|
|
2003-02-15 21:03:40 +00:00
|
|
|
|
case MenuItem::Separator:
|
|
|
|
|
if (!items_.empty()
|
|
|
|
|
&& items_.back().kind() != MenuItem::Separator)
|
|
|
|
|
items_.push_back(i);
|
|
|
|
|
break;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
|
2003-02-15 21:03:40 +00:00
|
|
|
|
default:
|
|
|
|
|
items_.push_back(i);
|
2003-03-04 09:27:27 +00:00
|
|
|
|
}
|
2003-02-15 21:03:40 +00:00
|
|
|
|
|
2000-07-24 21:49:58 +00:00
|
|
|
|
return *this;
|
2000-07-24 13:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
Menu & Menu::read(Lexer & lex)
|
2000-07-24 13:53:19 +00:00
|
|
|
|
{
|
|
|
|
|
enum Menutags {
|
|
|
|
|
md_item = 1,
|
2003-08-17 11:28:23 +00:00
|
|
|
|
md_branches,
|
2000-07-24 13:53:19 +00:00
|
|
|
|
md_documents,
|
2006-11-01 15:55:17 +00:00
|
|
|
|
md_bookmarks,
|
2003-11-12 14:38:26 +00:00
|
|
|
|
md_charstyles,
|
2000-07-24 13:53:19 +00:00
|
|
|
|
md_endmenu,
|
2000-08-30 03:40:51 +00:00
|
|
|
|
md_exportformats,
|
2000-11-06 11:20:22 +00:00
|
|
|
|
md_importformats,
|
2000-07-24 13:53:19 +00:00
|
|
|
|
md_lastfiles,
|
2000-07-25 10:46:18 +00:00
|
|
|
|
md_optitem,
|
2003-02-15 21:03:40 +00:00
|
|
|
|
md_optsubmenu,
|
2000-07-24 13:53:19 +00:00
|
|
|
|
md_separator,
|
2000-08-31 11:51:59 +00:00
|
|
|
|
md_submenu,
|
|
|
|
|
md_toc,
|
2000-08-30 03:40:51 +00:00
|
|
|
|
md_updateformats,
|
|
|
|
|
md_viewformats,
|
2001-05-04 10:36:36 +00:00
|
|
|
|
md_floatlistinsert,
|
|
|
|
|
md_floatinsert,
|
2003-06-17 15:33:49 +00:00
|
|
|
|
md_pasterecent,
|
2006-11-02 16:01:36 +00:00
|
|
|
|
md_toolbars,
|
2000-07-24 13:53:19 +00:00
|
|
|
|
md_last
|
|
|
|
|
};
|
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
|
struct keyword_item menutags[md_last - 1] = {
|
2006-11-03 08:17:26 +00:00
|
|
|
|
{ "bookmarks", md_bookmarks },
|
2003-08-17 11:28:23 +00:00
|
|
|
|
{ "branches", md_branches },
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{ "charstyles", md_charstyles },
|
2000-07-24 13:53:19 +00:00
|
|
|
|
{ "documents", md_documents },
|
|
|
|
|
{ "end", md_endmenu },
|
2000-08-30 03:40:51 +00:00
|
|
|
|
{ "exportformats", md_exportformats },
|
2001-05-04 10:36:36 +00:00
|
|
|
|
{ "floatinsert", md_floatinsert },
|
|
|
|
|
{ "floatlistinsert", md_floatlistinsert },
|
2000-11-06 11:20:22 +00:00
|
|
|
|
{ "importformats", md_importformats },
|
2000-07-24 13:53:19 +00:00
|
|
|
|
{ "item", md_item },
|
|
|
|
|
{ "lastfiles", md_lastfiles },
|
2002-03-21 17:27:08 +00:00
|
|
|
|
{ "optitem", md_optitem },
|
2003-02-15 21:03:40 +00:00
|
|
|
|
{ "optsubmenu", md_optsubmenu },
|
2003-06-17 15:33:49 +00:00
|
|
|
|
{ "pasterecent", md_pasterecent },
|
2000-07-24 13:53:19 +00:00
|
|
|
|
{ "separator", md_separator },
|
2000-08-30 03:40:51 +00:00
|
|
|
|
{ "submenu", md_submenu },
|
2000-08-31 11:51:59 +00:00
|
|
|
|
{ "toc", md_toc },
|
2006-11-02 16:01:36 +00:00
|
|
|
|
{ "toolbars", md_toolbars },
|
2006-11-03 08:17:26 +00:00
|
|
|
|
{ "updateformats", md_updateformats },
|
2000-08-30 03:40:51 +00:00
|
|
|
|
{ "viewformats", md_viewformats }
|
2000-07-24 13:53:19 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
lex.pushTable(menutags, md_last - 1);
|
|
|
|
|
if (lyxerr.debugging(Debug::PARSER))
|
|
|
|
|
lex.printTable(lyxerr);
|
|
|
|
|
|
|
|
|
|
bool quit = false;
|
2000-07-25 10:46:18 +00:00
|
|
|
|
bool optional = false;
|
2000-07-24 13:53:19 +00:00
|
|
|
|
|
2001-08-06 19:12:46 +00:00
|
|
|
|
while (lex.isOK() && !quit) {
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (lex.lex()) {
|
2000-07-25 10:46:18 +00:00
|
|
|
|
case md_optitem:
|
|
|
|
|
optional = true;
|
|
|
|
|
// fallback to md_item
|
2000-07-24 13:53:19 +00:00
|
|
|
|
case md_item: {
|
2001-07-23 09:11:14 +00:00
|
|
|
|
lex.next(true);
|
2006-11-23 16:31:48 +00:00
|
|
|
|
docstring const name = translateIfPossible(lex.getDocString());
|
2001-07-23 09:11:14 +00:00
|
|
|
|
lex.next(true);
|
2001-08-06 19:12:46 +00:00
|
|
|
|
string const command = lex.getString();
|
2003-09-21 23:00:47 +00:00
|
|
|
|
FuncRequest func = lyxaction.lookupFunc(command);
|
|
|
|
|
add(MenuItem(MenuItem::Command, name, func, optional));
|
2000-07-25 10:46:18 +00:00
|
|
|
|
optional = false;
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2000-08-31 11:51:59 +00:00
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
case md_separator:
|
|
|
|
|
add(MenuItem(MenuItem::Separator));
|
|
|
|
|
break;
|
2000-08-31 11:51:59 +00:00
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
case md_lastfiles:
|
|
|
|
|
add(MenuItem(MenuItem::Lastfiles));
|
|
|
|
|
break;
|
2000-08-31 11:51:59 +00:00
|
|
|
|
|
2003-11-12 14:38:26 +00:00
|
|
|
|
case md_charstyles:
|
|
|
|
|
add(MenuItem(MenuItem::CharStyles));
|
|
|
|
|
break;
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
case md_documents:
|
|
|
|
|
add(MenuItem(MenuItem::Documents));
|
|
|
|
|
break;
|
2000-08-31 11:51:59 +00:00
|
|
|
|
|
2006-11-01 15:55:17 +00:00
|
|
|
|
case md_bookmarks:
|
|
|
|
|
add(MenuItem(MenuItem::Bookmarks));
|
|
|
|
|
break;
|
|
|
|
|
|
2000-08-31 11:51:59 +00:00
|
|
|
|
case md_toc:
|
|
|
|
|
add(MenuItem(MenuItem::Toc));
|
|
|
|
|
break;
|
|
|
|
|
|
2000-08-30 03:40:51 +00:00
|
|
|
|
case md_viewformats:
|
|
|
|
|
add(MenuItem(MenuItem::ViewFormats));
|
|
|
|
|
break;
|
2000-08-31 11:51:59 +00:00
|
|
|
|
|
2000-08-30 03:40:51 +00:00
|
|
|
|
case md_updateformats:
|
|
|
|
|
add(MenuItem(MenuItem::UpdateFormats));
|
|
|
|
|
break;
|
2000-08-31 11:51:59 +00:00
|
|
|
|
|
2000-08-30 03:40:51 +00:00
|
|
|
|
case md_exportformats:
|
|
|
|
|
add(MenuItem(MenuItem::ExportFormats));
|
|
|
|
|
break;
|
2000-08-31 11:51:59 +00:00
|
|
|
|
|
2000-11-06 11:20:22 +00:00
|
|
|
|
case md_importformats:
|
|
|
|
|
add(MenuItem(MenuItem::ImportFormats));
|
|
|
|
|
break;
|
|
|
|
|
|
2001-05-04 10:36:36 +00:00
|
|
|
|
case md_floatlistinsert:
|
|
|
|
|
add(MenuItem(MenuItem::FloatListInsert));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case md_floatinsert:
|
|
|
|
|
add(MenuItem(MenuItem::FloatInsert));
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-06-17 15:33:49 +00:00
|
|
|
|
case md_pasterecent:
|
|
|
|
|
add(MenuItem(MenuItem::PasteRecent));
|
|
|
|
|
break;
|
|
|
|
|
|
2006-11-02 16:01:36 +00:00
|
|
|
|
case md_toolbars:
|
|
|
|
|
add(MenuItem(MenuItem::Toolbars));
|
|
|
|
|
break;
|
|
|
|
|
|
2003-08-17 11:28:23 +00:00
|
|
|
|
case md_branches:
|
|
|
|
|
add(MenuItem(MenuItem::Branches));
|
|
|
|
|
break;
|
|
|
|
|
|
2003-02-15 21:03:40 +00:00
|
|
|
|
case md_optsubmenu:
|
|
|
|
|
optional = true;
|
|
|
|
|
// fallback to md_submenu
|
2000-07-24 13:53:19 +00:00
|
|
|
|
case md_submenu: {
|
2001-07-23 09:11:14 +00:00
|
|
|
|
lex.next(true);
|
2006-11-23 16:31:48 +00:00
|
|
|
|
docstring const mlabel = translateIfPossible(lex.getDocString());
|
2001-07-23 09:11:14 +00:00
|
|
|
|
lex.next(true);
|
2006-11-22 09:15:38 +00:00
|
|
|
|
docstring const mname = lex.getDocString();
|
2003-02-15 21:03:40 +00:00
|
|
|
|
add(MenuItem(MenuItem::Submenu, mlabel, mname,
|
|
|
|
|
optional));
|
|
|
|
|
optional = false;
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2000-08-31 11:51:59 +00:00
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
case md_endmenu:
|
|
|
|
|
quit = true;
|
|
|
|
|
break;
|
2000-08-31 11:51:59 +00:00
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
default:
|
2002-07-20 21:50:05 +00:00
|
|
|
|
lex.printError("Menu::read: "
|
2000-07-24 13:53:19 +00:00
|
|
|
|
"Unknown menu tag: `$$Token'");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
lex.popTable();
|
2000-07-26 14:08:09 +00:00
|
|
|
|
return *this;
|
2000-07-24 13:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
|
|
2004-08-14 18:06:10 +00:00
|
|
|
|
MenuItem const & Menu::operator[](size_type i) const
|
|
|
|
|
{
|
|
|
|
|
return items_[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Menu::hasFunc(FuncRequest const & func) const
|
|
|
|
|
{
|
|
|
|
|
return find_if(begin(), end(),
|
|
|
|
|
bind(std::equal_to<FuncRequest>(),
|
|
|
|
|
bind(&MenuItem::func, _1),
|
|
|
|
|
func)) != end();
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-03 13:26:55 +00:00
|
|
|
|
void Menu::checkShortcuts() const
|
|
|
|
|
{
|
|
|
|
|
// This is a quadratic algorithm, but we do not care because
|
2003-07-22 09:15:55 +00:00
|
|
|
|
// menus are short enough
|
2000-11-03 13:26:55 +00:00
|
|
|
|
for (const_iterator it1 = begin(); it1 != end(); ++it1) {
|
2006-09-09 22:27:22 +00:00
|
|
|
|
docstring shortcut = it1->shortcut();
|
2000-11-03 13:26:55 +00:00
|
|
|
|
if (shortcut.empty())
|
|
|
|
|
continue;
|
|
|
|
|
if (!contains(it1->label(), shortcut))
|
|
|
|
|
lyxerr << "Menu warning: menu entry \""
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< to_utf8(it1->label())
|
2000-11-03 13:26:55 +00:00
|
|
|
|
<< "\" does not contain shortcut `"
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< to_utf8(shortcut) << "'." << endl;
|
2000-11-03 13:26:55 +00:00
|
|
|
|
for (const_iterator it2 = begin(); it2 != it1 ; ++it2) {
|
2007-02-26 18:54:03 +00:00
|
|
|
|
if (!compare_ascii_no_case(it2->shortcut(), shortcut)) {
|
2000-11-03 13:26:55 +00:00
|
|
|
|
lyxerr << "Menu warning: menu entries "
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< '"' << to_utf8(it1->fulllabel())
|
|
|
|
|
<< "\" and \"" << to_utf8(it2->fulllabel())
|
2000-11-03 13:26:55 +00:00
|
|
|
|
<< "\" share the same shortcut."
|
|
|
|
|
<< endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-20 17:23:17 +00:00
|
|
|
|
|
2007-01-03 11:59:10 +00:00
|
|
|
|
void MenuBackend::specialMenu(Menu const & menu)
|
2004-08-14 18:06:10 +00:00
|
|
|
|
{
|
2007-01-03 11:59:10 +00:00
|
|
|
|
specialmenu_ = menu;
|
2004-08-14 18:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-04-04 21:35:36 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2001-01-24 15:33:06 +00:00
|
|
|
|
class compare_format {
|
|
|
|
|
public:
|
|
|
|
|
bool operator()(Format const * p1, Format const * p2) {
|
2002-03-21 17:27:08 +00:00
|
|
|
|
return *p1 < *p2;
|
2001-01-24 15:33:06 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
docstring const limit_string_length(docstring const & str)
|
2002-07-24 22:32:03 +00:00
|
|
|
|
{
|
2006-10-11 19:40:50 +00:00
|
|
|
|
docstring::size_type const max_item_length = 45;
|
2002-07-24 22:32:03 +00:00
|
|
|
|
|
|
|
|
|
if (str.size() > max_item_length)
|
|
|
|
|
return str.substr(0, max_item_length - 3) + "...";
|
|
|
|
|
else
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-29 21:40:56 +00:00
|
|
|
|
void expandLastfiles(Menu & tomenu)
|
2002-07-22 20:12:08 +00:00
|
|
|
|
{
|
2006-10-29 20:01:00 +00:00
|
|
|
|
lyx::LastFilesSection::LastFiles const & lf = LyX::cref().session().lastFiles().lastFiles();
|
2006-10-27 14:18:03 +00:00
|
|
|
|
lyx::LastFilesSection::LastFiles::const_iterator lfit = lf.begin();
|
2003-10-14 21:30:23 +00:00
|
|
|
|
|
2002-07-22 20:12:08 +00:00
|
|
|
|
int ii = 1;
|
|
|
|
|
|
2006-04-05 22:56:18 +00:00
|
|
|
|
for (; lfit != lf.end() && ii < 10; ++lfit, ++ii) {
|
2006-12-02 16:07:15 +00:00
|
|
|
|
string const file = lfit->absFilename();
|
2006-10-11 19:40:50 +00:00
|
|
|
|
docstring const label = convert<docstring>(ii) + ". "
|
2006-12-02 16:07:15 +00:00
|
|
|
|
+ makeDisplayPath(file, 30)
|
2006-09-09 22:27:22 +00:00
|
|
|
|
+ char_type('|') + convert<docstring>(ii);
|
2006-12-02 16:07:15 +00:00
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FILE_OPEN, file)));
|
2002-07-22 20:12:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-04-04 21:35:36 +00:00
|
|
|
|
|
2005-01-06 15:40:49 +00:00
|
|
|
|
|
2006-09-29 21:40:56 +00:00
|
|
|
|
void expandDocuments(Menu & tomenu)
|
2002-07-22 20:12:08 +00:00
|
|
|
|
{
|
2007-08-06 16:15:00 +00:00
|
|
|
|
Buffer * first = theBufferList().first();
|
|
|
|
|
if (first) {
|
|
|
|
|
Buffer * b = first;
|
|
|
|
|
int ii = 1;
|
|
|
|
|
|
|
|
|
|
// We cannot use a for loop as the buffer list cycles.
|
|
|
|
|
do {
|
|
|
|
|
docstring label = makeDisplayPath(b->fileName(), 20);
|
|
|
|
|
if (!b->isClean()) label = label + "*";
|
|
|
|
|
if (ii < 10)
|
|
|
|
|
label = convert<docstring>(ii) + ". " + label + '|' + convert<docstring>(ii);
|
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BUFFER_SWITCH, b->fileName())));
|
|
|
|
|
|
|
|
|
|
b = theBufferList().next(b);
|
|
|
|
|
++ii;
|
|
|
|
|
} while (b != first);
|
|
|
|
|
} else {
|
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command, _("No Documents Open!"),
|
|
|
|
|
FuncRequest(LFUN_NOACTION)));
|
2002-07-22 20:12:08 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-01 15:55:17 +00:00
|
|
|
|
void expandBookmarks(Menu & tomenu)
|
|
|
|
|
{
|
|
|
|
|
lyx::BookmarksSection const & bm = LyX::cref().session().bookmarks();
|
|
|
|
|
|
|
|
|
|
for (size_t i = 1; i <= bm.size(); ++i) {
|
|
|
|
|
if (bm.isValid(i)) {
|
|
|
|
|
docstring const label = convert<docstring>(i) + ". "
|
2006-12-02 16:07:15 +00:00
|
|
|
|
+ makeDisplayPath(bm.bookmark(i).filename.absFilename(), 20)
|
2006-11-01 15:55:17 +00:00
|
|
|
|
+ char_type('|') + convert<docstring>(i);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BOOKMARK_GOTO,
|
2006-11-01 15:55:17 +00:00
|
|
|
|
convert<docstring>(i))));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-29 21:40:56 +00:00
|
|
|
|
void expandFormats(MenuItem::Kind kind, Menu & tomenu, Buffer const * buf)
|
2000-10-04 09:54:31 +00:00
|
|
|
|
{
|
2006-09-29 21:40:56 +00:00
|
|
|
|
if (!buf && kind != MenuItem::ImportFormats) {
|
2002-07-22 20:12:08 +00:00
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command,
|
2007-05-31 12:07:48 +00:00
|
|
|
|
_("No Document Open!"),
|
2006-09-29 21:40:56 +00:00
|
|
|
|
FuncRequest(LFUN_NOACTION)));
|
2002-07-22 20:12:08 +00:00
|
|
|
|
return;
|
2002-08-21 07:30:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-22 20:12:08 +00:00
|
|
|
|
typedef vector<Format const *> Formats;
|
|
|
|
|
Formats formats;
|
|
|
|
|
kb_action action;
|
2002-08-21 07:30:57 +00:00
|
|
|
|
|
2002-07-22 20:12:08 +00:00
|
|
|
|
switch (kind) {
|
|
|
|
|
case MenuItem::ImportFormats:
|
|
|
|
|
formats = Importer::GetImportableFormats();
|
2006-05-05 20:23:12 +00:00
|
|
|
|
action = LFUN_BUFFER_IMPORT;
|
2002-07-22 20:12:08 +00:00
|
|
|
|
break;
|
|
|
|
|
case MenuItem::ViewFormats:
|
2006-09-29 21:40:56 +00:00
|
|
|
|
formats = Exporter::getExportableFormats(*buf, true);
|
2006-05-05 20:23:12 +00:00
|
|
|
|
action = LFUN_BUFFER_VIEW;
|
2002-07-22 20:12:08 +00:00
|
|
|
|
break;
|
|
|
|
|
case MenuItem::UpdateFormats:
|
2006-09-29 21:40:56 +00:00
|
|
|
|
formats = Exporter::getExportableFormats(*buf, true);
|
2006-05-05 20:23:12 +00:00
|
|
|
|
action = LFUN_BUFFER_UPDATE;
|
2000-10-04 09:54:31 +00:00
|
|
|
|
break;
|
2002-07-22 20:12:08 +00:00
|
|
|
|
default:
|
2006-09-29 21:40:56 +00:00
|
|
|
|
formats = Exporter::getExportableFormats(*buf, false);
|
2006-05-05 20:23:12 +00:00
|
|
|
|
action = LFUN_BUFFER_EXPORT;
|
2002-07-22 20:12:08 +00:00
|
|
|
|
}
|
|
|
|
|
sort(formats.begin(), formats.end(), compare_format());
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-07-22 20:12:08 +00:00
|
|
|
|
Formats::const_iterator fit = formats.begin();
|
|
|
|
|
Formats::const_iterator end = formats.end();
|
|
|
|
|
for (; fit != end ; ++fit) {
|
|
|
|
|
if ((*fit)->dummy())
|
|
|
|
|
continue;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
docstring label = from_utf8((*fit)->prettyname());
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-20 12:03:40 +00:00
|
|
|
|
switch (kind) {
|
|
|
|
|
case MenuItem::ImportFormats:
|
2007-02-04 15:16:44 +00:00
|
|
|
|
// FIXME: This is a hack, we should rather solve
|
|
|
|
|
// FIXME: bug 2488 instead.
|
2002-07-22 20:12:08 +00:00
|
|
|
|
if ((*fit)->name() == "text")
|
2007-01-20 18:38:06 +00:00
|
|
|
|
label = _("Plain Text");
|
2002-07-22 20:12:08 +00:00
|
|
|
|
else if ((*fit)->name() == "textparagraph")
|
2007-01-20 18:38:06 +00:00
|
|
|
|
label = _("Plain Text, Join Lines");
|
2006-10-11 19:40:50 +00:00
|
|
|
|
label += "...";
|
2006-05-20 12:03:40 +00:00
|
|
|
|
break;
|
|
|
|
|
case MenuItem::ViewFormats:
|
|
|
|
|
case MenuItem::ExportFormats:
|
2006-05-30 13:48:27 +00:00
|
|
|
|
case MenuItem::UpdateFormats:
|
2006-05-20 12:03:40 +00:00
|
|
|
|
if (!(*fit)->documentFormat())
|
2006-02-03 21:47:25 +00:00
|
|
|
|
continue;
|
2006-05-20 12:03:40 +00:00
|
|
|
|
break;
|
2006-05-30 13:48:27 +00:00
|
|
|
|
default:
|
|
|
|
|
BOOST_ASSERT(false);
|
2006-05-20 12:03:40 +00:00
|
|
|
|
break;
|
2003-01-16 10:41:14 +00:00
|
|
|
|
}
|
2002-07-22 20:12:08 +00:00
|
|
|
|
if (!(*fit)->shortcut().empty())
|
2006-10-21 00:16:43 +00:00
|
|
|
|
label += char_type('|') + from_utf8((*fit)->shortcut());
|
2003-09-21 18:57:15 +00:00
|
|
|
|
|
2006-09-29 21:40:56 +00:00
|
|
|
|
if (buf)
|
|
|
|
|
tomenu.addWithStatusCheck(MenuItem(MenuItem::Command, label,
|
|
|
|
|
FuncRequest(action, (*fit)->name())));
|
|
|
|
|
else
|
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command, label,
|
|
|
|
|
FuncRequest(action, (*fit)->name())));
|
2002-07-22 20:12:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-07-24 22:32:03 +00:00
|
|
|
|
|
2006-09-29 21:40:56 +00:00
|
|
|
|
void expandFloatListInsert(Menu & tomenu, Buffer const * buf)
|
2002-07-22 20:12:08 +00:00
|
|
|
|
{
|
2006-09-29 21:40:56 +00:00
|
|
|
|
if (!buf) {
|
2002-08-27 15:51:19 +00:00
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command,
|
2007-05-31 12:07:48 +00:00
|
|
|
|
_("No Document Open!"),
|
2006-09-29 21:40:56 +00:00
|
|
|
|
FuncRequest(LFUN_NOACTION)));
|
2002-08-27 15:51:19 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-15 21:03:40 +00:00
|
|
|
|
FloatList const & floats =
|
2007-04-29 19:53:54 +00:00
|
|
|
|
buf->params().getTextClass().floats();
|
2002-08-27 15:51:19 +00:00
|
|
|
|
FloatList::const_iterator cit = floats.begin();
|
|
|
|
|
FloatList::const_iterator end = floats.end();
|
2002-07-22 20:12:08 +00:00
|
|
|
|
for (; cit != end; ++cit) {
|
2006-09-29 21:40:56 +00:00
|
|
|
|
tomenu.addWithStatusCheck(MenuItem(MenuItem::Command,
|
2006-09-09 22:27:22 +00:00
|
|
|
|
_(cit->second.listName()),
|
2003-09-21 18:57:15 +00:00
|
|
|
|
FuncRequest(LFUN_FLOAT_LIST,
|
2006-09-29 21:40:56 +00:00
|
|
|
|
cit->second.type())));
|
2002-07-22 20:12:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-10-04 09:54:31 +00:00
|
|
|
|
|
2002-07-24 22:32:03 +00:00
|
|
|
|
|
2006-09-29 21:40:56 +00:00
|
|
|
|
void expandFloatInsert(Menu & tomenu, Buffer const * buf)
|
2002-07-22 20:12:08 +00:00
|
|
|
|
{
|
2006-09-29 21:40:56 +00:00
|
|
|
|
if (!buf) {
|
2002-08-27 15:51:19 +00:00
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command,
|
2007-05-31 12:07:48 +00:00
|
|
|
|
_("No Document Open!"),
|
2006-09-29 21:40:56 +00:00
|
|
|
|
FuncRequest(LFUN_NOACTION)));
|
2002-08-27 15:51:19 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-15 21:03:40 +00:00
|
|
|
|
FloatList const & floats =
|
2007-04-29 19:53:54 +00:00
|
|
|
|
buf->params().getTextClass().floats();
|
2002-08-27 15:51:19 +00:00
|
|
|
|
FloatList::const_iterator cit = floats.begin();
|
|
|
|
|
FloatList::const_iterator end = floats.end();
|
2002-07-22 20:12:08 +00:00
|
|
|
|
for (; cit != end; ++cit) {
|
|
|
|
|
// normal float
|
2006-09-09 22:27:22 +00:00
|
|
|
|
docstring const label = _(cit->second.name());
|
2006-09-29 21:40:56 +00:00
|
|
|
|
tomenu.addWithStatusCheck(MenuItem(MenuItem::Command, label,
|
2006-05-05 20:23:12 +00:00
|
|
|
|
FuncRequest(LFUN_FLOAT_INSERT,
|
2006-09-29 21:40:56 +00:00
|
|
|
|
cit->second.type())));
|
2002-07-22 20:12:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-24 22:32:03 +00:00
|
|
|
|
|
2006-09-29 21:40:56 +00:00
|
|
|
|
void expandCharStyleInsert(Menu & tomenu, Buffer const * buf)
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2006-09-29 21:40:56 +00:00
|
|
|
|
if (!buf) {
|
2003-11-12 14:38:26 +00:00
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command,
|
2007-05-31 12:07:48 +00:00
|
|
|
|
_("No Document Open!"),
|
2006-09-29 21:40:56 +00:00
|
|
|
|
FuncRequest(LFUN_NOACTION)));
|
2003-11-12 14:38:26 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2004-01-31 15:30:24 +00:00
|
|
|
|
CharStyles & charstyles =
|
2007-04-29 19:53:54 +00:00
|
|
|
|
buf->params().getTextClass().charstyles();
|
2003-11-12 14:38:26 +00:00
|
|
|
|
CharStyles::iterator cit = charstyles.begin();
|
|
|
|
|
CharStyles::iterator end = charstyles.end();
|
|
|
|
|
for (; cit != end; ++cit) {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
docstring const label = from_utf8(cit->name);
|
2006-09-29 21:40:56 +00:00
|
|
|
|
tomenu.addWithStatusCheck(MenuItem(MenuItem::Command, label,
|
2006-05-05 20:23:12 +00:00
|
|
|
|
FuncRequest(LFUN_CHARSTYLE_INSERT,
|
2006-12-22 09:23:10 +00:00
|
|
|
|
label)));
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-24 22:32:03 +00:00
|
|
|
|
Menu::size_type const max_number_of_items = 25;
|
|
|
|
|
|
2003-07-27 13:18:55 +00:00
|
|
|
|
void expandToc2(Menu & tomenu,
|
2006-11-13 16:53:49 +00:00
|
|
|
|
Toc const & toc_list,
|
|
|
|
|
Toc::size_type from,
|
|
|
|
|
Toc::size_type to, int depth)
|
2002-07-24 22:32:03 +00:00
|
|
|
|
{
|
|
|
|
|
int shortcut_count = 0;
|
2005-05-12 10:16:04 +00:00
|
|
|
|
|
|
|
|
|
// check whether depth is smaller than the smallest depth in toc.
|
|
|
|
|
int min_depth = 1000;
|
2006-11-13 16:53:49 +00:00
|
|
|
|
for (Toc::size_type i = from; i < to; ++i)
|
2006-04-22 18:48:28 +00:00
|
|
|
|
min_depth = std::min(min_depth, toc_list[i].depth());
|
2005-05-12 10:16:04 +00:00
|
|
|
|
if (min_depth > depth)
|
|
|
|
|
depth = min_depth;
|
|
|
|
|
|
|
|
|
|
|
2002-07-24 22:32:03 +00:00
|
|
|
|
if (to - from <= max_number_of_items) {
|
2006-11-13 16:53:49 +00:00
|
|
|
|
for (Toc::size_type i = from; i < to; ++i) {
|
2006-09-09 22:27:22 +00:00
|
|
|
|
docstring label(4 * max(0, toc_list[i].depth() - depth), char_type(' '));
|
2006-10-11 19:40:50 +00:00
|
|
|
|
label += limit_string_length(toc_list[i].str());
|
2006-04-22 18:48:28 +00:00
|
|
|
|
if (toc_list[i].depth() == depth
|
2003-10-25 09:20:51 +00:00
|
|
|
|
&& shortcut_count < 9) {
|
2006-09-09 22:27:22 +00:00
|
|
|
|
if (label.find(convert<docstring>(shortcut_count + 1)) != docstring::npos)
|
|
|
|
|
label += char_type('|') + convert<docstring>(++shortcut_count);
|
2002-07-24 22:32:03 +00:00
|
|
|
|
}
|
2003-09-21 18:57:15 +00:00
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command, label,
|
|
|
|
|
FuncRequest(toc_list[i].action())));
|
2002-07-24 22:32:03 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2006-11-13 16:53:49 +00:00
|
|
|
|
Toc::size_type pos = from;
|
2002-07-24 22:32:03 +00:00
|
|
|
|
while (pos < to) {
|
2006-11-13 16:53:49 +00:00
|
|
|
|
Toc::size_type new_pos = pos + 1;
|
2002-07-24 22:32:03 +00:00
|
|
|
|
while (new_pos < to &&
|
2006-04-22 18:48:28 +00:00
|
|
|
|
toc_list[new_pos].depth() > depth)
|
2002-07-24 22:32:03 +00:00
|
|
|
|
++new_pos;
|
|
|
|
|
|
2006-09-09 22:27:22 +00:00
|
|
|
|
docstring label(4 * max(0, toc_list[pos].depth() - depth), ' ');
|
2006-10-11 19:40:50 +00:00
|
|
|
|
label += limit_string_length(toc_list[pos].str());
|
2006-04-22 18:48:28 +00:00
|
|
|
|
if (toc_list[pos].depth() == depth &&
|
2003-10-25 09:20:51 +00:00
|
|
|
|
shortcut_count < 9) {
|
2006-09-09 22:27:22 +00:00
|
|
|
|
if (label.find(convert<docstring>(shortcut_count + 1)) != docstring::npos)
|
|
|
|
|
label += char_type('|') + convert<docstring>(++shortcut_count);
|
2006-10-11 19:40:50 +00:00
|
|
|
|
}
|
2002-07-24 22:32:03 +00:00
|
|
|
|
if (new_pos == pos + 1) {
|
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command,
|
2003-09-21 18:57:15 +00:00
|
|
|
|
label, FuncRequest(toc_list[pos].action())));
|
2002-07-24 22:32:03 +00:00
|
|
|
|
} else {
|
|
|
|
|
MenuItem item(MenuItem::Submenu, label);
|
|
|
|
|
item.submenu(new Menu);
|
|
|
|
|
expandToc2(*item.submenu(),
|
|
|
|
|
toc_list, pos, new_pos, depth + 1);
|
|
|
|
|
tomenu.add(item);
|
|
|
|
|
}
|
|
|
|
|
pos = new_pos;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-29 21:40:56 +00:00
|
|
|
|
void expandToc(Menu & tomenu, Buffer const * buf)
|
2002-07-24 22:32:03 +00:00
|
|
|
|
{
|
2006-09-29 21:40:56 +00:00
|
|
|
|
// To make things very cleanly, we would have to pass buf to
|
2003-02-15 21:03:40 +00:00
|
|
|
|
// all MenuItem constructors and to expandToc2. However, we
|
|
|
|
|
// know that all the entries in a TOC will be have status_ ==
|
|
|
|
|
// OK, so we avoid this unnecessary overhead (JMarc)
|
|
|
|
|
|
2005-07-28 14:36:16 +00:00
|
|
|
|
if (!buf) {
|
2002-09-10 11:50:13 +00:00
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command,
|
2007-05-31 12:07:48 +00:00
|
|
|
|
_("No Document Open!"),
|
2006-09-29 21:40:56 +00:00
|
|
|
|
FuncRequest(LFUN_NOACTION)));
|
2002-09-10 11:50:13 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-09 22:21:21 +00:00
|
|
|
|
Buffer* cbuf = const_cast<Buffer*>(buf);
|
|
|
|
|
cbuf->tocBackend().update();
|
|
|
|
|
cbuf->structureChanged();
|
2007-06-06 21:19:15 +00:00
|
|
|
|
|
2006-11-13 16:53:49 +00:00
|
|
|
|
// Add an entry for the master doc if this is a child doc
|
|
|
|
|
Buffer const * const master = buf->getMasterBuffer();
|
|
|
|
|
if (buf != master) {
|
|
|
|
|
ParIterator const pit = par_iterator_begin(master->inset());
|
|
|
|
|
string const arg = convert<string>(pit->id());
|
|
|
|
|
FuncRequest f(LFUN_PARAGRAPH_GOTO, arg);
|
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command, _("Master Document"), f));
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
FloatList const & floatlist = buf->params().getTextClass().floats();
|
2006-11-13 16:53:49 +00:00
|
|
|
|
TocList const & toc_list = buf->tocBackend().tocs();
|
|
|
|
|
TocList::const_iterator cit = toc_list.begin();
|
|
|
|
|
TocList::const_iterator end = toc_list.end();
|
2002-07-24 22:32:03 +00:00
|
|
|
|
for (; cit != end; ++cit) {
|
|
|
|
|
// Handle this later
|
2006-11-11 00:35:14 +00:00
|
|
|
|
if (cit->first == "tableofcontents")
|
2002-10-24 09:52:26 +00:00
|
|
|
|
continue;
|
2002-07-24 22:32:03 +00:00
|
|
|
|
|
|
|
|
|
// All the rest is for floats
|
2003-11-03 17:47:28 +00:00
|
|
|
|
auto_ptr<Menu> menu(new Menu);
|
2006-11-13 16:53:49 +00:00
|
|
|
|
TocIterator ccit = cit->second.begin();
|
|
|
|
|
TocIterator eend = cit->second.end();
|
2002-07-24 22:32:03 +00:00
|
|
|
|
for (; ccit != eend; ++ccit) {
|
2006-10-11 19:40:50 +00:00
|
|
|
|
docstring const label = limit_string_length(ccit->str());
|
2002-07-24 22:32:03 +00:00
|
|
|
|
menu->add(MenuItem(MenuItem::Command,
|
2003-09-21 18:57:15 +00:00
|
|
|
|
label,
|
|
|
|
|
FuncRequest(ccit->action())));
|
2002-07-24 22:32:03 +00:00
|
|
|
|
}
|
2005-07-28 14:36:16 +00:00
|
|
|
|
string const & floatName = floatlist.getType(cit->first).listName();
|
2007-05-22 20:29:58 +00:00
|
|
|
|
docstring label;
|
|
|
|
|
if (!floatName.empty())
|
|
|
|
|
label = _(floatName);
|
|
|
|
|
// BUG3633: listings is not a proper float so its name
|
|
|
|
|
// is not shown in floatlist.
|
|
|
|
|
else if (cit->first == "listing")
|
|
|
|
|
label = _("List of listings");
|
|
|
|
|
// this should not happen now, but if something else like
|
|
|
|
|
// listings is added later, this can avoid an empty menu name.
|
|
|
|
|
else
|
|
|
|
|
label = _("Other floats");
|
|
|
|
|
MenuItem item(MenuItem::Submenu, label);
|
2003-11-03 17:47:28 +00:00
|
|
|
|
item.submenu(menu.release());
|
2002-07-24 22:32:03 +00:00
|
|
|
|
tomenu.add(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle normal TOC
|
2006-11-11 00:35:14 +00:00
|
|
|
|
cit = toc_list.find("tableofcontents");
|
2002-07-24 22:32:03 +00:00
|
|
|
|
if (cit == end) {
|
2006-09-29 21:40:56 +00:00
|
|
|
|
tomenu.addWithStatusCheck(MenuItem(MenuItem::Command,
|
2006-09-09 22:27:22 +00:00
|
|
|
|
_("No Table of contents"),
|
2006-09-29 21:40:56 +00:00
|
|
|
|
FuncRequest()));
|
2002-07-24 22:32:03 +00:00
|
|
|
|
} else {
|
|
|
|
|
expandToc2(tomenu, cit->second, 0, cit->second.size(), 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-29 21:40:56 +00:00
|
|
|
|
void expandPasteRecent(Menu & tomenu, Buffer const * buf)
|
2003-06-17 15:33:49 +00:00
|
|
|
|
{
|
2006-09-29 21:40:56 +00:00
|
|
|
|
if (!buf)
|
2003-08-18 12:27:49 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
vector<docstring> const sel =
|
2006-10-21 00:16:43 +00:00
|
|
|
|
cap::availableSelections(*buf);
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
vector<docstring>::const_iterator cit = sel.begin();
|
|
|
|
|
vector<docstring>::const_iterator end = sel.end();
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2003-06-17 15:33:49 +00:00
|
|
|
|
for (unsigned int index = 0; cit != end; ++cit, ++index) {
|
2006-10-11 19:40:50 +00:00
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command, *cit,
|
2005-01-06 15:40:49 +00:00
|
|
|
|
FuncRequest(LFUN_PASTE, convert<string>(index))));
|
2003-06-17 15:33:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-10 23:23:25 +00:00
|
|
|
|
void expandToolbars(Menu & tomenu)
|
2006-11-02 16:01:36 +00:00
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
// extracts the toolbars from the backend
|
|
|
|
|
ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
|
|
|
|
|
ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
|
|
|
|
|
|
2006-11-10 23:23:25 +00:00
|
|
|
|
for (; cit != end; ++cit) {
|
|
|
|
|
docstring label = _(cit->gui_name);
|
2007-06-06 13:52:31 +00:00
|
|
|
|
// frontends are not supposed to turn on/off toolbars,
|
|
|
|
|
// if they cannot update ToolbarBackend::flags. That
|
|
|
|
|
// is to say, ToolbarsBackend::flags should reflect
|
|
|
|
|
// the true state of toolbars.
|
2007-05-28 22:27:45 +00:00
|
|
|
|
//
|
|
|
|
|
// menu is displayed as
|
2006-11-02 18:59:33 +00:00
|
|
|
|
// on/off review
|
2007-05-28 22:27:45 +00:00
|
|
|
|
// and
|
2006-11-02 18:59:33 +00:00
|
|
|
|
// review (auto)
|
|
|
|
|
// in the case of auto.
|
2007-04-19 19:43:15 +00:00
|
|
|
|
if (cit->flags & ToolbarInfo::AUTO)
|
2006-11-02 16:01:36 +00:00
|
|
|
|
label += _(" (auto)");
|
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command, label,
|
2007-06-06 13:52:31 +00:00
|
|
|
|
FuncRequest(LFUN_TOOLBAR_TOGGLE, cit->name + " allowauto")));
|
2006-11-02 16:01:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-29 21:40:56 +00:00
|
|
|
|
void expandBranches(Menu & tomenu, Buffer const * buf)
|
2003-08-17 11:28:23 +00:00
|
|
|
|
{
|
2007-05-31 12:07:48 +00:00
|
|
|
|
if (!buf) {
|
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command,
|
|
|
|
|
_("No Document Open!"),
|
|
|
|
|
FuncRequest(LFUN_NOACTION)));
|
2003-08-18 12:27:49 +00:00
|
|
|
|
return;
|
2007-05-31 12:07:48 +00:00
|
|
|
|
}
|
2003-08-18 12:27:49 +00:00
|
|
|
|
|
2006-09-29 21:40:56 +00:00
|
|
|
|
BufferParams const & params = buf->getMasterBuffer()->params();
|
2007-05-31 12:07:48 +00:00
|
|
|
|
if (params.branchlist().empty()) {
|
|
|
|
|
tomenu.add(MenuItem(MenuItem::Command,
|
|
|
|
|
_("No Branch in Document!"),
|
|
|
|
|
FuncRequest(LFUN_NOACTION)));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-08-17 11:28:23 +00:00
|
|
|
|
|
2005-10-25 15:21:49 +00:00
|
|
|
|
BranchList::const_iterator cit = params.branchlist().begin();
|
|
|
|
|
BranchList::const_iterator end = params.branchlist().end();
|
2003-08-28 07:41:31 +00:00
|
|
|
|
|
2003-08-17 11:28:23 +00:00
|
|
|
|
for (int ii = 1; cit != end; ++cit, ++ii) {
|
2006-11-03 15:16:45 +00:00
|
|
|
|
docstring label = cit->getBranch();
|
2003-08-17 11:28:23 +00:00
|
|
|
|
if (ii < 10)
|
2006-10-11 19:40:50 +00:00
|
|
|
|
label = convert<docstring>(ii) + ". " + label + char_type('|') + convert<docstring>(ii);
|
2006-09-29 21:40:56 +00:00
|
|
|
|
tomenu.addWithStatusCheck(MenuItem(MenuItem::Command, label,
|
2006-05-05 20:23:12 +00:00
|
|
|
|
FuncRequest(LFUN_BRANCH_INSERT,
|
2006-09-29 21:40:56 +00:00
|
|
|
|
cit->getBranch())));
|
2003-08-17 11:28:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-22 20:12:08 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
|
|
2002-07-23 22:42:12 +00:00
|
|
|
|
void MenuBackend::expand(Menu const & frommenu, Menu & tomenu,
|
2006-09-29 21:40:56 +00:00
|
|
|
|
Buffer const * buf) const
|
2002-07-22 20:12:08 +00:00
|
|
|
|
{
|
2006-03-15 15:07:20 +00:00
|
|
|
|
if (!tomenu.empty())
|
|
|
|
|
tomenu.clear();
|
|
|
|
|
|
2002-07-23 22:42:12 +00:00
|
|
|
|
for (Menu::const_iterator cit = frommenu.begin();
|
|
|
|
|
cit != frommenu.end() ; ++cit) {
|
2002-07-22 20:12:08 +00:00
|
|
|
|
switch (cit->kind()) {
|
2002-08-21 07:30:57 +00:00
|
|
|
|
case MenuItem::Lastfiles:
|
2006-09-29 21:40:56 +00:00
|
|
|
|
expandLastfiles(tomenu);
|
2002-07-22 20:12:08 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MenuItem::Documents:
|
2006-09-29 21:40:56 +00:00
|
|
|
|
expandDocuments(tomenu);
|
2002-07-22 20:12:08 +00:00
|
|
|
|
break;
|
2000-10-04 09:54:31 +00:00
|
|
|
|
|
2006-11-01 15:55:17 +00:00
|
|
|
|
case MenuItem::Bookmarks:
|
|
|
|
|
expandBookmarks(tomenu);
|
|
|
|
|
break;
|
|
|
|
|
|
2000-11-13 10:35:02 +00:00
|
|
|
|
case MenuItem::ImportFormats:
|
2000-10-04 09:54:31 +00:00
|
|
|
|
case MenuItem::ViewFormats:
|
|
|
|
|
case MenuItem::UpdateFormats:
|
2002-07-22 20:12:08 +00:00
|
|
|
|
case MenuItem::ExportFormats:
|
2006-09-29 21:40:56 +00:00
|
|
|
|
expandFormats(cit->kind(), tomenu, buf);
|
2002-07-22 20:12:08 +00:00
|
|
|
|
break;
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
2003-11-12 14:38:26 +00:00
|
|
|
|
case MenuItem::CharStyles:
|
2006-09-29 21:40:56 +00:00
|
|
|
|
expandCharStyleInsert(tomenu, buf);
|
2003-11-12 14:38:26 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2001-05-04 10:36:36 +00:00
|
|
|
|
case MenuItem::FloatListInsert:
|
2006-09-29 21:40:56 +00:00
|
|
|
|
expandFloatListInsert(tomenu, buf);
|
2002-07-22 20:12:08 +00:00
|
|
|
|
break;
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
|
|
|
|
case MenuItem::FloatInsert:
|
2006-09-29 21:40:56 +00:00
|
|
|
|
expandFloatInsert(tomenu, buf);
|
2002-07-22 20:12:08 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-06-17 15:33:49 +00:00
|
|
|
|
case MenuItem::PasteRecent:
|
2006-09-29 21:40:56 +00:00
|
|
|
|
expandPasteRecent(tomenu, buf);
|
2003-06-17 15:33:49 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-11-02 16:01:36 +00:00
|
|
|
|
case MenuItem::Toolbars:
|
2006-11-10 23:23:25 +00:00
|
|
|
|
expandToolbars(tomenu);
|
2006-11-02 16:01:36 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2003-08-17 11:28:23 +00:00
|
|
|
|
case MenuItem::Branches:
|
2006-09-29 21:40:56 +00:00
|
|
|
|
expandBranches(tomenu, buf);
|
2003-08-17 11:28:23 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-07-24 22:32:03 +00:00
|
|
|
|
case MenuItem::Toc:
|
2006-09-29 21:40:56 +00:00
|
|
|
|
expandToc(tomenu, buf);
|
2002-07-24 22:32:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-07-23 22:42:12 +00:00
|
|
|
|
case MenuItem::Submenu: {
|
|
|
|
|
MenuItem item(*cit);
|
2002-07-24 22:32:03 +00:00
|
|
|
|
item.submenu(new Menu(cit->submenuname()));
|
|
|
|
|
expand(getMenu(cit->submenuname()),
|
2006-09-29 21:40:56 +00:00
|
|
|
|
*item.submenu(), buf);
|
|
|
|
|
tomenu.addWithStatusCheck(item);
|
2002-07-23 22:42:12 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2002-08-21 07:30:57 +00:00
|
|
|
|
|
2004-08-14 18:06:10 +00:00
|
|
|
|
case MenuItem::Separator:
|
2006-09-29 21:40:56 +00:00
|
|
|
|
tomenu.addWithStatusCheck(*cit);
|
2004-08-14 18:06:10 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MenuItem::Command:
|
2007-01-03 11:59:10 +00:00
|
|
|
|
if (!specialmenu_.hasFunc(cit->func()))
|
2006-09-29 21:40:56 +00:00
|
|
|
|
tomenu.addWithStatusCheck(*cit);
|
2000-10-04 09:54:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-11-03 13:26:55 +00:00
|
|
|
|
|
2003-02-15 21:03:40 +00:00
|
|
|
|
// we do not want the menu to end with a separator
|
|
|
|
|
if (!tomenu.empty()
|
|
|
|
|
&& tomenu.items_.back().kind() == MenuItem::Separator)
|
|
|
|
|
tomenu.items_.pop_back();
|
|
|
|
|
|
2000-11-03 13:26:55 +00:00
|
|
|
|
// Check whether the shortcuts are unique
|
2003-07-22 09:15:55 +00:00
|
|
|
|
tomenu.checkShortcuts();
|
2000-10-04 09:54:31 +00:00
|
|
|
|
}
|
2000-07-24 13:53:19 +00:00
|
|
|
|
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
void MenuBackend::read(Lexer & lex)
|
2000-07-24 13:53:19 +00:00
|
|
|
|
{
|
|
|
|
|
enum Menutags {
|
|
|
|
|
md_menu = 1,
|
|
|
|
|
md_menubar,
|
|
|
|
|
md_endmenuset,
|
|
|
|
|
md_last
|
|
|
|
|
};
|
|
|
|
|
|
2000-07-24 21:49:58 +00:00
|
|
|
|
struct keyword_item menutags[md_last - 1] = {
|
2000-07-24 13:53:19 +00:00
|
|
|
|
{ "end", md_endmenuset },
|
|
|
|
|
{ "menu", md_menu },
|
|
|
|
|
{ "menubar", md_menubar }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//consistency check
|
2002-07-16 21:17:10 +00:00
|
|
|
|
if (compare_ascii_no_case(lex.getString(), "menuset")) {
|
2000-07-24 13:53:19 +00:00
|
|
|
|
lyxerr << "Menubackend::read: ERROR wrong token:`"
|
2001-08-06 19:12:46 +00:00
|
|
|
|
<< lex.getString() << '\'' << endl;
|
|
|
|
|
}
|
2000-07-24 13:53:19 +00:00
|
|
|
|
|
|
|
|
|
lex.pushTable(menutags, md_last - 1);
|
|
|
|
|
if (lyxerr.debugging(Debug::PARSER))
|
|
|
|
|
lex.printTable(lyxerr);
|
|
|
|
|
|
|
|
|
|
bool quit = false;
|
|
|
|
|
|
2001-08-06 19:12:46 +00:00
|
|
|
|
while (lex.isOK() && !quit) {
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (lex.lex()) {
|
2002-03-21 17:27:08 +00:00
|
|
|
|
case md_menubar:
|
2002-07-20 21:50:05 +00:00
|
|
|
|
menubar_.read(lex);
|
|
|
|
|
break;
|
2000-07-24 13:53:19 +00:00
|
|
|
|
case md_menu: {
|
2001-07-23 09:11:14 +00:00
|
|
|
|
lex.next(true);
|
2006-11-22 09:15:38 +00:00
|
|
|
|
docstring const name = lex.getDocString();
|
2000-07-26 14:08:09 +00:00
|
|
|
|
if (hasMenu(name)) {
|
2002-07-20 21:50:05 +00:00
|
|
|
|
getMenu(name).read(lex);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
} else {
|
2002-07-20 21:50:05 +00:00
|
|
|
|
Menu menu(name);
|
2000-07-26 14:08:09 +00:00
|
|
|
|
menu.read(lex);
|
|
|
|
|
add(menu);
|
|
|
|
|
}
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case md_endmenuset:
|
|
|
|
|
quit = true;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
lex.printError("menubackend::read: "
|
|
|
|
|
"Unknown menu tag: `$$Token'");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
lex.popTable();
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-24 21:49:58 +00:00
|
|
|
|
|
|
|
|
|
void MenuBackend::add(Menu const & menu)
|
2000-07-24 13:53:19 +00:00
|
|
|
|
{
|
|
|
|
|
menulist_.push_back(menu);
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-24 21:49:58 +00:00
|
|
|
|
|
2006-09-09 22:27:22 +00:00
|
|
|
|
bool MenuBackend::hasMenu(docstring const & name) const
|
2000-07-24 13:53:19 +00:00
|
|
|
|
{
|
2004-01-31 15:30:24 +00:00
|
|
|
|
return find_if(begin(), end(), MenuNamesEqual(name)) != end();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-07-24 21:49:58 +00:00
|
|
|
|
|
2006-09-09 22:27:22 +00:00
|
|
|
|
Menu const & MenuBackend::getMenu(docstring const & name) const
|
2000-07-24 13:53:19 +00:00
|
|
|
|
{
|
2004-01-31 15:30:24 +00:00
|
|
|
|
const_iterator cit = find_if(begin(), end(), MenuNamesEqual(name));
|
2002-09-06 01:41:01 +00:00
|
|
|
|
if (cit == end())
|
2006-10-21 00:16:43 +00:00
|
|
|
|
lyxerr << "No submenu named " << to_utf8(name) << endl;
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(cit != end());
|
2000-10-11 21:06:43 +00:00
|
|
|
|
return (*cit);
|
2000-07-24 13:53:19 +00:00
|
|
|
|
}
|
2000-07-26 14:08:09 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-09 22:27:22 +00:00
|
|
|
|
Menu & MenuBackend::getMenu(docstring const & name)
|
2000-07-26 14:08:09 +00:00
|
|
|
|
{
|
2004-01-31 15:30:24 +00:00
|
|
|
|
iterator it = find_if(begin(), end(), MenuNamesEqual(name));
|
|
|
|
|
if (it == end())
|
2006-10-21 00:16:43 +00:00
|
|
|
|
lyxerr << "No submenu named " << to_utf8(name) << endl;
|
2004-01-31 15:30:24 +00:00
|
|
|
|
BOOST_ASSERT(it != end());
|
2000-10-11 21:06:43 +00:00
|
|
|
|
return (*it);
|
2000-07-26 14:08:09 +00:00
|
|
|
|
}
|
2002-07-20 21:50:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Menu const & MenuBackend::getMenubar() const
|
|
|
|
|
{
|
|
|
|
|
return menubar_;
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|