]> git.lyx.org Git - lyx.git/commitdiff
Add NewlineCmd InsetLayout and Argument option
authorJuergen Spitzmueller <spitz@lyx.org>
Thu, 18 Apr 2019 09:35:03 +0000 (11:35 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Thu, 18 Apr 2019 09:35:03 +0000 (11:35 +0200)
This allows to specific an alternative macro for newlines

Fixes: #10407
14 files changed:
lib/doc/Customization.lyx
lib/doc/de/Customization.lyx
lib/layouts/pdfcomment.module
lib/scripts/layout2layout.py
src/Layout.cpp
src/Layout.h
src/OutputParams.h
src/TextClass.cpp
src/insets/InsetArgument.cpp
src/insets/InsetArgument.h
src/insets/InsetLayout.cpp
src/insets/InsetLayout.h
src/insets/InsetNewline.cpp
src/insets/InsetText.cpp

index 568c31bf1681126056964ad12976cdbd12d307ab..07c13d8d4f3843e7417f43a422cca1d6a7dd490b 100644 (file)
@@ -11995,6 +11995,56 @@ status collapsed
 \end_inset
 
 
+\change_inserted -712698321 1555579782
+
+\end_layout
+
+\begin_layout Itemize
+
+\change_inserted -712698321 1555579780
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1555579780
+NewlineCmd
+\end_layout
+
+\end_inset
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1555579780
+[string]
+\end_layout
+
+\end_inset
+
+ Option to define a different command (from the default 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1555579780
+
+\backslash
+
+\backslash
+
+\end_layout
+
+\end_inset
+
+) to be used for line breaks.
+ The initial backslash must not be specified.
+\change_unchanged
+
 \end_layout
 
 \begin_layout Itemize
@@ -20537,7 +20587,7 @@ cprotect
 
 \begin_layout Description
 
-\change_inserted -712698321 1552395824
+\change_inserted -712698321 1555579651
 \begin_inset Flex Code
 status collapsed
 
@@ -20632,6 +20682,54 @@ soul
 \family default
  commands which parse their content in complex ways.
  Default is false.
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1555579742
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1555579658
+NewlineCmd
+\end_layout
+
+\end_inset
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1555579651
+[string]
+\end_layout
+
+\end_inset
+
+ Option to define a different command (from the default 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1555579742
+
+\backslash
+
+\backslash
+
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+) to be used for line breaks.
+ The initial backslash must not be specified.
 \change_unchanged
 
 \end_layout
index 372acb55af22ae952817b2bcc6dd093ce8a8f9e6..afdcfe12a815d733d8ede8de05b55e6d81db2a38 100644 (file)
@@ -10080,6 +10080,57 @@ LabelString
 \begin_inset Flex Code
 status collapsed
 
+\begin_layout Plain Layout
+NewlineCmd
+\end_layout
+
+\end_inset
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+[string]
+\end_layout
+
+\end_inset
+
+ erlaubt es, ein (von 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\backslash
+
+\backslash
+
+\end_layout
+
+\end_inset
+
+) abweichendes Makro für Zeilenumbrüche zu verwenden.
+ Das 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\backslash
+
+\end_layout
+
+\end_inset
+
+ am Anfang des Makros müssen Sie bei der Spezifizierung nicht eingeben.
+\end_layout
+
+\begin_layout Itemize
+\begin_inset Flex Code
+status collapsed
+
 \begin_layout Plain Layout
 Tooltip
 \end_layout
@@ -18670,6 +18721,57 @@ nicht
 \begin_inset Flex Code
 status collapsed
 
+\begin_layout Plain Layout
+NewlineCmd
+\end_layout
+
+\end_inset
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+[string]
+\end_layout
+
+\end_inset
+
+ erlaubt es, ein (von 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\backslash
+
+\backslash
+
+\end_layout
+
+\end_inset
+
+) abweichendes Makro für Zeilenumbrüche zu verwenden.
+ Das 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\backslash
+
+\end_layout
+
+\end_inset
+
+ am Anfang des Makros müssen Sie bei der Spezifizierung nicht eingeben.
+\end_layout
+
+\begin_layout Description
+\begin_inset Flex Code
+status collapsed
+
 \begin_layout Plain Layout
 NoInsetLayout
 \end_layout
index 38a3e9a70dc4a6f3509901432594fb9bf0f31b4b..c0f9a39b977a4ebaa778c79457d0da9f572a8f84 100644 (file)
@@ -8,7 +8,7 @@
 # Author: Juergen Spitzmueller <spitz@lyx.org>
 #         Uwe Stöhr <uwestoehr@lyx.org>
 
-Format 72
+Format 74
 
 #
 # helper commands
@@ -102,6 +102,7 @@ InsetLayout "Flex:PDF-Annotation"
          Size                  Small
        EndFont
        MultiPar                false
+       NewlineCmd              textCR
        Argument 1
          MenuString            "PDFComment Options"
          LabelString           "Opts"
@@ -125,10 +126,12 @@ InsetLayout "Flex:PDF-Markup"
        LabelString             "PDF (Markup)"
        LatexName               pdfmarkupcomment
        NeedMBoxProtect         1
+       NewlineCmd              ""
        Argument post:1
          LabelString           "Comment"
          Mandatory             1
          ToolTip               "Insert the comment to the marked-up text here"
+         NewlineCmd            textCR
        EndArgument
 End
 
@@ -136,24 +139,28 @@ InsetLayout "Flex:PDF-Freetext"
        CopyStyle               "Flex:PDF-Margin"
        LabelString             "PDF (Freetext)"
        LatexName               pdffreetextcomment
+       NewlineCmd              ""
 End
 
 InsetLayout "Flex:PDF-Square"
        CopyStyle               "Flex:PDF-Margin"
        LabelString             "PDF (Square)"
        LatexName               pdfsquarecomment
+       NewlineCmd              ""
 End
 
 InsetLayout "Flex:PDF-Circle"
        CopyStyle               "Flex:PDF-Margin"
        LabelString             "PDF (Circle)"
        LatexName               pdfcirclecomment
+       NewlineCmd              ""
 End
 
 InsetLayout "Flex:PDF-Line"
        CopyStyle               "Flex:PDF-Margin"
        LabelString             "PDF (Line)"
        LatexName               pdflinecomment
+       NewlineCmd              ""
 End
 
 InsetLayout "Flex:PDF-Sideline"
@@ -162,10 +169,12 @@ InsetLayout "Flex:PDF-Sideline"
        LatexType               environment
        LatexName               pdfsidelinecomment
        MultiPar                true
+       NewlineCmd              ""
        Argument 2
          LabelString           "Comment"
          Mandatory             1
          ToolTip               "Insert the comment here"
+         NewlineCmd            textCR
        EndArgument
 End
 
@@ -184,6 +193,7 @@ InsetLayout "Flex:PDF-Tooltip"
        LabelString             "PDF (Tooltip)"
        LatexName               pdftooltip
        NeedMBoxProtect         0
+       NewlineCmd              ""
        LabelFont
          Color                 red
          Size                  Small
index b89969537ca633de307226f5b691855864f0c59f..8fdc9fdf7299a4f7eda4eca62f8975be535c2a5a 100644 (file)
@@ -11,7 +11,7 @@
 # This script will update a .layout file to current format
 
 # The latest layout format is also defined in src/TextClass.cpp
-currentFormat = 73
+currentFormat = 74
 
 
 # Incremented to format 4, 6 April 2007, lasgouttes
@@ -245,6 +245,9 @@ currentFormat = 73
 # Incremented to format 73, 18 April 2019 by spitz
 # New InsetLayout tag MenuString
 
+# Incremented to format 74, 18 April 2019 by spitz
+# New InsetLayout and Argument tag NewlineCmd
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
@@ -494,7 +497,7 @@ def convert(lines, end_format):
                 i += 1
             continue
 
-        if format >= 65 and format <= 72:
+        if format >= 65 and format <= 73:
             # nothing to do.
             i += 1
             continue
index e4b6b3e3db20e7386396b83804ae4996561fd709..be31ccb5a1ad8753143721a081ba53d590171e64 100644 (file)
@@ -1076,6 +1076,9 @@ void Layout::readArgument(Lexer & lex)
                } else if (tok == "decoration") {
                        lex.next();
                        arg.decoration = lex.getString();
+               } else if (tok == "newlinecmd") {
+                       lex.next();
+                       arg.newlinecmd = lex.getString();
                } else if (tok == "font") {
                        arg.font = lyxRead(lex, arg.font);
                } else if (tok == "labelfont") {
@@ -1146,6 +1149,8 @@ void writeArgument(ostream & os, string const & id, Layout::latexarg const & arg
                os << "\t\tRequires \"" << arg.requires << "\"\n";
        if (!arg.decoration.empty())
                os << "\t\tDecoration \"" << arg.decoration << "\"\n";
+       if (!arg.newlinecmd.empty())
+               os << "\t\tNewlineCmd \"" << arg.newlinecmd << "\"\n";
        if (arg.font != inherit_font)
                lyxWrite(os, arg.font, "Font", 2);
        if (arg.labelfont != inherit_font)
index 6c4b6c01d87c1bd82f60d1ed871d08fae28e5707..fcfdc11872ba495055a312bf02027ca4c916ead6 100644 (file)
@@ -109,6 +109,7 @@ public:
                ArgPassThru passthru;
                docstring pass_thru_chars;
                bool is_toc_caption;
+               std::string newlinecmd;
        };
        ///
        typedef std::map<std::string, latexarg> LaTeXArgMap;
index 5faa68e2e49001c091db9cc8739455fac06cf66f..52ab2925a5f5fe3cda53673a330eb4b6450b53b5 100644 (file)
@@ -302,6 +302,9 @@ public:
        /// Should we output verbatim specific chars?
        docstring pass_thru_chars;
 
+       /// A specific newline macro
+       std::string newlinecmd;
+
        /// Should we output captions?
        bool html_disable_captions;
 
index e381060e0cdc3f0e4022bd222958399981c3ea89..a3cadd2ff9ed0803bd0035dbfd76e2f7ad8a7cf8 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 = 73; // spitz: MenuString
+int const LAYOUT_FORMAT = 74; // spitz: NewlineCmd
 
 
 // Layout format for the current lyx file format. Controls which format is
index ba7031dab360c4c64b9e6922fbf7a8bc63997566..37c244d1582296e8d60b54788f17ba8ce6172060 100644 (file)
@@ -43,7 +43,7 @@ InsetArgument::InsetArgument(Buffer * buf, string const & name)
     : InsetCollapsible(buf), name_(name), labelstring_(docstring()),
       font_(inherit_font), labelfont_(inherit_font), decoration_(string()),
       pass_thru_context_(false), pass_thru_local_(false), pass_thru_(false),
-      pass_thru_chars_(docstring()), is_toc_caption_(false)
+      pass_thru_chars_(docstring()), is_toc_caption_(false), newline_cmd_(string())
 {}
 
 
@@ -118,6 +118,7 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype)
                labelfont_ = (*lait).second.labelfont;
                decoration_ = (*lait).second.decoration;
                pass_thru_chars_ = (*lait).second.pass_thru_chars;
