Re: r34591 - in lyx-devel/trunk: lib/scripts src src/insets src/tex2lyx

2010-06-09 Thread Guenter Milde
On 2010-06-08, José Matos wrote:

 On the same vein as your work and since I dislike the latex output of
 lyx- beamer I have a workaround in the form of a python script and
 another layout.

Did already you consider using custom insets for the frames?

I started doing this for the seminar.layout.
This easily translates to the way these environments are used in LaTeX.

Unfortunately, there is no easy obsoleting a Layout with an Inset.

Günter



Re: r34591 - in lyx-devel/trunk: lib/scripts src src/insets src/tex2lyx

2010-06-09 Thread Jürgen Spitzmüller
2010/6/9 Guenter Milde:
 Did already you consider using custom insets for the frames?

 I started doing this for the seminar.layout.
 This easily translates to the way these environments are used in LaTeX.

While I agree this is cleaner, there are also disadvantages:

1. you lose the outliner features. I.e., you cannot any longer reorder
frames via the outliner (which is a rather crucial feature for me).

2. inserting a frame is double work: you need to insert the frame and
you (usually) need to insert a title

Both are solveable, but both should be solved IMHO before we change the layout.

Jürgen


Re: r34591 - in lyx-devel/trunk: lib/scripts src src/insets src/tex2lyx

2010-06-09 Thread Guenter Milde
On 2010-06-08, José Matos wrote:

> On the same vein as your work and since I dislike the latex output of
> lyx- beamer I have a workaround in the form of a python script and
> another layout.

Did already you consider using custom insets for the frames?

I started doing this for the seminar.layout.
This easily translates to the way these environments are used in LaTeX.

Unfortunately, there is no easy obsoleting a Layout with an Inset.

Günter



Re: r34591 - in lyx-devel/trunk: lib/scripts src src/insets src/tex2lyx

2010-06-09 Thread Jürgen Spitzmüller
2010/6/9 Guenter Milde:
> Did already you consider using custom insets for the frames?
>
> I started doing this for the seminar.layout.
> This easily translates to the way these environments are used in LaTeX.

While I agree this is cleaner, there are also disadvantages:

1. you lose the outliner features. I.e., you cannot any longer reorder
frames via the outliner (which is a rather crucial feature for me).

2. inserting a frame is double work: you need to insert the frame and
you (usually) need to insert a title

Both are solveable, but both should be solved IMHO before we change the layout.

Jürgen


Re: r34591 - in lyx-devel/trunk: lib/scripts src src/insets src/tex2lyx

2010-06-08 Thread José Matos
On Friday 04 June 2010 23:32:40 Richard Heck wrote:
 Thoughts?
 
 Richard

I agree with your analysis.

It would possible for us to have the user configuring from its personal .lyx 
directory lyx2lyx to bypass some conversion filters. It is not difficult and I 
am not suggesting it for this case I am just saying that it could be done 
easily.

On the same vein as your work and since I dislike the latex output of lyx-
beamer I have a workaround in the form of a python script and another layout.

This work is incomplete in the sense that only supports normal frames (no 
plain or otherwise) but it allows me to share the latex output with my 
colleagues that only use plain latex. (for any definition of plain that I will 
ignore due to the respect to the readers :-) )

-- 
José Abílio
import sys

end_frame=\\end_deeper

\\begin_layout Separator

\\end_layout


begin_frame=\\begin_layout BeginFrame

\\end_layout
\\begin_deeper



titlepage=r\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
titlepage
\end_layout

\end_inset


\end_layout


def clean(lyx_file):
# find textclass
for line in lyx_file:
# strip endline char
line = line[:-1]

if line.startswith(\\textclass):
print(\\textclass beamer-clean)
break
else:
print line

# goto the document body
for line in lyx_file:
# strip endline char
line = line[:-1]

print line
if line.startswith(\\begin_body):
break

# scan document body
print (begin_frame)
frame_closed = False
first_frame = True

for line in lyx_file:
# strip endline char
line = line[:-1]

if line.startswith(\\begin_layout):
layout = line[len(\\begin_layout ):]
if layout in (BeginFrame, Section, SubSection, Section*, Subsection*):
if first_frame:
print (titlepage)
first_frame = False

if not frame_closed:
print(end_frame)
frame_closed = True

if layout == BeginFrame:
frame_closed = False
print (begin_frame)
line = \\begin_layout FrameTitle

if layout == EndFrame:
if first_frame:
print (titlepage)
first_frame = False
frame_closed = True
print (\\end_deeper)
print ()
line = \\begin_layout Separator

