]> git.lyx.org Git - lyx.git/commitdiff
Some AutoNest polishment.
authorJuergen Spitzmueller <spitz@lyx.org>
Fri, 29 Dec 2017 09:03:00 +0000 (10:03 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Fri, 29 Dec 2017 09:03:00 +0000 (10:03 +0100)
* Rename Nests to AutoNests
* Do it when changing from any style

lib/doc/Customization.lyx
lib/layouts/beamer.layout
lib/scripts/layout2layout.py
src/Layout.cpp
src/Layout.h
src/Text3.cpp
src/TextClass.cpp

index 410b527f19f384dc7bcc198c0e9a7de15998a805..cf6d7bab7481806bada59b0949d0be1d8e9c577d 100644 (file)
@@ -12161,6 +12161,45 @@ Argument item:1
 \end_layout
 
 \end_deeper
+\begin_layout Description
+
+\change_inserted -712698321 1514534780
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1514534780
+AutoNests
+\end_layout
+
+\end_inset
+
+ 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) 
+\begin_inset Quotes eld
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1514538124
+EndAutoNests
+\end_layout
+
+\end_inset
+
+
+\begin_inset Quotes erd
+\end_inset
+
+.
+\end_layout
+
 \begin_layout Description
 \begin_inset Flex Code
 status collapsed
@@ -14617,49 +14656,6 @@ protect
 not
 \emph default
  whether this command should itself be protected.)
-\change_inserted -712698321 1514479340
-
-\end_layout
-
-\begin_layout Description
-
-\change_inserted -712698321 1514479340
-\begin_inset Flex Code
-status collapsed
-
-\begin_layout Plain Layout
-
-\change_inserted -712698321 1514479340
-Nests
-\end_layout
-
-\end_inset
-
- 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) 
-\begin_inset Quotes eld
-\end_inset
-
-
-\begin_inset Flex Code
-status collapsed
-
-\begin_layout Plain Layout
-
-\change_inserted -712698321 1514479340
-EndNests
-\end_layout
-
-\end_inset
-
-
-\begin_inset Quotes erd
-\end_inset
-
-.
-\change_unchanged
-
 \end_layout
 
 \begin_layout Description
index 4ffc8b62b24c10b74bab9ccee0b4b3613ab872cd..fef205a96a56cd833a250351c815d40dd01dea47 100644 (file)
@@ -482,12 +482,12 @@ Style Frame
     EndFont
     AutoInsert     1
   EndArgument
-  Nests 
+  AutoNests 
        Standard,Itemize,Enumerate,Description,FrameTitle,FrameSubtitle,Column,
        Columns,ColumnsCenterAligned,ColumnsTopAligned,Pause,Overprint,OverlayArea,Only,Block,
        ExampleBlock,AlertBlock,Bibliography,Quotation,Quote,Verse,Corollary,Definition,Definitions,
        Example,Examples,Fact,Lemma,Proof,Theorem,LyX-Code
-  EndNests
+  EndAutoNests
 End
 
 Style PlainFrame
@@ -671,11 +671,11 @@ Style Columns
     Family         Roman
     Color          latex
   EndFont
-  Nests 
+  AutoNests 
        Standard,Itemize,Enumerate,Description,Pause,Overprint,OverlayArea,Only,Block,
        ExampleBlock,AlertBlock,Bibliography,Quotation,Quote,Verse,Corollary,Definition,Definitions,
        Example,Examples,Fact,Lemma,Proof,Theorem,LyX-Code
-  EndNests
+  EndAutoNests
 End
 
 Style ColumnsCenterAligned
@@ -896,10 +896,10 @@ Style Block
     EndFont
     AutoInsert     1
   EndArgument
-  Nests 
+  AutoNests 
        Standard,Itemize,Enumerate,Description,Pause,Overprint,OverlayArea,Only,Quotation,
        Quote,Verse,Corollary,Definition,Definitions,Example,Examples,Fact,Lemma,Proof,Theorem,LyX-Code
-  EndNests
+  EndAutoNests
 End
 
 Style ExampleBlock
