Introduce new beamer frame layouts

The old layouts are still there (marked as deprecated). The new ones are more or less correctly reverted (polishment required), but the old ones not yet converted to the new. Once this is done, a further file format change should be made.
This commit is contained in:
Juergen Spitzmueller 2012-12-31 13:00:46 +01:00
parent f94220a79c
commit 846dd9b995
7 changed files with 469 additions and 107 deletions

View File

@ -12,6 +12,13 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
-----------------------
2012-12-31 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 459: Introduce new beamer frames:
Frame, PlainFrame, FragileFrame (LaTeX: \begin{frame},
\begin{frame}[plain], \begin{frame}[fragile]). These will
eventually replace the old BeginFrame, BeginPlainFrame, which
still exist.
2012-12-30 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 458: Extended caption inset support.
Former special caption layouts (e.g. of KOMA) are now proper caption

View File

@ -25,6 +25,24 @@ Preamble
}
EndPreamble
##########################################
# OBSOLETE STUFF
# Everything below should be removed
# (but this is a file format change)
#
# TODO:
# * conversion of old frame
# and plain frame to new layout
##########################################
#
# Backwards compatible definitions
#
AddToPreamble
\providecommand\lyxframeend{}
EndPreamble
# Frame control definition
Style BeginFrame
# This redefinition is needed to make beamerarticle work

View File

