]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/artist.el
Merge from trunk.
[gnu-emacs] / lisp / textmodes / artist.el
index 2325d7b26ffaa3c41dcc01ca9a308949d736f638..76d03dd164fc8ae98f3eb10b3c2351157be65bb3 100644 (file)
@@ -1,6 +1,6 @@
 ;;; artist.el --- draw ascii graphics with your mouse
 
-;; Copyright (C) 2000-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2000-2012  Free Software Foundation, Inc.
 
 ;; Author:       Tomas Abrahamsson <tab@lysator.liu.se>
 ;; Maintainer:   Tomas Abrahamsson <tab@lysator.liu.se>
@@ -349,7 +349,7 @@ Example:
 
 
 (defvar artist-pointer-shape (if (eq window-system 'x) x-pointer-crosshair nil)
-  "*If in X Windows, use this pointer shape while drawing with the mouse.")
+  "If in X Windows, use this pointer shape while drawing with the mouse.")
 
 
 (defcustom artist-text-renderer-function 'artist-figlet
@@ -397,13 +397,13 @@ Example:
   ;; This is a defvar, not a defcustom, since the custom
   ;; package shows lists of characters as a lists of integers,
   ;; which is confusing
-  "*Characters (``color'') to use when spraying.
+  "Characters (``color'') to use when spraying.
 They should be ordered from the ``lightest'' to the ``heaviest''
 since spraying replaces a light character with the next heavier one.")
 
 
 (defvar artist-spray-new-char ?.
-  "*Initial character to use when spraying.
+  "Initial character to use when spraying.
 This character is used if spraying upon a character that is not in
 `artist-spray-chars'.  The character defined by this variable should
 be in `artist-spray-chars', or spraying will behave strangely.")
@@ -535,7 +535,8 @@ This variable is initialized by the `artist-make-prev-next-op-alist' function.")
                  ("Text" artist-select-op-text-overwrite text-ovwrt)
                  ("Ellipse" artist-select-op-circle circle)
                  ("Poly-line" artist-select-op-straight-poly-line spolyline)
-                 ("Rectangle" artist-select-op-square square)
+                 ("Square" artist-select-op-square square)
+                 ("Rectangle" artist-select-op-rectangle rectangle)
                  ("Line" artist-select-op-straight-line s-line)
                  ("Pen" artist-select-op-pen-line pen-line)))
       (define-key map (vector (nth 2 op))
@@ -1196,9 +1197,9 @@ PREV-OP-ARG are used when invoked recursively during the build-up."
 ;;; ---------------------------------
 
 ;;;###autoload
-(defun artist-mode (&optional state)
+(define-minor-mode artist-mode
   "Toggle Artist mode.
-With argument STATE, turn Artist mode on if STATE is positive.
+With argument ARG, turn Artist mode on if ARG is positive.
 Artist lets you draw lines, squares, rectangles and poly-lines,
 ellipses and circles with your mouse and/or keyboard.
 
@@ -1387,36 +1388,24 @@ Variables
 
 Hooks
 
- When entering artist-mode, the hook `artist-mode-init-hook' is called.
- When quitting artist-mode, the hook `artist-mode-exit-hook' is called.
+ Turning the mode on or off runs `artist-mode-hook'.
 
 
 Keymap summary
 
 \\{artist-mode-map}"
-  (interactive)
-  (if (setq artist-mode
-           (if (null state) (not artist-mode)
-             (> (prefix-numeric-value state) 0)))
-      (artist-mode-init)
-    (artist-mode-exit)))
-
-;; insert our minor mode string
-(or (assq 'artist-mode minor-mode-alist)
-    (setq minor-mode-alist
-         (cons '(artist-mode artist-mode-name)
-               minor-mode-alist)))
-
-;; insert our minor mode keymap
-(or (assq 'artist-mode minor-mode-map-alist)
-    (setq minor-mode-map-alist
-         (cons (cons 'artist-mode artist-mode-map)
-               minor-mode-map-alist)))
-
+  :init-value nil :group 'artist :lighter artist-mode-name
+  :keymap artist-mode-map
+  (cond ((null artist-mode)
+        ;; Turn mode off
+        (artist-mode-exit))
+       (t
+        ;; Turn mode on
+        (artist-mode-init))))
 
 ;; Init and exit
 (defun artist-mode-init ()
-  "Init Artist mode.  This will call the hook `artist-mode-init-hook'."
+  "Init Artist mode.  This will call the hook `artist-mode-hook'."
   ;; Set up a conversion table for mapping tabs and new-lines to spaces.
   ;; the last case, 0, is for the last position in buffer/region, where
   ;; the `following-char' function returns 0.
@@ -1458,15 +1447,13 @@ Keymap summary
       (progn
        (picture-mode)
        (message "")))
-  (run-hooks 'artist-mode-init-hook)
   (artist-mode-line-show-curr-operation artist-key-is-drawing))
 
 (defun artist-mode-exit ()
-  "Exit Artist mode.  This will call the hook `artist-mode-exit-hook'."
+  "Exit Artist mode.  This will call the hook `artist-mode-hook'."
   (if (and artist-picture-compatibility (eq major-mode 'picture-mode))
       (picture-mode-exit))
-  (kill-local-variable 'next-line-add-newlines)
-  (run-hooks 'artist-mode-exit-hook))
+  (kill-local-variable 'next-line-add-newlines))
 
 (defun artist-mode-off ()
   "Turn Artist mode off."
@@ -1985,7 +1972,7 @@ Also updates the variables `artist-draw-min-y' and `artist-draw-max-y'."
   "Retrieve a replacement for character C from `artist-replacement-table'.
 The replacement is used to convert tabs and new-lines to spaces."
   ;; Characters may be outside the range of the `artist-replacement-table',
-  ;; for example if they are unicode code points >= 256.
+  ;; for example if they are Unicode code points >= 256.
   ;; Check so we don't attempt to access the array out of its bounds,
   ;; assuming no such character needs to be replaced.
   (if (< c (length artist-replacement-table))
@@ -2263,7 +2250,7 @@ Returns a DIRECTION, a number 0--7, coded as follows:
 
 
 ;; Things for drawing lines in all directions.
-;; The line drawing engine is the eight-point alrogithm.
+;; The line drawing engine is the eight-point algorithm.
 ;;
 ;; A line is here a list of (x y saved-char new-char)s.
 ;;
@@ -2338,7 +2325,7 @@ Octant are numbered 1--8, anti-clockwise as:
          5
        6))))
 
-;; Some inline funtions for creating, setting and reading
+;; Some inline functions for creating, setting and reading
 ;; members of a coordinate
 ;;
 
@@ -2437,7 +2424,7 @@ in the coord."
     point-list))
 
 ;; artist-save-chars-under-point-list
-;; Remebers the chars that were there before we did draw the line.
+;; Remembers the chars that were there before we did draw the line.
 ;; Returns point-list.
 ;;
 (defun artist-save-chars-under-point-list (point-list)
@@ -2514,7 +2501,7 @@ This function returns a point-list."
 
 
 ;;
-;; functions for accessing endoints and elements in object requiring
+;; functions for accessing endpoints and elements in object requiring
 ;; 2 endpoints
 ;;
 
@@ -3215,7 +3202,7 @@ X1, Y1.  An endpoint is a cons pair, (ENDPOINT-X . ENDPOINT-Y)."
 ;;         2|     |
 ;;         3+-----+
 ;;
-;;   We will then pop (0,0) and remove the left-most vertival line while
+;;   We will then pop (0,0) and remove the left-most vertical line while
 ;;   pushing the lower left corner (0,3) on the stack, and so on until
 ;;   the entire rectangle is vaporized.
 ;;
@@ -3582,7 +3569,7 @@ FILL-INFO is a list of vectors on the form [X Y ELLIPSE-WIDTH-ON-THIS-LINE]."
          (width (abs (- x2 x1)))
         (height (abs (- y2 y1)))
         ;; When drawing our circle, we want it to through the cursor
-        ;; just as when drawing the ellispe, but we have to take
+        ;; just as when drawing the ellipse, but we have to take
         ;; care for the aspect-ratio.
         ;; The equation for the ellipse  (where a is the x-radius and
         ;; b is the y-radius):
@@ -3960,11 +3947,11 @@ The 2-point shape SHAPE is drawn from X1, Y1 to X2, Y2."
 ;; Implementation note: This really should honor the interval-fn entry
 ;; in the master table, `artist-mt', which would mean leaving a timer
 ;; that calls `draw-fn' every now and then. That timer would then have
-;; to be cancelled and reinstalled whenever the user moves the cursor.
+;; to be canceled and reinstalled whenever the user moves the cursor.
 ;; This could be done, but what if the user suddenly switches to another
 ;; drawing mode, or even kills the buffer! In the mouse case, it is much
 ;; simpler: when at the end of `artist-mouse-draw-continously', the
-;; user has released the button, so the timer will always be cancelled
+;; user has released the button, so the timer will always be canceled
 ;; at that point.
 (defun artist-key-draw-continously (x y)
   "Draw current continuous shape at X,Y."
@@ -4455,7 +4442,7 @@ If N is negative, move backward."
   "Set current fill character to be C."
   (interactive "cType fill char (type RET to turn off): ")
   (cond ((eq c ?\r) (setq artist-fill-char-set nil)
-                   (message "Fill cancelled"))
+                   (message "Fill canceled"))
        (t          (setq artist-fill-char-set t)
                    (setq artist-fill-char c)
                    (message "Fill set to \"%c\"" c))))
@@ -5589,7 +5576,7 @@ The event, EV, is the mouse event."
 ;;         of drawing mode.
 ;;
 ;;         You should provide these functions. You might think that
-;;         only you is using your type of mode, so noone will be able
+;;         only you is using your type of mode, so no one will be able
 ;;         to switch to another operation of the same type of mode,
 ;;         but someone else might base a new drawing mode upon your
 ;;         work.