;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\302\303\304\305\306\301%\207" [require chess-display custom-declare-group chess-images nil "Module for drawing a chess-display using graphical images." :group] 6) (defvar chess-images-cache nil) (defvar chess-images-size nil) (defvar chess-images-sizes nil) (byte-code "\300\301!\210\300\302!\210\300\303!\207" [make-variable-buffer-local chess-images-cache chess-images-size chess-images-sizes] 2) #@18 (fn SYM VALUE) (defalias 'chess-images-clear-image-cache #[514 "L\210\301\211\207" [chess-images-cache nil] 4 (#$ . 512)]) (byte-code "\300\301\302\303\304DD\305\306\307%\210\300\310\302\303\311DD\312\306\313\314\315&\210\300\316\302\303\317DD\320\306\321%\210\300\322\302\303\323DD\324\306\325\314\315&\210\300\326\302\303\327DD\330\306\331\314\315&\210\300\332\302\303\333DD\334\306\331\314\315&\210\300\335\302\303\336DD\337\306\331\314\315&\210\300\340\302\303\341DD\342\306\331\314\315&\210\300\343\302\303\344DD\345\306\331\314\315&\210\300\346\302\303\347DD\350\306\331\314\315&\210\300\351\302\303\352DD\353\306\325\314\315&\210\300\354\302\303\355DD\356\306\357\314\315&\210\300\360\302\303\361DD\362\306\303%\207" [custom-declare-variable chess-images-separate-frame funcall function #[0 "\300 \207" [display-multi-frame-p] 1] "If non-nil, display the chessboard in its own frame." :type boolean chess-images-directory #[0 "\302\303!\203\303\207\304\305\306\206 !\"\207" [load-file-name buffer-file-name file-directory-p "/usr/share/games/xboard/pixmaps" expand-file-name "pieces/xboard" file-name-directory] 4] "Directory containing the chess piece bitmap images.\nYou are free to use your own chess pieces, of any size. By default, I\nassume you have xboard installed, or can go get the pixmaps that come\nwith xboard. I am not an artist, and have not taken the time to draw\nmy own set of pieces.\n\nIf you want to draw your own images, each piece must be named\nCOLOR-PIECE.EXT, where COLOR is either black or white, and PIECE is\none of rook, knight, bishop, queen, king or pawn.\n\nAt the moment only XPM has been tested, and I'm afraid it's probably\nthe only one that will work. ImageMagick can be used to convert other\ngraphics formats into XPM for you.\n\nEach piece must define the background color to use the symbolic color\nname \"background\", so that the chess program can use the same pieces\nfor all squares. If you want really custom pieces, you can use the\nsymbolic colors dark_square, light_square and dark_piece and\nlight_piece." directory :set chess-images-clear-image-cache chess-images-default-size #[0 "\300\207" [nil] 1] "The default pixel width to use for chess pieces.\nIf this width is not available, then next smallest will be chosen.\nIf there is none smaller, then the best size available will be chosen.\nIf `chess-images-default-size' is nil (the default), then the best\nwidth for the current display is calculated used." (choice integer (const :tag "Best fit" nil)) chess-images-background-image #[0 "\300\207" [#1="blank"] 1 #1#] "The name of the file used for background squares.\nThis file is optional. If there is no file available by this name, a\nsolid color square will be created and used. This option exists so\nthat specialized squares may be used such as marble tiles, etc." file chess-images-border-color #[0 "\300\301 \236A\207" [background-color frame-parameters] 2] "Color to use for the border around pieces." color chess-images-dark-color #[0 "\300 \203\301\207\302\207" [display-color-p "#77a26d" "gray60"] 1] "Color to use for \"dark\" background squares." chess-images-light-color #[0 "\300 \203\301\207\302\207" [display-color-p "#c8c365" "gray80"] 1] "Color to use for \"light\" background squares." chess-images-black-color #[0 "\300 \203\301\207\302\207" [display-color-p "#202020" "gray0"] 1] "Color to use for \"black\" pieces." chess-images-white-color #[0 "\300 \203\301\207\302\207" [display-color-p "#ffffcc" "gray100"] 1] "Color to use for \"white\" pieces." chess-images-highlight-color #[0 "\300 \203\301\207\302\207" [display-color-p "#add8e6" "gray90"] 1] "Color to use for highlighting pieces that have been selected." chess-images-extension #[0 "\300\207" [#2="xpm"] 1 #2#] "The file extension used for chess display bitmaps." chess-images-border-width #[0 "\300\207" [2] 1] "This defines the width of the border that surrounds each piece." (choice integer (const :tag "No border" nil)) chess-images-popup-function #[0 "\300\207" [chess-images-popup] 1] "The function used to popup a chess-images display.\nThe current-buffer is set to the display buffer when this function is\ncalled."] 8) #@53 The names and index values of the different pieces. (defconst chess-images-piece-names '((114 "rook" 0) (110 "knight" 1) (98 "bishop" 2) (113 "queen" 3) (107 "king" 4) (112 "pawn" 5)) (#$ . 4731)) (chess-message-catalog 'english '((no-images-fallback . "Could not find any suitable or properly sized chess images"))) #@25 (fn EVENT &rest ARGS) (defalias 'chess-images-handler #[385 "\303\267\2029\304 \205:\305 \210\206\306\307\306\310\311\312#!\266\207 \207\311\313\"\207\311\314\"\207\311\315\"\207\316\211\207\306\211\207\306\207" [chess-images-size chess-images-popup-function cursor-type #s(hash-table size 7 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (initialize 6 popup 31 draw 34 draw-square 39 highlight 44 start-edit 49 end-edit 53)) display-graphic-p chess-images-initialize nil no-images-fallback message apply chess-string chess-images-draw chess-images-draw-square chess-images-highlight t] 10 (#$ . 5054)]) (defalias 'chess-images-determine-size #[0 ";\205\305\211\306\307! \310>\203\311\202\312Z\313!\312Z\"\211\207" [chess-images-separate-frame cursor-type chess-images-cache window-system chess-images-size nil chess-images-best-size display-pixel-height (mac windows w32) 80 20 display-pixel-width] 6]) (defalias 'chess-images-initialize #[0 "\300 \301\302\303#\210\301\304\305#\210\301\306\307#\266\310 \207" [current-local-map define-key [94] chess-images-increase-size [86] chess-images-decrease-size [80] chess-images-set-directory chess-images-determine-size] 5]) (chess-message-catalog 'english '((no-images . "Cannot find any piece images; check `chess-images-directory'"))) (defalias 'chess-images-popup #[0 "\204\303\304\305\306\307#!\266 \2038\310\n\206\311\312_\312_\\!\313\314 \245!\313\315 \245!\316\317\\\320\321 \236A#\207\322 \207" [chess-images-size chess-images-separate-frame chess-images-border-width no-images nil error apply chess-string float 0 8 ceiling frame-char-height frame-char-width chess-display-popup-in-frame 2 font frame-parameters chess-display-popup-in-window] 8]) #@195 Return the image used for PIECE at RANK and FILE. Rank and file are important because the colors of the squares on the chess board are light or dark depending on location. (fn PIECE RANK FILE) (defalias 'chess-images-piece-image #[771 "\211\\\302\246\303U\203\304ZH\207\305V\203\306\202\307H\306U\203(\307\202)\306H\302\227 \2368H\207" [chess-images-cache chess-images-piece-names 2 32 3 97 0 1] 8 (#$ . 6828)]) #@80 Draw a piece image at point on an already drawn display. (fn POS PIECE INDEX) (defalias 'chess-images-draw-square #[771 "\300\211T\301\302\211\250\203\211\303Y\203\211\304X\204#\305\306\307\310E\"\210\211\311\245\262\211\250\203;\211\303Y\203;\211\304X\204C\305\306\312\310E\"\210\313\311\"\262#$\207" [put-text-property display chess-images-piece-image 0 63 signal wrong-type-argument (integer 0 63) index 8 (integer 0 63) mod] 16 (#$ . 7263)]) (byte-code "\300\301\302\303#\304\301\305\306#\207" [function-put chess-images-draw-square speed -1 put byte-optimizer byte-compile-inline-expand] 5) #@69 Draw the current chess display position. (fn POSITION PERSPECTIVE) (defalias 'chess-images-draw #[514 "\302\211?\211\203\f\303\202 \304\203\303\202\304`\305\211 \204#\306 \210\307 \210edU\211\262\204/eb\210\2039\304Y\202<\310W\203\307\203I\304Y\202L\310W\203\254\250\203d\304Y\203d\303X\204l\311\312\313\314E\"\210\211\250\203}\211\304Y\203}\211\303X\204\205\311\312\315\316E\"\210\310_\\\266\202\317!\205\227\211G\320U\262\204\244\311\312\321\322E\"\210\211\250\203\265\211\304Y\203\265\211\323X\204\275\311\312\324\325E\"\210H\266\202\326#\204\343\327``T\330$\210`TdU\204\232\331u\266\202\234`\262\332!\210\203\364\304\202\365\303U\203\203\304\202\303U\204\333c\210\202\332 \334H!\210\335`\336\n\n\250\203.\304Y\203.\303X\2046\311\312\313\314E\"\210\211\250\203G\211\304Y\203G\211\303X\204O\311\312\315\316E\"\210\310_\\\266\202\337\340\341\250\203n\304Y\203n\303X\204v\311\312\313\314E\"\210\211\250\203\207\211\304Y\203\207\211\303X\204\217\311\312\315\316E\"\210\310_\\\266\202\257#\210\266\203\245S\202\247T\262\202?\203\264\303\202\265\304\262\203\300S\202\302T\262\202/\342\305!\210b)\207" [inhibit-redisplay chess-images-cache t 7 0 nil chess-images-init-cache erase-buffer 8 signal wrong-type-argument (integer 0 7) rank (integer 0 7) file vectorp 75 chess-pos position 63 (integer 0 63) index chess-images-piece-image put-text-property display 2 insert-image 10 5 add-text-properties intangible rear-nonsticky (intangible) chess-coord set-buffer-modified-p] 25 (#$ . 7886)]) #@236 Highlight the piece on the board at INDEX, using the given MODE. Common modes are: `selected' show that the piece has been selected for movement. `unselected' show that the piece has been unselected. (fn INDEX &optional MODE) (defalias 'chess-images-highlight #[513 "\301\302\"\303\304\305\"!\306!\307\310=\203\202B\311\310=\203%\202&B\312\310=\2033\2025BE\240\210\313\211T\305$\207" [chess-images-highlight-color chess-display-index-pos nil copy-alist get-text-property display last "light_square" :selected "dark_square" "background" put-text-property] 10 (#$ . 9518)]) (chess-message-catalog 'english '((redrawing-frame . "Redrawing chess display with different size...") (redrawing-frame-done . "Redrawing chess display with different size...done"))) #@13 (fn SIZE) (defalias 'chess-images-change-size #[257 "p\302!\211\205 \303!\304\211\203\305\306\"\210\307\304\310\311\312#!\266\313\306\"\210\314!\210\315\304\310\311\312#!\207" [chess-images-size chess-images-cache get-buffer-window window-frame nil delete-frame t redrawing-frame message apply chess-string chess-display-update chess-display-popup redrawing-frame-done] 11 (#$ . 10312)]) #@64 Resize the chessboard based on the frame or window's new size. (defalias 'chess-images-resize #[0 "\301 \210\203 \302!\207\303\304\305\306\307#!\207" [chess-images-size chess-images-determine-size chess-images-change-size no-images-fallback nil message apply chess-string] 7 (#$ . 10724)]) #@13 (fn TEST) (defalias 'chess-images-alter-size #[257 "\302=\203\f\303!\262\211\205*@ \"\203#\304@!\210\305\262\202\f\211A\262\202\f\207" [chess-images-sizes chess-images-size < reverse chess-images-change-size nil] 5 (#$ . 11025)]) #@47 Increase the size of the pieces on the board. (defalias 'chess-images-increase-size #[0 "\300\301!\207" [chess-images-alter-size >] 2 (#$ . 11277) nil]) #@47 Increase the size of the pieces on the board. (defalias 'chess-images-decrease-size #[0 "\300\301!\207" [chess-images-alter-size <] 2 (#$ . 11436) nil]) #@131 Return the set of available sizes for the current piece set. They are returned in ascending order, or nil for no sizes available. (defalias 'chess-images-sizes #[0 "\303\304\305\" \"\306!\203,\307\310\311\"r\211q\210\312\313\"\216\314!\210\315\316!\210\317\320\321!!C\211*\207\322\323 \322\304\324\"#\211\203S\211@\325\326\"\203L\317\320\321\"!B\262A\266\202\2025\210\327\330\"\211\207" [chess-images-extension chess-images-directory chess-images-sizes expand-file-name format "black-rook.%s" file-readable-p generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] insert-file-contents-literally re-search-forward "\"\\([0-9]+\\)" string-to-number match-string 1 nil directory-files "rdd[0-9]+\\.%s" string-match "rdd\\([0-9]+\\)\\." sort <] 8 (#$ . 11596)]) #@92 Return the piece size that works best for a window of HEIGHT. (fn &optional HEIGHT WIDTH) (defalias 'chess-images-best-size #[512 "\206!\206\n\302 \303\245 \206\304Z\206\305 \303\245 \206\304Z^\306 \211@\203A@V\2036\307\262\202%@\262A\262\202%\211\206P\205P\307\310\")\207" [chess-images-default-size chess-images-border-width frame-pixel-height 8 0 frame-pixel-width chess-images-sizes nil chess-images-best-size] 8 (#$ . 12434)]) #@63 Increase the size of the pieces on the board. (fn DIRECTORY) (defalias 'chess-images-set-directory #[257 "\211\301 \304 \305\306\307!\207" [chess-images-directory chess-images-sizes chess-images-size chess-images-cache chess-images-best-size nil chess-images-alter-size =] 3 (#$ . 12902) "DUse chess pieces in: "]) #@31 (fn HEIGHT &optional WIDTH) (defalias 'chess-images-create-xpm #[513 "\300\301\302\"r\211q\210\303\304\"\216\305c\210\306c\210\307c\210\310\311\206#c\210\312c\210\313c\210\314c\210\315\211W\203L\316\317\320\206<\321\"\317\322\323\261\266\211T\262\202,\266\324\325!\210\326c\210\327 *\207" [generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] "/* XPM */\n" "static char *chessdotel[] = {\n" "/* columns rows colors chars-per-pixel */\n" format "\"%d %d 2 1\",\n" "\" c red s void\",\n" "\". c red s background\",\n" "/* pixels */\n" 0 nil 34 make-string 46 44 10 delete-char -2 "\n};\n" buffer-string] 11 (#$ . 13228)]) #@122 Hack an XPM to append ADD-HEIGHT rows of COLOR. This is necessary for bizzare Emacs reasons. (fn FILE ADD-HEIGHT COLOR) (defalias 'chess-images-hack-xpm #[771 "\300\301\302\"r\211q\210\303\304\"\216\305\306\"\203c\210\202\307!\210eb\210\310\311\312\302#\203\315\313\314\315!!\313\314\316!!\313\314\317!!\313\314\320!!\321\322\"\323\324\n\\!\302\211\312\316%\210\325 \303\326\"\216\212\310\327\330\n\"\312\302#\205k\314\315!\331O\211\262*\262\204\210\323\324T!\302\211\312\317%\210\312\210\332\333 \334\261\210\335 \210Ty\210\336\337!\203\233\312y\210\202\217\331\211W\203\313\312\340c\210\331\211W\203\276\312c\266\211T\262\202\253\266\341c\266\211T\262\202\236\266\342 *\207" [generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] string-match "\\`/\\* XPM \\*/" insert-file-contents-literally re-search-forward "\"\\([0-9]+\\)\\s-+\\([0-9]+\\)\\s-+\\([0-9]+\\)\\s-+\\([0-9]+\\)\"" nil string-to-number match-string 1 2 3 4 make-string 126 replace-match int-to-string match-data #[0 "\301\300\302\"\207" [V0 set-match-data evaporate] 3] format "^\"\\(..\\)\\s-*c\\s-+%s" 0 "\n\"" " c " "\"," beginning-of-line looking-at "/\\*" "\"" "\",\n" buffer-string] 16 (#$ . 13936)]) #@102 Create an Emacs image object, for insertion on the board. (fn FILE BACKGROUND &optional FOREGROUND) (defalias 'chess-images-create-image #[770 "\306B\307 BD8\310B\310 BD8D\203$\211\311\nB\312 BD8C\244\210\f\2034\313\314\f #\315\316\317%\207\313\315\320\321\"\317%\207" [chess-images-dark-color chess-images-light-color chess-images-black-color chess-images-white-color chess-images-border-width chess-images-border-color "dark_square" "light_square" "background" "dark_piece" "light_piece" create-image chess-images-hack-xpm nil t :color-symbols string-match "\\`/\\* XPM \\*/"] 10 (#$ . 15222)]) (byte-code "\300\301\302\303#\304\301\305\306#\210\307\310\311\"\207" [function-put chess-images-create-image speed -1 put byte-optimizer byte-compile-inline-expand chess-message-catalog english ((piece-images-loading . "Loading chess piece images...") (piece-images-loaded . "Loading chess piece images...done"))] 5) #@37 Initialize the display image cache. (defalias 'chess-images-init-cache #[0 "\306\307\310\311\312#!\266\313\211\314\315\307\"\314\315\307\"\"\313\314\315\307\"\314\315\307\"\"\307\211\211\211&\316\307\211\211\317\320\211W\203Q\211\317\320\211W\203H\211 \211\203?\211@\321\322\3238A@\n$ \"\324!\203\267HH\3178\n\325\fB\326 BD8\327\fB\327 BD8D\203\215\211\330/B\3310BD8C\244\2101\203\244\332\33312#\307\334\335%\266\204\202\261\332\307\336\337\"\335%\266\204I\266\2028\321\322\340@\n\320U\203\307\341\202\310\342\320U\203\323\341\202\324\3423\n& \"\262HH\3178\n\325\fB\326 BD8\327\fB\327 BD8D\203\211\330/B\3310BD8C\244\2101\203(\332\33312#\307\334\335%\266\204\2025\332\307\336\337\"\335%\266\204I\266A\266\202\202>\266\211T\262\2026\266\211T\262\202-\266\324\321\322\3434\n# \"\211\262!\203 \317\320\307\325\fB\326 BD8\327\fB\327 BD8D\203\217\211\330/B\3310BD8C\244\2101\203\246\332\33312#\307\334\335%\266\204\202\263\332\307\336\337\"\335%\266\204I\210\344\345\307\325\fB\326 BD8\327\fB\327 BD8D\203\340\211\330/B\3310BD8C\244\2101\203\367\332\33312#\307\334\335%\266\204\202\332\307\336\337\"\335%\266\204I\210\202{\324\322\3463\n#\262\321 \"\211\262!\203\315\317\320\307\325\fB\326 BD8\327\fB\327 BD8D\203H\211\330/B\3310BD8C\244\2101\203_\332\33312#\307\334\335%\266\204\202l\332\307\336\337\"\335%\266\204I\210\320\342I\210\321 \"\262\344\345\307\325\fB\326 BD8\327\fB\327 BD8D\203\244\211\330/B\3310BD8C\244\2101\203\273\332\33312#\307\334\335%\266\204\202\310\332\307\336\337\"\335%\266\204I\210\202{\n\347\230\205\327\3503!\262\317\320\307\325\fB\326 BD8\327\fB\327 BD8D\203\211\330/B\3310BD8C\244\2101\203\332\33312#\307\334\335%\266\204\202(\332\307\336\337\"\335%\266\204I\210\344\345\307\325\fB\326 BD8\327\fB\327 BD8D\203U\211\330/B\3310BD8C\244\2101\203l\332\33312#\307\334\335%\266\204\202y\332\307\336\337\"\335%\266\204I\2101\203\257\351\332\3501\3523_\3531_\\\"\307\334\335\3272BC%I\210\354\332\35031\"\307\334\335\3272BC%I\210\266\355 \210\356\307\310\311\312#!\207" [chess-images-cache chess-images-piece-names chess-images-extension chess-images-directory chess-images-dark-color chess-images-light-color piece-images-loading nil message apply chess-string vector make-vector 6 ("black" "white") 2 0 expand-file-name format "%s-%s.%s" file-readable-p "dark_square" "light_square" "background" "dark_piece" "light_piece" create-image chess-images-hack-xpm t :color-symbols string-match "\\`/\\* XPM \\*/" "%c%c%c%d.%s" 100 108 "%s.%s" 3 1 "dsq%d.%s" "xpm" chess-images-create-xpm 4 8 9 5 garbage-collect piece-images-loaded chess-images-black-color chess-images-white-color chess-images-border-width chess-images-border-color chess-images-size chess-images-background-image] 25 (#$ . 16158)]) (provide 'chess-images)