Function: 5x5-draw-grid
5x5-draw-grid is a byte-compiled function defined in 5x5.el.gz.
Signature
(5x5-draw-grid GRIDS)
Documentation
Draw the grids GRIDS into the current buffer.
Source Code
;; Defined in /usr/src/emacs/lisp/play/5x5.el.gz
(defun 5x5-draw-grid (grids)
"Draw the grids GRIDS into the current buffer."
(let ((inhibit-read-only t) grid-org)
(erase-buffer)
(dolist (_ grids) (5x5-draw-grid-end))
(insert "\n")
(setq grid-org (point))
(dotimes (y 5x5-grid-size)
(dotimes (_lines 5x5-y-scale)
(dolist (grid grids)
(dotimes (x 5x5-grid-size)
(insert (if (zerop x) "| " " ")
(make-string 5x5-x-scale
(if (5x5-cell grid y x) ?# ?.))))
(insert " | "))
(insert "\n")))
(when 5x5-solver-output
(if (= (car 5x5-solver-output) 5x5-moves)
(save-excursion
(goto-char grid-org)
(beginning-of-line (+ 1 (/ 5x5-y-scale 2)))
(let ((solution-grid (cdadr 5x5-solver-output)))
(dotimes (y 5x5-grid-size)
(save-excursion
(forward-char (+ 1 (/ (1+ 5x5-x-scale) 2)))
(dotimes (x 5x5-grid-size)
(when (5x5-cell solution-grid y x)
(if (= 0 (mod 5x5-x-scale 2))
(progn
(insert "()")
(delete-region (point) (+ (point) 2))
(backward-char 2))
(insert-char ?O 1)
(delete-char 1)
(backward-char)))
(forward-char (1+ 5x5-x-scale))))
(forward-line 5x5-y-scale))))
(setq 5x5-solver-output nil)))
(dolist (_grid grids) (5x5-draw-grid-end))
(insert "\n")
(insert (format "On: %d Moves: %d" (5x5-grid-value (car grids)) 5x5-moves))))