#LyX 2.1 created this file. For more info see http://www.lyx.org/
-\lyxformat 453
+\lyxformat 455
\begin_document
\begin_header
\textclass scrbook
\begin_layout Standard
+\change_inserted -712698321 1356689813
+By default, the text entered in the LyX workarea in the respective layout
+ is the last (mandatory) argument of a command if the
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1356689619
+LatexType
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+ is
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1356689629
+Command
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+.
+ However, arguments with the prefix
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1356689679
+post:
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+ are output after this workarea argument.
+ Note that post-argument numbering restarts at 1, so the first argument
+ following the workarea argument is
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1356689813
+post:1
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+.
+ Post-arguments are ignored in any other
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1356689801
+LatexType
+\end_layout
+
+\end_inset
+
+ than
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1356689801
+Command
+\end_layout
+
+\end_inset
+
+.
+\change_unchanged
+
+\end_layout
+
+\begin_layout Standard
+
\change_inserted 155139281 1354199102
Arguments for list
\begin_inset Flex Code
string id;
lex >> id;
bool const itemarg = prefixIs(id, "item:");
+ bool const postcmd = prefixIs(id, "post:");
while (!finished && lex.isOK() && !error) {
lex.next();
LYXERR0("Incomplete Argument definition!");
else if (itemarg)
itemargs_[id] = arg;
+ else if (postcmd)
+ postcommandargs_[id] = arg;
else
latexargs_[id] = arg;
}
Layout::LaTeXArgMap Layout::args() const
{
LaTeXArgMap args = latexargs_;
+ if (!postcommandargs_.empty())
+ args.insert(postcommandargs_.begin(), postcommandargs_.end());
if (!itemargs_.empty())
args.insert(itemargs_.begin(), itemargs_.end());
return args;
if (!(*it).second.mandatory)
++nr;
}
+ LaTeXArgMap::const_iterator iit = postcommandargs_.begin();
+ for (; iit != postcommandargs_.end(); ++iit) {
+ if (!(*iit).second.mandatory)
+ ++nr;
+ }
return nr;
}
if ((*it).second.mandatory)
++nr;
}
+ LaTeXArgMap::const_iterator iit = postcommandargs_.begin();
+ for (; iit != postcommandargs_.end(); ++iit) {
+ if (!(*iit).second.mandatory)
+ ++nr;
+ }
return nr;
}
///
LaTeXArgMap const & latexargs() const { return latexargs_; }
///
+ LaTeXArgMap const & postcommandargs() const { return postcommandargs_; }
+ ///
LaTeXArgMap const & itemargs() const { return itemargs_; }
///
int optArgs() const;
///
LaTeXArgMap latexargs_;
///
+ LaTeXArgMap postcommandargs_;
+ ///
LaTeXArgMap itemargs_;
};
// this will output "{" at the beginning, but not at the end
owner_->latex(bp, f, os, features.runparams(), 0, -1, true);
if (ods.str().length() > length) {
- if (is_command)
+ if (is_command) {
ods << '}';
+ if (!layout_->postcommandargs().empty()) {
+ OutputParams rp = features.runparams();
+ rp.local_font = &owner_->getFirstFontSettings(bp);
+ latexArgInsets(*owner_, os, rp, layout_->postcommandargs(), "post:");
+ }
+ }
string const snippet = to_utf8(ods.str());
features.addPreambleSnippet(snippet);
}
Inset const * inset = &bv->cursor().inset();
Layout::LaTeXArgMap args = bv->cursor().paragraph().layout().args();
if (inset && args.empty())
- args = inset->getLayout().latexargs();
+ args = inset->getLayout().args();
if (args.empty() || (switcharg && args.size() == 1))
return;
Layout::LaTeXArgMap::const_iterator lait = args.begin();
pass_thru_ = it.paragraph().layout().pass_thru;
bool const insetlayout = &it.inset() && args.empty();
if (insetlayout) {
- args = it.inset().getLayout().latexargs();
+ args = it.inset().getLayout().args();
pass_thru_ = it.inset().getLayout().isPassThru();
}
TexRow texrow;
odocstringstream ods;
otexstream os(ods, texrow);
- ins->getOptArg(os, runparams);
+ ins->getArgs(os, runparams);
ods << '[';
odocstringstream odss;
otexstream oss(odss, texrow);
arg.labelfont = inherit_font;
string nr;
lex >> nr;
+ bool const postcmd = support::prefixIs(nr, "post:");
while (!finished && lex.isOK() && !error) {
lex.next();
string const tok = support::ascii_lowercase(lex.getString());
}
if (arg.labelstring.empty())
LYXERR0("Incomplete Argument definition!");
+ else if (postcmd)
+ postcommandargs_[nr] = arg;
else
latexargs_[nr] = arg;
}
+
+Layout::LaTeXArgMap InsetLayout::args() const
+{
+ Layout::LaTeXArgMap args = latexargs_;
+ if (!postcommandargs_.empty())
+ args.insert(postcommandargs_.begin(), postcommandargs_.end());
+ return args;
+}
+
+
unsigned int InsetLayout::optArgs() const
{
unsigned int nr = 0;
- Layout::LaTeXArgMap::const_iterator it = latexargs_.begin();
- for (; it != latexargs_.end(); ++it) {
+ Layout::LaTeXArgMap::const_iterator it = args().begin();
+ for (; it != args().end(); ++it) {
if (!(*it).second.mandatory)
++nr;
}
unsigned int InsetLayout::requiredArgs() const
{
unsigned int nr = 0;
- Layout::LaTeXArgMap::const_iterator it = latexargs_.begin();
- for (; it != latexargs_.end(); ++it) {
+ Layout::LaTeXArgMap::const_iterator it = args().begin();
+ for (; it != args().end(); ++it) {
if ((*it).second.mandatory)
++nr;
}
///
ColorCode bgcolor() const { return bgcolor_; }
///
+ Layout::LaTeXArgMap args() const;
+ ///
Layout::LaTeXArgMap latexargs() const { return latexargs_; }
///
+ Layout::LaTeXArgMap postcommandargs() const { return postcommandargs_; }
+ ///
unsigned int optArgs() const;
///
unsigned int requiredArgs() const;
bool forcelocalfontswitch_;
///
Layout::LaTeXArgMap latexargs_;
+ ///
+ Layout::LaTeXArgMap postcommandargs_;
};
///
TexRow texrow;
odocstringstream ods;
otexstream os(ods, texrow);
- ins->getOptArg(os, runparams);
+ ins->getArgs(os, runparams);
ins->getArgument(os, runparams);
// the caption may contain \label{} but the listings
// package prefer caption={}, label={}
if (&buffer().inset() == this || !cur.paragraph().layout().args().empty())
return text_.getStatus(cur, cmd, status);
- Layout::LaTeXArgMap args = getLayout().latexargs();
+ Layout::LaTeXArgMap args = getLayout().args();
Layout::LaTeXArgMap::const_iterator const lait = args.find(arg);
if (lait != args.end()) {
status.setEnabled(true);
os << "\\protect";
os << '\\' << from_utf8(il.latexname());
if (!il.latexargs().empty())
- getOptArg(os, runparams);
+ getArgs(os, runparams);
if (!il.latexparam().empty())
os << from_utf8(il.latexparam());
os << '{';
runparams.lastpos);
os << "\\begin{" << from_utf8(il.latexname()) << "}";
if (!il.latexargs().empty())
- getOptArg(os, runparams);
+ getArgs(os, runparams);
if (!il.latexparam().empty())
os << from_utf8(il.latexparam());
os << '\n';
}
} else {
if (!il.latexargs().empty())
- getOptArg(os, runparams);
+ getArgs(os, runparams);
if (!il.latexparam().empty())
os << from_utf8(il.latexparam());
}
if (!il.latexname().empty()) {
if (il.latextype() == InsetLayout::COMMAND) {
os << "}";
+ if (!il.postcommandargs().empty())
+ getArgs(os, runparams, true);
} else if (il.latextype() == InsetLayout::ENVIRONMENT) {
// A comment environment doesn't need a % before \n\end
if (il.isDisplay() || runparams.inComment)
- os << breakln;
+ os << breakln;
else
- os << safebreakln;
+ os << safebreakln;
os << "\\end{" << from_utf8(il.latexname()) << "}\n";
if (!il.isDisplay())
os.protectSpace(true);
return docstring();
}
-void InsetText::getOptArg(otexstream & os,
- OutputParams const & runparams_in) const
+void InsetText::getArgs(otexstream & os, OutputParams const & runparams_in,
+ bool const post) const
{
OutputParams runparams = runparams_in;
runparams.local_font =
¶graphs()[0].getFirstFontSettings(buffer().masterBuffer()->params());
if (isPassThru())
runparams.pass_thru = true;
- latexArgInsets(paragraphs(), paragraphs().begin(), os, runparams, getLayout().latexargs());
+ if (post)
+ latexArgInsets(paragraphs(), paragraphs().begin(), os, runparams, getLayout().postcommandargs(), "post:");
+ else
+ latexArgInsets(paragraphs(), paragraphs().begin(), os, runparams, getLayout().latexargs());
}
///
void validate(LaTeXFeatures & features) const;
- /// return the optional argument(s) only
- void getOptArg(otexstream & os, OutputParams const &) const;
+ /// return the argument(s) only
+ void getArgs(otexstream & os, OutputParams const &, bool const post = false) const;
/// return x,y of given position relative to the inset's baseline
void cursorPos(BufferView const & bv, CursorSlice const & sl,
void getArgInsets(otexstream & os, OutputParams const & runparams, Layout::LaTeXArgMap const & latexargs,
- map<int, lyx::InsetArgument const *> ilist, vector<string> required, bool item)
+ map<int, lyx::InsetArgument const *> ilist, vector<string> required, string const & prefix)
{
unsigned int const argnr = latexargs.size();
if (argnr == 0)
Layout::LaTeXArgMap::const_iterator lait = latexargs.begin();
Layout::LaTeXArgMap::const_iterator const laend = latexargs.end();
for (; lait != laend; ++lait) {
- string const name = item ? "item:" + convert<string>(i) : convert<string>(i);
+ string const name = prefix + convert<string>(i);
if ((*lait).first == name) {
Layout::latexarg arg = (*lait).second;
if (arg.mandatory) {
void latexArgInsets(Paragraph const & par, otexstream & os,
- OutputParams const & runparams, Layout::LaTeXArgMap const & latexargs, bool item)
+ OutputParams const & runparams, Layout::LaTeXArgMap const & latexargs, string const & prefix)
{
map<int, InsetArgument const *> ilist;
vector<string> required;
if (ins->name().empty())
LYXERR0("Error: Unnamed argument inset!");
else {
- string const name = item ? split(ins->name(), ':') : ins->name();
+ string const name = prefix.empty() ? ins->name() : split(ins->name(), ':');
unsigned int const nr = convert<unsigned int>(name);
ilist[nr] = ins;
Layout::LaTeXArgMap::const_iterator const lit =
}
}
}
- getArgInsets(os, runparams, latexargs, ilist, required, item);
+ getArgInsets(os, runparams, latexargs, ilist, required, prefix);
}
void latexArgInsets(ParagraphList const & pars, ParagraphList::const_iterator pit,
- otexstream & os, OutputParams const & runparams, Layout::LaTeXArgMap const & latexargs)
+ otexstream & os, OutputParams const & runparams, Layout::LaTeXArgMap const & latexargs,
+ string const & prefix)
{
map<int, InsetArgument const *> ilist;
vector<string> required;
if (ins->name().empty())
LYXERR0("Error: Unnamed argument inset!");
else {
- string const name = ins->name();
+ string const name = prefix.empty() ? ins->name() : split(ins->name(), ':');
unsigned int const nr = convert<unsigned int>(name);
if (ilist.find(nr) == ilist.end())
ilist[nr] = ins;
}
}
}
- getArgInsets(os, runparams, latexargs, ilist, required, false);
+ getArgInsets(os, runparams, latexargs, ilist, required, prefix);
}
namespace {
os << "\\" + style.itemcommand();
// Item arguments
if (!style.itemargs().empty())
- latexArgInsets(par, os, runparams, style.itemargs(), true);
+ latexArgInsets(par, os, runparams, style.itemargs(), "item:");
os << " ";
break;
case LATEX_BIB_ENVIRONMENT:
os << "\\" << from_ascii(font.latexSize()) << " \\par}";
} else if (is_command) {
os << '}';
+ if (!style.postcommandargs().empty())
+ latexArgInsets(par, os, runparams, style.postcommandargs(), "post:");
if (runparams.encoding != prev_encoding) {
runparams.encoding = prev_encoding;
if (!runparams.isFullUnicode())
*/
void latexArgInsets(Paragraph const & par,
otexstream & os, OutputParams const & runparams,
- Layout::LaTeXArgMap const & latexargs, bool item = false);
+ Layout::LaTeXArgMap const & latexargs,
+ std::string const & prefix = std::string());
/// Same for multi-par sequences (e.g. merged environments or InsetLayouts)
void latexArgInsets(ParagraphList const & pars, ParagraphList::const_iterator pit,
otexstream & os, OutputParams const & runparams,
- Layout::LaTeXArgMap const & latexargs);
+ Layout::LaTeXArgMap const & latexargs,
+ std::string const & prefix = std::string());
/** Export \p paragraphs of buffer \p buf to LaTeX.
Don't use a temporary stringstream for \p os if the final output is
supposed to go to a file.