#include "frontends/Clipboard.h"
#include "frontends/Selection.h"
+#include "insets/InsetArgument.h"
#include "insets/InsetCollapsable.h"
#include "insets/InsetCommand.h"
#include "insets/InsetExternal.h"
FontInfo const & fontinfo = cur.real_current_font.fontInfo();
bool enable = true;
+ bool allow_in_passthru = false;
InsetCode code = NO_CODE;
switch (cmd.action()) {
break;
case LFUN_ARGUMENT_INSERT: {
code = ARG_CODE;
+ allow_in_passthru = true;
+ string const arg = cmd.getArg(0);
+ if (arg.empty()) {
+ enable = false;
+ break;
+ }
Layout const & lay = cur.paragraph().layout();
- int const numargs = lay.reqargs + lay.optargs;
- enable = cur.paragraph().insetList().count(ARG_CODE) < numargs;
+ Layout::LaTeXArgMap args = lay.latexargs();
+ Layout::LaTeXArgMap::const_iterator const lait =
+ args.find(convert<unsigned int>(arg));
+ if (lait != args.end()) {
+ enable = true;
+ InsetList::const_iterator it = cur.paragraph().insetList().begin();
+ InsetList::const_iterator const end = cur.paragraph().insetList().end();
+ for (; it != end; ++it) {
+ if (it->inset->lyxCode() == ARG_CODE) {
+ InsetArgument const * ins =
+ static_cast<InsetArgument const *>(it->inset);
+ if (ins->name() == arg) {
+ // we have this already
+ enable = false;
+ break;
+ }
+ }
+ }
+ } else
+ enable = false;
break;
}
case LFUN_INDEX_INSERT:
if (code != NO_CODE
&& (cur.empty()
|| !cur.inset().insetAllowed(code)
- || cur.paragraph().layout().pass_thru))
+ || (cur.paragraph().layout().pass_thru && !allow_in_passthru)))
enable = false;
flag.setEnabled(enable);