@ -233,7 +233,7 @@ Style Section
Category Sectioning
Margin First_Dynamic
LatexType Command
LatexName lyxframeend{}\section
LatexName section
NeedProtect 1
NextNoIndent 1
LabelSep xx
@ -273,7 +273,7 @@ Style Section*
CopyStyle Section
Category Unnumbered
Margin Static
LatexName lyxframeend{}\section
LatexName section
LabelType No_Label
ResetArgs 1
Argument 1
@ -290,7 +290,7 @@ Style Subsection
Category Sectioning
Margin First_Dynamic
LatexType Command
LatexName lyxframeend{}\subsection
LatexName subsection
NeedProtect 1
NextNoIndent 1
LabelSep xx
@ -330,7 +330,7 @@ Style Subsection*
CopyStyle Subsection
Category Unnumbered
Margin Static
LatexName lyxframeend{}\subsection
LatexName subsection
LabelType No_Label
ResetArgs 1
Argument 1
@ -347,7 +347,7 @@ Style Subsubsection
Category Sectioning
Margin First_Dynamic
LatexType Command
LatexName lyxframeend{}\subsubsection
LatexName subsubsection
NeedProtect 1
NextNoIndent 1
LabelSep xx
@ -387,7 +387,7 @@ Style Subsubsection*
CopyStyle Subsubsection
Category Unnumbered
Margin Static
LatexName lyxframeend{}\subsubsection
LatexName subsubsection
LabelType No_Label
ResetArgs 1
Argument 1
@ -405,90 +405,88 @@ End
# FRAMES
#
Style BeginFrame
Style Frame
Category Frames
Margin Dynamic
LatexType Environment
LatexName frame
LabelString "Frame"
TocLevel 4
KeepEmpty 1
LatexType Command
LatexName lyxframeend{}\lyxframe
Argument 1
LabelString "Frame Options"
Tooltip "Frame options (see beamer manual)"
EndArgument
Margin First_Dynamic
NextNoIndent 1
ParSkip 0
TopSep 2.5
BottomSep 0.5
ParSep 0
Align Center
Align Left
LabelType Static
LabelBottomSep 0
LeftMargin M
LabelSep xx
LabelString "Frame"
Font
Series Bold
Size Largest
Color Blue
EndFont
LabelFont
ParSkip 0.5
TopSep 1
BottomSep 1
ParSep 0
LabelFont
Size largest
Family Roman
Color latex
EndFont
Preamble
\long\def\lyxframe#1{\@lyxframe#1\@lyxframestop}%
\def\@lyxframe{\@ifnextchar<{\@@lyxframe}{\@@lyxframe<*>}}%
\def\@@lyxframe<#1>{\@ifnextchar[{\@@@lyxframe<#1>}{\@@@lyxframe<#1>[]}}
\def\@@@lyxframe<#1>[{\@ifnextchar<{\@@@@@lyxframe<#1>[}{\@@@@lyxframe<#1>[<*>][}}
\def\@@@@@lyxframe<#1>[#2]{\@ifnextchar[{\@@@@lyxframe<#1>[#2]}{\@@@@lyxframe<#1>[#2][]}}
\long\def\@@@@lyxframe<#1>[#2][#3]#4\@lyxframestop#5\lyxframeend{%
\frame<#1>[#2][#3]{\frametitle{#4}#5}}
EndPreamble
Argument 1
LabelString "Action"
MenuString "Overlay Specifications|S"
Tooltip "Overlay specifications for this frame"
LeftDelim <
RightDelim >
EndArgument
Argument 2
LabelString "Default Overlay Specifications"
Tooltip "Default overlay specifications within this frame"
LeftDelim [<
RightDelim >]
EndArgument
Argument 3
MenuString "Frame Options"
LabelString "Options"
Tooltip "Frame options (see beamer manual)"
EndArgument
Argument 4
LabelString "Frame Title"
Tooltip "Enter the block title here"
LeftDelim {
RightDelim }
Decoration conglomerate
Font
Color blue
Size largest
EndFont
AutoInsert 1
EndArgument
End
Style BeginPlainFrame
Category Frames
TocLevel 4
KeepEmpty 1
LatexType Command
LatexName lyxframeend{}\lyxplainframe
Margin First_Dynamic
NextNoIndent 1
ParSkip 0
TopSep 2.5
BottomSep 0.5
ParSep 0
Align Center
LabelType Static
LabelBottomSep 0
LeftMargin M
LabelSep xx
LabelString "Frame (no head/foot/sidebars)"
Font
Series Bold
Size Largest
Color Blue
EndFont
LabelFont
Family Roman
Color latex
EndFont
Preamble
\long\def\lyxplainframe#1{\@lyxplainframe#1\@lyxframestop}%
\def\@lyxplainframe{\@ifnextchar<{\@@lyxplainframe}{\@@lyxplainframe<*>}}%
\long\def\@@lyxplainframe<#1>#2\@lyxframestop#3\lyxframeend{%
\frame<#1>[plain]{\frametitle{#2}#3}}
EndPreamble
Style PlainFrame
CopyStyle Frame
LabelString "Frame (plain)"
Argument 3
MenuString "Frame Options"
LabelString "Options"
Tooltip "Frame options (see beamer manual)"
PresetArg "plain"
EndArgument
End
Style FragileFrame
CopyStyle Frame
LabelString "Frame (fragile)"
Argument 3
MenuString "Frame Options"
LabelString "Options"
Tooltip "Frame options (see beamer manual)"
PresetArg "fragile"
EndArgument
End
Style AgainFrame
Category Frames
KeepEmpty 0
LatexType Command
LatexName lyxframeend{}\againframe
LatexName againframe
Argument 1
LabelString "On Slide"
LabelString "Slide"
MenuString "Overlay Specifications|S"
Tooltip "Overlay specifications for this frame"
LeftDelim <
@ -511,7 +509,6 @@ Style AgainFrame
TopSep 3
BottomSep 3
ParSep 0
Align Center
LabelType Static
LabelBottomSep 0
LeftMargin M
@ -523,37 +520,10 @@ Style AgainFrame
LabelFont
Family Roman
Color latex
Series Bold
Size Largest
EndFont
End
Style EndFrame
Category Frames
KeepEmpty 1
LatexType Command
LatexName lyxframeend
Margin First_Dynamic
ParSkip 0
TopSep 0
BottomSep 3
ParSep 0
Align Center
LabelType Static
LabelBottomSep 0
LeftMargin MMMMM
LabelString "________________________________"
LabelFont
Family typewriter
Series Medium
Size Normal
Color latex
EndFont
Preamble
\def\lyxframeend{} % In case there is a superfluous frame end
EndPreamble
End
Style FrameTitle
Category Frames
Margin Static
@ -564,10 +534,9 @@ Style FrameTitle
TopSep 0
BottomSep 1
ParSep 1
Align Center
Align Block
LabelType No_Label
Font
Series Bold
Color Blue
Size Largest
EndFont
@ -594,10 +563,9 @@ Style FrameSubtitle
TopSep 0
BottomSep 1
ParSep 1
Align Center
Align Block
LabelType No_Label
Font
Series Bold
Color Blue
EndFont
Argument 1
@ -1593,3 +1561,158 @@ End
Input theorems-refprefix.inc
##########################################
# OBSOLETE STUFF
# Everything below should be removed
# (but this is a file format change)
#
# TODO:
# * conversion of old frame
# and plain frame to new layout
##########################################
#
# Backwards compatible definitions
#
AddToPreamble
\providecommand\lyxframeend{}
EndPreamble
IfStyle Section
LatexName lyxframeend{}\section
End
IfStyle Section*
LatexName lyxframeend{}\section
End
IfStyle Subsection
LatexName lyxframeend{}\subsection
End
IfStyle Subsection*
LatexName lyxframeend{}\subsection
End
IfStyle Subsubsection
LatexName lyxframeend{}\subsubsection
End
IfStyle Subsubsection*
LatexName lyxframeend{}\subsubsection
End
IfStyle AgainFrame
LatexName lyxframeend{}\againframe
End
#
# Deprecated Styles
#
Style BeginFrame
Category "Deprecated Styles"
TocLevel 4
KeepEmpty 1
LatexType Command
LatexName lyxframeend{}\lyxframe
Argument 1
LabelString "Frame Options"
Tooltip "Frame options (see beamer manual)"
EndArgument
Margin First_Dynamic
NextNoIndent 1
ParSkip 0
TopSep 2.5
BottomSep 0.5
ParSep 0
Align Center
LabelType Static
LabelBottomSep 0
LeftMargin M
LabelSep xx
LabelString "Frame"
Font
Series Bold
Size Largest
Color Blue
EndFont
LabelFont
Family Roman
Color latex
EndFont
Preamble
\long\def\lyxframe#1{\@lyxframe#1\@lyxframestop}%
\def\@lyxframe{\@ifnextchar<{\@@lyxframe}{\@@lyxframe<*>}}%
\def\@@lyxframe<#1>{\@ifnextchar[{\@@@lyxframe<#1>}{\@@@lyxframe<#1>[]}}
\def\@@@lyxframe<#1>[{\@ifnextchar<{\@@@@@lyxframe<#1>[}{\@@@@lyxframe<#1>[<*>][}}
\def\@@@@@lyxframe<#1>[#2]{\@ifnextchar[{\@@@@lyxframe<#1>[#2]}{\@@@@lyxframe<#1>[#2][]}}
\long\def\@@@@lyxframe<#1>[#2][#3]#4\@lyxframestop#5\lyxframeend{%
\frame<#1>[#2][#3]{\frametitle{#4}#5}}
EndPreamble
End
Style BeginPlainFrame
Category "Deprecated Styles"
TocLevel 4
KeepEmpty 1
LatexType Command
LatexName lyxframeend{}\lyxplainframe
Margin First_Dynamic
NextNoIndent 1
ParSkip 0
TopSep 2.5
BottomSep 0.5
ParSep 0
Align Center
LabelType Static
LabelBottomSep 0
LeftMargin M
LabelSep xx
LabelString "Frame (no head/foot/sidebars)"
Font
Series Bold
Size Largest
Color Blue
EndFont
LabelFont
Family Roman
Color latex
EndFont
Preamble
\long\def\lyxplainframe#1{\@lyxplainframe#1\@lyxframestop}%
\def\@lyxplainframe{\@ifnextchar<{\@@lyxplainframe}{\@@lyxplainframe<*>}}%
\long\def\@@lyxplainframe<#1>#2\@lyxframestop#3\lyxframeend{%
\frame<#1>[plain]{\frametitle{#2}#3}}
EndPreamble
End
Style EndFrame
Category "Deprecated Styles"
KeepEmpty 1
LatexType Command
LatexName lyxframeend
Margin First_Dynamic
ParSkip 0
TopSep 0
BottomSep 3
ParSep 0
Align Center
LabelType Static
LabelBottomSep 0
LeftMargin MMMMM
LabelString "________________________________"
LabelFont
Family typewriter
Series Medium
Size Normal
Color latex
EndFont
Preamble
\def\lyxframeend{} % In case there is a superfluous frame end
EndPreamble
End

