#include "insets/Inset.h"
#include "insets/InsetCitation.h"
#include "insets/InsetGraphics.h"
+#include "insets/InsetInfo.h"
#include "insets/InsetQuotes.h"
#include "support/lassert.h"
IndicesListsContext,
/** Available citation styles for a given citation */
CiteStyles,
+ /** Available arguments for a given info inset */
+ InfoArguments,
/** Available graphics groups */
GraphicsGroups,
/// Words suggested by the spellchecker.
void expandIndices(Buffer const * buf, bool listof = false);
void expandIndicesContext(Buffer const * buf, bool listof = false);
void expandCiteStyles(BufferView const *);
+ void expandInfoArguments(BufferView const *);
void expandGraphicsGroups(BufferView const *);
void expandSpellingSuggestions(BufferView const *);
void expandLanguageSelector(Buffer const * buf);
md_indicescontext,
md_indiceslists,
md_indiceslistscontext,
+ md_infoarguments,
md_lastfiles,
md_optitem,
md_optsubmenu,
{ "indicescontext", md_indicescontext },
{ "indiceslists", md_indiceslists },
{ "indiceslistscontext", md_indiceslistscontext },
+ { "infoarguments", md_infoarguments },
{ "item", md_item },
{ "languageselector", md_languageselector },
{ "lastfiles", md_lastfiles },
add(MenuItem(MenuItem::CiteStyles));
break;
+ case md_infoarguments:
+ add(MenuItem(MenuItem::InfoArguments));
+ break;
+
+
case md_graphicsgroups:
add(MenuItem(MenuItem::GraphicsGroups));
break;
if (cit->second.lyxtype() == type) {
if (!cit->second.obsoleted_by().empty())
continue;
- docstring label = cit->first;
+ docstring name = cit->first;
// we remove the "Flex:" prefix, if it is present
- if (prefixIs(label, from_ascii("Flex:")))
- label = label.substr(5);
+ if (prefixIs(name, from_ascii("Flex:")))
+ name = name.substr(5);
+ docstring const label = (cit->second.menustring().empty()) ?
+ name
+ : cit->second.menustring();
addWithStatusCheck(MenuItem(MenuItem::Command,
toqstr(translateIfPossible(label)),
- FuncRequest(LFUN_FLEX_INSERT, Lexer::quoteString(label))));
+ FuncRequest(LFUN_FLEX_INSERT, Lexer::quoteString(name))));
}
}
// FIXME This is a little clunky.
}
+void MenuDefinition::expandInfoArguments(BufferView const * bv)
+{
+ if (!bv)
+ return;
+
+ Inset const * inset = bv->cursor().nextInset();
+ if (!inset || inset->lyxCode() != INFO_CODE) {
+ add(MenuItem(MenuItem::Command,
+ qt_("No Text Field in Scope!"),
+ FuncRequest(LFUN_NOACTION)));
+ return;
+ }
+ InsetInfo const * iinset = static_cast<InsetInfo const *>(inset);
+
+ string const type = iinset->params().infoType();
+ vector<pair<string,docstring>> const args =
+ iinset->params().getArguments(&bv->buffer(), type);
+
+ // Don't generate a menu for big lists (such as lfuns and rcs)
+ if (args.size() > 15)
+ return;
+
+ for (auto const & p : args) {
+ if (p.first == "invalid")
+ // non-selectable
+ continue;
+ if (p.first == "custom") {
+ add(MenuItem(MenuItem::Command, qt_("Custom..."),
+ FuncRequest(LFUN_INSET_SETTINGS, "info")));
+ continue;
+ }
+ docstring label = p.second;
+ addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(label),
+ FuncRequest(LFUN_INSET_MODIFY, type + " " + p.first)));
+ }
+}
+
+
+
void MenuDefinition::expandArguments(BufferView const * bv, bool switcharg)
{
if (!bv)
translateIfPossible(prevlayout));
// We use command-alternatives here since this is how the binding is defined
// (otherwise, the binding is not displayed in the menu)
- add(MenuItem(MenuItem::Command, toqstr(label),
- FuncRequest(LFUN_COMMAND_ALTERNATIVES,
- from_ascii("environment-split ; environment-split previous"))));
+ if (getStatus(FuncRequest(LFUN_ENVIRONMENT_SPLIT)).enabled())
+ add(MenuItem(MenuItem::Command, toqstr(label),
+ FuncRequest(LFUN_COMMAND_ALTERNATIVES,
+ from_ascii("environment-split ; environment-split previous"))));
}
if (!outerlayout.empty()) {
docstring label;
tomenu.expandCiteStyles(bv);
break;
+ case MenuItem::InfoArguments:
+ tomenu.expandInfoArguments(bv);
+ break;
+
+
case MenuItem::Toc:
tomenu.expandToc(buf);
break;
bool Menus::searchMenu(FuncRequest const & func,
- docstring_list & names) const
+ docstring_list & names, BufferView const * bv) const
{
MenuDefinition menu;
- d->expand(d->menubar_, menu, 0);
+ d->expand(d->menubar_, menu, bv);
return menu.searchMenu(func, names);
}