]> git.lyx.org Git - features.git/commitdiff
New InsetLayout tag ParbreakIgnored
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 2 Jun 2019 16:16:30 +0000 (18:16 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:32 +0000 (15:48 +0200)
This effectively allow paragraph breaks in insets only for cosmetic
reasons (e.g., to align contents on different lines).

This is the last change necessary for an enhanced covington gloss support
(which uses the new covington gloss ui)

lib/doc/Customization.lyx
lib/doc/de/Customization.lyx
lib/scripts/layout2layout.py
src/Cursor.cpp
src/insets/InsetLayout.cpp
src/insets/InsetLayout.h
src/output_latex.cpp

index fcd8c165c3c7a36218007f00028659ff33f89b89..d8475feb7f062993ff1f02574aa6c9e30e5d7b3e 100644 (file)
@@ -20936,6 +20936,74 @@ InsetLayout
 \end_inset
 
 , while keeping backward compatibility.
+\change_inserted -712698321 1559491850
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1559492002
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1559491854
+ParbreakIgnored
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1559491850
+
+\emph on
+0
+\end_layout
+
+\end_inset
+
+,
+\begin_inset space \thinspace{}
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1559491850
+1
+\end_layout
+
+\end_inset
+
+] If this is set to 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1559491881
+1
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+, paragraph breaks will be ignored in the output.
+ This might be useful for insets where the content should be alignable on
+ different lines only in the \SpecialChar LyX
+ workarea, without any effect in the output.
+\change_unchanged
+
 \end_layout
 
 \begin_layout Description
index 011b4836772434c0056a2bccb9bf845a8f4a5894..f838e20c5448f3ec2b42499034b496c2b5c82b3a 100644 (file)
@@ -18948,6 +18948,55 @@ InsetLayout
 \begin_inset Flex Code
 status collapsed
 
+\begin_layout Plain Layout
+ParbreakIgnored
+\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
+
+] Wenn dies auf 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+1
+\end_layout
+
+\end_inset
+
+ gesetzt wird, werden Absatzwechsel in der Ausgabe ignoriert.
+ Das kann dann sinnvoll sein, wenn der Inhalt von Einfügungen im \SpecialChar LyX
+-Arbeitsbereich
+ auf verschiedenen Zeilen angeordnet werden soll, ohne dass dies eine Wirkung
+ in der Ausgabe hat.
+\end_layout
+
+\begin_layout Description
+\begin_inset Flex Code
+status collapsed
+
 \begin_layout Plain Layout
 ParbreakIsNewline
 \end_layout
index ad588bf7970c57dde717cb96438b7cdf3177d26e..5e9d3483dee51f3871fcc7dd7ba3ef9b889ee765 100644 (file)
@@ -250,6 +250,7 @@ currentFormat = 75
 
 # Incremented to format 75, 2 June 2019 by spitz
 # New Argument tags FreeSpacing, InsertOnNewline