View File

@ -25,6 +25,24 @@ Preamble
}
EndPreamble
##########################################
# OBSOLETE STUFF
# Everything below should be removed
# (but this is a file format change)
#
# TODO:
# * conversion of old frame
# and plain frame to new layout
##########################################
#
# Backwards compatible definitions
#
AddToPreamble
\providecommand\lyxframeend{}
EndPreamble
# Frame control definition
Style BeginFrame
# This redefinition is needed to make beamerarticle work

View File

@ -3165,6 +3165,197 @@ def revert_captionlayouts(document):
i = i + 1
def revert_fragileframe(document):
" Reverts beamer FragileFrame layout to ERT "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
i = 0
while True:
i = find_token(document.body, "\\begin_layout FragileFrame", i)
if i == -1:
return
# Find end of sequence
j = find_end_of_sequence(document.body, i)
if j == -1:
document.warning("Malformed lyx document. Cannot find end of FragileFrame sequence!")
i = i + 1
continue
endseq = j
subst = ["\\begin_layout Standard"] + put_cmd_in_ert("\\begin{frame}")
esubst = ["\\end_layout", "", "\\begin_layout Standard"] + put_cmd_in_ert("\\end{frame}")
endseq = endseq + len(esubst) - len(document.body[j : j])
if document.body[j] == "\\end_deeper":
document.body[j : j] = ["\\end_deeper", ""] + esubst
else:
document.body[j : j] = esubst
for q in range(i, j):
if document.body[q] == "\\begin_layout FragileFrame":
document.body[q] = "\\begin_layout %s" % document.default_layout
r = i
while r < j:
if document.body[r] == "\\begin_deeper":
s = find_end_of(document.body, r, "\\begin_deeper", "\\end_deeper")
if s != -1:
document.body[r] = ""
document.body[s] = ""
r = s
continue
r = r + 1
for p in range(1, 5):
arg = find_token(document.body, "\\begin_inset Argument %d" % p, i, j)
if arg != -1:
if p == 1:
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg)
endPlain = find_end_of_layout(document.body, beginPlain)
endInset = find_end_of_inset(document.body, arg)
content = document.body[beginPlain + 1 : endPlain]
# Adjust range end
j = j - len(document.body[arg : endInset + 1])
# Remove arg inset
del document.body[arg : endInset + 1]
subst += put_cmd_in_ert("<") + content + put_cmd_in_ert(">")
elif p == 2:
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg)
endPlain = find_end_of_layout(document.body, beginPlain)
endInset = find_end_of_inset(document.body, arg)
content = document.body[beginPlain + 1 : endPlain]
# Adjust range end
j = j - len(document.body[arg : endInset + 1])
# Remove arg inset
del document.body[arg : endInset + 1]
subst += put_cmd_in_ert("[<") + content + put_cmd_in_ert(">]")
elif p == 3:
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg)
endPlain = find_end_of_layout(document.body, beginPlain)
endInset = find_end_of_inset(document.body, arg)
content = document.body[beginPlain + 1 : endPlain]
# Adjust range end
j = j - len(document.body[arg : endInset + 1])
# Remove arg inset
del document.body[arg : endInset + 1]
subst += put_cmd_in_ert("[fragile,") + content + put_cmd_in_ert("]")
elif p == 4:
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg)
endPlain = find_end_of_layout(document.body, beginPlain)
endInset = find_end_of_inset(document.body, arg)
content = document.body[beginPlain + 1 : endPlain]
# Adjust range end
j = j - len(document.body[arg : endInset + 1])
# Remove arg inset
del document.body[arg : endInset + 1]
subst += put_cmd_in_ert("{") + content + put_cmd_in_ert("}")
elif p == 3:
subst += put_cmd_in_ert("[fragile]")
document.body[i : i + 1] = subst
i = j
def revert_newframes(document):
" Reverts beamer Frame and PlainFrame layouts to old forms "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
frame_dict = {
"Frame" : "BeginFrame",
"PlainFrame" : "BeginPlainFrame",
}
rx = re.compile(r'^\\begin_layout (\S+)$')
i = 0
while True:
i = find_token(document.body, "\\begin_layout", i)
if i == -1:
return
m = rx.match(document.body[i])
val = ""
if m:
val = m.group(1)
if val not in frame_dict.keys():
i = i + 1
continue
# Find end of sequence
j = find_end_of_sequence(document.body, i)
if j == -1:
document.warning("Malformed lyx document. Cannot find end of Frame sequence!")
i = i + 1
continue
endseq = j
subst = ["\\begin_layout %s" % frame_dict[val]]
esubst = ["\\end_layout", "", "\\begin_layout EndFrame", "", "\\end_layout"]
endseq = endseq + len(esubst) - len(document.body[j : j])
if document.body[j] == "\\end_deeper":
document.body[j : j] = ["\\end_deeper", ""] + esubst
else:
document.body[j : j] = esubst
for q in range(i, j):
if document.body[q] == "\\begin_layout %s" % val:
document.body[q] = "\\begin_layout %s" % document.default_layout
r = i
while r < j:
if document.body[r] == "\\begin_deeper":
s = find_end_of(document.body, r, "\\begin_deeper", "\\end_deeper")
if s != -1:
document.body[r] = ""
document.body[s] = ""
r = s
continue
r = r + 1
l = find_end_of_layout(document.body, i)
for p in range(1, 5):
arg = find_token(document.body, "\\begin_inset Argument %d" % p, i, l)
if arg != -1:
if p == 1:
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg)
endPlain = find_end_of_layout(document.body, beginPlain)
endInset = find_end_of_inset(document.body, arg)
content = document.body[beginPlain + 1 : endPlain]
# Adjust range end
l = l - len(document.body[arg : endInset + 1])
# Remove arg inset
del document.body[arg : endInset + 1]
subst += put_cmd_in_ert("<") + content + put_cmd_in_ert(">")
elif p == 2:
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg)
endPlain = find_end_of_layout(document.body, beginPlain)
endInset = find_end_of_inset(document.body, arg)
content = document.body[beginPlain + 1 : endPlain]
# Adjust range end
l = l - len(document.body[arg : endInset + 1])
# Remove arg inset
del document.body[arg : endInset + 1]
subst += put_cmd_in_ert("[<") + content + put_cmd_in_ert(">]")
elif p == 3:
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg)
endPlain = find_end_of_layout(document.body, beginPlain)
endInset = find_end_of_inset(document.body, arg)
content = document.body[beginPlain + 1 : endPlain]
# Adjust range end
l = l - len(document.body[arg : endInset + 1])
# Remove arg inset
del document.body[arg : endInset + 1]
subst += put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
elif p == 4:
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg)
endPlain = find_end_of_layout(document.body, beginPlain)
endInset = find_end_of_inset(document.body, arg)
content = document.body[beginPlain + 1 : endPlain]
# Adjust range end
l = l - len(document.body[arg : endInset + 1])
# Remove arg inset
del document.body[arg : endInset + 1]
subst += content
document.body[i : i + 1] = subst
i = j
##
# Conversion hub
#
@ -3215,10 +3406,12 @@ convert = [
[455, []],
[456, [convert_epigraph]],
[457, [convert_use_stackrel]],
[458, [convert_captioninsets, convert_captionlayouts]]
[458, [convert_captioninsets, convert_captionlayouts]],
[459, []]
]
revert = [
[458, [revert_fragileframe, revert_newframes]],
[457, [revert_captioninsets, revert_captionlayouts]],
[456, [revert_use_stackrel]],
[455, [revert_epigraph]],

View File

@ -98,6 +98,9 @@ Format LaTeX feature LyX feature
456 memoir: \epigraph{text}{source} layout Epigraph, InsetArgument
457 automatic stackrel loading \use_package stackrel
458 Extended InsetCaption syntax InsetCaption
459 beamer: \begin{frame}, \begin_layout Frame
\begin{frame}[plain], \begin_layout PlainFrame
\begin{frame}[fragile] \begin_layout FragileFrame
General

View File

@ -30,8 +30,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
#define LYX_FORMAT_LYX 458 // spitz: extended caption inset
#define LYX_FORMAT_TEX2LYX 458 // spitz: extended caption inset
#define LYX_FORMAT_LYX 459 // spitz: new beamer frame layouts
#define LYX_FORMAT_TEX2LYX 459 // spitz: new beamer frame layouts
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER