diff options
| author | Thien-Thi Nguyen | 2004-12-11 14:51:32 +0000 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2004-12-11 14:51:32 +0000 |
| commit | 0ccb50fc8a57e07c85a005cc4455dd44c9885939 (patch) | |
| tree | 8289c766f3ab67c1c340401df62c6c50ee15fe76 | |
| parent | 982f55b0a9ebfecc3743bfaf09d28a1604d6ac60 (diff) | |
| download | emacs-0ccb50fc8a57e07c85a005cc4455dd44c9885939.tar.gz emacs-0ccb50fc8a57e07c85a005cc4455dd44c9885939.zip | |
(zone-programs): Add `zone-pgm-random-life'.
(zone-fill-out-screen): New func.
(zone-pgm-drip): Use `zone-fill-out-screen'.
Also, no longer go to point-min on every cycle.
(zone-pgm-paragraph-spaz): Allow spazzing for texinfo-mode.
(zone-pgm-random-life-wait): New user var.
(zone-pgm-random-life): New func.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/play/zone.el | 103 |
2 files changed, 89 insertions, 24 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8caec00e85e..879e6a5195a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2004-12-11 Thien-Thi Nguyen <ttn@gnu.org> | ||
| 2 | |||
| 3 | * play/zone.el (zone-programs): Add `zone-pgm-random-life'. | ||
| 4 | (zone-fill-out-screen): New func. | ||
| 5 | (zone-pgm-drip): Use `zone-fill-out-screen'. | ||
| 6 | Also, no longer go to point-min on every cycle. | ||
| 7 | (zone-pgm-paragraph-spaz): Allow spazzing for texinfo-mode. | ||
| 8 | (zone-pgm-random-life-wait): New user var. | ||
| 9 | (zone-pgm-random-life): New func. | ||
| 10 | |||
| 1 | 2004-12-10 Thien-Thi Nguyen <ttn@gnu.org> | 11 | 2004-12-10 Thien-Thi Nguyen <ttn@gnu.org> |
| 2 | 12 | ||
| 3 | * files.el (auto-mode-alist): Map .com to DCL mode. | 13 | * files.el (auto-mode-alist): Map .com to DCL mode. |
diff --git a/lisp/play/zone.el b/lisp/play/zone.el index abe9657a9d8..e073e343f02 100644 --- a/lisp/play/zone.el +++ b/lisp/play/zone.el | |||
| @@ -75,6 +75,7 @@ If nil, don't interrupt for about 1^26 seconds.") | |||
| 75 | zone-pgm-paragraph-spaz | 75 | zone-pgm-paragraph-spaz |
| 76 | zone-pgm-stress | 76 | zone-pgm-stress |
| 77 | zone-pgm-stress-destress | 77 | zone-pgm-stress-destress |
| 78 | zone-pgm-random-life | ||
| 78 | ]) | 79 | ]) |
| 79 | 80 | ||
| 80 | (defmacro zone-orig (&rest body) | 81 | (defmacro zone-orig (&rest body) |
| @@ -459,6 +460,26 @@ If the element is a function or a list of a function and a number, | |||
| 459 | (sit-for wait)) | 460 | (sit-for wait)) |
| 460 | (delete-char -1) (insert c-string))) | 461 | (delete-char -1) (insert c-string))) |
| 461 | 462 | ||
| 463 | (defun zone-fill-out-screen (width height) | ||
| 464 | (save-excursion | ||
| 465 | (goto-char (point-min)) | ||
| 466 | ;; fill out rectangular ws block | ||
| 467 | (while (not (eobp)) | ||
| 468 | (end-of-line) | ||
| 469 | (let ((cc (current-column))) | ||
| 470 | (if (< cc width) | ||
| 471 | (insert (make-string (- width cc) 32)) | ||
| 472 | (delete-char (- width cc)))) | ||
| 473 | (unless (eobp) | ||
| 474 | (forward-char 1))) | ||
| 475 | ;; pad ws past bottom of screen | ||
| 476 | (let ((nl (- height (count-lines (point-min) (point))))) | ||
| 477 | (when (> nl 0) | ||
| 478 | (let ((line (concat (make-string (1- width) ? ) "\n"))) | ||
| 479 | (do ((i 0 (1+ i))) | ||
| 480 | ((= i nl)) | ||
| 481 | (insert line))))))) | ||
| 482 | |||
| 462 | (defun zone-fall-through-ws (c col wend) | 483 | (defun zone-fall-through-ws (c col wend) |
| 463 | (let ((fall-p nil) ; todo: move outward | 484 | (let ((fall-p nil) ; todo: move outward |
| 464 | (wait 0.15) | 485 | (wait 0.15) |
| @@ -486,27 +507,9 @@ If the element is a function or a list of a function and a number, | |||
| 486 | (mc 0) ; miss count | 507 | (mc 0) ; miss count |
| 487 | (total (* ww wh)) | 508 | (total (* ww wh)) |
| 488 | (fall-p nil)) | 509 | (fall-p nil)) |
| 489 | (goto-char (point-min)) | 510 | (zone-fill-out-screen ww wh) |
| 490 | ;; fill out rectangular ws block | ||
| 491 | (while (not (eobp)) | ||
| 492 | (end-of-line) | ||
| 493 | (let ((cc (current-column))) | ||
| 494 | (if (< cc ww) | ||
| 495 | (insert (make-string (- ww cc) ? )) | ||
| 496 | (delete-char (- ww cc)))) | ||
| 497 | (unless (eobp) | ||
| 498 | (forward-char 1))) | ||
| 499 | ;; pad ws past bottom of screen | ||
| 500 | (let ((nl (- wh (count-lines (point-min) (point))))) | ||
| 501 | (when (> nl 0) | ||
| 502 | (let ((line (concat (make-string (1- ww) ? ) "\n"))) | ||
| 503 | (do ((i 0 (1+ i))) | ||
| 504 | ((= i nl)) | ||
| 505 | (insert line))))) | ||
| 506 | (catch 'done | 511 | (catch 'done |
| 507 | (while (not (input-pending-p)) | 512 | (while (not (input-pending-p)) |
| 508 | (goto-char (point-min)) | ||
| 509 | (sit-for 0) | ||
| 510 | (let ((wbeg (window-start)) | 513 | (let ((wbeg (window-start)) |
| 511 | (wend (window-end))) | 514 | (wend (window-end))) |
| 512 | (setq mc 0) | 515 | (setq mc 0) |
| @@ -552,7 +555,9 @@ If the element is a function or a list of a function and a number, | |||
| 552 | ;;;; zone-pgm-paragraph-spaz | 555 | ;;;; zone-pgm-paragraph-spaz |
| 553 | 556 | ||
| 554 | (defun zone-pgm-paragraph-spaz () | 557 | (defun zone-pgm-paragraph-spaz () |
| 555 | (if (memq (zone-orig major-mode) '(text-mode fundamental-mode)) | 558 | (if (memq (zone-orig major-mode) |
| 559 | ;; there should be a better way to distinguish textish modes | ||
| 560 | '(text-mode texinfo-mode fundamental-mode)) | ||
| 556 | (let ((fill-column fill-column) | 561 | (let ((fill-column fill-column) |
| 557 | (fc-min fill-column) | 562 | (fc-min fill-column) |
| 558 | (fc-max fill-column) | 563 | (fc-max fill-column) |
| @@ -570,7 +575,7 @@ If the element is a function or a list of a function and a number, | |||
| 570 | (zone-pgm-rotate))) | 575 | (zone-pgm-rotate))) |
| 571 | 576 | ||
| 572 | 577 | ||
| 573 | ;;;; zone-pgm-stress | 578 | ;;;; stressing and destressing |
| 574 | 579 | ||
| 575 | (defun zone-pgm-stress () | 580 | (defun zone-pgm-stress () |
| 576 | (goto-char (point-min)) | 581 | (goto-char (point-min)) |
| @@ -596,9 +601,6 @@ If the element is a function or a list of a function and a number, | |||
| 596 | (message (concat (make-string (random (- (frame-width) 5)) ? ) "grrr")) | 601 | (message (concat (make-string (random (- (frame-width) 5)) ? ) "grrr")) |
| 597 | (sit-for 0.1))))) | 602 | (sit-for 0.1))))) |
| 598 | 603 | ||
| 599 | |||
| 600 | ;;;; zone-pgm-stress-destress | ||
| 601 | |||
| 602 | (defun zone-pgm-stress-destress () | 604 | (defun zone-pgm-stress-destress () |
| 603 | (zone-call 'zone-pgm-stress 25) | 605 | (zone-call 'zone-pgm-stress 25) |
| 604 | (zone-hiding-modeline | 606 | (zone-hiding-modeline |
| @@ -617,6 +619,59 @@ If the element is a function or a list of a function and a number, | |||
| 617 | zone-pgm-drip)))) | 619 | zone-pgm-drip)))) |
| 618 | 620 | ||
| 619 | 621 | ||
| 622 | ;;;; the lyfe so short the craft so long to lerne --chaucer | ||
| 623 | |||
| 624 | (defvar zone-pgm-random-life-wait nil | ||
| 625 | "*Seconds to wait between successive `life' generations. | ||
| 626 | If nil, `zone-pgm-random-life' chooses a value from 0-3 (inclusive).") | ||
| 627 | |||
| 628 | (defun zone-pgm-random-life () | ||
| 629 | (require 'life) | ||
| 630 | (zone-fill-out-screen (1- (window-width)) (1- (window-height))) | ||
| 631 | (let ((top (progn (goto-char (window-start)) (forward-line 7) (point))) | ||
| 632 | (bot (progn (goto-char (window-end)) (forward-line -7) (point))) | ||
| 633 | (rtc (- (frame-width) 11)) | ||
| 634 | (min (window-start)) | ||
| 635 | (max (1- (window-end))) | ||
| 636 | c col) | ||
| 637 | (delete-region max (point-max)) | ||
| 638 | (while (progn (goto-char (+ min (random max))) | ||
| 639 | (and (sit-for 0.005) | ||
| 640 | (or (progn (skip-chars-forward " @\n" max) | ||
| 641 | (not (= max (point)))) | ||
| 642 | (unless (or (= 0 (skip-chars-backward " @\n" min)) | ||
| 643 | (= min (point))) | ||
| 644 | (forward-char -1) | ||
| 645 | t)))) | ||
| 646 | (setq c (char-after)) | ||
| 647 | (unless (or (not c) (= ?\n c)) | ||
| 648 | (forward-char 1) | ||
| 649 | (insert-and-inherit ; keep colors | ||
| 650 | (cond ((or (> top (point)) | ||
| 651 | (< bot (point)) | ||
| 652 | (or (> 11 (setq col (current-column))) | ||
| 653 | (< rtc col))) | ||
| 654 | 32) | ||
| 655 | ((and (<= ?a c) (>= ?z c)) (+ c (- ?A ?a))) | ||
| 656 | ((and (<= ?A c) (>= ?Z c)) ?*) | ||
| 657 | (t ?@))) | ||
| 658 | (forward-char -1) | ||
| 659 | (delete-char -1))) | ||
| 660 | (sit-for 3) | ||
| 661 | (setq col nil) | ||
| 662 | (goto-char bot) | ||
| 663 | (while (< top (point)) | ||
| 664 | (setq c (point)) | ||
| 665 | (move-to-column 9) | ||
| 666 | (setq col (cons (buffer-substring (point) c) col)) | ||
| 667 | (end-of-line 0) | ||
| 668 | (forward-char -10)) | ||
| 669 | (let ((life-patterns (vector (cons (make-string (length (car col)) 32) | ||
| 670 | col)))) | ||
| 671 | (life (or zone-pgm-random-life-wait (random 4))) | ||
| 672 | (kill-buffer nil)))) | ||
| 673 | |||
| 674 | |||
| 620 | ;;;;;;;;;;;;;;; | 675 | ;;;;;;;;;;;;;;; |
| 621 | (provide 'zone) | 676 | (provide 'zone) |
| 622 | 677 | ||