mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Add IsAutoNestedBy
This is complementary to AutoNests: Styles can determine which other style should auto-nest them. This is particularly useful for modules that add new styles which should be auto-nested in a given context.
This commit is contained in:
parent
d6fb2abbea
commit
f3b89e4c72
@ -12163,7 +12163,7 @@ Argument item:1
|
||||
\end_deeper
|
||||
\begin_layout Description
|
||||
|
||||
\change_inserted -712698321 1514534780
|
||||
\change_inserted -712698321 1514539256
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
@ -12177,7 +12177,8 @@ AutoNests
|
||||
|
||||
Includes a comma-separated list of layout names that should be nested in
|
||||
and after the current one.
|
||||
Only makes sense for nestable layouts (such as environments)
|
||||
Only makes sense for nestable layouts (such as environments).
|
||||
Must be ended by
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
@ -12197,6 +12198,21 @@ EndAutoNests
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
.
|
||||
See also
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1514539161
|
||||
IsAutoNestedBy
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
\end_layout
|
||||
|
||||
@ -12929,6 +12945,63 @@ TitleLatexName
|
||||
\end_inset
|
||||
|
||||
global entries).
|
||||
\change_inserted -712698321 1514539171
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\change_inserted -712698321 1514539282
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1514539190
|
||||
IsAutoNestedBy
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
Includes a comma-separated list of layout names after which this one should
|
||||
be nested.
|
||||
Only makes sense with regard to nestable layouts (such as environments).
|
||||
Must be ended by
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1514539279
|
||||
EndIsAutoNestedBy
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
.
|
||||
See also
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1514539172
|
||||
AutoNest
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
@ -221,7 +221,8 @@ currentFormat = 66
|
||||
# Color collapsable -> collapsible
|
||||
|
||||
# Incremented to format 66, 28 December 2017 by spitz
|
||||
# New Layout tag "AutoNests ... EndAutoNests"
|
||||
# New Layout tags "AutoNests ... EndAutoNests" and
|
||||
# "IsAutoNestedBy ... EndIsAutoNestedBy"
|
||||
|
||||
# Do not forget to document format change in Customization
|
||||
# Manual (section "Declaring a new text class").
|
||||
|
@ -41,6 +41,7 @@ enum LayoutTags {
|
||||
LT_ALIGNPOSSIBLE,
|
||||
LT_ARGUMENT,
|
||||
LT_AUTONESTS,
|
||||
LT_AUTONESTEDBY,
|
||||
LT_MARGIN,
|
||||
LT_BOTTOMSEP,
|
||||
LT_CATEGORY,
|
||||
@ -219,6 +220,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
|
||||
{ "innertag", LT_INNERTAG },
|
||||
{ "inpreamble", LT_INPREAMBLE },
|
||||
{ "intitle", LT_INTITLE },
|
||||
{ "isautonestedby", LT_AUTONESTEDBY },
|
||||
{ "istoccaption", LT_ISTOCCAPTION },
|
||||
{ "itemcommand", LT_ITEMCOMMAND },
|
||||
{ "itemsep", LT_ITEMSEP },
|
||||
@ -606,6 +608,18 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
|
||||
break;
|
||||
}
|
||||
|
||||
case LT_AUTONESTEDBY: {
|
||||
docstring const autonest =
|
||||
subst(subst(subst(lex.getLongString(from_ascii("EndIsAutoNestedBy")),
|
||||
from_ascii("\n"), docstring()),
|
||||
from_ascii(" "), docstring()),
|
||||
from_ascii("\t"), docstring());
|
||||
vector<docstring> const autonests =
|
||||
getVectorFromString(autonest);
|
||||
autonested_by_.insert(autonests.begin(), autonests.end());
|
||||
break;
|
||||
}
|
||||
|
||||
case LT_REFPREFIX: {
|
||||
docstring arg;
|
||||
lex >> arg;
|
||||
@ -1411,6 +1425,16 @@ void Layout::write(ostream & os) const
|
||||
}
|
||||
os << "\n\tEndAutoNests\n";
|
||||
}
|
||||
if (!autonested_by_.empty()) {
|
||||
os << "\tIsAutoNestedBy\n\t";
|
||||
for (set<docstring>::const_iterator it = autonested_by_.begin();
|
||||
it != autonested_by_.end(); ++it) {
|
||||
if (it != autonested_by_.begin())
|
||||
os << ',';
|
||||
os << to_utf8(*it);
|
||||
}
|
||||
os << "\n\tIsAutoNestedBy\n";
|
||||
}
|
||||
if (refprefix.empty())
|
||||
os << "\tRefPrefix OFF\n";
|
||||
else
|
||||
|
@ -151,6 +151,8 @@ public:
|
||||
///
|
||||
std::set<docstring> const & autonests() const { return autonests_; }
|
||||
///
|
||||
std::set<docstring> const & isAutonestedBy() const { return autonested_by_; }
|
||||
///
|
||||
std::string const & latexparam() const { return latexparam_; }
|
||||
///
|
||||
docstring leftdelim() const { return leftdelim_; }
|
||||
@ -472,6 +474,8 @@ private:
|
||||
std::set<std::string> requires_;
|
||||
/// Layouts that are by default nested after this one
|
||||
std::set<docstring> autonests_;
|
||||
/// Layouts that by auto-nest this one
|
||||
std::set<docstring> autonested_by_;
|
||||
///
|
||||
LaTeXArgMap latexargs_;
|
||||
///
|
||||
|
@ -1478,11 +1478,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
setLayout(cur, layout);
|
||||
bool do_nest = false;
|
||||
set<docstring> autonests;
|
||||
set<docstring> autonested;
|
||||
if (cur.pit() > 0) {
|
||||
autonests = pars_[cur.pit() - 1].layout().autonests();
|
||||
autonested = pars_[cur.pit()].layout().isAutonestedBy();
|
||||
do_nest = !ignoreautonests;
|
||||
}
|
||||
if (do_nest && autonests.find(layout) != autonests.end())
|
||||
if (do_nest && (autonests.find(layout) != autonests.end()
|
||||
|| autonested.find(old_layout) != autonested.end()))
|
||||
lyx::dispatch(FuncRequest(LFUN_DEPTH_INCREMENT));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user