Mercurial > emacs
annotate lisp/play/zone.el @ 48471:ea89037b6852
(setwins_almost): Renamed from finder_setwins.
(custom-deps): Use it.
(finder-data): Adjust to that name change.
author | Markus Rost <rost@math.uni-bielefeld.de> |
---|---|
date | Wed, 20 Nov 2002 07:15:41 +0000 |
parents | bcb77f40c06e |
children | 695cf19ef79e d7ddb3e565de |
rev | line source |
---|---|
30565 | 1 ;;; zone.el --- idle display hacks |
2 | |
38677
7177c6c2aaba
(zone-pgm-stress): Use unwind-protect to make sure
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
3 ;; Copyright (C) 2000, 2001 Free Software Foundation, Inc. |
30565 | 4 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32348
diff
changeset
|
5 ;; Author: Victor Zandy <zandy@cs.wisc.edu> |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32348
diff
changeset
|
6 ;; Maintainer: Thien-Thi Nguyen <ttn@gnu.org> |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32348
diff
changeset
|
7 ;; Keywords: games |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32348
diff
changeset
|
8 ;; Created: June 6, 1998 |
30565 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
26 | |
27 ;;; Commentary: | |
28 | |
29 ;; Don't zone out in front of Emacs! Try M-x zone. | |
30 ;; If it eventually irritates you, try M-x zone-leave-me-alone. | |
31 | |
32 ;; Bored by the zone pyrotechnics? Write your own! Add it to | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
33 ;; `zone-programs'. See `zone-call' for higher-ordered zoning. |
30565 | 34 |
35 ;; WARNING: Not appropriate for Emacs sessions over modems or | |
36 ;; computers as slow as mine. | |
37 | |
38 ;; THANKS: Christopher Mayer, Scott Flinchbaugh, Rachel Kalmar, | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
39 ;; Max Froumentin. |
30565 | 40 |
41 ;;; Code: | |
42 | |
43 (require 'timer) | |
44 (require 'tabify) | |
45 (eval-when-compile (require 'cl)) | |
46 | |
45819
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
47 (defvar zone-timer nil |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
48 "The timer we use to decide when to zone out, or nil if none.") |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
49 |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
50 (defvar zone-timeout nil |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
51 "*Seconds to timeout the zoning. |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
52 If nil, don't interrupt for about 1^26 seconds.") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
53 |
30565 | 54 ;; Vector of functions that zone out. `zone' will execute one of |
55 ;; these functions, randomly chosen. The chosen function is invoked | |
56 ;; in the *zone* buffer, which contains the text of the selected | |
57 ;; window. If the function loops, it *must* periodically check and | |
58 ;; halt if `input-pending-p' is t (because quitting is disabled when | |
59 ;; Emacs idle timers are run). | |
60 (defvar zone-programs [ | |
61 zone-pgm-jitter | |
62 zone-pgm-putz-with-case | |
63 zone-pgm-dissolve | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
64 ;; zone-pgm-explode |
30565 | 65 zone-pgm-whack-chars |
66 zone-pgm-rotate | |
67 zone-pgm-rotate-LR-lockstep | |
68 zone-pgm-rotate-RL-lockstep | |
69 zone-pgm-rotate-LR-variable | |
70 zone-pgm-rotate-RL-variable | |
71 zone-pgm-drip | |
72 zone-pgm-drip-fretfully | |
73 zone-pgm-five-oclock-swan-dive | |
74 zone-pgm-martini-swan-dive | |
75 zone-pgm-paragraph-spaz | |
76 zone-pgm-stress | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
77 zone-pgm-stress-destress |
30565 | 78 ]) |
79 | |
80 (defmacro zone-orig (&rest body) | |
81 `(with-current-buffer (get 'zone 'orig-buffer) | |
82 ,@body)) | |
83 | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
84 (defmacro zone-hiding-modeline (&rest body) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
85 `(let (bg mode-line-fg mode-line-bg mode-line-box) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
86 (unwind-protect |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
87 (progn |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
88 (when (and (= 0 (get 'zone 'modeline-hidden-level)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
89 (display-color-p)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
90 (setq bg (face-background 'default) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
91 mode-line-box (face-attribute 'mode-line :box) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
92 mode-line-fg (face-attribute 'mode-line :foreground) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
93 mode-line-bg (face-attribute 'mode-line :background)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
94 (set-face-attribute 'mode-line nil |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
95 :foreground bg |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
96 :background bg |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
97 :box nil)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
98 (put 'zone 'modeline-hidden-level |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
99 (1+ (get 'zone 'modeline-hidden-level))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
100 ,@body) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
101 (put 'zone 'modeline-hidden-level |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
102 (1- (get 'zone 'modeline-hidden-level))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
103 (when (and (> 1 (get 'zone 'modeline-hidden-level)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
104 mode-line-fg) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
105 (set-face-attribute 'mode-line nil |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
106 :foreground mode-line-fg |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
107 :background mode-line-bg |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
108 :box mode-line-box))))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
109 |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
110 (defun zone-call (program &optional timeout) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
111 "Call PROGRAM in a zoned way. |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
112 If PROGRAM is a function, call it, interrupting after the amount |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
113 of time in seconds specified by optional arg TIMEOUT, or `zone-timeout' |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
114 if unspecified, q.v. |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
115 PROGRAM can also be a list of elements, which are interpreted like so: |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
116 If the element is a function or a list of a function and a number, |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
117 apply `zone-call' recursively." |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
118 (cond ((functionp program) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
119 (with-timeout ((or timeout zone-timeout (ash 1 26))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
120 (funcall program))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
121 ((listp program) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
122 (mapcar (lambda (elem) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
123 (cond ((functionp elem) (zone-call elem)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
124 ((and (listp elem) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
125 (functionp (car elem)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
126 (numberp (cadr elem))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
127 (apply 'zone-call elem)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
128 (t (error "bad `zone-call' elem:" elem)))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
129 program)))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
130 |
30565 | 131 ;;;###autoload |
132 (defun zone () | |
133 "Zone out, completely." | |
134 (interactive) | |
30592
fbdf4c1e1acf
(zone, zone-pgm-stress): Don't use window-system.
Eli Zaretskii <eliz@gnu.org>
parents:
30565
diff
changeset
|
135 (let ((f (selected-frame)) |
30565 | 136 (outbuf (get-buffer-create "*zone*")) |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
137 (text (buffer-substring (window-start) (window-end))) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
138 (wp (1+ (- (window-point (selected-window)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
139 (window-start))))) |
30565 | 140 (put 'zone 'orig-buffer (current-buffer)) |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
141 (put 'zone 'modeline-hidden-level 0) |
30565 | 142 (set-buffer outbuf) |
143 (setq mode-name "Zone") | |
144 (erase-buffer) | |
145 (insert text) | |
146 (switch-to-buffer outbuf) | |
147 (setq buffer-undo-list t) | |
148 (untabify (point-min) (point-max)) | |
149 (set-window-start (selected-window) (point-min)) | |
150 (set-window-point (selected-window) wp) | |
151 (sit-for 0 500) | |
152 (let ((pgm (elt zone-programs (random (length zone-programs)))) | |
153 (ct (and f (frame-parameter f 'cursor-type)))) | |
154 (when ct (modify-frame-parameters f '((cursor-type . (bar . 0))))) | |
155 (condition-case nil | |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
156 (progn |
30565 | 157 (message "Zoning... (%s)" pgm) |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
158 (garbage-collect) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
159 ;; If some input is pending, zone says "sorry", which |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
160 ;; isn't nice; this might happen e.g. when they invoke the |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
161 ;; game by clicking the menu bar. So discard any pending |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
162 ;; input before zoning out. |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
163 (if (input-pending-p) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
164 (discard-input)) |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
165 (zone-call pgm) |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
166 (message "Zoning...sorry")) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
167 (error |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
168 (while (not (input-pending-p)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
169 (message (format "We were zoning when we wrote %s..." pgm)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
170 (sit-for 3) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
171 (message "...here's hoping we didn't hose your buffer!") |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
172 (sit-for 3))) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
173 (quit (ding) (message "Zoning...sorry"))) |
30565 | 174 (when ct (modify-frame-parameters f (list (cons 'cursor-type ct))))) |
45819
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
175 (kill-buffer outbuf))) |
30565 | 176 |
177 ;;;; Zone when idle, or not. | |
178 | |
179 (defun zone-when-idle (secs) | |
180 "Zone out when Emacs has been idle for SECS seconds." | |
181 (interactive "nHow long before I start zoning (seconds): ") | |
45819
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
182 (if (timerp zone-timer) |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
183 (cancel-timer zone-timer)) |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
184 (setq zone-timer nil) |
30565 | 185 (or (<= secs 0) |
45819
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
186 (setq zone-timer (run-with-idle-timer secs t 'zone)))) |
30565 | 187 |
188 (defun zone-leave-me-alone () | |
189 "Don't zone out when Emacs is idle." | |
190 (interactive) | |
45819
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
191 (if (timerp zone-timer) |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
192 (cancel-timer zone-timer)) |
a04951f92260
(zone-timer): New variable holds the idle timer.
Richard M. Stallman <rms@gnu.org>
parents:
42645
diff
changeset
|
193 (setq zone-timer nil) |
30565 | 194 (message "I won't zone out any more")) |
195 | |
196 | |
197 ;;;; zone-pgm-jitter | |
198 | |
199 (defun zone-shift-up () | |
200 (let* ((b (point)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
201 (e (progn |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
202 (end-of-line) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
203 (if (looking-at "\n") (1+ (point)) (point)))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
204 (s (buffer-substring b e))) |
30565 | 205 (delete-region b e) |
206 (goto-char (point-max)) | |
207 (insert s))) | |
208 | |
209 (defun zone-shift-down () | |
210 (goto-char (point-max)) | |
211 (forward-line -1) | |
212 (beginning-of-line) | |
213 (let* ((b (point)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
214 (e (progn |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
215 (end-of-line) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
216 (if (looking-at "\n") (1+ (point)) (point)))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
217 (s (buffer-substring b e))) |
30565 | 218 (delete-region b e) |
219 (goto-char (point-min)) | |
220 (insert s))) | |
221 | |
222 (defun zone-shift-left () | |
223 (while (not (eobp)) | |
224 (or (eolp) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
225 (let ((c (following-char))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
226 (delete-char 1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
227 (end-of-line) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
228 (insert c))) |
30565 | 229 (forward-line 1))) |
230 | |
231 (defun zone-shift-right () | |
232 (while (not (eobp)) | |
233 (end-of-line) | |
234 (or (bolp) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
235 (let ((c (preceding-char))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
236 (delete-backward-char 1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
237 (beginning-of-line) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
238 (insert c))) |
30565 | 239 (forward-line 1))) |
240 | |
241 (defun zone-pgm-jitter () | |
242 (let ((ops [ | |
243 zone-shift-left | |
244 zone-shift-left | |
245 zone-shift-left | |
246 zone-shift-left | |
247 zone-shift-right | |
248 zone-shift-down | |
249 zone-shift-down | |
250 zone-shift-down | |
251 zone-shift-down | |
252 zone-shift-down | |
253 zone-shift-up | |
254 ])) | |
255 (goto-char (point-min)) | |
256 (while (not (input-pending-p)) | |
257 (funcall (elt ops (random (length ops)))) | |
258 (goto-char (point-min)) | |
259 (sit-for 0 10)))) | |
260 | |
261 | |
262 ;;;; zone-pgm-whack-chars | |
263 | |
264 (defun zone-pgm-whack-chars () | |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
265 (let ((tbl (copy-sequence (get 'zone-pgm-whack-chars 'wc-tbl)))) |
30565 | 266 (while (not (input-pending-p)) |
267 (let ((i 48)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
268 (while (< i 122) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
269 (aset tbl i (+ 48 (random (- 123 48)))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
270 (setq i (1+ i))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
271 (translate-region (point-min) (point-max) tbl) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
272 (sit-for 0 2))))) |
30565 | 273 |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
274 (put 'zone-pgm-whack-chars 'wc-tbl |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
275 (let ((tbl (make-string 128 ?x)) |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
276 (i 0)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
277 (while (< i 128) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
278 (aset tbl i i) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
279 (setq i (1+ i))) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
280 tbl)) |
30565 | 281 |
282 ;;;; zone-pgm-dissolve | |
283 | |
284 (defun zone-remove-text () | |
285 (let ((working t)) | |
286 (while working | |
287 (setq working nil) | |
288 (save-excursion | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
289 (goto-char (point-min)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
290 (while (not (eobp)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
291 (if (looking-at "[^(){}\n\t ]") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
292 (let ((n (random 5))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
293 (if (not (= n 0)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
294 (progn |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
295 (setq working t) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
296 (forward-char 1)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
297 (delete-char 1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
298 (insert " "))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
299 (forward-char 1)))) |
30565 | 300 (sit-for 0 2)))) |
301 | |
302 (defun zone-pgm-dissolve () | |
303 (zone-remove-text) | |
304 (zone-pgm-jitter)) | |
305 | |
306 | |
307 ;;;; zone-pgm-explode | |
308 | |
309 (defun zone-exploding-remove () | |
310 (let ((i 0)) | |
311 (while (< i 20) | |
312 (save-excursion | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
313 (goto-char (point-min)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
314 (while (not (eobp)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
315 (if (looking-at "[^*\n\t ]") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
316 (let ((n (random 5))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
317 (if (not (= n 0)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
318 (forward-char 1)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
319 (insert " "))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
320 (forward-char 1))) |
30565 | 321 (setq i (1+ i)) |
322 (sit-for 0 2))) | |
323 (zone-pgm-jitter)) | |
324 | |
325 (defun zone-pgm-explode () | |
326 (zone-exploding-remove) | |
327 (zone-pgm-jitter)) | |
328 | |
329 | |
330 ;;;; zone-pgm-putz-with-case | |
331 | |
332 ;; Faster than `zone-pgm-putz-with-case', but not as good: all | |
333 ;; instances of the same letter have the same case, which produces a | |
334 ;; less interesting effect than you might imagine. | |
335 (defun zone-pgm-2nd-putz-with-case () | |
336 (let ((tbl (make-string 128 ?x)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
337 (i 0)) |
30565 | 338 (while (< i 128) |
339 (aset tbl i i) | |
340 (setq i (1+ i))) | |
341 (while (not (input-pending-p)) | |
342 (setq i ?a) | |
343 (while (<= i ?z) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
344 (aset tbl i |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
345 (if (zerop (random 5)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
346 (upcase i) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
347 (downcase i))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
348 (setq i (+ i (1+ (random 5))))) |
30565 | 349 (setq i ?A) |
350 (while (<= i ?z) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
351 (aset tbl i |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
352 (if (zerop (random 5)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
353 (downcase i) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
354 (upcase i))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
355 (setq i (+ i (1+ (random 5))))) |
30565 | 356 (translate-region (point-min) (point-max) tbl) |
357 (sit-for 0 2)))) | |
358 | |
359 (defun zone-pgm-putz-with-case () | |
360 (goto-char (point-min)) | |
361 (while (not (input-pending-p)) | |
362 (let ((np (+ 2 (random 5))) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
363 (pm (point-max))) |
30565 | 364 (while (< np pm) |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
365 (goto-char np) |
30565 | 366 (let ((prec (preceding-char)) |
367 (props (text-properties-at (1- (point))))) | |
368 (insert (if (zerop (random 2)) | |
369 (upcase prec) | |
370 (downcase prec))) | |
371 (set-text-properties (1- (point)) (point) props)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
372 (backward-char 2) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
373 (delete-char 1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
374 (setq np (+ np (1+ (random 5)))))) |
30565 | 375 (goto-char (point-min)) |
376 (sit-for 0 2))) | |
377 | |
378 | |
379 ;;;; zone-pgm-rotate | |
380 | |
381 (defun zone-line-specs () | |
382 (let (ret) | |
383 (save-excursion | |
384 (goto-char (window-start)) | |
385 (while (< (point) (window-end)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
386 (when (looking-at "[\t ]*\\([^\n]+\\)") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
387 (setq ret (cons (cons (match-beginning 1) (match-end 1)) ret))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
388 (forward-line 1))) |
30565 | 389 ret)) |
390 | |
391 (defun zone-pgm-rotate (&optional random-style) | |
392 (let* ((specs (apply | |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
393 'vector |
30565 | 394 (let (res) |
395 (mapcar (lambda (ent) | |
396 (let* ((beg (car ent)) | |
397 (end (cdr ent)) | |
398 (amt (if random-style | |
399 (funcall random-style) | |
400 (- (random 7) 3)))) | |
401 (when (< (- end (abs amt)) beg) | |
402 (setq amt (random (- end beg)))) | |
403 (unless (= 0 amt) | |
404 (setq res | |
405 (cons | |
406 (vector amt beg (- end (abs amt))) | |
407 res))))) | |
408 (zone-line-specs)) | |
409 res))) | |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
410 (n (length specs)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
411 amt aamt cut paste txt i ent) |
30565 | 412 (while (not (input-pending-p)) |
413 (setq i 0) | |
414 (while (< i n) | |
32348
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
415 (setq ent (aref specs i)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
416 (setq amt (aref ent 0) aamt (abs amt)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
417 (if (> 0 amt) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
418 (setq cut 1 paste 2) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
419 (setq cut 2 paste 1)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
420 (goto-char (aref ent cut)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
421 (setq txt (buffer-substring (point) (+ (point) aamt))) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
422 (delete-char aamt) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
423 (goto-char (aref ent paste)) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
424 (insert txt) |
abc299ad3386
(zone-timer, zone-wc-tbl): Rework
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
30628
diff
changeset
|
425 (setq i (1+ i))) |
30565 | 426 (sit-for 0.04)))) |
427 | |
428 (defun zone-pgm-rotate-LR-lockstep () | |
429 (zone-pgm-rotate (lambda () 1))) | |
430 | |
431 (defun zone-pgm-rotate-RL-lockstep () | |
432 (zone-pgm-rotate (lambda () -1))) | |
433 | |
434 (defun zone-pgm-rotate-LR-variable () | |
435 (zone-pgm-rotate (lambda () (1+ (random 3))))) | |
436 | |
437 (defun zone-pgm-rotate-RL-variable () | |
438 (zone-pgm-rotate (lambda () (1- (- (random 3)))))) | |
439 | |
440 | |
441 ;;;; zone-pgm-drip | |
442 | |
443 (defun zone-cpos (pos) | |
444 (buffer-substring pos (1+ pos))) | |
445 | |
446 (defun zone-fret (pos) | |
447 (let* ((case-fold-search nil) | |
448 (c-string (zone-cpos pos)) | |
449 (hmm (cond | |
450 ((string-match "[a-z]" c-string) (upcase c-string)) | |
451 ((string-match "[A-Z]" c-string) (downcase c-string)) | |
452 (t " ")))) | |
453 (do ((i 0 (1+ i)) | |
454 (wait 0.5 (* wait 0.8))) | |
455 ((= i 20)) | |
456 (goto-char pos) | |
457 (delete-char 1) | |
458 (insert (if (= 0 (% i 2)) hmm c-string)) | |
459 (sit-for wait)) | |
460 (delete-char -1) (insert c-string))) | |
461 | |
462 (defun zone-fall-through-ws (c col wend) | |
463 (let ((fall-p nil) ; todo: move outward | |
464 (wait 0.15) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
465 (o (point)) ; for terminals w/o cursor hiding |
30565 | 466 (p (point))) |
467 (while (progn | |
468 (forward-line 1) | |
469 (move-to-column col) | |
470 (looking-at " ")) | |
471 (setq fall-p t) | |
472 (delete-char 1) | |
473 (insert (if (< (point) wend) c " ")) | |
474 (save-excursion | |
475 (goto-char p) | |
476 (delete-char 1) | |
477 (insert " ") | |
478 (goto-char o) | |
479 (sit-for (setq wait (* wait 0.8)))) | |
480 (setq p (1- (point)))) | |
481 fall-p)) | |
482 | |
483 (defun zone-pgm-drip (&optional fret-p pancake-p) | |
484 (let* ((ww (1- (window-width))) | |
485 (wh (window-height)) | |
486 (mc 0) ; miss count | |
487 (total (* ww wh)) | |
488 (fall-p nil)) | |
489 (goto-char (point-min)) | |
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))) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
499 ;; pad ws past bottom of screen |
30565 | 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))))) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
506 (catch 'done |
30565 | 507 (while (not (input-pending-p)) |
508 (goto-char (point-min)) | |
509 (sit-for 0) | |
510 (let ((wbeg (window-start)) | |
511 (wend (window-end))) | |
512 (setq mc 0) | |
513 ;; select non-ws character, but don't miss too much | |
514 (goto-char (+ wbeg (random (- wend wbeg)))) | |
515 (while (looking-at "[ \n\f]") | |
516 (if (= total (setq mc (1+ mc))) | |
517 (throw 'done 'sel) | |
518 (goto-char (+ wbeg (random (- wend wbeg)))))) | |
519 ;; character animation sequence | |
520 (let ((p (point))) | |
521 (when fret-p (zone-fret p)) | |
522 (goto-char p) | |
523 (setq fall-p (zone-fall-through-ws | |
524 (zone-cpos p) (current-column) wend)))) | |
525 ;; assuming current-column has not changed... | |
526 (when (and pancake-p | |
527 fall-p | |
528 (< (count-lines (point-min) (point)) | |
529 wh)) | |
530 (previous-line 1) | |
531 (forward-char 1) | |
532 (sit-for 0.137) | |
533 (delete-char -1) | |
534 (insert "@") | |
535 (sit-for 0.137) | |
536 (delete-char -1) | |
537 (insert "*") | |
538 (sit-for 0.137) | |
539 (delete-char -1) | |
540 (insert "_")))))) | |
541 | |
542 (defun zone-pgm-drip-fretfully () | |
543 (zone-pgm-drip t)) | |
544 | |
545 (defun zone-pgm-five-oclock-swan-dive () | |
546 (zone-pgm-drip nil t)) | |
547 | |
548 (defun zone-pgm-martini-swan-dive () | |
549 (zone-pgm-drip t t)) | |
550 | |
551 | |
552 ;;;; zone-pgm-paragraph-spaz | |
553 | |
554 (defun zone-pgm-paragraph-spaz () | |
555 (if (memq (zone-orig major-mode) '(text-mode fundamental-mode)) | |
556 (let ((fill-column fill-column) | |
557 (fc-min fill-column) | |
558 (fc-max fill-column) | |
559 (max-fc (1- (frame-width)))) | |
560 (while (sit-for 0.1) | |
561 (fill-paragraph 1) | |
562 (setq fill-column (+ fill-column (- (random 5) 2))) | |
563 (when (< fill-column fc-min) | |
564 (setq fc-min fill-column)) | |
565 (when (> fill-column max-fc) | |
566 (setq fill-column max-fc)) | |
567 (when (> fill-column fc-max) | |
568 (setq fc-max fill-column)))) | |
569 (message "Zoning... (zone-pgm-rotate)") | |
570 (zone-pgm-rotate))) | |
571 | |
572 | |
573 ;;;; zone-pgm-stress | |
574 | |
575 (defun zone-pgm-stress () | |
576 (goto-char (point-min)) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
577 (let (lines) |
30565 | 578 (while (< (point) (point-max)) |
579 (let ((p (point))) | |
580 (forward-line 1) | |
581 (setq lines (cons (buffer-substring p (point)) lines)))) | |
582 (sit-for 5) | |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
583 (zone-hiding-modeline |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
584 (let ((msg "Zoning... (zone-pgm-stress)")) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
585 (while (not (string= msg "")) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
586 (message (setq msg (substring msg 1))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
587 (sit-for 0.05))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
588 (while (not (input-pending-p)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
589 (when (< 50 (random 100)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
590 (goto-char (point-max)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
591 (forward-line -1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
592 (let ((kill-whole-line t)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
593 (kill-line)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
594 (goto-char (point-min)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
595 (insert (nth (random (length lines)) lines))) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
596 (message (concat (make-string (random (- (frame-width) 5)) ? ) "grrr")) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
597 (sit-for 0.1))))) |
38677
7177c6c2aaba
(zone-pgm-stress): Use unwind-protect to make sure
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
598 |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
599 |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
600 ;;;; zone-pgm-stress-destress |
38677
7177c6c2aaba
(zone-pgm-stress): Use unwind-protect to make sure
Gerd Moellmann <gerd@gnu.org>
parents:
38414
diff
changeset
|
601 |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
602 (defun zone-pgm-stress-destress () |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
603 (zone-call 'zone-pgm-stress 25) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
604 (zone-hiding-modeline |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
605 (sit-for 3) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
606 (erase-buffer) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
607 (sit-for 3) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
608 (insert-buffer "*Messages*") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
609 (message "") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
610 (goto-char (point-max)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
611 (recenter -1) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
612 (sit-for 3) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
613 (delete-region (point-min) (window-start)) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
614 (message "hey why stress out anyway?") |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
615 (zone-call '((zone-pgm-rotate 30) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
616 (zone-pgm-whack-chars 10) |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
617 zone-pgm-drip)))) |
30565 | 618 |
42645
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
619 |
ac1b9223bb7f
(zone-timeout): New var.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
40347
diff
changeset
|
620 ;;;;;;;;;;;;;;; |
30565 | 621 (provide 'zone) |
622 | |
623 ;;; zone.el ends here |