@@ -1243,9 +1243,9 @@ Style Corollary
     LabelString    "Additional Theorem Text"
     Tooltip        "Additional text appended to the theorem header"
   EndArgument
-  Nests 
+  AutoNests 
        Standard,Itemize,Enumerate,Description,Pause,Overprint,OverlayArea,Only,LyX-Code
-  EndNests
+  EndAutoNests
 End
 
 Style Definition
index 4ae3fbff7f45a4f95805312e9716d6d04580c43c..a5b00e10bfda19a036b404ae3864916203a62af9 100644 (file)
@@ -221,7 +221,7 @@ currentFormat = 66
 # Color collapsable -> collapsible
 
 # Incremented to format 66, 28 December 2017 by spitz
-# New Layout tag "Nests ... EndNests"
+# New Layout tag "AutoNests ... EndAutoNests"
 
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
index 2f9c867e3311e0163575d58db8aa0ef78742c8d1..1dcd7dd2bcd5d72b08d4e9b8b82ef30506ff508c 100644 (file)
@@ -40,6 +40,7 @@ enum LayoutTags {
        LT_ALIGN = 1,
        LT_ALIGNPOSSIBLE,
        LT_ARGUMENT,
+       LT_AUTONESTS,
        LT_MARGIN,
        LT_BOTTOMSEP,
        LT_CATEGORY,
@@ -75,7 +76,6 @@ enum LayoutTags {
        LT_NEED_PROTECT,
        LT_NEWLINE,
        LT_NEXTNOINDENT,
-       LT_NESTS,
        LT_PAR_GROUP,
        LT_PARINDENT,
        LT_PARSEP,
@@ -192,6 +192,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                { "align",          LT_ALIGN },
                { "alignpossible",  LT_ALIGNPOSSIBLE },
                { "argument",       LT_ARGUMENT },
+               { "autonests",      LT_AUTONESTS },
                { "babelpreamble",  LT_BABELPREAMBLE },
                { "bottomsep",      LT_BOTTOMSEP },
                { "category",       LT_CATEGORY },
@@ -240,7 +241,6 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                { "leftmargin",     LT_LEFTMARGIN },
                { "margin",         LT_MARGIN },
                { "needprotect",    LT_NEED_PROTECT },
-               { "nests",          LT_NESTS },
                { "newline",        LT_NEWLINE },
                { "nextnoindent",   LT_NEXTNOINDENT },
                { "obsoletedby",    LT_OBSOLETEDBY },
@@ -594,14 +594,15 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                        break;
                }
 
-               case LT_NESTS: {
-                       docstring const nest = subst(subst(subst(lex.getLongString(from_ascii("EndNests")),
-                                                    from_ascii("\n"), docstring()),
-                                                    from_ascii(" "), docstring()),
-                                                    from_ascii("\t"), docstring());
-                       vector<docstring> const nests =
-                               getVectorFromString(nest);
-                       nests_.insert(nests.begin(), nests.end());
+               case LT_AUTONESTS: {
+                       docstring const autonest =
+                               subst(subst(subst(lex.getLongString(from_ascii("EndAutoNests")),
+                                                 from_ascii("\n"), docstring()),
+                                           from_ascii(" "), docstring()),
+                                     from_ascii("\t"), docstring());
+                       vector<docstring> const autonests =
+                               getVectorFromString(autonest);
+                       autonests_.insert(autonests.begin(), autonests.end());
                        break;
                }
 
@@ -1400,15 +1401,15 @@ void Layout::write(ostream & os) const
                }
                os << '\n';
        }
