]> git.lyx.org Git - features.git/commitdiff
Rework chessboard support
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 23 Sep 2018 10:26:43 +0000 (12:26 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 23 Sep 2018 10:26:43 +0000 (12:26 +0200)
* Use a module rather than a layout, since this package can be used with
  any class
* Do not hardcode options and settings. The package is very flexible,
  there is no need to limit this in LyX

lib/Makefile.am
lib/chkconfig.ltx
lib/examples/chessboard-article.lyx
lib/layouts/chessboard.layout [deleted file]
lib/layouts/chessboard.module [new file with mode: 0644]
src/LaTeXFeatures.cpp

index fc8f2706b5bc868b866e06639bef856239340415..3816d5c7279e763d19a0056a372e20dac6558efa 100644 (file)
@@ -2169,7 +2169,7 @@ dist_layouts_DATA =\
        layouts/bxjsslide.layout \
        layouts/changebars.module \
        layouts/chess.layout \
-       layouts/chessboard.layout \
+       layouts/chessboard.module \
        layouts/cl2emult.layout \
        layouts/copernicus.layout \
        layouts/ctex-article.layout \
index 7c8b669bcfe1a38467122d705a58870972ff91bb..8abcc53c3f47314486ef229894469f7d398f9e3e 100644 (file)
 \TestPackage{cancel}
 \TestPackage{chapterbib}
 \TestPackage{chemgreek}
+\TestPackage{chessboard}
+\TestPackage{chessfss}
 \TestPackage{chicago}
 \TestPackage{color} % this one should be there if graphics.sty is there.
 \TestPackage{covington}
 \TestPackage[xetex.def]{xetex-def}
 \TestPackage{xkeyval}
 \TestPackage{xltabular}
+\TestPackage{xskak} % required by chessboard
 
 % Packages used by LyX's documentation files
 \TestPackage{arydshln}
index aad0c85f8b96ff30f0b147b263328dde62629602..6ab13e4b563d795d81aff991050220475e35ba97 100644 (file)
@@ -1,17 +1,22 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 563
+\lyxformat 564
 \begin_document
 \begin_header
 \save_transient_properties true
 \origin /systemlyxdir/examples/
-\textclass chessboard
+\textclass article
 \begin_preamble
-\usepackage{multicol}
+\AtBeginDocument{%
 \columnsep 0.25in
 \columnseprule 0.4pt
 \hyphenpenalty 10000
+}
 \end_preamble
 \use_default_options true
+\begin_modules
+chessboard
+multicol
+\end_modules
 \maintain_unincluded_children false
 \language english
 \language_package default
 \use_package stackrel 1
 \use_package stmaryrd 1
 \use_package undertilde 1
-\cite_engine biblatex-natbib
-\cite_engine_type authoryear
-\biblatex_bibstyle authoryear
-\biblatex_citestyle authoryear
+\cite_engine basic
+\cite_engine_type default
+\biblio_style plain
 \use_bibtopic false
 \use_indices false
 \paperorientation portrait
 \secnumdepth 3
 \tocdepth 3
 \paragraph_separation skip
-\defskip medskip
+\defskip smallskip
 \is_math_indent 0
 \math_numbering_side default
 \quotes_style english
 \dynamic_quotes 0
 \papercolumns 1
 \papersides 1
-\paperpagestyle default
+\paperpagestyle empty
 \tracking_changes false
 \output_changes false
 \html_math_output 0
@@ -116,37 +120,25 @@ Game start 05/29/2001
 \end_layout
 
 \begin_layout Standard
-\begin_inset ERT
-status collapsed
+\begin_inset Flex Multiple Columns
+status open
 
 \begin_layout Plain Layout
-
-
-\backslash
-begin{multicols}{2}
-\end_layout
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Standard
 The following game was played at the IECC (International Email Chess Club).
  It is presented as an example of the fun you can have with \SpecialChar LyX
 's new chessboard
layout (based on the 
-\begin_inset Quotes eld
-\end_inset
-
-xskak.sty
-\begin_inset Quotes erd
-\end_inset
-
- package from CTAN
module (using the 
+\family sans
+xskak
+\family default
+ and 
+\family sans
+chessboard
+\family default
+ packages).
 \end_layout
 
-\begin_layout Standard
+\begin_layout Plain Layout
 \begin_inset CommandInset line
 LatexCommand rule
 offset "0.5ex"
@@ -158,14 +150,14 @@ height "1pt"
 
 \end_layout
 
-\begin_layout Standard
+\begin_layout Plain Layout
 
 \noun on
 Sylvan, Kayvan
 \begin_inset space \hfill{}
 \end_inset
 
-Wakeham, Marc 
+Wakeham, Marc
 \noun default
 
 \begin_inset Newline newline
@@ -175,10 +167,10 @@ Wakeham, Marc
 \begin_inset space \hfill{}
 \end_inset
 
- (1639)
+(1639)
 \end_layout
 
-\begin_layout Standard
+\begin_layout Plain Layout
 \noindent
 \begin_inset CommandInset line
 LatexCommand rule
@@ -191,7 +183,24 @@ height "1pt"
 
 \end_layout
 
-\begin_layout Standard
+\begin_layout NewChessGame
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Flex SetChessBoard
+status open
+
+\begin_layout Plain Layout
+pgfstyle=straightmove,arrow=to,linewidth=0.1em,smallboard
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
 \begin_inset Flex Mainline
 status open
 
@@ -207,12 +216,6 @@ outvar
 
 \end_inset
 
-
-\begin_inset Argument 2
-status open
-
-\begin_layout Plain Layout
-
 1.
  e4 c5 2.
  Nc3 d6 3.
@@ -226,44 +229,22 @@ status open
 
 \end_layout
 
-\end_inset
-
-
-\end_layout
-
-\begin_layout Standard
+\begin_layout ChessBoard
 \noindent
 \align center
 \begin_inset Flex ChessBoard
 status open
 
 \begin_layout Plain Layout
+\noindent
+\align center
 \begin_inset Argument 1
 status open
 
 \begin_layout Plain Layout
 
-d2-d4
-\end_layout
-
-\end_inset
-
-
-\begin_inset Argument 3
-status open
-
-\begin_layout Plain Layout
-d4,f4
-\end_layout
-
-\end_inset
-
-
-\begin_inset Argument 2
-status open
-
-\begin_layout Plain Layout
-g1-e2
+markmoves={d2-d4},pgfstyle=knightmove,markmove={g1-e2},pgfstyle=circle,markfield
+s={d4,f4}
 \end_layout
 
 \end_inset
@@ -276,7 +257,7 @@ g1-e2
 
 \end_layout
 
-\begin_layout Standard
+\begin_layout Plain Layout
 \noindent
 \align block
 So far, so good.
@@ -285,13 +266,8 @@ So far, so good.
  The diagrammed position has been reached before in hundreds of GM games.
 \end_layout
 
-\begin_layout Standard
-\begin_inset Flex Mainline
-status open
-
 \begin_layout Plain Layout
-
-\begin_inset Argument 2
+\begin_inset Flex Mainline
 status open
 
 \begin_layout Plain Layout
@@ -305,12 +281,7 @@ status open
 
 \end_layout
 
-\end_inset
-
-
-\end_layout
-
-\begin_layout Standard
+\begin_layout Plain Layout
 \noindent
 \align block
 \begin_inset Flex Variation
@@ -328,20 +299,9 @@ invar
 
 \end_inset
 
-
-\begin_inset Argument 2
-status open
-
-\begin_layout Plain Layout
-
 5...
  Ng7
-\end_layout
-
-\end_inset
-
-
-\begin_inset Argument 3
+\begin_inset Argument post:1
 status open
 
 \begin_layout Plain Layout
@@ -361,7 +321,7 @@ equal{} was better
 
 \end_layout
 
-\begin_layout Standard
+\begin_layout Plain Layout
 \begin_inset Flex Mainline
 status open
 
@@ -377,12 +337,6 @@ outvar
 
 \end_inset
 
-
-\begin_inset Argument 2
-status open
-
-\begin_layout Plain Layout
-
 6.
  d4 cxd4 7.
  Nxd4 a6
@@ -393,21 +347,16 @@ status open
 
 \end_layout
 
-\end_inset
-
-
-\end_layout
-
-\begin_layout Standard
+\begin_layout Plain Layout
 With 7...
  a6, we are back in the well-trodden theory of this opening.
 \end_layout
 
-\begin_layout Standard
+\begin_layout Plain Layout
 \noindent
 \align center
 \begin_inset Flex ChessBoard
-status open
+status collapsed
 
 \begin_layout Plain Layout
 
@@ -418,13 +367,8 @@ status open
 
 \end_layout
 
-\begin_layout Standard
-\begin_inset Flex Mainline
-status open
-
 \begin_layout Plain Layout
-
-\begin_inset Argument 2
+\begin_inset Flex Mainline
 status open
 
 \begin_layout Plain Layout
@@ -442,24 +386,21 @@ status open
 
 \end_layout
 
-\end_inset
-
-
-\end_layout
-
-\begin_layout Standard
+\begin_layout ChessBoard
 \noindent
 \align center
 \begin_inset Flex ChessBoard
 status open
 
 \begin_layout Plain Layout
+\noindent
+\align center
 \begin_inset Argument 1
 status open
 
 \begin_layout Plain Layout
 
-a1-d1
+markmoves={a1-d1}
 \end_layout
 
 \end_inset
@@ -472,29 +413,19 @@ a1-d1
 
 \end_layout
 
-\begin_layout Standard
+\begin_layout Plain Layout
 White continues to develop pieces and also sets a trap for Black.
 \end_layout
 
-\begin_layout Standard
-\begin_inset Flex Mainline
-status open
-
 \begin_layout Plain Layout
-
-\begin_inset Argument 2
+\begin_inset Flex Mainline
 status open
 
 \begin_layout Plain Layout
 
 12...
- O-O?
-\end_layout
-
-\end_inset
-
-\begin_inset Argument 3
+ O-O? 
+\begin_inset Argument post:1
 status open
 
 \begin_layout Plain Layout
@@ -512,11 +443,11 @@ This move loses instantly.
 
 \end_layout
 
-\begin_layout Standard
+\begin_layout Plain Layout
 The following was better, even though white retains the upper hand.
 \end_layout
 
-\begin_layout Standard
+\begin_layout Plain Layout
 \begin_inset Flex Variation
 status open
 
@@ -532,22 +463,11 @@ invar
 
 \end_inset
 
-
-\begin_inset Argument 2
-status open
-
-\begin_layout Plain Layout
-
 12...
  e5 13.
  Be3 Qc7 14.
  Na4 O-O
-\end_layout
-
-\end_inset
-
-
-\begin_inset Argument 3
+\begin_inset Argument post:1
 status open
 
 \begin_layout Plain Layout
@@ -567,7 +487,7 @@ wbetter
 
 \end_layout
 
-\begin_layout Standard
+\begin_layout Plain Layout
 \begin_inset Flex Mainline
 status open
 
@@ -583,12 +503,6 @@ outvar
 
 \end_inset
 
-
-\begin_inset Argument 2
-status open
-
-\begin_layout Plain Layout
-
 13.
  e5!
 \end_layout
@@ -598,23 +512,13 @@ status open
 
 \end_layout
 
-\end_inset
-
-
-\end_layout
-
-\begin_layout Standard
+\begin_layout Plain Layout
 Black's knight and bishop form a bumbling pair here.
  The bishop is doomed.
 \end_layout
 
-\begin_layout Standard
-\begin_inset Flex Mainline
-status open
-
 \begin_layout Plain Layout
-
-\begin_inset Argument 2
+\begin_inset Flex Mainline
 status open
 
 \begin_layout Plain Layout
@@ -626,12 +530,7 @@ status open
  Bxd6 Rfd8 17.
  Bc7 Rd7 18.
  Bf4
-\end_layout
-
-\end_inset
-
-
-\begin_inset Argument 3
+\begin_inset Argument post:1
 status open
 
 \begin_layout Plain Layout
@@ -649,11 +548,11 @@ status open
 
 \end_layout
 
-\begin_layout Standard
+\begin_layout Plain Layout
 \noindent
 \align center
 \begin_inset Flex ChessBoard
-status open
+status collapsed
 
 \begin_layout Plain Layout
 
@@ -664,17 +563,6 @@ status open
 
 \end_layout
 
-\begin_layout Standard
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-
-\backslash
-end{multicols}
-\end_layout
-
 \end_inset
 
 
diff --git a/lib/layouts/chessboard.layout b/lib/layouts/chessboard.layout
deleted file mode 100644 (file)
index a92ab74..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-#% Do not delete the line below; configure depends on this
-#  \DeclareLaTeXClass[scrartcl]{Chessboard}
-#  \DeclareCategory{Articles}
-# chessboard article textclass definition file.
-
-Format          69
-
-Requires        chessfss
-
-ClassOptions
-       Other           "parskip"
-End
-
-Preamble
-       \usepackage{xskak}
-       \pagestyle{empty}
-       \AtBeginDocument{
-         \newchessgame
-         \setchessboard{pgfstyle=straightmove, arrow=to,linewidth=0.1em, smallboard}
-       }
-EndPreamble
-
-Style Standard
-       Align           Block
-       AlignPossible   Block, Left, Right, Center
-End
-
-Input           stdsections.inc
-Input           stdtitle.inc
-
-InsetLayout Flex:Mainline
-       LyXType         custom
-       LatexType       Command
-       LatexName       mainline
-       Decoration      Classic
-       LabelString     "Mainline:"
-       PassThru        1
-       ParbreakIsNewline 1
-       LabelFont
-               Color           blue
-               Series          bold
-       EndFont
-       Font
-               Color           blue
-       EndFont
-       Argument 1
-               LabelString     id
-               ToolTip         "'invar' or 'outvar'"
-               Decoration      Conglomerate
-       EndArgument
-       Argument 2
-               Mandatory       1
-               LabelString     "Moves"
-               PassThru        1
-               Decoration      Conglomerate
-       EndArgument
-       Argument 3
-               LabelString     "Comment"
-               Mandatory       1
-               LeftDelim       "{ "
-               Font
-                       Color           Green
-               EndFont
-               Decoration      Conglomerate
-       EndArgument
-End
-
-InsetLayout Flex:Variation
-       CopyStyle       Flex:Mainline
-       LatexName       variation
-       LabelString     Variation
-End
-
-InsetLayout Flex:ChessBoard
-       LyXType         custom
-       LatexType       Command
-       LatexName       chessboard
-       LabelString     "[chessboard]"
-       Decoration      Classic
-       KeepEmpty       1
-       LabelFont
-               Color           Red
-       EndFont
-       Argument 1
-               LabelString     "Arrows"
-               ToolTip         "Comma separated list of the form from-to (like d2-d4)"
-               LeftDelim       "[pgfstyle=straightmove,markmoves={"
-               RightDelim      "},"
-               DefaultArg      " "
-               PassThru        1
-               Decoration      Conglomerate
-       EndArgument
-       Argument 2
-               LabelString     "Knigt"
-               ToolTip         "List of knight moves (crooked arrows) g1-e2, g1-h3"
-               LeftDelim       "pgfstyle=knightmove,markmove={"
-               RightDelim      "},"
-               Decoration      Conglomerate
-       EndArgument
-       Argument 3
-               LabelString     "Mark"
-               ToolTip         "Comma separated list of fields to be marked with a circle (like d4,f4,c7)"
-               DefaultArg      " "
-               LeftDelim       "pgfstyle=circle,markfields={"
-               RightDelim      "}]"
-               Decoration      Conglomerate
-       EndArgument
-End
-
-InsetLayout Flex:ChessBoardStore
-       CopyStyle       Flex:ChessBoard
-       ResetArgs       1
-       LabelString     "StoreChessboard"
-       Argument 1
-               LabelString     "Store FEN"
-               ToolTip         "Store the 'FEN' under the given name"
-               LeftDelim       "[print=false,storefen={"
-               RightDelim      "}]"
-       EndArgument
-End
-
-InsetLayout Flex:ChessBoardRestore
-       CopyStyle       Flex:ChessBoard
-       ResetArgs       1
-       LabelString     "RestoreChessboard"
-       Argument 1
-               LabelString     "Restore FEN"
-               ToolTip         "Restore the 'FEN' to the version saved under the given name"
-               LeftDelim       "[print=false,restorefen={"
-               RightDelim      "}]"
-       EndArgument
-End
-
diff --git a/lib/layouts/chessboard.module b/lib/layouts/chessboard.module
new file mode 100644 (file)
index 0000000..1381030
--- /dev/null
@@ -0,0 +1,139 @@
+#\DeclareLyXModule[chessboard.sty,chessfss.sty,xskak.sty]{Chessboard}
+#DescriptionBegin
+#Support for the chessboard package to print chess games
+#See chessboard-article.lyx example file.
+#DescriptionEnd
+# Author: Kornel Benko <kornel@lyx.org>
+#         Jürgen Spitzmüller <spitz@lyx.org>
+
+Format          69
+
+#
+# XSkak basics
+#
+
+Style NewChessGame
+       LatexType               command
+       LatexName               newchessgame
+       Margin                  Dynamic
+       LabelType               Static
+       LabelSep                XX
+       LabelString             "[Start New Chess Game]"
+       LabelFont
+               Family         typewriter
+               Series         Medium
+               Size           Normal
+               Color          red
+       EndFont
+       KeepEmpty               1
+       Argument 1
+               LabelString     "Options"
+               MenuString      "Chessgame Options"
+               ToolTip         "See xskak manual for a comprehensive list of keys and values"
+               PassThru        1
+               Font
+                       Color   latex
+                       Family  typewriter
+               EndFont
+       EndArgument
+       Requires                xskak
+End
+
+
+InsetLayout Flex:Mainline
+       LyXType                 custom
+       LatexType               command
+       LatexName               mainline
+       Decoration              classic
+       LabelString             "Mainline:"
+       PassThru                1
+       ParbreakIsNewline       1
+       LabelFont
+               Color           blue
+       EndFont
+       Font
+               Color           blue
+       EndFont
+       Argument 1
+               LabelString     "Options"
+               MenuString      "Mainline Options"
+               ToolTip         "See xskak manual for possible options"
+               Font
+                       Color   latex
+                       Family  typewriter
+               EndFont
+       EndArgument
+       Argument post:1
+               LabelString     "Comment"
+               MenuString      "Comment"
+               LeftDelim       "<br/>"
+               RightDelim      "%"
+               Font
+                       Color   green
+               EndFont
+       EndArgument
+       Requires                xskak
+End
+
+InsetLayout Flex:Variation
+       CopyStyle               Flex:Mainline
+       LatexName               variation
+       LabelString             Variation
+End
+
+
+#
+# Chessboard additions
+#
+
+InsetLayout Flex:SetChessBoard
+       LyxType                 custom
+       Decoration              classic
+       LatexType               command
+       LatexName               setchessboard
+       LabelString             "Global Chessboard Settings"
+       Font
+               Color           latex
+               Family          typewriter
+       EndFont
+       LabelFont
+               Color           blue
+       EndFont
+       Requires                chessboard
+End
+
+
+InsetLayout Flex:SetBoardStoreStyle
+       CopyStyle               Flex:SetChessBoard
+       LabelString             "Set Chessboard Style"
+       Argument 1
+               Mandatory       true
+               LabelString     "Style Name"
+               MenuString      "Chessboard Style Name"
+               ToolTip         "Here you can store chessboard settings under a style name for later reuse. See chessboard manual for details."
+               AutoInsert      true
+               Decoration      conglomerate
+       EndArgument
+End
+
+
+InsetLayout Flex:ChessBoard
+       LyxType                 custom
+       Decoration              classic
+       LatexType               command
+       LatexType               command
+       LatexName               chessboard
+       LabelString             "Chessboard"
+       Argument 1
+               LabelString     "Options"
+               MenuString      "Chessboard Options"
+               ToolTip         "See chessboard manual for a comprehensive list of keys and values"
+               PassThru        1
+               Font
+                       Color   latex
+                       Family  typewriter
+               EndFont
+       EndArgument
+       Requires                chessboard
+End
+
index c78e73573001bfbf36e48b33a808733e0e17e2a4..eb31dbab66fcabf739b2f28c1b307ff5f6223415 100644 (file)
@@ -999,7 +999,9 @@ char const * simplefeatures[] = {
        "tablefootnote",
        "afterpage",
        "tabularx",
-       "xltabular"
+       "xltabular",
+       "chessboard",
+       "xskak"
 };
 
 char const * bibliofeatures[] = {