#if layout == Title:
#line = \\begin_layout FrameTitle

if line.startswith(\\end_body):
if not frame_closed:
print(end_frame)

print(line)


def main():
if len(sys.argv)  2:
lyx_file = sys.stdin
else:
lyx_file = open(sys.argv[1])

clean(lyx_file)


if __name__ == __main__:
main()
#% Do not delete the line below; configure depends on this
#  \DeclareLaTeXClass[beamer,pgf.sty,xcolor.sty]{presentation (beamer, clean 
lattex code)}

Format 11
Input beamer

# Section style _re_definition
Style Section
  LatexNamesection
End

# Section* style _re_definition
Style Section*
  LatexNamesection*
End

# Subsection style _re_definition
Style Subsection
  LatexNamesubsection
End

# Subsection* style _re_definition
Style Subsection*
  LatexNamesubsection*
End

Style FrameTitle
  CopyStyle BeginFrame
  LatexNameframetitle
  LabelString  
  Preamble
  EndPreamble
End

Style BeginFrame
  LatexNameframe
  LatexTypeEnvironment
  Margin   Static
  AlignCenter
  AlignPossibleCenter
  LabelString  __ Frame __
  Preamble
  EndPreamble
  Font
Series Medium
Size   Normal
Color  None
  EndFont

End

TitleLaTeXName titlepage

Preamble
EndPreamble


Re: r34591 - in lyx-devel/trunk: lib/scripts src src/insets src/tex2lyx

2010-06-08 Thread José Matos
On Friday 04 June 2010 23:32:40 Richard Heck wrote:
> Thoughts?
> 
> Richard

I agree with your analysis.

It would possible for us to have the user configuring from its personal .lyx 
directory lyx2lyx to bypass some conversion filters. It is not difficult and I 
am not suggesting it for this case I am just saying that it could be done 
easily.

On the same vein as your work and since I dislike the latex output of lyx-
beamer I have a workaround in the form of a python script and another layout.

This work is incomplete in the sense that only supports normal frames (no 
plain or otherwise) but it allows me to share the latex output with my 
colleagues that only use plain latex. (for any definition of plain that I will 
ignore due to the respect to the readers :-) )

-- 
José Abílio
import sys

end_frame="""\\end_deeper

\\begin_layout Separator

\\end_layout
"""

begin_frame="""\\begin_layout BeginFrame

\\end_layout
\\begin_deeper

"""

titlepage=r"""\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
titlepage
\end_layout

\end_inset


\end_layout
"""

def clean(lyx_file):
# find textclass
for line in lyx_file:
# strip endline char
line = line[:-1]

if line.startswith("\\textclass"):
print("\\textclass beamer-clean")
break
else:
print line

# goto the document body
for line in lyx_file:
# strip endline char
line = line[:-1]

print line
if line.startswith("\\begin_body"):
break

# scan document body
print (begin_frame)
frame_closed = False
first_frame = True

for line in lyx_file:
# strip endline char
line = line[:-1]

if line.startswith("\\begin_layout"):
layout = line[len("\\begin_layout "):]
if layout in ("BeginFrame", "Section", "SubSection", "Section*", "Subsection*"):
if first_frame:
print (titlepage)
first_frame = False

if not frame_closed:
print(end_frame)
frame_closed = True

if layout == "BeginFrame":
frame_closed = False
print (begin_frame)
line = "\\begin_layout FrameTitle"

if layout == "EndFrame":
if first_frame:
print (titlepage)
first_frame = False
frame_closed = True
print ("\\end_deeper")
print ("")
line = "\\begin_layout Separator"

#if layout == "Title":
#line = "\\begin_layout FrameTitle"

if line.startswith("\\end_body"):
if not frame_closed:
print(end_frame)

print(line)


def main():
if len(sys.argv) < 2:
lyx_file = sys.stdin
else:
lyx_file = open(sys.argv[1])

clean(lyx_file)


if __name__ == "__main__":
main()
#% Do not delete the line below; configure depends on this
#  \DeclareLaTeXClass[beamer,pgf.sty,xcolor.sty]{presentation (beamer, clean 
lattex code)}

Format 11
Input beamer

# Section style _re_definition
Style Section
  LatexNamesection
End

# Section* style _re_definition
Style Section*
  LatexNamesection*
End

# Subsection style _re_definition
Style Subsection
  LatexNamesubsection
End

# Subsection* style _re_definition
Style Subsection*
  LatexNamesubsection*
End

Style FrameTitle
  CopyStyle BeginFrame
  LatexNameframetitle
  LabelString  ""
  Preamble
  EndPreamble
