diff options
| author | Gerd Moellmann | 2001-07-23 09:46:39 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-07-23 09:46:39 +0000 |
| commit | 73496807fbd6774d70b3ed6b8a264a7381d2dd6c (patch) | |
| tree | 64246df884b4fc396b8cb23c6d5679b19d2b12bd | |
| parent | ea229bec478445d9198579f450704afe0a9658c5 (diff) | |
| download | emacs-73496807fbd6774d70b3ed6b8a264a7381d2dd6c.tar.gz emacs-73496807fbd6774d70b3ed6b8a264a7381d2dd6c.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/ChangeLog | 74 | ||||
| -rw-r--r-- | lisp/play/animate.el | 167 |
2 files changed, 206 insertions, 35 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e8ab516e36f..b2930047ffe 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2001-07-23 Gerd Moellmann <gerd@gnu.org> | ||
| 2 | |||
| 3 | * play/animate.el: New file. | ||
| 4 | |||
| 1 | 2001-07-22 Eli Zaretskii <eliz@is.elta.co.il> | 5 | 2001-07-22 Eli Zaretskii <eliz@is.elta.co.il> |
| 2 | 6 | ||
| 3 | * startup.el (normal-top-level-add-subdirs-to-load-path): On | 7 | * startup.el (normal-top-level-add-subdirs-to-load-path): On |
| @@ -9,29 +13,29 @@ | |||
| 9 | * ediff-util.el: Copyright years. | 13 | * ediff-util.el: Copyright years. |
| 10 | (ediff-choose-syntax-table): New function. | 14 | (ediff-choose-syntax-table): New function. |
| 11 | (ediff-setup): Use ediff-choose-syntax-table. | 15 | (ediff-setup): Use ediff-choose-syntax-table. |
| 12 | (ediff-file-checked-out-p,ediff-file-checked-in-p): check if | 16 | (ediff-file-checked-out-p,ediff-file-checked-in-p): Check if |
| 13 | vc-state is available. | 17 | vc-state is available. |
| 14 | (ediff-make-temp-file): use ediff-coding-system-for-write. | 18 | (ediff-make-temp-file): Use ediff-coding-system-for-write. |
| 15 | 19 | ||
| 16 | * ediff-init.el (ediff-with-syntax-table): New macro, uses | 20 | * ediff-init.el (ediff-with-syntax-table): New macro, uses |
| 17 | with-syntax-table. | 21 | with-syntax-table. |
| 18 | (ediff-coding-system-for-read): from ediff-diff.el | 22 | (ediff-coding-system-for-read): From ediff-diff.el |
| 19 | (ediff-coding-system-for-write): new variable. | 23 | (ediff-coding-system-for-write): New variable. |
| 20 | (ediff-highest-priority): fixed the bug having to do with disappearing | 24 | (ediff-highest-priority): Fixed the bug having to do with disappearing |
| 21 | overlays. | 25 | overlays. |
| 22 | (ediff-file-remote-p): use file-remote-p, if available. | 26 | (ediff-file-remote-p): Use file-remote-p, if available. |
| 23 | (ediff-listable-file): new function. | 27 | (ediff-listable-file): New function. |
| 24 | (ediff-file-attributes): use ediff-listable-file. | 28 | (ediff-file-attributes): Use ediff-listable-file. |
| 25 | 29 | ||
| 26 | * ediff-mult.el (ediff-meta-insert-file-info1): use | 30 | * ediff-mult.el (ediff-meta-insert-file-info1): Use |
| 27 | ediff-listable-file. | 31 | ediff-listable-file. |
| 28 | 32 | ||
| 29 | * ediff-ptch.el (ediff-prompt-for-patch-file): use | 33 | * ediff-ptch.el (ediff-prompt-for-patch-file): Use |
| 30 | ediff-coding-system-for-read. | 34 | ediff-coding-system-for-read. |
| 31 | (ediff-patch-file-internal): use ediff-coding-system-for-write. | 35 | (ediff-patch-file-internal): Use ediff-coding-system-for-write. |
| 32 | 36 | ||
| 33 | * ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el. | 37 | * ediff-diff.el (ediff-coding-system-for-read): Moved to ediff-init.el. |
| 34 | (ediff-match-diff3-line,ediff-get-diff3-group): improved pattern. | 38 | (ediff-match-diff3-line,ediff-get-diff3-group): Improved pattern. |
| 35 | 39 | ||
| 36 | * ediff.el: Date of last update, copyright years. | 40 | * ediff.el: Date of last update, copyright years. |
| 37 | 41 | ||
| @@ -44,40 +48,40 @@ | |||
| 44 | Deleted functions. | 48 | Deleted functions. |
| 45 | (viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new | 49 | (viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new |
| 46 | ex-token-list. | 50 | ex-token-list. |
| 47 | (viper-get-ex-address-subr): convert registers to char data type. | 51 | (viper-get-ex-address-subr): Convert registers to char data type. |
| 48 | 52 | ||
| 49 | * viper-util.el (viper-int-to-char,viper-char-equal): new | 53 | * viper-util.el (viper-int-to-char,viper-char-equal): New |
| 50 | functions. | 54 | functions. |
| 51 | (viper-memq-char): use viper-int-to-char. | 55 | (viper-memq-char): Use viper-int-to-char. |
| 52 | (viper-file-checked-in-p): use vc-locking-user, if vc doesn't have | 56 | (viper-file-checked-in-p): Use vc-locking-user, if vc doesn't have |
| 53 | vc-locking-state. | 57 | vc-locking-state. |
| 54 | (viper-read-key): use viper-read-key-sequence. | 58 | (viper-read-key): Use viper-read-key-sequence. |
| 55 | 59 | ||
| 56 | * viper.el (viper-major-mode-modifier-list): added | 60 | * viper.el (viper-major-mode-modifier-list): Added |
| 57 | inferior-emacs-lisp-mode. | 61 | inferior-emacs-lisp-mode. |
| 58 | (this-major-mode-requires-vi-state): new function that uses simple | 62 | (this-major-mode-requires-vi-state): New function that uses simple |
| 59 | heuristics to decide if vi state is appropriate. | 63 | heuristics to decide if vi state is appropriate. |
| 60 | (set-viper-state-in-major-mode): use this-major-mode-requires-vi-state. | 64 | (set-viper-state-in-major-mode): Use this-major-mode-requires-vi-state. |
| 61 | (viper-non-hook-settings): don't advise read-key-sequence. | 65 | (viper-non-hook-settings): Don't advise read-key-sequence. |
| 62 | (viper-read-key-sequence): new function that replaces the | 66 | (viper-read-key-sequence): New function that replaces the |
| 63 | previously used advice to read-key-sequence. | 67 | previously used advice to read-key-sequence. |
| 64 | 68 | ||
| 65 | * viper-cmd.el (viper-test-com-defun,viper-exec-change, | 69 | * viper-cmd.el (viper-test-com-defun,viper-exec-change) |
| 66 | viper-exec-Change,viper-execute-com,viper-insert,viper-append, | 70 | (viper-exec-Change,viper-execute-com,viper-insert,viper-append) |
| 67 | viper-Append,viper-Insert,viper-open-line,viper-Open-line, | 71 | (viper-Append,viper-Insert,viper-open-line,viper-Open-line) |
| 68 | viper-open-line-at-point,viper-substitute,viper-overwrite, | 72 | (viper-open-line-at-point,viper-substitute,viper-overwrite) |
| 69 | viper-replace-char-subr,viper-forward-word,viper-forward-Word): | 73 | (viper-replace-char-subr,viper-forward-word,viper-forward-Word): |
| 70 | got rid of the negative character hack. | 74 | Got rid of the negative character hack. |
| 71 | (viper-escape-to-state,viper-replace-state-exit-cmd): | 75 | (viper-escape-to-state,viper-replace-state-exit-cmd): |
| 72 | use viper-read-key-sequence. | 76 | Use viper-read-key-sequence. |
| 73 | (viper-envelop-ESC-key): no need for ad-get-orig-definition. | 77 | (viper-envelop-ESC-key): No need for ad-get-orig-definition. |
| 74 | (viper-minibuffer-standard-hook,viper-read-string-with-history): | 78 | (viper-minibuffer-standard-hook,viper-read-string-with-history): |
| 75 | don't override existing minibuffer-setup-hook. | 79 | Don't override existing minibuffer-setup-hook. |
| 76 | (viper-mark-point,viper-goto-mark-subr,viper-brac-function): | 80 | (viper-mark-point,viper-goto-mark-subr,viper-brac-function): |
| 77 | convert registers to char data type. | 81 | Convert registers to char data type. |
| 78 | (viper-autoindent): use viper-indent-line. | 82 | (viper-autoindent): Use viper-indent-line. |
| 79 | 83 | ||
| 80 | * viper-keym.el: use viper-exec-key-in-emacs. | 84 | * viper-keym.el: Use viper-exec-key-in-emacs. |
| 81 | 85 | ||
| 82 | 2001-07-20 Stefan Monnier <monnier@cs.yale.edu> | 86 | 2001-07-20 Stefan Monnier <monnier@cs.yale.edu> |
| 83 | 87 | ||
diff --git a/lisp/play/animate.el b/lisp/play/animate.el new file mode 100644 index 00000000000..4d4a6e7a648 --- /dev/null +++ b/lisp/play/animate.el | |||
| @@ -0,0 +1,167 @@ | |||
| 1 | ;;; animate.el --- make text dance | ||
| 2 | |||
| 3 | ;; Copyright (C) 2001 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software; you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation; either version 2, or (at your option) | ||
| 10 | ;; any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | ||
| 19 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 20 | ;; Boston, MA 02111-1307, USA. | ||
| 21 | |||
| 22 | ;;; Commentary: | ||
| 23 | |||
| 24 | ;; (animate-string STRING VPOS &optional HPOS) | ||
| 25 | ;; makes the string STRING appear starting at VPOS, HPOS | ||
| 26 | ;; by having each letter swoop into place from random starting position. | ||
| 27 | |||
| 28 | ;; animate-birthday-present was the first application of this program. | ||
| 29 | |||
| 30 | ;;; Code: | ||
| 31 | |||
| 32 | ;;; STRING is the string to be displayed, | ||
| 33 | ;;; and DEST-X, DEST-Y say where on the screen | ||
| 34 | ;;; it should end up. | ||
| 35 | |||
| 36 | ;;; This function returns a list describing | ||
| 37 | ;;; all the characters and the paths they should take. | ||
| 38 | ;;; Each element has the form | ||
| 39 | ;;; (CHAR START-Y START-X DEST-Y DEST-X). | ||
| 40 | |||
| 41 | ;;; The start position of each character is chosen randomly. | ||
| 42 | ;;; The destination is chosen to put it in the right place | ||
| 43 | ;;; in the string when the whole string finally reaches its | ||
| 44 | ;;; specified position. | ||
| 45 | |||
| 46 | (defun animate-initialize (string vpos hpos) | ||
| 47 | (let ((characters nil)) | ||
| 48 | (dotimes (i (length string)) | ||
| 49 | (setq characters | ||
| 50 | (cons (list (aref string i) | ||
| 51 | ;; Random starting positions. | ||
| 52 | (random (window-height)) | ||
| 53 | (random (1- (window-width))) | ||
| 54 | ;; All the chars should end up | ||
| 55 | ;; on the specified line. | ||
| 56 | vpos | ||
| 57 | ;; The Ith character in the string | ||
| 58 | ;; needs to end up I positions later. | ||
| 59 | (+ hpos i)) | ||
| 60 | characters))) | ||
| 61 | characters)) | ||
| 62 | |||
| 63 | ;;; Display the characters in CHARACTERS, | ||
| 64 | ;;; each one FRACTION of the way from its start to its destination. | ||
| 65 | ;;; If FRACTION is 0, the characters appear in their starting positions. | ||
| 66 | ;;; If FRACTION is 1, the characters appear in their destinations. | ||
| 67 | |||
| 68 | (defun animate-step (characters fraction) | ||
| 69 | (let ((remains (- 1 fraction))) | ||
| 70 | (dolist (item characters) | ||
| 71 | (let ((vpos (+ (* remains (nth 1 item)) | ||
| 72 | (* fraction (nth 3 item)))) | ||
| 73 | (hpos (+ (* remains (nth 2 item)) | ||
| 74 | (* fraction (nth 4 item))))) | ||
| 75 | (animate-place-char (car item) vpos hpos))))) | ||
| 76 | |||
| 77 | ;;; Place the character CHAR at position VPOS, HPOS in the current buffer. | ||
| 78 | (defun animate-place-char (char vpos hpos) | ||
| 79 | (goto-char (window-start)) | ||
| 80 | (let ((next-line-add-newlines t)) | ||
| 81 | (dotimes (i vpos) | ||
| 82 | (next-line 1))) | ||
| 83 | (beginning-of-line) | ||
| 84 | (move-to-column (floor hpos) t) | ||
| 85 | (unless (eolp) (delete-char 1)) | ||
| 86 | (insert-char char 1)) | ||
| 87 | |||
| 88 | (defvar animate-n-steps 10 | ||
| 89 | "Number of steps to use `animate-string'.") | ||
| 90 | |||
| 91 | ;;;###autoload | ||
| 92 | (defun animate-string (string vpos &optional hpos) | ||
| 93 | "Display STRING starting at position VPOS, HPOS, using animation. | ||
| 94 | The characters start at randomly chosen places, | ||
| 95 | and all slide in parallel to their final positions, | ||
| 96 | passing through `animate-n-steps' positions before the final ones. | ||
| 97 | If HPOS is nil (or omitted), center the string horizontally | ||
| 98 | in the current window." | ||
| 99 | (let ((characters | ||
| 100 | (animate-initialize string vpos | ||
| 101 | (or hpos | ||
| 102 | ;; HPOS unspecified, so compute | ||
| 103 | ;; it so as to center the string. | ||
| 104 | (/ (- (window-width) (length string)) 2))))) | ||
| 105 | (dotimes (i animate-n-steps) | ||
| 106 | ;; Bind buffer-undo-list so it will be unchanged when we are done. | ||
| 107 | ;; (We're going to undo all our changes anyway.) | ||
| 108 | (let (buffer-undo-list | ||
| 109 | list-to-undo) | ||
| 110 | ;; Display the characters at the Ith position. | ||
| 111 | ;; This inserts them in the buffer. | ||
| 112 | (animate-step characters (/ i 1.0 animate-n-steps)) | ||
| 113 | ;; Make sure buffer is displayed starting at the beginning. | ||
| 114 | (set-window-start nil 1) | ||
| 115 | ;; Display it, and wait just a little while. | ||
| 116 | (sit-for .05) | ||
| 117 | ;; Now undo the changes we made in the buffer. | ||
| 118 | (setq list-to-undo buffer-undo-list) | ||
| 119 | (while list-to-undo | ||
| 120 | (let ((undo-in-progress t)) | ||
| 121 | (setq list-to-undo (primitive-undo 1 list-to-undo)))))) | ||
| 122 | ;; Insert the characters in their final positions. | ||
| 123 | (animate-step characters 1) | ||
| 124 | ;; Put the cursor at the end of the text on the line. | ||
| 125 | (end-of-line) | ||
| 126 | ;; Redisplay so they appear on the screen there. | ||
| 127 | (sit-for 0) | ||
| 128 | ;; This is so that the undo command, used afterwards, | ||
| 129 | ;; will undo the "animate" calls one by one. | ||
| 130 | (undo-boundary))) | ||
| 131 | |||
| 132 | ;;;###autoload | ||
| 133 | (defun animate-birthday-present () | ||
| 134 | "Display Sarah's birthday present." | ||
| 135 | (interactive) | ||
| 136 | ;; Make a suitable buffer to display the birthday present in. | ||
| 137 | (switch-to-buffer (get-buffer-create "Sarah")) | ||
| 138 | (erase-buffer) | ||
| 139 | ;; Display the empty buffer. | ||
| 140 | (sit-for 0) | ||
| 141 | ;; Make sure indentation does not use tabs. | ||
| 142 | ;; They would confuse things. | ||
| 143 | (setq indent-tabs-mode nil) | ||
| 144 | |||
| 145 | (animate-string "Happy Birthday," 6) | ||
| 146 | (animate-string "Sarah" 7) | ||
| 147 | |||
| 148 | (sit-for 1) | ||
| 149 | |||
| 150 | (animate-string "You are my sunshine," 10 30) | ||
| 151 | (sit-for .5) | ||
| 152 | (animate-string "My only sunshine." 11 30) | ||
| 153 | (sit-for .5) | ||
| 154 | (animate-string "I'm awful sad that" 12 30) | ||
| 155 | (sit-for .5) | ||
| 156 | (animate-string "You've moved away." 13 30) | ||
| 157 | (sit-for .5) | ||
| 158 | (animate-string "Let's talk together" 15 30) | ||
| 159 | (sit-for .5) | ||
| 160 | (animate-string "And love more deeply." 16 30) | ||
| 161 | (sit-for .5) | ||
| 162 | (animate-string "Please bring back" 17 30) | ||
| 163 | (animate-string "my sunshine" 18 34) | ||
| 164 | (animate-string "to stay!" 19 34)) | ||
| 165 | |||
| 166 | ;;; animate.el ends here | ||
| 167 | |||