summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-08-29 06:50:26 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-08-29 06:50:26 -0400
commitfdd86011d95b6b1b41dc903fe7acd7027accff63 (patch)
tree451445710e7b81ad6d846d8b2265d09b1a36af25
parenta13cef52f2638feeb1bd7da368f7d3b1c290a4f5 (diff)
Added optional code for highlighting the last move.
-rw-r--r--chess-display.el18
1 files changed, 17 insertions, 1 deletions
diff --git a/chess-display.el b/chess-display.el
index 553de49..27fadbb 100644
--- a/chess-display.el
+++ b/chess-display.el
@@ -26,6 +26,11 @@ occurs."
:type 'boolean
:group 'chess-display)
+(defcustom chess-display-highlight-last-move nil
+ "If non-nil, highlight the last move made on the game."
+ :type 'boolean
+ :group 'chess-display)
+
(chess-message-catalog 'english
'((mode-white . "White")
(mode-black . "Black")
@@ -321,6 +326,8 @@ also view the same game."
(defun chess-display-paint-move (display ply)
(chess-with-current-buffer display
+ (if chess-display-highlight-last-move
+ (chess-display-redraw))
(let ((position (chess-ply-pos ply))
(ch (chess-ply-changes ply)))
(while ch
@@ -344,7 +351,9 @@ also view the same game."
(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)))))))
+ (setq ch (cddr ch)))))
+ (if chess-display-highlight-last-move
+ (chess-display-highlight-move display ply))))
(chess-message-catalog 'english
'((not-your-move . "It is not your turn to move")
@@ -394,6 +403,13 @@ that is supported by most displays, and is the default mode."
(chess-display-highlight nil "pale green"
(chess-ply-target ply)))))
+(defun chess-display-highlight-move (display ply)
+ "Highlight the last move made in the current game."
+ (chess-with-current-buffer display
+ (chess-display-highlight nil "medium sea green"
+ (chess-ply-source ply)
+ (chess-ply-target ply))))
+
(defun chess-display-highlight-passed-pawns (&optional display)
(interactive)
(mapc