From 6b8ac5acf330b03e88d0b342c79abbb7d338e0c2 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 9 Apr 2002 04:26:02 +0000 Subject: Bug fixes and the beginnings of ICS client support --- chess-display.el | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'chess-display.el') diff --git a/chess-display.el b/chess-display.el index 0d53548..85eac1b 100644 --- a/chess-display.el +++ b/chess-display.el @@ -285,15 +285,18 @@ See `chess-display-type' for the different kinds of displays." (with-current-buffer display (cond ((eq event 'shutdown) - (chess-display-destroy nil)) + (ignore-errors + (chess-display-destroy nil))) ((eq event 'pass) (chess-display-set-perspective nil (not (chess-display-perspective nil)))) - ((memq event '(move game-over)) - (chess-display-set-index - nil (chess-game-index (chess-display-game nil))))) + ((memq event '(move game-over resign)) + (chess-display-set-index nil (chess-game-index + (chess-display-game nil))))) + (if (eq event 'resign) + (message-box "%s resigns" (if (car args) "White" "Black"))) (unless (eq event 'shutdown) (chess-display-update nil)))) @@ -321,6 +324,7 @@ See `chess-display-type' for the different kinds of displays." (define-key map [?@] 'chess-display-remote) (define-key map [? ] 'chess-display-pass) (define-key map [?S] 'chess-display-shuffle) + (define-key map [?R] 'chess-display-resign) (define-key map [?<] 'chess-display-move-first) (define-key map [?,] 'chess-display-move-backward) @@ -424,16 +428,14 @@ Basically, it means we are playing, not editing or reviewing." (interactive) (let* ((x-select-enable-clipboard t) (fen (chess-pos-to-fen (chess-display-position nil)))) - (kill-new fen) - (message "Copied board: %s" fen))) + (kill-new fen))) (defun chess-display-paste-board () "Send the current board configuration to the user." (interactive) (let* ((x-select-enable-clipboard t) (fen (current-kill 0))) - (chess-display-set-from-fen fen) - (message "Pasted board: %s" fen))) + (chess-display-set-from-fen fen))) (defun chess-display-set-piece () "Set the piece under point to command character, or space for clear." @@ -475,17 +477,26 @@ Basically, it means we are playing, not editing or reviewing." (defun chess-display-pass () "Pass the move to your opponent. Only valid on the first move." (interactive) - (when (and (chess-display-active-p) - (= 0 (chess-display-index nil))) - (chess-game-run-hooks chess-display-game 'pass))) + (if (and (chess-display-active-p) + (= 0 (chess-display-index nil))) + (chess-game-run-hooks chess-display-game 'pass) + (ding))) (defun chess-display-shuffle () "Generate a shuffled opening position." (interactive) - (when (and (chess-display-active-p) - (= 0 (chess-display-index nil))) - (chess-game-set-start-position chess-display-game - (chess-fischer-random-position)))) + (if (and (chess-display-active-p) + (= 0 (chess-display-index nil))) + (chess-game-set-start-position chess-display-game + (chess-fischer-random-position)) + (ding))) + +(defun chess-display-resign () + "Generate a shuffled opening position." + (interactive) + (if (chess-display-active-p) + (chess-game-resign chess-display-game) + (ding))) (defun chess-display-set-current (dir) "Change the currently displayed board. -- cgit v1.2.3