diff options
| author | dickmao <dick.r.chiang@gmail.com> | 2018-08-27 17:00:35 -0400 |
|---|---|---|
| committer | dickmao <dick.r.chiang@gmail.com> | 2018-09-06 09:24:10 -0400 |
| commit | 3222b53d942daa404852e5148ba9d3ebb8fe96d0 (patch) | |
| tree | 37e2af6242423e57adbbc1238433f58c92ac9bd0 /chess-images.el | |
| parent | 67339d896aa65d75272b80134a8128276c8c6a0f (diff) | |
Pre-moves
To activate, look for Chess Display Allow Pre Moves in:
M-x customize-group
chess-display
Tested via:
make test
make test24 (requires evim)
Diffstat (limited to 'chess-images.el')
| -rw-r--r-- | chess-images.el | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/chess-images.el b/chess-images.el index 1164c45..aacd153 100644 --- a/chess-images.el +++ b/chess-images.el @@ -305,22 +305,31 @@ chess board are light or dark depending on location." (goto-char pos))) (defun chess-images-highlight (index &optional mode) - "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." + "Highlight the piece on the board at INDEX, using the given MODE, which +is often an arbitrary color or + :selected show that the piece has been selected for movement. + :unselected show that the piece has been unselected." (let* ((pos (chess-display-index-pos nil index)) - (highlight (copy-alist (get-text-property pos 'display)))) - (setcar (last highlight) - (list (cons "light_square" (if (eq mode :selected) - chess-images-highlight-color - mode)) - (cons "dark_square" (if (eq mode :selected) - chess-images-highlight-color - mode)) - (cons "background" (if (eq mode :selected) - chess-images-highlight-color - mode)))) + (highlight (copy-alist (get-text-property pos 'display))) + (light-color (if (eq mode :selected) + chess-images-highlight-color + (if (eq mode :unselected) chess-images-light-color mode))) + (dark-color (if (eq mode :selected) + chess-images-highlight-color + (if (eq mode :unselected) chess-images-dark-color mode))) + (square-color (% (+ (chess-index-file index) (chess-index-rank index)) 2)) + (background (if (eq mode :selected) + chess-images-highlight-color + (if (eq mode :unselected) + (if (= square-color 0) chess-images-light-color chess-images-dark-color) mode))) + (color-syms (car (last highlight)))) + (setcar (last highlight) + (mapcar (lambda (cp) + (cond ((string= (car cp) "light_square") (cons (car cp) light-color)) + ((string= (car cp) "dark_square") (cons (car cp) dark-color)) + ((string= (car cp) "background") (cons (car cp) background)) + (t cp))) + color-syms)) (put-text-property pos (1+ pos) 'display highlight))) (chess-message-catalog 'english |
