Possibility to specify a preset argument

This will be needed for beamer plain and fragile frame support.
This commit is contained in:
Juergen Spitzmueller 2012-12-10 14:09:51 +01:00
parent 625e25264b
commit e93f4d470d
7 changed files with 129 additions and 7 deletions

View File

@ -10748,7 +10748,7 @@ status collapsed
\begin_layout Itemize
\change_inserted -712698321 1354263106
\change_inserted -712698321 1355144479
\begin_inset Flex Code
status collapsed
@ -10810,6 +10810,39 @@ status collapsed
\end_inset
.
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1355144578
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1355144487
PresetArg
\change_unchanged
\end_layout
\end_inset
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1355144500
[string]
\end_layout
\end_inset
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
@ -12494,7 +12527,42 @@ LatexName
\end_inset
stuff.
This parameter cannot be changed from within LyX.
This parameter cannot be changed from within LyX
\change_inserted -712698321 1355144804
(use
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1355144804
Argument
\end_layout
\end_inset
for customizable parameters)
\change_unchanged
.
\change_inserted -712698321 1355144804
This will be output as is after all LaTeX
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1355144658
Arguments
\change_unchanged
\end_layout
\end_inset
.
\change_unchanged
\end_layout
\begin_layout Description
@ -16636,7 +16704,40 @@ status collapsed
\end_inset
.
This parameter cannot be changed from within LyX.
\change_inserted -712698321 1355144715
This will be output as is after all LaTeX
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1355144713
Arguments
\end_layout
\end_inset
.
\change_unchanged
This parameter cannot be changed from within LyX
\change_inserted -712698321 1355144775
(use
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1355144747
Argument
\end_layout
\end_inset
for customizable parameters)
\change_unchanged
.
\end_layout
\begin_layout Description

View File

@ -916,6 +916,9 @@ void Layout::readArgument(Lexer & lex)
arg.rdelim = lex.getDocString();
arg.rdelim = support::subst(arg.rdelim, from_ascii("<br/>"),
from_ascii("\n"));
} else if (tok == "presetarg") {
lex.next();
arg.presetarg = lex.getDocString();
} else if (tok == "tooltip") {
lex.next();
arg.tooltip = lex.getDocString();

View File

@ -94,6 +94,7 @@ public:
bool mandatory;
docstring ldelim;
docstring rdelim;
docstring presetarg;
docstring tooltip;
std::string requires;
std::string decoration;

View File

@ -239,7 +239,7 @@ InsetLayout::InsetDecoration InsetArgument::decoration() const
void InsetArgument::latexArgument(otexstream & os,
OutputParams const & runparams_in, docstring const & ldelim,
docstring const & rdelim) const
docstring const & rdelim, docstring const & presetarg) const
{
TexRow texrow;
odocstringstream ss;
@ -247,6 +247,9 @@ void InsetArgument::latexArgument(otexstream & os,
OutputParams runparams = runparams_in;
InsetText::latex(ots, runparams);
docstring str = ss.str();
docstring const sep = str.empty() ? docstring() : from_ascii(", ");
if (!presetarg.empty())
str = presetarg + sep + str;
if (ldelim != "{" && support::contains(str, rdelim))
str = '{' + str + '}';
os << ldelim << str << rdelim;

View File

@ -31,7 +31,8 @@ public:
/// Outputting the parameter of a LaTeX command
void latexArgument(otexstream &, OutputParams const &,
docstring const&, docstring const &) const;
docstring const&, docstring const &,
docstring const &) const;
std::string name() const { return name_; }

View File

@ -544,6 +544,9 @@ void InsetLayout::readArgument(Lexer & lex)
arg.rdelim = lex.getDocString();
arg.rdelim = support::subst(arg.rdelim,
from_ascii("<br/>"), from_ascii("\n"));
} else if (tok == "presetarg") {
lex.next();
arg.presetarg = lex.getDocString();
} else if (tok == "tooltip") {
lex.next();
arg.tooltip = lex.getDocString();

View File

@ -368,7 +368,7 @@ void latexArgInsets(Paragraph const & par, otexstream & os,
ldelim = arg.ldelim;
if (!arg.rdelim.empty())
rdelim = arg.rdelim;
ins->latexArgument(os, runparams, ldelim, rdelim);
ins->latexArgument(os, runparams, ldelim, rdelim, arg.presetarg);
inserted = true;
}
}
@ -385,7 +385,17 @@ void latexArgInsets(Paragraph const & par, otexstream & os,
from_ascii("{") : arg.ldelim;
docstring rdelim = arg.rdelim.empty() ?
from_ascii("}") : arg.rdelim;
os << ldelim << 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;
} else if (find(required.begin(), required.end(),
(*lait).first) != required.end()) {
docstring ldelim = arg.ldelim.empty() ?