commit c7efb677f8550a44b1262944c15515097723fa31
Author: Juergen Spitzmueller <[email protected]>
Date: Sun Jun 2 18:16:30 2019 +0200
New InsetLayout tag ParbreakIgnored
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 | 68 ++++++++++++++++++++++++++++++++++++++++++
lib/doc/de/Customization.lyx | 49 ++++++++++++++++++++++++++++++
lib/scripts/layout2layout.py | 1 +
src/Cursor.cpp | 2 +
src/insets/InsetLayout.cpp | 7 ++++-
src/insets/InsetLayout.h | 4 ++
src/output_latex.cpp | 18 +++++++----
7 files changed, 141 insertions(+), 8 deletions(-)
diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index fcd8c16..d8475fe 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -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
diff --git a/lib/doc/de/Customization.lyx b/lib/doc/de/Customization.lyx
index 011b483..f838e20 100644
--- a/lib/doc/de/Customization.lyx
+++ b/lib/doc/de/Customization.lyx
@@ -18949,6 +18949,55 @@ InsetLayout
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
diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index ad588bf..5e9d348 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -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").
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index 4e0dfb2..35a3452 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -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
diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp
index d81acf3..b523457 100644
--- a/src/insets/InsetLayout.cpp
+++ b/src/insets/InsetLayout.cpp
@@ -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;
diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h
index f36afa1..bed2136 100644
--- a/src/insets/InsetLayout.h
+++ b/src/insets/InsetLayout.h
@@ -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_;
diff --git a/src/output_latex.cpp b/src/output_latex.cpp
index 152efaf..b26fb1b 100644
--- a/src/output_latex.cpp
+++ b/src/output_latex.cpp
@@ -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()