commit 9e6d22ea9cc508c3ffd0f92c0ec619ceafbee017
Author: Juergen Spitzmueller <[email protected]>
Date:   Sun Jun 2 18:07:10 2019 +0200

    Add InsertOnNewline argument tag
    
    This adds a paragraph break before auto-inserting arguments in flex
    insets.
    
    Useful for specific arguments (particularly ling glosses)
---
 lib/doc/Customization.lyx    |   53 ++++++++++++++++++++++++++++++++++++++++++
 lib/doc/de/Customization.lyx |   43 ++++++++++++++++++++++++++++++++++
 lib/scripts/layout2layout.py |    2 +-
 src/Layout.cpp               |    1 +
 src/Layout.h                 |    1 +
 src/Text3.cpp                |    8 ++++++
 src/insets/InsetLayout.cpp   |    4 +++
 7 files changed, 111 insertions(+), 1 deletions(-)

diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index 6a5e369..fcd8c16 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -12445,6 +12445,59 @@ layout can be automatically inserted.
 \end_layout
 
 \begin_layout Itemize
+
+\change_inserted -712698321 1559491402
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1559490711
+InsertOnNewline
+\end_layout
+
+\end_inset
+
+ 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1559490703
+[int=0]
+\end_layout
+
+\end_inset
+
+ If this is set to 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1559490703
+1
+\end_layout
+
+\end_inset
+
+, this argument will be inserted on a new line with 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1559491402
+AutoInsert
+\end_layout
+
+\end_inset
+
+ (only available within Flex insets).
+\end_layout
+
+\begin_layout Itemize
 \begin_inset Flex Code
 status collapsed
 
diff --git a/lib/doc/de/Customization.lyx b/lib/doc/de/Customization.lyx
index 97e876f..011b483 100644
--- a/lib/doc/de/Customization.lyx
+++ b/lib/doc/de/Customization.lyx
@@ -10589,6 +10589,49 @@ e Absatzstil ausgewählt wird.
 status collapsed
 
 \begin_layout Plain Layout
+InsertOnNewline
+\end_layout
+
+\end_inset
+
+ 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+[int=0]
+\end_layout
+
+\end_inset
+
+ Wenn dies auf 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+1
+\end_layout
+
+\end_inset
+
+ gesetzt ist, wird dieses Argument mit 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+AutoInsert
+\end_layout
+
+\end_inset
+
+ auf eine neue Zeile gesetzt (nur mit Flex-Einfügungen verfügbar).
+\end_layout
+
+\begin_layout Itemize
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
 InsertCotext
 \end_layout
 
diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index 80a21d7..ad588bf 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -249,7 +249,7 @@ currentFormat = 75
 # New InsetLayout and Argument tag NewlineCmd
 
 # Incremented to format 75, 2 June 2019 by spitz
-# New Argument tag FreeSpacing
+# New Argument tags FreeSpacing, InsertOnNewline
 
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
diff --git a/src/Layout.cpp b/src/Layout.cpp
index 7d3a1f8..3c1a9bd 100644
--- a/src/Layout.cpp
+++ b/src/Layout.cpp
@@ -1016,6 +1016,7 @@ void Layout::readArgument(Lexer & lex)
        arg.nodelims = false;
        arg.autoinsert = false;
        arg.insertcotext = false;
+       arg.insertonnewline = false;
        bool error = false;
        bool finished = false;
        arg.font = inherit_font;
diff --git a/src/Layout.h b/src/Layout.h
index 5a2567c..53fb682 100644
--- a/src/Layout.h
+++ b/src/Layout.h
@@ -106,6 +106,7 @@ public:
                FontInfo labelfont;
                bool autoinsert;
                bool insertcotext;
+               bool insertonnewline;
                ArgPassThru passthru;
                docstring pass_thru_chars;
                bool is_toc_caption;
diff --git a/src/Text3.cpp b/src/Text3.cpp
index 30cc08d..f234c7c 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -2078,6 +2078,10 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                Layout::LaTeXArgMap::const_iterator const laend = args.end();
                for (; lait != laend; ++lait) {
                        Layout::latexarg arg = (*lait).second;
+                       if (!inautoarg && arg.insertonnewline && cur.pos() > 0) 
{
+                               FuncRequest cmd2(LFUN_PARAGRAPH_BREAK);
+                               lyx::dispatch(cmd2);
+                       }
                        if (arg.autoinsert) {
                                // The cursor might have been invalidated by 
the replaceSelection.
                                cur.buffer()->changed(true);
@@ -2087,6 +2091,10 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                        cur.leaveInset(cur.inset());
                                        cur.posForward();
                                        inautoarg = false;
+                                       if (arg.insertonnewline && cur.pos() > 
0) {
+                                               FuncRequest 
cmd2(LFUN_PARAGRAPH_BREAK);
+                                               lyx::dispatch(cmd2);
+                                       }
                                }
                                FuncRequest cmd2(LFUN_ARGUMENT_INSERT, 
(*lait).first);
                                lyx::dispatch(cmd2);
diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp
index f486e3d..d81acf3 100644
--- a/src/insets/InsetLayout.cpp
+++ b/src/insets/InsetLayout.cpp
@@ -605,6 +605,7 @@ void InsetLayout::readArgument(Lexer & lex)
        arg.mandatory = false;
        arg.autoinsert = false;
        arg.insertcotext = false;
+       arg.insertonnewline = false;
        bool error = false;
        bool finished = false;
        arg.font = inherit_font;
@@ -639,6 +640,9 @@ void InsetLayout::readArgument(Lexer & lex)
                } else if (tok == "insertcotext") {
                        lex.next();
                        arg.insertcotext = lex.getBool();
+               } else if (tok == "insertonnewline") {
+                       lex.next();
+                       arg.insertonnewline = lex.getBool();
                } else if (tok == "leftdelim") {
                        lex.next();
                        arg.ldelim = lex.getDocString();

Reply via email to