On Tue, Oct 30, 2001 at 02:54:47PM +0200, Dekel Tsur wrote:
> > 
> > Secondly, this does not work since the fen file is not found in the
> > temporary lyx directory (and I don't like running with tmpdir off).
> > 
> > Any ideas to fix the problem?
> 
> Change the lyx sources, adding a $$lyxfilepath token to the external
> inset template that expands to the absolute path to the lyx file when
> when previewing the file in LyX, and expands to an empty string when
> exporting to latex.
> 
> If this is too much work, leave the chess template as is and perhaps I will
> try to do the changes if I find some time.

I have done this, but I could not figure out how to make it expand to an
empty string when exporting to latex. I hope Dekel (or anyone else) can
tell me how to do that piece.

Right now, it inserts the path to the FEN file in the LaTeX code
and it works great (without any intermediate tex fragments). This means
that we can even lose fen2latex.py (but keep fen2ascii.py).

I submit my chess patch again. Please apply this. It's quite limited
in scope and won't break anything else. ;-)

                        ---Kayvan
-- 
Kayvan A. Sylvan          | Proud husband of       | Father to my kids:
Sylvan Associates, Inc.   | Laura Isabella Sylvan  | Katherine Yelena (8/8/89)
http://sylvan.com/~kayvan | "crown of her husband" | Robin Gregory (2/28/92)
? lib/scripts/fen2ascii.py
? lib/tex/lyxskak.sty
? src/version_info.h
Index: lib/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/ChangeLog,v
retrieving revision 1.121
diff -u -r1.121 ChangeLog
--- lib/ChangeLog       2001/10/30 17:05:57     1.121
+++ lib/ChangeLog       2001/10/30 19:04:11
@@ -1,3 +1,9 @@
+2001-10-30  Kayvan A. Sylvan  <[EMAIL PROTECTED]>
+
+       * external_templates: Fix up the help message for ChessDiagram
+       again (referring to the new lyxskak.sty). Reworked the LaTeX
+       output to use skak.sty \loadgame{file} feature.
+
 2001-10-30  John Levon  <[EMAIL PROTECTED]>
 
        * Makefile.am: remove BUGS.lyx mention
@@ -6,6 +12,21 @@
 
        * ui/default.ui: remove Known Bugs entry
  
+2001-10-28  Kayvan A. Sylvan  <[EMAIL PROTECTED]>
+
+       * scripts/fen2latex.py: Simplified greatly. Now uses skak.
+       
+       * scripts/fen2ascii.py: New file added. Makes a nice ascii
+       representation of the chess position.
+
+2001-10-28  Kayvan A. Sylvan  <[EMAIL PROTECTED]>
+
+       * external_templates: Changed comment to inform user to use skak
+       package instead of the very old chess.sty for external chess
+       material. Added the -mode EditPosition flag to the "xboard"
+       invocation. Fixed the invocation of fen2ascii (which did *not*
+       exist, even though it was referenced).
+
 2001-10-24  José Matos  <[EMAIL PROTECTED]>
 
        * layouts/db_lyxmacros.inc:
Index: lib/Makefile.am
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/Makefile.am,v
retrieving revision 1.29
diff -u -r1.29 Makefile.am
--- lib/Makefile.am     2001/10/30 17:05:57     1.29
+++ lib/Makefile.am     2001/10/30 19:04:11
@@ -19,7 +19,7 @@
 LAYOUT = layouts/*.layout layouts/*.inc 
 LYXSCRIPTS = configure configure.cmd scripts/*
 TEMPL = templates/*.lyx
-TEXSUPPORT = tex/*.cls
+TEXSUPPORT = tex/*.cls tex/*.sty
 UI = ui/*.ui
 
 configure: configure.m4
Index: lib/external_templates
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/external_templates,v
retrieving revision 1.4
diff -u -r1.4 external_templates
--- lib/external_templates      2000/06/20 07:58:10     1.4
+++ lib/external_templates      2001/10/30 19:04:11
@@ -99,21 +99,21 @@
                remember to middle and right click to 
                insert new material in the board.
                In order for this to work, you have to
-               install the lyxchess.sty which is bundled
-               with LyX, and the chess.sty from CTAN.
+               put the bundled lyxskak.sty in a place
+               that TeX will find it, and you will need
+               to install the skak package from CTAN.
        HelpTextEnd
        FileFilter "*.fen"
        ViewCommand "xboard -lpf $$FName"
-       EditCommand "xboard -lpf $$FName"
+       EditCommand "xboard -lpf $$FName -mode EditPosition"
        AutomaticProduction true
        Format LaTeX
-               Product "$$Contents(\"$$Basename.tex\")"
-               UpdateCommand "python $$Sysdir/scripts/fen2latex.py $$FName 
$$Basename.tex"
+               Product "\\loadgame{$$lyxfilepath/$$Basename}\\showboard"
                Requirement "chess"
        FormatEnd
        Format Ascii
                Product "$$Contents(\"$$Basename.asc\")"
-               UpdateCommand "python $$Sysdir/scripts/fen2ascii.py $$FName 
$$Basename.tex"
+               UpdateCommand "python $$Sysdir/scripts/fen2ascii.py $$FName 
+$$Basename.asc"
        FormatEnd
        Format DocBook
                Product "[Chess: $$Basename]"
Index: lib/scripts/fen2latex.py
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/scripts/fen2latex.py,v
retrieving revision 1.1
diff -u -r1.1 fen2latex.py
--- lib/scripts/fen2latex.py    2000/06/12 11:27:08     1.1
+++ lib/scripts/fen2latex.py    2001/10/30 19:04:11
@@ -1,11 +1,11 @@
 #!/usr/bin/python
 #
-# Copyright (C) 2000 The LyX Team.
+# Copyright (C) 2001 The LyX Team.
 #
 # This file is distributed under the GPL license.
 #
 # This script will convert a chess position in the FEN
-# format to a chunk of LaTeX to be used with the chess.sty
+# format to a chunk of LaTeX to be used with the skak.sty
 # style.
 
 import sys,string,os
@@ -19,33 +19,6 @@
 if line[-1] == '\n':
     line = line[:-1]
 
-line=string.split(line,' ')[0]
-comp=string.split(line,'/')
-
-first = 1
-cont=1
-margin= " "*6
-
-for i in range(8):
-
-    cont = cont + 1
-    tmp=""
-    for j in comp[i]:
-       if j>='0' and j <= '9':
-           for k in range(int(j)):
-               cont = cont + 1
-               x, mod = divmod(cont,2)
-               if mod : tmp = tmp + ' '
-               else : tmp = tmp + '*'
-       else :
-           tmp = tmp + j
-           cont = cont + 1
-
-    if first: 
-       first = 0
-       print "\\board{"+tmp+"}"
-    else : 
-       print margin+"{"+tmp+"}"
-
+print "\\fenboard{"+line+"}" 
 print "\\showboard%"
 
Index: po/POTFILES.in
===================================================================
RCS file: /cvs/lyx/lyx-devel/po/POTFILES.in,v
retrieving revision 1.226
diff -u -r1.226 POTFILES.in
--- po/POTFILES.in      2001/10/24 13:21:19     1.226
+++ po/POTFILES.in      2001/10/30 19:04:11
@@ -1,24 +1,21 @@
+src/buffer.C
+src/bufferlist.C
 src/BufferView2.C
+src/bufferview_funcs.C
 src/BufferView_pimpl.C
 src/Chktex.C
 src/ColorHandler.C
-src/CutAndPaste.C
-src/FontLoader.C
-src/LColor.C
-src/LaTeX.C
-src/LyXAction.C
-src/LyXSendto.C
-src/LyXView.C
-src/MenuBackend.C
-src/buffer.C
-src/bufferlist.C
-src/bufferview_funcs.C
 src/converter.C
+src/CutAndPaste.C
 src/debug.C
 src/exporter.C
+src/ext_l10n.h
 src/figureForm.C
 src/figure_form.C
+src/FontLoader.C
+src/frontends/controllers/biblio.C
 src/frontends/controllers/ButtonController.h
+src/frontends/controllers/character.C
 src/frontends/controllers/ControlAboutlyx.C
 src/frontends/controllers/ControlBibtex.C
 src/frontends/controllers/ControlCharacter.C
@@ -31,8 +28,6 @@
 src/frontends/controllers/ControlSpellchecker.C
 src/frontends/controllers/ControlTexinfo.C
 src/frontends/controllers/ControlThesaurus.C
-src/frontends/controllers/biblio.C
-src/frontends/controllers/character.C
 src/frontends/controllers/helper_funcs.C
 src/frontends/gnome/FormCitation.C
 src/frontends/gnome/FormIndex.C
@@ -41,6 +36,7 @@
 src/frontends/gnome/FormToc.C
 src/frontends/gnome/Menubar_pimpl.C
 src/frontends/qt2/FileDialog.C
+src/frontends/qt2/lengthcombo.C
 src/frontends/qt2/QAbout.C
 src/frontends/qt2/QBibitem.C
 src/frontends/qt2/QBibtex.C
@@ -49,8 +45,8 @@
 src/frontends/qt2/QCitation.C
 src/frontends/qt2/QCitationDialog.C
 src/frontends/qt2/QDocument.C
-src/frontends/qt2/QERT.C
 src/frontends/qt2/QError.C
+src/frontends/qt2/QERT.C
 src/frontends/qt2/QExternal.C
 src/frontends/qt2/QExternalDialog.C
 src/frontends/qt2/QGraphics.C
@@ -72,87 +68,86 @@
 src/frontends/qt2/QToc.C
 src/frontends/qt2/QURL.C
 src/frontends/qt2/QVCLog.C
-src/frontends/qt2/lengthcombo.C
+src/frontends/xforms/combox.C
 src/frontends/xforms/FileDialog.C
 src/frontends/xforms/FormAboutlyx.C
-src/frontends/xforms/FormBibitem.C
-src/frontends/xforms/FormBibtex.C
-src/frontends/xforms/FormCharacter.C
-src/frontends/xforms/FormCitation.C
-src/frontends/xforms/FormDocument.C
-src/frontends/xforms/FormERT.C
-src/frontends/xforms/FormError.C
-src/frontends/xforms/FormExternal.C
-src/frontends/xforms/FormFiledialog.C
-src/frontends/xforms/FormFloat.C
-src/frontends/xforms/FormGraphics.C
-src/frontends/xforms/FormInclude.C
-src/frontends/xforms/FormIndex.C
-src/frontends/xforms/FormLog.C
-src/frontends/xforms/FormMathsBitmap.C
-src/frontends/xforms/FormMathsDeco.C
-src/frontends/xforms/FormMathsDelim.C
-src/frontends/xforms/FormMathsMatrix.C
-src/frontends/xforms/FormMathsPanel.C
-src/frontends/xforms/FormMathsSpace.C
-src/frontends/xforms/FormMinipage.C
-src/frontends/xforms/FormParagraph.C
-src/frontends/xforms/FormPreamble.C
-src/frontends/xforms/FormPreferences.C
-src/frontends/xforms/FormPrint.C
-src/frontends/xforms/FormRef.C
-src/frontends/xforms/FormSearch.C
-src/frontends/xforms/FormSpellchecker.C
-src/frontends/xforms/FormTabular.C
-src/frontends/xforms/FormTabularCreate.C
-src/frontends/xforms/FormTexinfo.C
-src/frontends/xforms/FormThesaurus.C
-src/frontends/xforms/FormToc.C
-src/frontends/xforms/FormUrl.C
-src/frontends/xforms/FormVCLog.C
-src/frontends/xforms/Menubar_pimpl.C
-src/frontends/xforms/combox.C
 src/frontends/xforms/form_aboutlyx.C
+src/frontends/xforms/FormBibitem.C
 src/frontends/xforms/form_bibitem.C
+src/frontends/xforms/FormBibtex.C
 src/frontends/xforms/form_bibtex.C
 src/frontends/xforms/form_browser.C
+src/frontends/xforms/FormCharacter.C
 src/frontends/xforms/form_character.C
+src/frontends/xforms/FormCitation.C
 src/frontends/xforms/form_citation.C
+src/frontends/xforms/FormDocument.C
 src/frontends/xforms/form_document.C
+src/frontends/xforms/FormError.C
 src/frontends/xforms/form_error.C
+src/frontends/xforms/FormERT.C
 src/frontends/xforms/form_ert.C
+src/frontends/xforms/FormExternal.C
 src/frontends/xforms/form_external.C
+src/frontends/xforms/FormFiledialog.C
 src/frontends/xforms/form_filedialog.C
+src/frontends/xforms/FormFloat.C
 src/frontends/xforms/form_float.C
+src/frontends/xforms/FormGraphics.C
 src/frontends/xforms/form_graphics.C
+src/frontends/xforms/FormInclude.C
 src/frontends/xforms/form_include.C
+src/frontends/xforms/FormIndex.C
 src/frontends/xforms/form_index.C
+src/frontends/xforms/FormLog.C
+src/frontends/xforms/FormMathsBitmap.C
+src/frontends/xforms/FormMathsDeco.C
 src/frontends/xforms/form_maths_deco.C
+src/frontends/xforms/FormMathsDelim.C
 src/frontends/xforms/form_maths_delim.C
+src/frontends/xforms/FormMathsMatrix.C
 src/frontends/xforms/form_maths_matrix.C
+src/frontends/xforms/FormMathsPanel.C
 src/frontends/xforms/form_maths_panel.C
+src/frontends/xforms/FormMathsSpace.C
 src/frontends/xforms/form_maths_space.C
+src/frontends/xforms/FormMinipage.C
 src/frontends/xforms/form_minipage.C
+src/frontends/xforms/FormParagraph.C
 src/frontends/xforms/form_paragraph.C
+src/frontends/xforms/FormPreamble.C
 src/frontends/xforms/form_preamble.C
+src/frontends/xforms/FormPreferences.C
 src/frontends/xforms/form_preferences.C
+src/frontends/xforms/FormPrint.C
 src/frontends/xforms/form_print.C
+src/frontends/xforms/FormRef.C
 src/frontends/xforms/form_ref.C
+src/frontends/xforms/FormSearch.C
 src/frontends/xforms/form_search.C
+src/frontends/xforms/FormSpellchecker.C
 src/frontends/xforms/form_spellchecker.C
+src/frontends/xforms/FormTabular.C
 src/frontends/xforms/form_tabular.C
+src/frontends/xforms/FormTabularCreate.C
 src/frontends/xforms/form_tabular_create.C
+src/frontends/xforms/FormTexinfo.C
 src/frontends/xforms/form_texinfo.C
+src/frontends/xforms/FormThesaurus.C
 src/frontends/xforms/form_thesaurus.C
+src/frontends/xforms/FormToc.C
 src/frontends/xforms/form_toc.C
+src/frontends/xforms/FormUrl.C
 src/frontends/xforms/form_url.C
+src/frontends/xforms/FormVCLog.C
 src/frontends/xforms/input_validators.C
+src/frontends/xforms/Menubar_pimpl.C
 src/frontends/xforms/xforms_helpers.C
 src/gettext.h
 src/importer.C
 src/insets/figinset.C
-src/insets/inset.C
 src/insets/insetbib.C
+src/insets/inset.C
 src/insets/insetcaption.C
 src/insets/inseterror.C
 src/insets/insetert.C
@@ -177,19 +172,25 @@
 src/insets/inseturl.C
 src/kbsequence.C
 src/language.C
+src/LaTeX.C
 src/layout.C
+src/LColor.C
+src/LyXAction.C
 src/lyx_cb.C
-src/lyx_gui_misc.C
-src/lyx_main.C
 src/lyxfind.C
 src/lyxfont.C
 src/lyxfunc.C
+src/lyx_gui_misc.C
+src/lyx_main.C
 src/lyxrc.C
+src/LyXSendto.C
 src/lyxvc.C
-src/mathed/formula.C
+src/LyXView.C
 src/mathed/formulabase.C
+src/mathed/formula.C
 src/mathed/formulamacro.C
 src/mathed/math_cursor.C
+src/MenuBackend.C
 src/minibuffer.C
 src/paragraph.C
 src/print_form.C
@@ -198,6 +199,6 @@
 src/support/path.C
 src/support/path.h
 src/tabular.C
-src/text.C
 src/text2.C
+src/text.C
 src/ext_l10n.h
Index: src/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/ChangeLog,v
retrieving revision 1.378
diff -u -r1.378 ChangeLog
--- src/ChangeLog       2001/10/30 17:05:57     1.378
+++ src/ChangeLog       2001/10/30 19:04:11
@@ -2,6 +2,15 @@
 
        * lyx_main.C: change ref to known bugs
  
+2001-10-30  Kayvan A. Sylvan  <[EMAIL PROTECTED]>
+
+       * LaTeXFeatures.C (getPackages): Use lyxskak.sty now instead
+       to work around older babel problems.
+
+2001-10-28  Kayvan A. Sylvan  <[EMAIL PROTECTED]>
+
+       * LaTeXFeatures.[hC]: Now uses skak.sty for chess material.
+
 2001-10-24  Juergen Vigna  <[EMAIL PROTECTED]>
 
        * tabular-old.C (ReadOld): below variable changes reflected.
Index: src/LaTeXFeatures.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/LaTeXFeatures.C,v
retrieving revision 1.47
diff -u -r1.47 LaTeXFeatures.C
--- src/LaTeXFeatures.C 2001/10/23 09:42:13     1.47
+++ src/LaTeXFeatures.C 2001/10/30 19:04:11
@@ -189,9 +189,9 @@
        //      packages << "\\usepackage{algorithm}\n";
        //}
 
-       // lyxchess.sty
+       // lyxskak.sty --- newer chess support based on skak.sty
        if (chess) {
-               packages << "\\usepackage{lyxchess}\n";
+               packages << "\\usepackage[ps,mover]{lyxskak}\n";
        }
 
        // setspace.sty
Index: src/LaTeXFeatures.h
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/LaTeXFeatures.h,v
retrieving revision 1.33
diff -u -r1.33 LaTeXFeatures.h
--- src/LaTeXFeatures.h 2001/10/23 09:42:13     1.33
+++ src/LaTeXFeatures.h 2001/10/30 19:04:11
@@ -94,7 +94,7 @@
        ///
        bool prettyref; // prettyref.sty
        ///
-       bool chess;     // chess.sty
+       bool chess;     // skak.sty (new chess support)
        ///
        bool natbib;    // natbib.sty
        ///
Index: src/insets/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.213
diff -u -r1.213 ChangeLog
--- src/insets/ChangeLog        2001/10/24 15:07:39     1.213
+++ src/insets/ChangeLog        2001/10/30 19:04:12
@@ -1,3 +1,8 @@
+2001-10-30  Kayvan A. Sylvan  <[EMAIL PROTECTED]>
+
+       * insetexternal.C (doSubstitution): Added $$lyxfilepath token
+       to list of usable substitutions in external inset templates.
+
 2001-10-24  Juergen Vigna  <[EMAIL PROTECTED]>
 
        * insettabular.C: use new ltType struct for setting longtable
Index: src/insets/insetexternal.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/insets/insetexternal.C,v
retrieving revision 1.31
diff -u -r1.31 insetexternal.C
--- src/insets/insetexternal.C  2001/09/04 11:02:06     1.31
+++ src/insets/insetexternal.C  2001/10/30 19:04:12
@@ -235,9 +235,12 @@
 {
        string result;
        string const basename = ChangeExtension(params_.filename, string());
+       string buf = MakeAbsPath(params_.filename);
+       string filepath = OnlyPath(buf);
        result = subst(s, "$$FName", params_.filename);
        result = subst(result, "$$Basename", basename);
        result = subst(result, "$$Parameters", params_.parameters);
+       result = subst(result, "$$lyxfilepath", filepath);
        result = ReplaceEnvironmentPath(result);
        result = subst(result, "$$Tempname", tempname_);
        result = subst(result, "$$Sysdir", system_lyxdir);

newchessfiles.tgz

Reply via email to