]> git.lyx.org Git - lyx.git/commitdiff
Add IsAutoNestedBy
authorJuergen Spitzmueller <spitz@lyx.org>
Fri, 29 Dec 2017 09:36:03 +0000 (10:36 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Fri, 29 Dec 2017 09:36:03 +0000 (10:36 +0100)
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.

lib/doc/Customization.lyx
lib/scripts/layout2layout.py
src/Layout.cpp
src/Layout.h
src/Text3.cpp

index cf6d7bab7481806bada59b0949d0be1d8e9c577d..33a9735ca8b5e1c6ba6d344924eddc82d3fdbe29 100644 (file)
@@ -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
index a5b00e10bfda19a036b404ae3864916203a62af9..d13f8bf1052082991daad7932cbe6b062a729756 100644 (file)
@@ -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").
index 1dcd7dd2bcd5d72b08d4e9b8b82ef30506ff508c..0a783d0aad1542fb5e2124be8c62521dd2716b3c 100644 (file)
@@ -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
index 4dc635c08b6272a85065f35912402c53f6d6a827..04f184f3a4d7d263824b39935c8aa25f2d88dd0d 100644 (file)
@@ -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_;
        ///
index aa519d39ab9913dfc6d42b64a63b8ff85593a0de..e8a401c5517dd189c2583320949c1080fdb482b4 100644 (file)
@@ -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));
                }