Add NewlineCmd InsetLayout and Argument option

This allows to specific an alternative macro for newlines

Fixes: #10407
This commit is contained in:
Juergen Spitzmueller 2019-04-18 11:35:03 +02:00
parent ed44bbddee
commit 70b3d3adcc
14 changed files with 250 additions and 7 deletions

View File

@ -11995,6 +11995,56 @@ status collapsed
\end_inset \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 \end_layout
\begin_layout Itemize \begin_layout Itemize
@ -20537,7 +20587,7 @@ cprotect
\begin_layout Description \begin_layout Description
\change_inserted -712698321 1552395824 \change_inserted -712698321 1555579651
\begin_inset Flex Code \begin_inset Flex Code
status collapsed status collapsed
@ -20632,6 +20682,54 @@ soul
\family default \family default
commands which parse their content in complex ways. commands which parse their content in complex ways.
Default is false. 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 \change_unchanged
\end_layout \end_layout

View File

@ -10080,6 +10080,57 @@ LabelString
\begin_inset Flex Code \begin_inset Flex Code
status collapsed 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 \begin_layout Plain Layout
Tooltip Tooltip
\end_layout \end_layout
@ -18670,6 +18721,57 @@ nicht
\begin_inset Flex Code \begin_inset Flex Code
status collapsed 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 \begin_layout Plain Layout
NoInsetLayout NoInsetLayout
\end_layout \end_layout

View File

@ -8,7 +8,7 @@
# Author: Juergen Spitzmueller <spitz@lyx.org> # Author: Juergen Spitzmueller <spitz@lyx.org>
# Uwe Stöhr <uwestoehr@lyx.org> # Uwe Stöhr <uwestoehr@lyx.org>
Format 72 Format 74
# #
# helper commands # helper commands
@ -102,6 +102,7 @@ InsetLayout "Flex:PDF-Annotation"
Size Small Size Small
EndFont EndFont
MultiPar false MultiPar false
NewlineCmd textCR
Argument 1 Argument 1
MenuString "PDFComment Options" MenuString "PDFComment Options"
LabelString "Opts" LabelString "Opts"
@ -125,10 +126,12 @@ InsetLayout "Flex:PDF-Markup"
LabelString "PDF (Markup)" LabelString "PDF (Markup)"
LatexName pdfmarkupcomment LatexName pdfmarkupcomment
NeedMBoxProtect 1 NeedMBoxProtect 1
NewlineCmd ""
Argument post:1 Argument post:1
LabelString "Comment" LabelString "Comment"
Mandatory 1 Mandatory 1
ToolTip "Insert the comment to the marked-up text here" ToolTip "Insert the comment to the marked-up text here"
NewlineCmd textCR
EndArgument EndArgument
End End
@ -136,24 +139,28 @@ InsetLayout "Flex:PDF-Freetext"
CopyStyle "Flex:PDF-Margin" CopyStyle "Flex:PDF-Margin"
LabelString "PDF (Freetext)" LabelString "PDF (Freetext)"
LatexName pdffreetextcomment LatexName pdffreetextcomment
NewlineCmd ""
End End
InsetLayout "Flex:PDF-Square" InsetLayout "Flex:PDF-Square"
CopyStyle "Flex:PDF-Margin" CopyStyle "Flex:PDF-Margin"
LabelString "PDF (Square)" LabelString "PDF (Square)"
LatexName pdfsquarecomment LatexName pdfsquarecomment
NewlineCmd ""
End End
InsetLayout "Flex:PDF-Circle" InsetLayout "Flex:PDF-Circle"
CopyStyle "Flex:PDF-Margin" CopyStyle "Flex:PDF-Margin"
LabelString "PDF (Circle)" LabelString "PDF (Circle)"
LatexName pdfcirclecomment LatexName pdfcirclecomment
NewlineCmd ""
End End
InsetLayout "Flex:PDF-Line" InsetLayout "Flex:PDF-Line"
CopyStyle "Flex:PDF-Margin" CopyStyle "Flex:PDF-Margin"
LabelString "PDF (Line)" LabelString "PDF (Line)"
LatexName pdflinecomment LatexName pdflinecomment
NewlineCmd ""
End End
InsetLayout "Flex:PDF-Sideline" InsetLayout "Flex:PDF-Sideline"
@ -162,10 +169,12 @@ InsetLayout "Flex:PDF-Sideline"
LatexType environment LatexType environment
LatexName pdfsidelinecomment LatexName pdfsidelinecomment
MultiPar true MultiPar true
NewlineCmd ""
Argument 2 Argument 2
LabelString "Comment" LabelString "Comment"
Mandatory 1 Mandatory 1
ToolTip "Insert the comment here" ToolTip "Insert the comment here"
NewlineCmd textCR
EndArgument EndArgument
End End
@ -184,6 +193,7 @@ InsetLayout "Flex:PDF-Tooltip"
LabelString "PDF (Tooltip)" LabelString "PDF (Tooltip)"
LatexName pdftooltip LatexName pdftooltip
NeedMBoxProtect 0 NeedMBoxProtect 0
NewlineCmd ""
LabelFont LabelFont
Color red Color red
Size Small Size Small