End

Style BeginFrame
  LatexNameframe
  LatexTypeEnvironment
  Margin   Static
  AlignCenter
  AlignPossibleCenter
  LabelString  "__ Frame __"
  Preamble
  EndPreamble
  Font
Series Medium
Size   Normal
Color  None
  EndFont

End

TitleLaTeXName titlepage

Preamble
EndPreamble


Re: r34591 - in lyx-devel/trunk: lib/scripts src src/insets src/tex2lyx

2010-06-04 Thread Richard Heck

On 06/04/2010 05:50 PM, rgh...@lyx.org wrote:

Author: rgheck
Date: Fri Jun  4 23:50:08 2010
New Revision: 34591
URL: http://www.lyx.org/trac/changeset/34591

Log:
Introduce a new RequiredArgs tag for layouts. This functions much as
the OptionalArgs tag does and is implemented by the now misnamed
InsetOptArgs, except that its content gets wrapped in {} rather than
[]. Required arguments do not actually have to be provided, but they
are always output.

This will allow e.g. beamer's Block environment to be implemented
without ERT.

   
Users of Beamer will know what this means: In a Block environment, you 
have to enter the first argument as ERT, whereas this will allow you to 
enter it in a Short Title environment if we just add:

RequiredArgs 1
to the Block style declaration in Beamer.

Unfortunately, doing so breaks old Beamer files, because RequiredArgs 
are output as empty arguments, {}, if they are not given. So you end up 
with:

\begin{block}{}
{This was ERT}Here is the content of the block
\end{block}
Any ideas? One I had, though I don't know if it will work, is to do a 
dummy format change and use lyx2lyx to convert beamer files to the new 
format, so something like:


\begin_layout Block
\begin_inset ERT
status collapsed

\begin_layout Plain Layout

{Crazy Thesis}
\end_layout

\end_inset

If reference is a binary relation between uttered expressions and things,
 then there is no such thing as reference.

\end_layout

would become:

\begin_layout Block
\begin_inset OptArg
status collapsed

\begin_layout Plain Layout

Crazy Thesis
\end_layout

\end_inset

If reference is a binary relation between uttered expressions and things,
 then there is no such thing as reference.

\end_layout

It would be fairly easy to write the lyx2lyx to do this.

The only worry is that someone might have a customized version of 
beamer.layout, and then these changes would break their file. Still, I 
think people who've customized layouts can deal with this sort of 
problem, and a note could be added to the release notes.


Thoughts?

Richard







Re: r34591 - in lyx-devel/trunk: lib/scripts src src/insets src/tex2lyx

2010-06-04 Thread Richard Heck

On 06/04/2010 05:50 PM, rgh...@lyx.org wrote:

Author: rgheck
Date: Fri Jun  4 23:50:08 2010
New Revision: 34591
URL: http://www.lyx.org/trac/changeset/34591

Log:
Introduce a new "RequiredArgs" tag for layouts. This functions much as
the OptionalArgs tag does and is implemented by the now misnamed
InsetOptArgs, except that its content gets wrapped in "{}" rather than
"[]". Required arguments do not actually have to be provided, but they
are always output.

This will allow e.g. beamer's Block environment to be implemented
without ERT.

   
Users of Beamer will know what this means: In a Block environment, you 
have to enter the first argument as ERT, whereas this will allow you to 
enter it in a Short Title environment if we just add:

RequiredArgs 1
to the Block style declaration in Beamer.

Unfortunately, doing so breaks old Beamer files, because RequiredArgs 
are output as empty arguments, {}, if they are not given. So you end up 
with:

\begin{block}{}
{This was ERT}Here is the content of the block
\end{block}
Any ideas? One I had, though I don't know if it will work, is to do a 
dummy format change and use lyx2lyx to convert beamer files to the "new 
format", so something like:


\begin_layout Block
\begin_inset ERT
status collapsed

\begin_layout Plain Layout

{Crazy Thesis}
\end_layout

\end_inset

If reference is a binary relation between uttered expressions and things,
 then there is no such thing as reference.

\end_layout

would become:

\begin_layout Block
\begin_inset OptArg
status collapsed

\begin_layout Plain Layout

Crazy Thesis
\end_layout

\end_inset

If reference is a binary relation between uttered expressions and things,
 then there is no such thing as reference.

\end_layout

It would be fairly easy to write the lyx2lyx to do this.

The only worry is that someone might have a customized version of 
beamer.layout, and then these changes would break their file. Still, I 
think people who've customized layouts can deal with this sort of 
problem, and a note could be added to the release notes.


Thoughts?

Richard