-       if (!nests_.empty()) {
-               os << "\tNests\n\t";
-               for (set<docstring>::const_iterator it = nests_.begin();
-                    it != nests_.end(); ++it) {
-                       if (it != nests_.begin())
+       if (!autonests_.empty()) {
+               os << "\tAutoNests\n\t";
+               for (set<docstring>::const_iterator it = autonests_.begin();
+                    it != autonests_.end(); ++it) {
+                       if (it != autonests_.begin())
                                os << ',';
                        os << to_utf8(*it);
                }
-               os << "\n\tEndNests\n";
+               os << "\n\tEndAutoNests\n";
        }
        if (refprefix.empty())
                os << "\tRefPrefix OFF\n";
index 37a10f0b93bb991888c36474d62225e0be890425..4dc635c08b6272a85065f35912402c53f6d6a827 100644 (file)
@@ -149,7 +149,7 @@ public:
        ///
        std::set<std::string> const & requires() const { return requires_; }
        ///
-       std::set<docstring> const & nests() const { return nests_; }
+       std::set<docstring> const & autonests() const { return autonests_; }
        ///
        std::string const & latexparam() const { return latexparam_; }
        ///
@@ -471,7 +471,7 @@ private:
        /// Packages needed for this layout
        std::set<std::string> requires_;
        /// Layouts that are by default nested after this one
-       std::set<docstring> nests_;
+       std::set<docstring> autonests_;
        ///
        LaTeXArgMap latexargs_;
        ///
index 76a0b3259f84d468f032fc97304e5f202f981262..aa519d39ab9913dfc6d42b64a63b8ff85593a0de 100644 (file)
@@ -1419,13 +1419,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_LAYOUT: {
-               bool const ignorenests = cmd.getArg(1) == "ignorenests";
-               docstring layout = ignorenests ? from_utf8(cmd.getArg(0)) : cmd.argument();
+               bool const ignoreautonests = cmd.getArg(1) == "ignoreautonests";
+               docstring layout = ignoreautonests ? from_utf8(cmd.getArg(0)) : cmd.argument();
                LYXERR(Debug::INFO, "LFUN_LAYOUT: (arg) " << to_utf8(layout));
 
                Paragraph const & para = cur.paragraph();
                docstring const old_layout = para.layout().name();
-               set<docstring> nests = para.layout().nests();
                DocumentClass const & tclass = bv->buffer().params().documentClass();
 
                if (layout.empty())
@@ -1478,9 +1477,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                if (change_layout) {
                        setLayout(cur, layout);
                        bool do_nest = false;
-                       if (cur.pit() > 0 && pars_[cur.pit() - 1].layout().name() == old_layout)
-                               do_nest = !ignorenests;
-                       if (do_nest && nests.find(layout) != nests.end())
+                       set<docstring> autonests;
+                       if (cur.pit() > 0) {
+                               autonests = pars_[cur.pit() - 1].layout().autonests();
+                               do_nest = !ignoreautonests;
+                       }
+                       if (do_nest && autonests.find(layout) != autonests.end())
                                lyx::dispatch(FuncRequest(LFUN_DEPTH_INCREMENT));
                }
 
@@ -1540,7 +1542,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                }
                DocumentClass const & tc = bv->buffer().params().documentClass();
                lyx::dispatch(FuncRequest(LFUN_LAYOUT, from_ascii("\"") + tc.plainLayout().name()
-                                         + from_ascii("\" ignorenests")));
+                                         + from_ascii("\" ignoreautonests")));
                lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "plain"));
                if (before) {
                        cur.backwardPos();
@@ -3182,8 +3184,8 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
 
        case LFUN_LAYOUT: {
                DocumentClass const & tclass = cur.buffer()->params().documentClass();
-               bool const ignorenests = cmd.getArg(1) == "ignorenests";
-               docstring layout = ignorenests ? from_utf8(cmd.getArg(0)) : cmd.argument();
+               bool const ignoreautonests = cmd.getArg(1) == "ignoreautonests";
+               docstring layout = ignoreautonests ? from_utf8(cmd.getArg(0)) : cmd.argument();
                if (layout.empty())
                        layout = tclass.defaultLayoutName();
                enable = !owner_->forcePlainLayout() && tclass.hasLayout(layout);
index a65cea18c7a1fb678e3cce2b708bed7e9dcfcd0f..cc8b0aa2d50c1bb7b263215f2b00854c1950bfcd 100644 (file)
@@ -62,7 +62,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 = 66; //spitz: New layout tag Nests
+int const LAYOUT_FORMAT = 66; //spitz: New layout tag AutoNests
 
 
 // Layout format for the current lyx file format. Controls which format is