+# New InsetLayout tag ParbreakIgnored
 
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
index 4e0dfb2234c6697ee7c021d803b77497056a0765..35a34527c0c48a3dee29e10c479c343bed867f46 100644 (file)
@@ -330,6 +330,8 @@ namespace {
 
 docstring parbreak(CursorData const * cur)
 {
+       if (cur->inset().getLayout().parbreakIgnored())
+               return docstring();
        odocstringstream os;
        os << '\n';
        // only add blank line if we're not in a ParbreakIsNewline situation
index d81acf32670aaf18401ea782aed3186ac5460bcb..b523457c6017235932bf8feda6873287668dda8d 100644 (file)
@@ -41,7 +41,7 @@ InsetLayout::InsetLayout() :
        fixedwidthpreambleencoding_(false), htmlforcecss_ (false),
        htmlisblock_(true), multipar_(true), custompars_(true),
        forceplain_(false), passthru_(false), parbreakisnewline_(false),
-       freespacing_(false), keepempty_(false), forceltr_(false),
+       parbreakignored_(false), freespacing_(false), keepempty_(false), forceltr_(false),
        forceownlines_(false), needprotect_(false), needcprotect_(false),
        needmboxprotect_(false), intoc_(false), spellcheck_(true),
        resetsfont_(false), display_(true), forcelocalfontswitch_(false),
@@ -128,6 +128,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                IL_NEWLINE_CMD,
                IL_PASSTHRU,
                IL_PASSTHRU_CHARS,
+               IL_PARBREAKIGNORED,
                IL_PARBREAKISNEWLINE,
                IL_PREAMBLE,
                IL_REQUIRES,
@@ -187,6 +188,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                { "needprotect", IL_NEEDPROTECT },
                { "newlinecmd", IL_NEWLINE_CMD },
                { "obsoletedby", IL_OBSOLETEDBY },
+               { "parbreakignored", IL_PARBREAKIGNORED },
                { "parbreakisnewline", IL_PARBREAKISNEWLINE },
                { "passthru", IL_PASSTHRU },
                { "passthruchars", IL_PASSTHRU_CHARS },
@@ -327,6 +329,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                case IL_NEWLINE_CMD:
                        lex >> newline_cmd_;
                        break;
+               case IL_PARBREAKIGNORED:
+                       lex >> parbreakignored_;
+                       break;
                case IL_PARBREAKISNEWLINE:
                        lex >> parbreakisnewline_;
                        break;
index f36afa11563a7a25ae3d7c7609831e7bc577de2e..bed2136c4fdf12ffb7191c50af88e321e08d3fe0 100644 (file)
@@ -164,6 +164,8 @@ public:
        ///
        bool parbreakIsNewline() const { return parbreakisnewline_; }
        ///
+       bool parbreakIgnored() const { return parbreakignored_; }
+       ///
        bool isNeedProtect() const { return needprotect_; }
        ///
        bool needsCProtect() const { return needcprotect_; }
@@ -289,6 +291,8 @@ private:
        ///
        bool parbreakisnewline_;
        ///
+       bool parbreakignored_;
+       ///
        bool freespacing_;
        ///
        bool keepempty_;
index 152efaf66cd114c820254d07a7bda59399152b5c..b26fb1b6305364146ab81c60318ca921d9b514a7 100644 (file)
@@ -763,7 +763,7 @@ void TeXOnePar(Buffer const & buf,
                Font const outerfont = text.outerFont(pit);
 
                // No newline before first paragraph in this lyxtext
-               if (pit > 0) {
+               if (pit > 0 && !text.inset().getLayout().parbreakIgnored()) {
                        os << '\n';
                        if (!text.inset().getLayout().parbreakIsNewline())
                                os << '\n';
@@ -1135,7 +1135,7 @@ void TeXOnePar(Buffer const & buf,
                            && nextpar->getDepth() < par.getDepth()))
                        close_lang_switch = using_begin_end;
                if (nextpar && par.params().depth() < nextpar->params().depth())
-                       pending_newline = true;
+                       pending_newline = !text.inset().getLayout().parbreakIgnored();
                break;
        case LATEX_ENVIRONMENT: {
                // if it's the last paragraph of the current environment
@@ -1154,7 +1154,7 @@ void TeXOnePar(Buffer const & buf,
        default:
                // we don't need it for the last paragraph and in InTitle commands!!!
                if (nextpar && !intitle_command)
-                       pending_newline = true;
+                       pending_newline = !text.inset().getLayout().parbreakIgnored();
        }
 
        // InTitle commands use switches (not environments) for space settings
@@ -1225,7 +1225,8 @@ void TeXOnePar(Buffer const & buf,
                                                                        localswitch)
                                                  : subst(lang_begin_command, "$$lang", current_lang);
                                        os << bc;
-                                       pending_newline = !localswitch;
+                                       pending_newline = !localswitch
+                                                       && !text.inset().getLayout().parbreakIgnored();
                                        unskip_newline = !localswitch;
                                        if (using_begin_end)
                                                pushLanguageName(current_lang, localswitch);
@@ -1255,7 +1256,8 @@ void TeXOnePar(Buffer const & buf,
                                                lang_end_command,
                                                "$$lang",
                                                par_lang));
-                                       pending_newline = !localswitch;
+                                       pending_newline = !localswitch
+                                                       && !text.inset().getLayout().parbreakIgnored();
                                        unskip_newline = !localswitch;
                                        if (using_begin_end)
                                                popLanguageName();
@@ -1370,9 +1372,10 @@ void TeXOnePar(Buffer const & buf,
        // Note from JMarc: we will re-add a \n explicitly in
        // TeXEnvironment, because it is needed in this case
        if (nextpar && !os.afterParbreak() && !last_was_separator) {
-               // Make sure to start a new line
-               os << breakln;
                Layout const & next_layout = nextpar->layout();
+               if (!text.inset().getLayout().parbreakIgnored())
+                       // Make sure to start a new line
+                       os << breakln;
                // A newline '\n' is always output before a command,
                // so avoid doubling it.
                if (!next_layout.isCommand()) {
@@ -1396,6 +1399,7 @@ void TeXOnePar(Buffer const & buf,
                        if ((style == next_layout
                             && !style.parbreak_is_newline
                             && !text.inset().getLayout().parbreakIsNewline()
+                            && !text.inset().getLayout().parbreakIgnored()
                             && style.latextype != LATEX_ITEM_ENVIRONMENT
                             && style.latextype != LATEX_LIST_ENVIRONMENT
                             && style.align == par.getAlign()