The following parameters can also be used:
\end_layout
+\begin_layout Description
+
+\change_inserted 1414654397 1370012684
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1414654397 1370012589
+InitialValue
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1414654397 1370012639
+number
+\end_layout
+
+\end_inset
+
+=1] Sets the initial value for the counter, to which it will be reset whenever
+ that happens.
+ Normally, one will want the default, 1.
+\end_layout
+
\begin_layout Description
\begin_inset Flex Code
status collapsed
# Incremented to format 47, 23 May 2013 by rgh
# Add PackageOptions tag
+# Incremented to format 48, 31 May 2013 by rgh
+# Add InitialValue tag for counters
+
# Do not forget to document format change in Customization
# Manual (section "Declaring a new text class").
# development/tools/updatelayouts.sh script to update all
# layout files to the new format.
-currentFormat = 47
+currentFormat = 48
def usage(prog_name):
i += 1
continue
- if format >= 44 and format <= 46:
+ if format >= 44 and format <= 47:
# nothing to do.
i += 1
continue
Counter::Counter(docstring const & mc, docstring const & ls,
docstring const & lsa)
- : master_(mc), labelstring_(ls), labelstringappendix_(lsa)
+ : initial_value_(0), master_(mc), labelstring_(ls), labelstringappendix_(lsa)
{
reset();
}
CT_LABELSTRING,
CT_LABELSTRING_APPENDIX,
CT_PRETTYFORMAT,
+ CT_INITIALVALUE,
CT_END
};
LexerKeyword counterTags[] = {
{ "end", CT_END },
+ { "initialvalue", CT_INITIALVALUE},
{ "labelstring", CT_LABELSTRING },
{ "labelstringappendix", CT_LABELSTRING_APPENDIX },
{ "prettyformat", CT_PRETTYFORMAT },
if (master_ == "none")
master_.erase();
break;
+ case CT_INITIALVALUE:
+ lex.next();
+ initial_value_ = lex.getInteger();
+ // getInteger() returns -1 on error, and larger
+ // negative values do not make much sense.
+ // In the other case, we subtract one, since the
+ // counter will be incremented before its first use.
+ if (initial_value_ <= -1)
+ initial_value_ = 0;
+ else
+ initial_value_ -= 1;
+ break;
case CT_PRETTYFORMAT:
lex.next();
prettyformat_ = lex.getDocString();
void Counter::reset()
{
- value_ = 0;
+ value_ = initial_value_;
}
private:
///
int value_;
+ /// This is actually one less than the initial value, since the
+ /// counter is always stepped before being used.
+ int initial_value_;
/// contains master counter name.
/** The master counter is the counter that, if stepped
* (incremented) zeroes this counter. E.g. "subsection"'s
// development/tools/updatelayouts.sh script, to update the format of
// all of our layout files.
//
-int const LAYOUT_FORMAT = 47; //rgh: package options
+int const LAYOUT_FORMAT = 48; //rgh: initial values for counter
namespace {