View File

@ -11,7 +11,7 @@
# This script will update a .layout file to current format # This script will update a .layout file to current format
# The latest layout format is also defined in src/TextClass.cpp # The latest layout format is also defined in src/TextClass.cpp
currentFormat = 73 currentFormat = 74
# Incremented to format 4, 6 April 2007, lasgouttes # Incremented to format 4, 6 April 2007, lasgouttes
@ -245,6 +245,9 @@ currentFormat = 73
# Incremented to format 73, 18 April 2019 by spitz # Incremented to format 73, 18 April 2019 by spitz
# New InsetLayout tag MenuString # 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 # Do not forget to document format change in Customization
# Manual (section "Declaring a new text class"). # Manual (section "Declaring a new text class").
@ -494,7 +497,7 @@ def convert(lines, end_format):
i += 1 i += 1
continue continue
if format >= 65 and format <= 72: if format >= 65 and format <= 73:
# nothing to do. # nothing to do.
i += 1 i += 1
continue continue

View File

@ -1076,6 +1076,9 @@ void Layout::readArgument(Lexer & lex)
} else if (tok == "decoration") { } else if (tok == "decoration") {
lex.next(); lex.next();
arg.decoration = lex.getString(); arg.decoration = lex.getString();
} else if (tok == "newlinecmd") {
lex.next();
arg.newlinecmd = lex.getString();
} else if (tok == "font") { } else if (tok == "font") {
arg.font = lyxRead(lex, arg.font); arg.font = lyxRead(lex, arg.font);
} else if (tok == "labelfont") { } 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"; os << "\t\tRequires \"" << arg.requires << "\"\n";
if (!arg.decoration.empty()) if (!arg.decoration.empty())
os << "\t\tDecoration \"" << arg.decoration << "\"\n"; os << "\t\tDecoration \"" << arg.decoration << "\"\n";
if (!arg.newlinecmd.empty())
os << "\t\tNewlineCmd \"" << arg.newlinecmd << "\"\n";
if (arg.font != inherit_font) if (arg.font != inherit_font)
lyxWrite(os, arg.font, "Font", 2); lyxWrite(os, arg.font, "Font", 2);
if (arg.labelfont != inherit_font) if (arg.labelfont != inherit_font)

View File

@ -109,6 +109,7 @@ public:
ArgPassThru passthru; ArgPassThru passthru;
docstring pass_thru_chars; docstring pass_thru_chars;
bool is_toc_caption; bool is_toc_caption;
std::string newlinecmd;
}; };
/// ///
typedef std::map<std::string, latexarg> LaTeXArgMap; typedef std::map<std::string, latexarg> LaTeXArgMap;

View File

@ -302,6 +302,9 @@ public:
/// Should we output verbatim specific chars? /// Should we output verbatim specific chars?
docstring pass_thru_chars; docstring pass_thru_chars;
/// A specific newline macro
std::string newlinecmd;
/// Should we output captions? /// Should we output captions?
bool html_disable_captions; bool html_disable_captions;

View File

