mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
New layout tags for better counter handling
* ResumeCounter: allow to resume an (enumerate) counter * StepMasterCounter: allow to increase a master counter
This commit is contained in:
parent
91f5d90971
commit
0eb651a2cf
@ -14684,6 +14684,62 @@ CopyStyle
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
ResumeCounter
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
[
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\emph on
|
||||
0
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
,
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
1
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
] Resumes a counter that is usually reset at each new sequence of layouts.
|
||||
This is currently only useful when
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
LabelType
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
is
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
Enumerate
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
RightDelim
|
||||
\end_layout
|
||||
@ -14918,6 +14974,63 @@ status collapsed
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
StepMasterCounter
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
[
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\emph on
|
||||
0
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
,
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
1
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
] Steps the master counter of a given counter at the beginning of a new
|
||||
sequence of layouts.
|
||||
This is currently only useful when
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
LabelType
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
is
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
Enumerate
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
TextFont
|
||||
\end_layout
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This script will update a .layout file to current format
|
||||
|
||||
# The latest layout format is also defined in src/TextClass.cpp
|
||||
currentFormat = 60
|
||||
currentFormat = 61
|
||||
|
||||
|
||||
# Incremented to format 4, 6 April 2007, lasgouttes
|
||||
@ -202,6 +202,9 @@ currentFormat = 60
|
||||
# Incremented to format 60, 25 March 2016 by lasgouttes
|
||||
# Rename caption subtype LongTableNoNumber to Unnumbered
|
||||
|
||||
# Incremented to format 61, 14 October 2016 by spitz
|
||||
# New Layout tags "ResumeCounter", "StepMasterCounter"
|
||||
|
||||
# Do not forget to document format change in Customization
|
||||
# Manual (section "Declaring a new text class").
|
||||
|
||||
@ -445,6 +448,11 @@ def convert(lines, end_format):
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if format == 60:
|
||||
# nothing to do.
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if format == 59:
|
||||
match = re_InsetLayout_CaptionLTNN.match(lines[i])
|
||||
if not match:
|
||||
|
@ -4673,7 +4673,7 @@ static bool needEnumCounterReset(ParIterator const & it)
|
||||
--prev_it.top().pit();
|
||||
Paragraph const & prev_par = *prev_it;
|
||||
if (prev_par.getDepth() <= cur_depth)
|
||||
return prev_par.layout().labeltype != LABEL_ENUMERATE;
|
||||
return prev_par.layout().name() != par.layout().name();
|
||||
}
|
||||
// start of nested inset: reset
|
||||
return true;
|
||||
@ -4757,8 +4757,12 @@ void Buffer::Impl::setLabel(ParIterator & it, UpdateType utype) const
|
||||
break;
|
||||
}
|
||||
|
||||
// Increase the master counter?
|
||||
if (layout.stepmastercounter && needEnumCounterReset(it))
|
||||
counters.stepMaster(enumcounter, utype);
|
||||
|
||||
// Maybe we have to reset the enumeration counter.
|
||||
if (needEnumCounterReset(it))
|
||||
if (!layout.resumecounter && needEnumCounterReset(it))
|
||||
counters.reset(enumcounter);
|
||||
counters.step(enumcounter, utype);
|
||||
|
||||
|
@ -278,6 +278,18 @@ void Counters::resetSlaves(docstring const & ctr)
|
||||
}
|
||||
|
||||
|
||||
void Counters::stepMaster(docstring const & ctr, UpdateType utype)
|
||||
{
|
||||
CounterList::iterator it = counterList_.find(ctr);
|
||||
if (it == counterList_.end()) {
|
||||
lyxerr << "step: Counter does not exist: "
|
||||
<< to_utf8(ctr) << endl;
|
||||
return;
|
||||
}
|
||||
step(it->second.master(), utype);
|
||||
}
|
||||
|
||||
|
||||
void Counters::step(docstring const & ctr, UpdateType utype)
|
||||
{
|
||||
CounterList::iterator it = counterList_.find(ctr);
|
||||
|
@ -130,6 +130,10 @@ public:
|
||||
int value(docstring const & ctr) const;
|
||||
/// Reset recursively all the counters that are slaves of the one named by \c ctr.
|
||||
void resetSlaves(docstring const & ctr);
|
||||
/// Increment by one master of counter named by \c ctr.
|
||||
/// This also resets the counter named by \c ctr.
|
||||
/// \param utype determines whether we track the counters.
|
||||
void stepMaster(docstring const & ctr, UpdateType utype);
|
||||
/// Increment by one counter named by \c ctr, and zeroes slave
|
||||
/// counter(s) for which it is the master.
|
||||
/// \param utype determines whether we track the counters.
|
||||
|
@ -105,6 +105,8 @@ enum LayoutTags {
|
||||
LT_SPELLCHECK,
|
||||
LT_REFPREFIX,
|
||||
LT_RESETARGS,
|
||||
LT_RESUMECOUNTER,
|
||||
LT_STEPMASTERCOUNTER,
|
||||
LT_RIGHTDELIM,
|
||||
LT_FORCELOCAL,
|
||||
LT_TOGGLE_INDENT,
|
||||
@ -121,6 +123,8 @@ Layout::Layout()
|
||||
unknown_ = false;
|
||||
margintype = MARGIN_STATIC;
|
||||
latextype = LATEX_PARAGRAPH;
|
||||
resumecounter = false;
|
||||
stepmastercounter = false;
|
||||
intitle = false;
|
||||
inpreamble = false;
|
||||
needprotect = false;
|
||||
@ -249,10 +253,12 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
|
||||
{ "refprefix", LT_REFPREFIX },
|
||||
{ "requires", LT_REQUIRES },
|
||||
{ "resetargs", LT_RESETARGS },
|
||||
{ "resumecounter", LT_RESUMECOUNTER },
|
||||
{ "rightdelim", LT_RIGHTDELIM },
|
||||
{ "rightmargin", LT_RIGHTMARGIN },
|
||||
{ "spacing", LT_SPACING },
|
||||
{ "spellcheck", LT_SPELLCHECK },
|
||||
{ "stepmastercounter", LT_STEPMASTERCOUNTER },
|
||||
{ "textfont", LT_TEXTFONT },
|
||||
{ "toclevel", LT_TOCLEVEL },
|
||||
{ "toggleindent", LT_TOGGLE_INDENT },
|
||||
@ -367,6 +373,14 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
|
||||
}
|
||||
break;
|
||||
|
||||
case LT_RESUMECOUNTER:
|
||||
lex >> resumecounter;
|
||||
break;
|
||||
|
||||
case LT_STEPMASTERCOUNTER:
|
||||
lex >> stepmastercounter;
|
||||
break;
|
||||
|
||||
case LT_ARGUMENT:
|
||||
readArgument(lex);
|
||||
break;
|
||||
@ -1139,7 +1153,9 @@ void Layout::write(ostream & os) const
|
||||
}
|
||||
os << "\tInTitle " << intitle << "\n"
|
||||
"\tInPreamble " << inpreamble << "\n"
|
||||
"\tTocLevel " << toclevel << '\n';
|
||||
"\tTocLevel " << toclevel << "\n"
|
||||
"\tResumeCounter " << resumecounter << "\n"
|
||||
"\tStepMasterCounter " << stepmastercounter << '\n';
|
||||
// ResetArgs does not make sense here
|
||||
for (LaTeXArgMap::const_iterator it = latexargs_.begin();
|
||||
it != latexargs_.end(); ++it)
|
||||
|
@ -313,6 +313,10 @@ public:
|
||||
bool inpreamble;
|
||||
/// Which counter to step
|
||||
docstring counter;
|
||||
/// Resume counter?
|
||||
bool resumecounter;
|
||||
/// Step master counter?
|
||||
bool stepmastercounter;
|
||||
/// Prefix to use when creating labels
|
||||
docstring refprefix;
|
||||
/// Depth of XML command
|
||||
|
@ -61,7 +61,7 @@ namespace lyx {
|
||||
// You should also run the development/tools/updatelayouts.py script,
|
||||
// to update the format of all of our layout files.
|
||||
//
|
||||
int const LAYOUT_FORMAT = 60; //lasgouttes LongTableNoNumber => Unnumbered
|
||||
int const LAYOUT_FORMAT = 61; //spitz ResumeCounter, StepMasterCounter
|
||||
|
||||
|
||||
// Layout format for the current lyx file format. Controls which format is
|
||||
|
Loading…
Reference in New Issue
Block a user