From: Juergen Spitzmueller Date: Sun, 2 Jun 2019 16:07:10 +0000 (+0200) Subject: Add InsertOnNewline argument tag X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=5c8b778c4041278d375a6118f315fb1900c43785;p=features.git Add InsertOnNewline argument tag This adds a paragraph break before auto-inserting arguments in flex insets. Useful for specific arguments (particularly ling glosses) --- diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index 6a5e3696c5..fcd8c165c3 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -12444,6 +12444,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 97e876f83d..011b483677 100644 --- a/lib/doc/de/Customization.lyx +++ b/lib/doc/de/Customization.lyx @@ -10588,6 +10588,49 @@ e Absatzstil ausgewählt wird. \begin_inset Flex Code 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 80a21d7813..ad588bf797 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 7d3a1f89ff..3c1a9bd955 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 5a2567c13d..53fb682a6e 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 30cc08d085..f234c7cb7d 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 f486e3d3d8..d81acf3267 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();