[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 01/01: * chess-display.el (chess-display-select-piece): Redraw le
From: |
Mario Lang |
Subject: |
[elpa] 01/01: * chess-display.el (chess-display-select-piece): Redraw legal targets if a move is either accepted or the same piece is selected again. This fixes ... (chess-display-highlight-legal): Now set to `t' by default. |
Date: |
Sat, 14 Jun 2014 23:12:49 +0000 |
mlang pushed a commit to branch externals/chess
in repository elpa.
commit aebafa98c17557b889b5a8b1bcb24854fcf9f5e9
Author: Mario Lang <address@hidden>
Date: Sun Jun 15 01:10:36 2014 +0200
* chess-display.el (chess-display-select-piece): Redraw legal targets
if a move is either accepted or the same piece is selected again.
This fixes ...
(chess-display-highlight-legal): Now set to `t' by default.
---
ChangeLog | 7 +++++++
chess-display.el | 19 ++++++++++++++-----
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1420d5f..9d7115d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-06-15 Mario Lang <address@hidden>
+
+ * chess-display.el (chess-display-select-piece): Redraw legal targets
+ if a move is either accepted or the same piece is selected again.
+ This fixes ...
+ (chess-display-highlight-legal): Now set to `t' by default.
+
2014-06-14 Mario Lang <address@hidden>
* chess-test.el (chess-test): Renamed to...
diff --git a/chess-display.el b/chess-display.el
index 804f9fc..1fc0295 100644
--- a/chess-display.el
+++ b/chess-display.el
@@ -43,7 +43,7 @@ occurs."
(make-variable-buffer-local 'chess-display-popup)
-(defcustom chess-display-highlight-legal nil
+(defcustom chess-display-highlight-legal t
"If non-nil, highlight legal target squares when a piece is selected."
:type 'boolean
:group 'chess-display)
@@ -432,8 +432,7 @@ that is supported by most displays, and is the default
mode."
(defun chess-display-highlight-legal (display pos)
"Highlight all legal move targets from POS."
(chess-with-current-buffer display
- (dolist (ply (chess-legal-plies (chess-display-position nil)
- :index pos))
+ (dolist (ply (chess-legal-plies (chess-display-position nil) :index pos))
(chess-display-highlight nil "pale green"
(chess-ply-target ply)))))
@@ -1184,8 +1183,7 @@ Clicking once on a piece selects it; then click on the
target location."
(if chess-display-last-selected
(let ((last-sel chess-display-last-selected))
;; if they select the same square again, just deselect
- ;; it by redrawing the display and removing all
- ;; highlights
+ ;; it by redrawing the square to remove highlights.
(if (= (point) (car last-sel))
(funcall chess-display-event-handler 'draw-square
(car last-sel)
@@ -1212,6 +1210,17 @@ Clicking once on a piece selects it; then click on the
target location."
(chess-display-move nil ply)
(error
(throw 'message (error-message-string err)))))))
+ ;; Redraw legal targets to clear highlight.
+ (when chess-display-highlight-legal
+ (dolist (index (mapcar #'chess-ply-target
+ (chess-legal-plies
+ position
+ :index (cdr last-sel))))
+ (unless (= index coord)
+ (funcall chess-display-event-handler 'draw-square
+ (chess-display-index-pos nil index)
+ (chess-pos-piece position index)
+ index))))
(setq chess-display-last-selected nil))
(let ((piece (chess-pos-piece position coord)))
(cond
- [elpa] branch externals/chess updated (08fc4c6 -> aebafa9), Mario Lang, 2014/06/14
- [elpa] 01/01: * chess-display.el (chess-display-select-piece): Redraw legal targets if a move is either accepted or the same piece is selected again. This fixes ... (chess-display-highlight-legal): Now set to `t' by default.,
Mario Lang <=