mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Add ProvideInsetLayout and ModifyInsetLayout (#12098)
This complements ProvideStyle and ModifyStyle.
This commit is contained in:
parent
897ee2ed88
commit
c567c78e90
@ -1,5 +1,5 @@
|
||||
#LyX 2.4 created this file. For more info see https://www.lyx.org/
|
||||
\lyxformat 605
|
||||
\lyxformat 606
|
||||
\begin_document
|
||||
\begin_header
|
||||
\save_transient_properties true
|
||||
@ -10389,6 +10389,8 @@ status collapsed
|
||||
|
||||
\change_inserted -712698321 1611646837
|
||||
InputGlobal
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
@ -10401,6 +10403,8 @@ status collapsed
|
||||
|
||||
\change_inserted -712698321 1611646804
|
||||
<filename>
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
@ -10413,6 +10417,8 @@ status collapsed
|
||||
|
||||
\change_inserted -712698321 1611646804
|
||||
Input
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
@ -10426,6 +10432,8 @@ status collapsed
|
||||
|
||||
\change_inserted -712698321 1611646804
|
||||
name.layout
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
@ -10438,6 +10446,8 @@ status collapsed
|
||||
|
||||
\change_inserted -712698321 1611646804
|
||||
name.inc
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
@ -10451,6 +10461,8 @@ status collapsed
|
||||
|
||||
\change_inserted -712698321 1611646853
|
||||
InputGlobal name
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
@ -10463,6 +10475,8 @@ status collapsed
|
||||
|
||||
\change_inserted -712698321 1611646855
|
||||
InputGlobal name.inc
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
@ -10475,6 +10489,8 @@ status collapsed
|
||||
|
||||
\change_inserted -712698321 1611646804
|
||||
Input
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
@ -10636,6 +10652,57 @@ noprefix "false"
|
||||
).
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\change_inserted -712698321 1612018485
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1612018457
|
||||
ModifyInsetLayout
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
[
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1612018466
|
||||
<type>
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
] Modifies the layout of an inset.
|
||||
If the layout does not exist, this section is ignored.
|
||||
Must end with
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1612018452
|
||||
End
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
@ -11212,6 +11279,61 @@ EndPreamble
|
||||
\end_inset
|
||||
|
||||
.
|
||||
\change_inserted -712698321 1612018500
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\change_inserted -712698321 1612018547
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1612018506
|
||||
ProvideInsetLayout
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
[
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1612018509
|
||||
<type>
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
] Defines the layout of an inset if it does not already exist.
|
||||
If the layout does exist, this section is ignored.
|
||||
Must end with
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -712698321 1612018500
|
||||
End
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
.
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX 2.4 created this file. For more info see https://www.lyx.org/
|
||||
\lyxformat 605
|
||||
\lyxformat 606
|
||||
\begin_document
|
||||
\begin_header
|
||||
\save_transient_properties true
|
||||
@ -8492,6 +8492,41 @@ noprefix "false"
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
ModifyInsetLayout
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
[
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
<Typ>
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
] Ändert die Eigenschaften des angegebenen Layouts einer Einfügung.
|
||||
Wenn dieses nicht existiert, wird die Anweisung ignoriert.
|
||||
Muss mit
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
End
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
beendet werden.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
ModifyStyle
|
||||
\end_layout
|
||||
@ -8958,6 +8993,51 @@ EndPreamble
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
ProvideInsetLayout
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
[
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
<Typ>
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
] Erstellt das Layout einer Einfügung, falls es noch nicht existiert.
|
||||
Existiert es bereits, wird
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
ProvideInsetLayout
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
ignoriert.
|
||||
Muss mit
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
End
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
beendet werden.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
Provides
|
||||
\end_layout
|
||||
|
@ -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 = 91
|
||||
currentFormat = 92
|
||||
|
||||
|
||||
# Incremented to format 4, 6 April 2007, lasgouttes
|
||||
@ -310,6 +310,9 @@ currentFormat = 91
|
||||
# Incremented to format 91, 25 January 2021 by spitz
|
||||
# InputGlobal tag
|
||||
|
||||
# Incremented to format 92, 30 January 2021 by spitz
|
||||
# Add ProvideInsetLayout and ModifyIndetLayout
|
||||
|
||||
# Do not forget to document format change in Customization
|
||||
# Manual (section "Declaring a new text class").
|
||||
|
||||
@ -560,7 +563,7 @@ def convert(lines, end_format):
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if 87 <= format <= 91:
|
||||
if 87 <= format <= 92:
|
||||
# nothing to do.
|
||||
i += 1
|
||||
continue
|
||||
|
@ -59,7 +59,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 = 91; // spitz: InputGlobal method
|
||||
int const LAYOUT_FORMAT = 92; // spitz: ProvideInsetLayout and ModifyInsetLayout
|
||||
|
||||
|
||||
// Layout format for the current lyx file format. Controls which format is
|
||||
@ -171,6 +171,8 @@ enum TextClassTags {
|
||||
TC_PROVIDESTYLE,
|
||||
TC_DEFAULTSTYLE,
|
||||
TC_INSETLAYOUT,
|
||||
TC_MODIFYINSETLAYOUT,
|
||||
TC_PROVIDEINSETLAYOUT,
|
||||
TC_NOINSETLAYOUT,
|
||||
TC_NOSTYLE,
|
||||
TC_COLUMNS,
|
||||
@ -254,6 +256,7 @@ LexerKeyword textClassTags[] = {
|
||||
{ "insetlayout", TC_INSETLAYOUT },
|
||||
{ "leftmargin", TC_LEFTMARGIN },
|
||||
{ "maxcitenames", TC_MAXCITENAMES },
|
||||
{ "modifyinsetlayout", TC_MODIFYINSETLAYOUT },
|
||||
{ "modifystyle", TC_MODIFYSTYLE },
|
||||
{ "nocounter", TC_NOCOUNTER },
|
||||
{ "nofloat", TC_NOFLOAT },
|
||||
@ -266,6 +269,7 @@ LexerKeyword textClassTags[] = {
|
||||
{ "pagesize", TC_PAGESIZE },
|
||||
{ "pagestyle", TC_PAGESTYLE },
|
||||
{ "preamble", TC_PREAMBLE },
|
||||
{ "provideinsetlayout", TC_PROVIDEINSETLAYOUT },
|
||||
{ "provides", TC_PROVIDES },
|
||||
{ "providesmodule", TC_PROVIDESMODULE },
|
||||
{ "providestyle", TC_PROVIDESTYLE },
|
||||
@ -431,8 +435,8 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
||||
}
|
||||
|
||||
// used below to track whether we are in an IfStyle or IfCounter tag.
|
||||
bool modifystyle = false;
|
||||
bool providestyle = false;
|
||||
bool modify = false;
|
||||
bool provide = false;
|
||||
bool ifcounter = false;
|
||||
bool only_global = false;
|
||||
|
||||
@ -499,13 +503,13 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
||||
break;
|
||||
|
||||
case TC_MODIFYSTYLE:
|
||||
modifystyle = true;
|
||||
modify = true;
|
||||
// fall through
|
||||
case TC_PROVIDESTYLE:
|
||||
// if modifystyle is true, then we got here by falling through
|
||||
// so we are not in an ProvideStyle block
|
||||
if (!modifystyle)
|
||||
providestyle = true;
|
||||
if (!modify)
|
||||
provide = true;
|
||||
// fall through
|
||||
case TC_STYLE: {
|
||||
if (!lexrc.next()) {
|
||||
@ -531,13 +535,13 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
||||
// If the layout already exists, then we want to add it to
|
||||
// the existing layout, as long as we are not in an ProvideStyle
|
||||
// block.
|
||||
if (have_layout && !providestyle) {
|
||||
if (have_layout && !provide) {
|
||||
Layout & lay = operator[](name);
|
||||
error = !readStyle(lexrc, lay, rt);
|
||||
}
|
||||
// If the layout does not exist, then we want to create a new
|
||||
// one, but not if we are in a ModifyStyle block.
|
||||
else if (!have_layout && !modifystyle) {
|
||||
else if (!have_layout && !modify) {
|
||||
Layout layout;
|
||||
layout.setName(name);
|
||||
error = !readStyle(lexrc, layout, rt);
|
||||
@ -732,6 +736,15 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
||||
rightmargin_ = lexrc.getDocString();
|
||||
break;
|
||||
|
||||
case TC_MODIFYINSETLAYOUT:
|
||||
modify = true;
|
||||
// fall through
|
||||
case TC_PROVIDEINSETLAYOUT:
|
||||
// if modifyinsetlayout is true, then we got here by falling through
|
||||
// so we are not in an ProvideInsetLayout block
|
||||
if (!modify)
|
||||
provide = true;
|
||||
// fall through
|
||||
case TC_INSETLAYOUT: {
|
||||
if (!lexrc.next()) {
|
||||
lexrc.printError("No name given for InsetLayout: `$$Token'.");
|
||||
@ -740,6 +753,7 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
||||
}
|
||||
docstring const name = subst(lexrc.getDocString(), '_', ' ');
|
||||
bool const validating = (rt == VALIDATION);
|
||||
bool const have_layout = name.empty() ? false : hasInsetLayout(name);
|
||||
if (name.empty()) {
|
||||
string s = "Could not read name for InsetLayout: `$$Token' "
|
||||
+ lexrc.getString() + " is probably not valid UTF-8!";
|
||||
@ -752,15 +766,19 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
||||
// in which case we want to report the error
|
||||
if (validating)
|
||||
error = true;
|
||||
} else if (hasInsetLayout(name)) {
|
||||
} else if (have_layout && !provide) {
|
||||
InsetLayout & il = insetlayoutlist_[name];
|
||||
error = !il.read(lexrc, *this, validating);
|
||||
} else {
|
||||
} else if (!modify && !have_layout) {
|
||||
InsetLayout il;
|
||||
il.setName(name);
|
||||
error = !il.read(lexrc, *this, validating);
|
||||
if (!error)
|
||||
insetlayoutlist_[name] = il;
|
||||
} else {
|
||||
InsetLayout il;
|
||||
// We just scan the rest of the style and discard it.
|
||||
il.read(lexrc, *this);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user