-/* This file is part of
- * ======================================================
+/**
+ * \file MenuBackend.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * LyX, The Document Processor
+ * \author Asger Alstrup
+ * \author Lars Gullik Bjønnes
+ * \author Jean-Marc Lasgouttes
+ * \author André Pönitz
+ * \author Dekel Tsur
+ * \author Martin Vermeer
*
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2001 The LyX Team.
- *
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS.
+ */
#include <config.h>
#include "format.h"
#include "exporter.h"
#include "importer.h"
+#include "Floating.h"
#include "FloatList.h"
#include "toc.h"
#include "CutAndPaste.h"
case FloatListInsert:
case FloatInsert:
case PasteRecent:
+ case Branches:
break;
case Command:
action_ = lyxaction.LookupFunc(command);
{
enum Menutags {
md_item = 1,
+ md_branches,
md_documents,
md_endmenu,
md_exportformats,
};
struct keyword_item menutags[md_last - 1] = {
+ { "branches", md_branches },
{ "documents", md_documents },
{ "end", md_endmenu },
{ "exportformats", md_exportformats },
add(MenuItem(MenuItem::PasteRecent));
break;
+ case md_branches:
+ add(MenuItem(MenuItem::Branches));
+ break;
+
case md_optsubmenu:
optional = true;
// fallback to md_submenu
action = LFUN_IMPORT;
break;
case MenuItem::ViewFormats:
- formats = Exporter::GetExportableFormats(view->buffer(), true);
+ formats = Exporter::GetExportableFormats(*view->buffer(), true);
action = LFUN_PREVIEW;
break;
case MenuItem::UpdateFormats:
- formats = Exporter::GetExportableFormats(view->buffer(), true);
+ formats = Exporter::GetExportableFormats(*view->buffer(), true);
action = LFUN_UPDATE;
break;
default:
- formats = Exporter::GetExportableFormats(view->buffer(), false);
+ formats = Exporter::GetExportableFormats(*view->buffer(), false);
action = LFUN_EXPORT;
}
sort(formats.begin(), formats.end(), compare_format());
Menu::size_type const max_number_of_items = 25;
-void expandToc2(Menu & tomenu, toc::Toc const & toc_list,
- toc::Toc::size_type from, toc::Toc::size_type to, int depth)
+void expandToc2(Menu & tomenu,
+ lyx::toc::Toc const & toc_list,
+ lyx::toc::Toc::size_type from,
+ lyx::toc::Toc::size_type to, int depth)
{
int shortcut_count = 0;
if (to - from <= max_number_of_items) {
- for (toc::Toc::size_type i = from; i < to; ++i) {
+ 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);
tomenu.add(MenuItem(MenuItem::Command, label, action));
}
} else {
- toc::Toc::size_type pos = from;
+ lyx::toc::Toc::size_type pos = from;
while (pos < to) {
- toc::Toc::size_type new_pos = pos + 1;
+ lyx::toc::Toc::size_type new_pos = pos + 1;
while (new_pos < to &&
toc_list[new_pos].depth > depth)
++new_pos;
return;
}
- toc::TocList toc_list = toc::getTocList(view->buffer());
- toc::TocList::const_iterator cit = toc_list.begin();
- toc::TocList::const_iterator end = toc_list.end();
+ lyx::toc::TocList toc_list = lyx::toc::getTocList(*view->buffer());
+ lyx::toc::TocList::const_iterator cit = toc_list.begin();
+ lyx::toc::TocList::const_iterator end = toc_list.end();
for (; cit != end; ++cit) {
// Handle this later
if (cit->first == "TOC")
// All the rest is for floats
Menu * menu = new Menu;
- toc::Toc::const_iterator ccit = cit->second.begin();
- toc::Toc::const_iterator eend = cit->second.end();
+ lyx::toc::Toc::const_iterator ccit = cit->second.begin();
+ lyx::toc::Toc::const_iterator eend = cit->second.end();
for (; ccit != eend; ++ccit) {
string const label = limit_string_length(ccit->str);
menu->add(MenuItem(MenuItem::Command,
void expandPasteRecent(Menu & tomenu, LyXView const * view)
{
+ if (!view || !view->buffer())
+ return;
+
vector<string> const selL =
CutAndPaste::availableSelections(*view->buffer());
}
+void expandBranches(Menu & tomenu, LyXView const * view)
+{
+ if (!view || !view->buffer())
+ return;
+
+ BufferParams const & params = view->buffer()->params;
+
+ std::list<Branch>::const_iterator cit = params.branchlist.begin();
+ std::list<Branch>::const_iterator end = params.branchlist.end();
+
+ 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);
+ }
+}
+
+
} // namespace anon
expandPasteRecent(tomenu, view);
break;
+ case MenuItem::Branches:
+ expandBranches(tomenu, view);
+ break;
+
case MenuItem::Toc:
expandToc(tomenu, view);
break;