Function: gomoku-init-display

gomoku-init-display is a byte-compiled function defined in gomoku.el.gz.

Signature

(gomoku-init-display N M)

Documentation

Display an N by M Gomoku board.

Source Code

;; Defined in /usr/src/emacs/lisp/play/gomoku.el.gz
  (sit-for 0))	; Display NOW

(defun gomoku-init-display (n m)
  "Display an N by M Gomoku board."
  (buffer-disable-undo (current-buffer))
  (let ((inhibit-read-only t)
	(point (point-min)) opoint
	(i m) j x)
    ;; Try to minimize number of chars (because of text properties)
    (setq tab-width
	  (if (zerop (% gomoku-x-offset gomoku-square-width))
	      gomoku-square-width
	    (max (/ (+ (% gomoku-x-offset gomoku-square-width)
		       gomoku-square-width 1) 2) 2)))
    (erase-buffer)
    (insert-char ?\n gomoku-y-offset)
    (while (progn
	     (setq j n
		   x (- gomoku-x-offset gomoku-square-width))
	     (while (>= (setq j (1- j)) 0)
               (insert-char ?\t (/ (- (setq x (+ x gomoku-square-width))
                                      (current-column))
                                   tab-width))
               (insert-char ?\s (- x (current-column)))
	       (and (zerop j)
		    (= i (- m 2))
		    (progn
		      (while (>= i 3)
			(append-to-buffer (current-buffer) opoint (point))
			(setq i (- i 2)))
		      (goto-char (point-max))))
	       (setq point (point))
	       (insert ?.)
	       (add-text-properties
		point (point)
		'(mouse-face highlight
		  help-echo "mouse-2: play at this square")))
	     (> (setq i (1- i)) 0))
      (if (= i (1- m))
	  (setq opoint point))
      (insert-char ?\n gomoku-square-height))
    (insert-char ?\n))
  (gomoku-goto-xy (/ (1+ n) 2) (/ (1+ m) 2)) ; center of the board
  (sit-for 0))                               ; Display NOW