]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetLayout.cpp
Support for command argument placement after the workarea argument
[lyx.git] / src / insets / InsetLayout.cpp
index b6dcf582dd51a9eb6578ba0c16276b2545a573f8..0dc7914dde7f6db102ba17b9a40dff32191f3d02 100644 (file)
@@ -518,6 +518,7 @@ void InsetLayout::readArgument(Lexer & lex)
        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());
@@ -571,15 +572,27 @@ void InsetLayout::readArgument(Lexer & lex)
        }
        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;
        }
@@ -590,8 +603,8 @@ unsigned int InsetLayout::optArgs() const
 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;
        }