diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index 632964499b..0772ff60a7 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -1,5 +1,5 @@ #LyX 2.1 created this file. For more info see http://www.lyx.org/ -\lyxformat 461 +\lyxformat 463 \begin_document \begin_header \textclass scrbook @@ -11024,7 +11024,44 @@ status collapsed \begin_layout Itemize -\change_inserted -712698321 1355144578 +\change_inserted -712698321 1361701444 +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1361701356 +DefaultArg +\end_layout + +\end_inset + + +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1361701356 +[string] +\end_layout + +\end_inset + + defines an argument that is inserted if and only if no user-specified arguments + were given, i. +\begin_inset space \thinspace{} +\end_inset + +e. + if no argument inset has been inserted (note that also an empty argument + inset omits the DefaultArg). + Multiple arguments need to be separated by comma. +\end_layout + +\begin_layout Itemize + +\change_inserted -712698321 1361701337 \begin_inset Flex Code status collapsed @@ -11053,8 +11090,6 @@ status collapsed defines an argument that is inserted in any case (alone or in addition to user-specified arguments). Multiple arguments need to be separated by comma. -\change_unchanged - \end_layout \begin_layout Itemize diff --git a/src/Layout.cpp b/src/Layout.cpp index 48489548c0..deec49fdbe 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -923,6 +923,9 @@ void Layout::readArgument(Lexer & lex) arg.rdelim = lex.getDocString(); arg.rdelim = support::subst(arg.rdelim, from_ascii("
"), from_ascii("\n")); + } else if (tok == "defaultarg") { + lex.next(); + arg.defaultarg = lex.getDocString(); } else if (tok == "presetarg") { lex.next(); arg.presetarg = lex.getDocString(); diff --git a/src/Layout.h b/src/Layout.h index d84ca372b6..88cb9a4edb 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -96,6 +96,7 @@ public: bool mandatory; docstring ldelim; docstring rdelim; + docstring defaultarg; docstring presetarg; docstring tooltip; std::string requires; diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index c1a6c113c2..77294856d2 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -551,6 +551,9 @@ void InsetLayout::readArgument(Lexer & lex) arg.rdelim = lex.getDocString(); arg.rdelim = support::subst(arg.rdelim, from_ascii("
"), from_ascii("\n")); + } else if (tok == "defaultarg") { + lex.next(); + arg.defaultarg = lex.getDocString(); } else if (tok == "presetarg") { lex.next(); arg.presetarg = lex.getDocString(); diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 2af9831d78..4acbe65433 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -351,22 +351,24 @@ void getArgInsets(otexstream & os, OutputParams const & runparams, Layout::LaTeX string const name = prefix + convert(i); if ((*lait).first == name) { Layout::latexarg arg = (*lait).second; + docstring preset = arg.presetarg; + if (!arg.defaultarg.empty()) { + if (!preset.empty()) + preset += ","; + preset += arg.defaultarg; + } if (arg.mandatory) { docstring ldelim = arg.ldelim.empty() ? from_ascii("{") : arg.ldelim; docstring rdelim = arg.rdelim.empty() ? from_ascii("}") : arg.rdelim; - os << ldelim << arg.presetarg << rdelim; - } else if (!arg.presetarg.empty()) { - docstring ldelim = arg.mandatory ? - from_ascii("{") : from_ascii("["); - docstring rdelim = arg.mandatory ? - from_ascii("}") : from_ascii("]"); - if (!arg.ldelim.empty()) - ldelim = arg.ldelim; - if (!arg.rdelim.empty()) - rdelim = arg.rdelim; - os << ldelim << arg.presetarg << rdelim; + os << ldelim << preset << rdelim; + } else if (!preset.empty()) { + docstring ldelim = arg.ldelim.empty() ? + from_ascii("[") : arg.ldelim; + docstring rdelim = arg.rdelim.empty() ? + from_ascii("]") : arg.rdelim; + os << ldelim << preset << rdelim; } else if (find(required.begin(), required.end(), (*lait).first) != required.end()) { docstring ldelim = arg.ldelim.empty() ?