@ -62,7 +62,7 @@ namespace lyx {
// You should also run the development/tools/updatelayouts.py script, // You should also run the development/tools/updatelayouts.py script,
// to update the format of all of our layout files. // 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 // Layout format for the current lyx file format. Controls which format is

View File

@ -43,7 +43,7 @@ InsetArgument::InsetArgument(Buffer * buf, string const & name)
: InsetCollapsible(buf), name_(name), labelstring_(docstring()), : InsetCollapsible(buf), name_(name), labelstring_(docstring()),
font_(inherit_font), labelfont_(inherit_font), decoration_(string()), font_(inherit_font), labelfont_(inherit_font), decoration_(string()),
pass_thru_context_(false), pass_thru_local_(false), pass_thru_(false), 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; labelfont_ = (*lait).second.labelfont;
decoration_ = (*lait).second.decoration; decoration_ = (*lait).second.decoration;
pass_thru_chars_ = (*lait).second.pass_thru_chars; pass_thru_chars_ = (*lait).second.pass_thru_chars;
newline_cmd_ = (*lait).second.newlinecmd;
pass_thru_local_ = false; pass_thru_local_ = false;
if (lait->second.is_toc_caption) { if (lait->second.is_toc_caption) {
is_toc_caption_ = true; is_toc_caption_ = true;
@ -311,6 +312,8 @@ void InsetArgument::latexArgument(otexstream & os,
OutputParams runparams = runparams_in; OutputParams runparams = runparams_in;
if (!pass_thru_chars_.empty()) if (!pass_thru_chars_.empty())
runparams.pass_thru_chars += pass_thru_chars_; runparams.pass_thru_chars += pass_thru_chars_;
if (!newline_cmd_.empty())
runparams.newlinecmd = newline_cmd_;
runparams.pass_thru = isPassThru(); runparams.pass_thru = isPassThru();
InsetText::latex(ots, runparams); InsetText::latex(ots, runparams);
TexString ts = ots.release(); TexString ts = ots.release();

View File

@ -119,6 +119,8 @@ private:
bool is_toc_caption_; bool is_toc_caption_;
/// The type of Toc this is the caption of, empty otherwise. /// The type of Toc this is the caption of, empty otherwise.
std::string caption_of_toc_; std::string caption_of_toc_;
/// Specific line break macro
std::string newline_cmd_;
protected: protected:
/// \name Protected functions inherited from Inset class /// \name Protected functions inherited from Inset class

View File

@ -125,6 +125,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
IL_NEEDCPROTECT, IL_NEEDCPROTECT,
IL_NEEDMBOXPROTECT, IL_NEEDMBOXPROTECT,
IL_NEEDPROTECT, IL_NEEDPROTECT,
IL_NEWLINE_CMD,
IL_PASSTHRU, IL_PASSTHRU,
IL_PASSTHRU_CHARS, IL_PASSTHRU_CHARS,
IL_PARBREAKISNEWLINE, IL_PARBREAKISNEWLINE,
@ -184,6 +185,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
{ "needcprotect", IL_NEEDCPROTECT }, { "needcprotect", IL_NEEDCPROTECT },
{ "needmboxprotect", IL_NEEDMBOXPROTECT }, { "needmboxprotect", IL_NEEDMBOXPROTECT },
{ "needprotect", IL_NEEDPROTECT }, { "needprotect", IL_NEEDPROTECT },
{ "newlinecmd", IL_NEWLINE_CMD },
{ "obsoletedby", IL_OBSOLETEDBY }, { "obsoletedby", IL_OBSOLETEDBY },
{ "parbreakisnewline", IL_PARBREAKISNEWLINE }, { "parbreakisnewline", IL_PARBREAKISNEWLINE },
{ "passthru", IL_PASSTHRU }, { "passthru", IL_PASSTHRU },
@ -322,6 +324,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
case IL_PASSTHRU_CHARS: case IL_PASSTHRU_CHARS:
lex >> passthru_chars_; lex >> passthru_chars_;
break; break;
case IL_NEWLINE_CMD:
lex >> newline_cmd_;
break;
case IL_PARBREAKISNEWLINE: case IL_PARBREAKISNEWLINE:
lex >> parbreakisnewline_; lex >> parbreakisnewline_;
break; break;
@ -658,6 +663,9 @@ void InsetLayout::readArgument(Lexer & lex)
} else if (tok == "decoration") { } else if (tok == "decoration") {
lex.next(); lex.next();
arg.decoration = lex.getString(); arg.decoration = lex.getString();
} else if (tok == "newlinecmd") {
lex.next();
arg.newlinecmd = lex.getString();
} else if (tok == "font") { } else if (tok == "font") {
arg.font = lyxRead(lex, arg.font); arg.font = lyxRead(lex, arg.font);
} else if (tok == "labelfont") { } else if (tok == "labelfont") {

View File

@ -160,6 +160,8 @@ public:
/// ///
docstring passThruChars() const { return passthru_chars_; } docstring passThruChars() const { return passthru_chars_; }
/// ///
std::string newlineCmd() const { return newline_cmd_; }
///
bool parbreakIsNewline() const { return parbreakisnewline_; } bool parbreakIsNewline() const { return parbreakisnewline_; }
/// ///
bool isNeedProtect() const { return needprotect_; } bool isNeedProtect() const { return needprotect_; }
@ -283,6 +285,8 @@ private:
/// ///
docstring passthru_chars_; docstring passthru_chars_;
/// ///
std::string newline_cmd_;
///
bool parbreakisnewline_; bool parbreakisnewline_;
/// ///
bool freespacing_; bool freespacing_;

View File

@ -146,7 +146,9 @@ void InsetNewline::latex(otexstream & os, OutputParams const & rp) const
{ {
switch (params_.kind) { switch (params_.kind) {
case InsetNewlineParams::NEWLINE: 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"; os << "\\newline\n";
else else
os << "\\\\\n"; os << "\\\\\n";

View File

@ -503,6 +503,8 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
++rp.inulemcmd; ++rp.inulemcmd;
if (!il.passThruChars().empty()) if (!il.passThruChars().empty())
rp.pass_thru_chars += il.passThruChars(); rp.pass_thru_chars += il.passThruChars();
if (!il.newlineCmd().empty())
rp.newlinecmd = il.newlineCmd();
rp.par_begin = 0; rp.par_begin = 0;
rp.par_end = paragraphs().size(); rp.par_end = paragraphs().size();