emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 01/01: * chess-input.el (chess-input-display-moves): Highlight va


From: Mario Lang
Subject: [elpa] 01/01: * chess-input.el (chess-input-display-moves): Highlight valid target squares if `chess-display-highlight-legal' is non-nil. (chess-input-shortcut): Redraw board to remove highlights if a ply was submitted and `chess-display-highlight-legal' is non-nil.
Date: Mon, 16 Jun 2014 08:12:29 +0000

mlang pushed a commit to branch externals/chess
in repository elpa.

commit cafc796e65de08c84583a53dfd9e4962e566f5cc
Author: Mario Lang <address@hidden>
Date:   Mon Jun 16 10:09:43 2014 +0200

    * chess-input.el (chess-input-display-moves): Highlight valid target
    squares if `chess-display-highlight-legal' is non-nil.
    (chess-input-shortcut): Redraw board to remove highlights if a ply
    was submitted and `chess-display-highlight-legal' is non-nil.
---
 ChangeLog      |    5 +++++
 chess-input.el |   22 ++++++++++++++--------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cbb7a13..ec4d840 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2014-06-16  Mario Lang  <address@hidden>
 
+       * chess-input.el (chess-input-display-moves): Highlight valid target
+       squares if `chess-display-highlight-legal' is non-nil.
+       (chess-input-shortcut): Redraw board to remove highlights if a ply
+       was submitted and `chess-display-highlight-legal' is non-nil.
+
        * chess-display.el (chess-display-move): Fix repainting when playing
        against the internal engine (AI) which runs off the `post-move' game
        event by adding a `redisplay' call just before the `post-move' emision.
diff --git a/chess-input.el b/chess-input.el
index ce7b348..7d5c946 100644
--- a/chess-input.el
+++ b/chess-input.el
@@ -69,14 +69,18 @@
           (t (setq i (1+ i) x (1+ x)))))))
     ply))
 
-(defsubst chess-input-display-moves (&optional move-list)
-  (if (> (length chess-input-move-string) 0)
-      (message "[%s] %s" chess-input-move-string
-              (mapconcat #'chess-ply-to-algebraic
-                         (or move-list
-                             (delq nil (mapcar 'chess-input-test-move
-                                               (cdr chess-input-moves))))
-                         " "))))
+(defun chess-input-display-moves (&optional move-list)
+  (unless move-list
+    (setq chess-input-test-move
+         (delq nil (mapcar #'chess-input-test-move (cdr chess-input-moves)))))
+  (when chess-display-highlight-legal
+    (chess-display-redraw nil))
+  (when (> (length chess-input-move-string) 0)
+    (when chess-display-highlight-legal
+      (apply #'chess-display-highlight
+            nil (cl-delete-duplicates (mapcar #'chess-ply-target move-list))))
+    (message "[%s] %s" chess-input-move-string
+            (mapconcat #'chess-ply-to-algebraic move-list " "))))
 
 (defun chess-input-shortcut-delete ()
   (interactive)
@@ -144,6 +148,8 @@
                        (downcase (chess-ply-to-algebraic (cadr moves))))
               (setq moves (cdr moves))))
       (funcall chess-input-move-function nil (car moves))
+      (when chess-display-highlight-legal
+       (chess-display-redraw nil))
       (setq chess-input-move-string nil
            chess-input-moves nil
            chess-input-moves-pos nil))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]