+               newline_cmd_ = (*lait).second.newlinecmd;
                pass_thru_local_ = false;
                if (lait->second.is_toc_caption) {
                        is_toc_caption_ = true;
@@ -311,6 +312,8 @@ void InsetArgument::latexArgument(otexstream & os,
        OutputParams runparams = runparams_in;
        if (!pass_thru_chars_.empty())
                runparams.pass_thru_chars += pass_thru_chars_;
+       if (!newline_cmd_.empty())
+               runparams.newlinecmd = newline_cmd_;
        runparams.pass_thru = isPassThru();
        InsetText::latex(ots, runparams);
        TexString ts = ots.release();
index 2bd0578f28cee35284fa14e77bb6b7c54669f856..88af23d2f322f01bdd17c1f22216dde05989da7c 100644 (file)
@@ -119,6 +119,8 @@ private:
        bool is_toc_caption_;
        /// The type of Toc this is the caption of, empty otherwise.
        std::string caption_of_toc_;
+       /// Specific line break macro
+       std::string newline_cmd_;
 
 protected:
        /// \name Protected functions inherited from Inset class
index 6094135024ca011cd46045c0b1e168bad810482e..4d6a5edfbd984362c2b75fe83d2efa370266039c 100644 (file)
@@ -125,6 +125,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                IL_NEEDCPROTECT,
                IL_NEEDMBOXPROTECT,
                IL_NEEDPROTECT,
+               IL_NEWLINE_CMD,
                IL_PASSTHRU,
                IL_PASSTHRU_CHARS,
                IL_PARBREAKISNEWLINE,
@@ -184,6 +185,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                { "needcprotect", IL_NEEDCPROTECT },
                { "needmboxprotect", IL_NEEDMBOXPROTECT },
                { "needprotect", IL_NEEDPROTECT },
+               { "newlinecmd", IL_NEWLINE_CMD },
                { "obsoletedby", IL_OBSOLETEDBY },
                { "parbreakisnewline", IL_PARBREAKISNEWLINE },
                { "passthru", IL_PASSTHRU },
@@ -322,6 +324,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                case IL_PASSTHRU_CHARS:
                        lex >> passthru_chars_;
                        break;
+               case IL_NEWLINE_CMD:
+                       lex >> newline_cmd_;
+                       break;
                case IL_PARBREAKISNEWLINE:
                        lex >> parbreakisnewline_;
                        break;
@@ -658,6 +663,9 @@ void InsetLayout::readArgument(Lexer & lex)
                } else if (tok == "decoration") {
                        lex.next();
                        arg.decoration = lex.getString();
+               } else if (tok == "newlinecmd") {
+                       lex.next();
+                       arg.newlinecmd = lex.getString();
                } else if (tok == "font") {
                        arg.font = lyxRead(lex, arg.font);
                } else if (tok == "labelfont") {
index dc46946897e4f9f9c9981816f9b50f9e914d59bc..f36afa11563a7a25ae3d7c7609831e7bc577de2e 100644 (file)
@@ -160,6 +160,8 @@ public:
        ///
        docstring passThruChars() const { return passthru_chars_; }
        ///
+       std::string newlineCmd() const { return newline_cmd_; }
+       ///
        bool parbreakIsNewline() const { return parbreakisnewline_; }
        ///
        bool isNeedProtect() const { return needprotect_; }
@@ -283,6 +285,8 @@ private:
        ///
        docstring passthru_chars_;
        ///
+       std::string newline_cmd_;
+       ///
        bool parbreakisnewline_;
        ///
        bool freespacing_;
index b10954d4da659210f8192c273c7b47273bd2d87d..b20886c8301fc57cd833054e8095960bdc180193 100644 (file)
@@ -146,7 +146,9 @@ void InsetNewline::latex(otexstream & os, OutputParams const & rp) const
 {
        switch (params_.kind) {
                case InsetNewlineParams::NEWLINE:
-                       if (rp.inTableCell == OutputParams::PLAIN)
+                       if (!rp.newlinecmd.empty())
+                               os << "\\" << rp.newlinecmd << "\n";
+                       else if (rp.inTableCell == OutputParams::PLAIN)
                                os << "\\newline\n";
                        else
                                os << "\\\\\n";
index 85da8dd4ec4c35a18f608d1509b203b271631014..ce69bef2554ee3fb954da62c1fa6a4feecb6fb07 100644 (file)
@@ -503,6 +503,8 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
                ++rp.inulemcmd;
        if (!il.passThruChars().empty())
                rp.pass_thru_chars += il.passThruChars();
+       if (!il.newlineCmd().empty())
+               rp.newlinecmd = il.newlineCmd();
        rp.par_begin = 0;
        rp.par_end = paragraphs().size();