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
\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

View 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

View 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

View 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

View 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)

View 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;

View 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;

View 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

View 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();

View 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

View 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") {

View 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_;

View 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";

View 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();