;; Code shared by all chess displays
;;
+(require 'chess-message)
(require 'chess-module)
(require 'chess-var)
(require 'chess-input)
+(require 'chess-random)
(defgroup chess-display nil
"Common code used by chess displays."
:group 'chess)
(defcustom chess-display-popup t
- "If non-nil, popup displays whenever a significant event occurs."
+ "If non-nil (the default), popup displays whenever a significant event
+occurs."
:type 'boolean
:group 'chess-display)
(make-variable-buffer-local 'chess-display-index)
(make-variable-buffer-local 'chess-display-move-text)
(make-variable-buffer-local 'chess-display-side-to-move)
+(put 'chess-display-side-to-move 'risky-local-variable t)
(make-variable-buffer-local 'chess-display-perspective)
(make-variable-buffer-local 'chess-display-event-handler)
(make-variable-buffer-local 'chess-display-edit-mode)
(make-variable-buffer-local 'chess-display-index-positions)
(defvar chess-display-handling-event nil
- "If non-nil, chess-display is aleady handling the event. This variable
+ "If non-nil, chess-display is already handling the event. This variable
is used to avoid reentrancy.")
(defvar chess-display-style)
(defalias 'chess-display-destroy 'chess-module-destroy)
(defun chess-display-clone (display style perspective)
- (let ((new-display (chess-display-create chess-module-game
+ (let ((new-display (chess-display-create (chess-display-game display)
style perspective)))
;; the display will have already been updated by the `set-' calls,
;; it's just not visible yet
(str (format " %s " (if color
(chess-string 'mode-white)
(chess-string 'mode-black)))))
- (add-text-properties
- 0 (length str) (list 'face (if color
- 'chess-display-white-face
- 'chess-display-black-face)) str)
+ (add-text-properties 0 (length str)
+ (list 'face (if color
+ 'chess-display-white-face
+ 'chess-display-black-face))
+ str)
str)))))
(force-mode-line-update)))
(downcase new-piece)) to)
(funcall chess-display-event-handler 'draw-square
(chess-display-index-pos nil to)
- (chess-pos-piece position from) to))))
+ (chess-pos-piece position from) to)))
+ (when (chess-ply-keyword ply :en-passant)
+ (funcall chess-display-event-handler 'draw-square
+ (chess-display-index-pos nil (chess-pos-en-passant position))
+ ? (chess-pos-en-passant position))))
(setq ch (cddr ch)))))))
(chess-message-catalog 'english
(chess-error 'game-is-over)))
(if (= chess-display-index (chess-game-index chess-module-game))
(let ((chess-display-handling-event t))
- (chess-display-paint-move nil ply)
(chess-game-move chess-module-game ply)
+ (chess-display-paint-move nil ply)
(chess-display-set-index* nil (chess-game-index chess-module-game)))
;; jww (2002-03-28): This should beget a variation within the
;; game, or alter the game, just as SCID allows
(chess-display-highlight nil "pale green"
(chess-ply-target ply)))))
+(defun chess-display-highlight-passed-pawns (&optional display)
+ (interactive)
+ (mapc
+ (lambda (index) (chess-display-highlight display index :selected))
+ (append
+ (chess-pos-passed-pawns (chess-display-position display) t)
+ (chess-pos-passed-pawns (chess-display-position display) nil))))
+
(defun chess-display-popup (display)
"Popup the given DISPLAY, so that it's visible to the user."
(chess-with-current-buffer display
(fit-window-to-buffer (display-buffer (current-buffer)))
(display-buffer (current-buffer)))))
-(defun chess-display-popup-in-frame (height width &optional
- display no-minibuffer)
+(defun chess-display-popup-in-frame (height width font
+ &optional display no-minibuffer)
"Popup the given DISPLAY, so that it's visible to the user."
(let ((window (get-buffer-window (current-buffer) t)))
(if window
(cons 'width width))))
(if display
(push (cons 'display display) params))
+ (if font
+ (push (cons 'font font) params))
(if no-minibuffer
(push (cons 'minibuffer nil) params))
(select-frame (make-frame params))
(funcall chess-display-event-handler 'draw-square
(point) (or piece last-command-char) index))))
+(unless (fboundp 'event-window)
+ (defalias 'event-point 'ignore))
+
(defun chess-display-mouse-set-piece (event)
"Select the piece the user clicked on."
(interactive "e")