diff options
| author | Thien-Thi Nguyen | 2004-12-17 11:48:56 +0000 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2004-12-17 11:48:56 +0000 |
| commit | e3fa1c11789420e6a72b7d34c85867ae91317b56 (patch) | |
| tree | 427e6949ca5a240c4a82f5e454ca32f1df591134 | |
| parent | a296137853e34c0d27e3a8720f0d57783ef353ee (diff) | |
| download | emacs-e3fa1c11789420e6a72b7d34c85867ae91317b56.tar.gz emacs-e3fa1c11789420e6a72b7d34c85867ae91317b56.zip | |
(zone): Init `line-spacing' from orig buffer.
(zone-replace-char): Take `count' and `del-count'
instead of `direction'. Update callers. When `del-count' is
non-nil, delete that many characters, otherwise `count' characters
backwards. Insert the newly-replaced string `count' times.
(zone-fret): Handle chars w/ width greater than one.
(zone-fall-through-ws): No longer take window width `ww'.
Update callers. Add handling for `char-width' greater than one.
(zone-pgm-drip): Update var holding window-end position every cycle.
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/play/zone.el | 51 |
2 files changed, 43 insertions, 20 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 03651cf32c2..7e19ddff5d7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2004-12-17 Thien-Thi Nguyen <ttn@gnu.org> | ||
| 2 | |||
| 3 | * play/zone.el (zone): Init `line-spacing' from orig buffer. | ||
| 4 | (zone-replace-char): Take `count' and `del-count' | ||
| 5 | instead of `direction'. Update callers. When `del-count' is | ||
| 6 | non-nil, delete that many characters, otherwise `count' characters | ||
| 7 | backwards. Insert the newly-replaced string `count' times. | ||
| 8 | (zone-fret): Handle chars w/ width greater than one. | ||
| 9 | (zone-fall-through-ws): No longer take window width `ww'. | ||
| 10 | Update callers. Add handling for `char-width' greater than one. | ||
| 11 | (zone-pgm-drip): Update var holding window-end position every cycle. | ||
| 12 | |||
| 1 | 2004-12-17 Andre Spiegel <spiegel@gnu.org> | 13 | 2004-12-17 Andre Spiegel <spiegel@gnu.org> |
| 2 | 14 | ||
| 3 | * vc.el (vc-default-update-changelog): Use insert-file-contents, | 15 | * vc.el (vc-default-update-changelog): Use insert-file-contents, |
diff --git a/lisp/play/zone.el b/lisp/play/zone.el index 6aa746c040c..9fc4ad6bf89 100644 --- a/lisp/play/zone.el +++ b/lisp/play/zone.el | |||
| @@ -146,7 +146,8 @@ If the element is a function or a list of a function and a number, | |||
| 146 | (erase-buffer) | 146 | (erase-buffer) |
| 147 | (setq buffer-undo-list t | 147 | (setq buffer-undo-list t |
| 148 | truncate-lines t | 148 | truncate-lines t |
| 149 | tab-width (zone-orig tab-width)) | 149 | tab-width (zone-orig tab-width) |
| 150 | line-spacing (zone-orig line-spacing)) | ||
| 150 | (insert text) | 151 | (insert text) |
| 151 | (untabify (point-min) (point-max)) | 152 | (untabify (point-min) (point-max)) |
| 152 | (set-window-start (selected-window) (point-min)) | 153 | (set-window-start (selected-window) (point-min)) |
| @@ -446,10 +447,10 @@ If the element is a function or a list of a function and a number, | |||
| 446 | (defsubst zone-cpos (pos) | 447 | (defsubst zone-cpos (pos) |
| 447 | (buffer-substring pos (1+ pos))) | 448 | (buffer-substring pos (1+ pos))) |
| 448 | 449 | ||
| 449 | (defsubst zone-replace-char (direction char-as-string new-value) | 450 | (defsubst zone-replace-char (count del-count char-as-string new-value) |
| 450 | (delete-char direction) | 451 | (delete-char (or del-count (- count))) |
| 451 | (aset char-as-string 0 new-value) | 452 | (aset char-as-string 0 new-value) |
| 452 | (insert char-as-string)) | 453 | (dotimes (i count) (insert char-as-string))) |
| 453 | 454 | ||
| 454 | (defsubst zone-park/sit-for (pos seconds) | 455 | (defsubst zone-park/sit-for (pos seconds) |
| 455 | (let ((p (point))) | 456 | (let ((p (point))) |
| @@ -460,10 +461,11 @@ If the element is a function or a list of a function and a number, | |||
| 460 | (defun zone-fret (wbeg pos) | 461 | (defun zone-fret (wbeg pos) |
| 461 | (let* ((case-fold-search nil) | 462 | (let* ((case-fold-search nil) |
| 462 | (c-string (zone-cpos pos)) | 463 | (c-string (zone-cpos pos)) |
| 464 | (cw-ceil (ceiling (char-width (aref c-string 0)))) | ||
| 463 | (hmm (cond | 465 | (hmm (cond |
| 464 | ((string-match "[a-z]" c-string) (upcase c-string)) | 466 | ((string-match "[a-z]" c-string) (upcase c-string)) |
| 465 | ((string-match "[A-Z]" c-string) (downcase c-string)) | 467 | ((string-match "[A-Z]" c-string) (downcase c-string)) |
| 466 | (t " ")))) | 468 | (t (propertize " " 'display `(space :width ,cw-ceil)))))) |
| 467 | (do ((i 0 (1+ i)) | 469 | (do ((i 0 (1+ i)) |
| 468 | (wait 0.5 (* wait 0.8))) | 470 | (wait 0.5 (* wait 0.8))) |
| 469 | ((= i 20)) | 471 | ((= i 20)) |
| @@ -496,16 +498,25 @@ If the element is a function or a list of a function and a number, | |||
| 496 | (recenter 0) | 498 | (recenter 0) |
| 497 | (sit-for 0))) | 499 | (sit-for 0))) |
| 498 | 500 | ||
| 499 | (defun zone-fall-through-ws (c ww wbeg wend) | 501 | (defun zone-fall-through-ws (c wbeg wend) |
| 500 | (let ((fall-p nil) ; todo: move outward | 502 | (let* ((cw-ceil (ceiling (char-width (aref c 0)))) |
| 501 | (wait 0.15)) | 503 | (spaces (make-string cw-ceil 32)) |
| 502 | (while (when (= 32 (char-after (+ (point) ww 1))) | 504 | (col (current-column)) |
| 505 | (wait 0.15) | ||
| 506 | newpos fall-p) | ||
| 507 | (while (when (save-excursion | ||
| 508 | (next-line 1) | ||
| 509 | (and (= col (current-column)) | ||
| 510 | (setq newpos (point)) | ||
| 511 | (string= spaces (buffer-substring-no-properties | ||
| 512 | newpos (+ newpos cw-ceil))) | ||
| 513 | (setq newpos (+ newpos (1- cw-ceil))))) | ||
| 503 | (setq fall-p t) | 514 | (setq fall-p t) |
| 504 | (delete-char 1) | 515 | (delete-char 1) |
| 505 | (insert " ") | 516 | (insert spaces) |
| 506 | (forward-char ww) | 517 | (goto-char newpos) |
| 507 | (when (< (point) wend) | 518 | (when (< (point) wend) |
| 508 | (delete-char 1) | 519 | (delete-char cw-ceil) |
| 509 | (insert c) | 520 | (insert c) |
| 510 | (forward-char -1) | 521 | (forward-char -1) |
| 511 | (zone-park/sit-for wbeg (setq wait (* wait 0.8)))))) | 522 | (zone-park/sit-for wbeg (setq wait (* wait 0.8)))))) |
| @@ -523,7 +534,7 @@ If the element is a function or a list of a function and a number, | |||
| 523 | wend (window-end)) | 534 | wend (window-end)) |
| 524 | (catch 'done | 535 | (catch 'done |
| 525 | (while (not (input-pending-p)) | 536 | (while (not (input-pending-p)) |
| 526 | (setq mc 0) | 537 | (setq mc 0 wend (window-end)) |
| 527 | ;; select non-ws character, but don't miss too much | 538 | ;; select non-ws character, but don't miss too much |
| 528 | (goto-char (+ wbeg (random (- wend wbeg)))) | 539 | (goto-char (+ wbeg (random (- wend wbeg)))) |
| 529 | (while (looking-at "[ \n\f]") | 540 | (while (looking-at "[ \n\f]") |
| @@ -535,17 +546,16 @@ If the element is a function or a list of a function and a number, | |||
| 535 | (when fret-p (zone-fret wbeg p)) | 546 | (when fret-p (zone-fret wbeg p)) |
| 536 | (goto-char p) | 547 | (goto-char p) |
| 537 | (setq c (zone-cpos p) | 548 | (setq c (zone-cpos p) |
| 538 | fall-p (zone-fall-through-ws c ww wbeg wend))) | 549 | fall-p (zone-fall-through-ws c wbeg wend))) |
| 539 | ;; assuming current-column has not changed... | 550 | ;; assuming current-column has not changed... |
| 540 | (when (and pancake-p | 551 | (when (and pancake-p |
| 541 | fall-p | 552 | fall-p |
| 542 | (< (count-lines (point-min) (point)) | 553 | (< (count-lines (point-min) (point)) |
| 543 | wh)) | 554 | wh)) |
| 544 | (zone-replace-char 1 c ?@) | 555 | (let ((cw (ceiling (char-width (aref c 0))))) |
| 545 | (zone-park/sit-for wbeg 0.137) | 556 | (zone-replace-char cw 1 c ?@) (zone-park/sit-for wbeg 0.137) |
| 546 | (zone-replace-char -1 c ?*) | 557 | (zone-replace-char cw nil c ?*) (zone-park/sit-for wbeg 0.137) |
| 547 | (zone-park/sit-for wbeg 0.137) | 558 | (zone-replace-char cw nil c ?_))))))) |
| 548 | (zone-replace-char -1 c ?_)))))) | ||
| 549 | 559 | ||
| 550 | (defun zone-pgm-drip-fretfully () | 560 | (defun zone-pgm-drip-fretfully () |
| 551 | (zone-pgm-drip t)) | 561 | (zone-pgm-drip t)) |
| @@ -652,7 +662,8 @@ If nil, `zone-pgm-random-life' chooses a value from 0-3 (inclusive).") | |||
| 652 | (setq s (zone-cpos (point)) | 662 | (setq s (zone-cpos (point)) |
| 653 | c (aref s 0)) | 663 | c (aref s 0)) |
| 654 | (zone-replace-char | 664 | (zone-replace-char |
| 655 | 1 s (cond ((or (> top (point)) | 665 | (char-width c) |
| 666 | t s (cond ((or (> top (point)) | ||
| 656 | (< bot (point)) | 667 | (< bot (point)) |
| 657 | (or (> 11 (setq col (current-column))) | 668 | (or (> 11 (setq col (current-column))) |
| 658 | (< rtc col))) | 669 | (< rtc col))) |