Function: artist-down-mouse-1

artist-down-mouse-1 is an interactive and byte-compiled function defined in artist.el.gz.

Signature

(artist-down-mouse-1 EV)

Documentation

Perform drawing action for event EV.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/artist.el.gz
(defun artist-down-mouse-1 (ev)
  "Perform drawing action for event EV."
  (interactive "@e")
  (let* ((real (artist-go-get-symbol-shift
		artist-curr-go (artist-event-is-shifted ev)))
	 (draw-how (artist-go-get-draw-how-from-symbol real))
	 ;; Remember original values for draw-region-min-y and max-y
	 ;; in case we are interrupting a key-draw operation.
	 (orig-draw-region-min-y artist-draw-region-min-y)
	 (orig-draw-region-max-y artist-draw-region-max-y)
	 (orig-pointer-shape (if (eq window-system 'x) x-pointer-shape nil))
	 (echo-keystrokes 0)	; Don't echo unfinished commands.
	 ;; Remember original binding for the button-up event to this
	 ;; button-down event.
	 (key (artist-compute-up-event-key ev))
	 (orig-button-up-binding (lookup-key (current-global-map) key)))

    (unwind-protect
	(progn
	  (if (eq window-system 'x)
	      (artist-set-pointer-shape artist-pointer-shape))

	  ;; Redefine the button-up binding temporarily (the original
	  ;; binding is restored in the unwind-forms below). This is to
	  ;; avoid the phenomenon outlined in this scenario:
	  ;;
	  ;; 1. A routine which reads something from the mini-buffer (such
	  ;;    as the text renderer) is called from below.
	  ;; 2. Meanwhile, the users releases the mouse button.
	  ;; 3. As a (funny :-) coincidence, the binding for the
	  ;;    button-up event is often mouse-set-point, so Emacs
	  ;;    sets the point to where the button was released, which is
	  ;;    in the buffer where the user wants to place the text.
	  ;; 4. The user types C-x o (or uses the mouse once again)
	  ;;    until he reaches the mini-buffer which is still prompting
	  ;;    for some text to render.
	  ;;
	  ;; To do this foolproof, all local and minor-mode maps should
	  ;; be searched and temporarily changed as well, since they
	  ;; too might have some binding for the button-up event,
	  ;; but I hope dealing with the global map will suffice.
	  (define-key (current-global-map) key 'artist-do-nothing)

	  (artist-draw-region-reset)

	  (artist-mode-line-show-curr-operation t)

          (cond ((or (eq draw-how 'artist-do-continuously)
                     ;; Typo in Emacs 29 or earlier.
                     (eq draw-how 'artist-do-continously))
                 (artist-mouse-draw-continuously ev))
		((eq draw-how 'artist-do-poly)
		 (artist-mouse-draw-poly ev))
		((and (numberp draw-how) (= draw-how 1))
		 (artist-mouse-draw-1point ev))
		((and (numberp draw-how) (= draw-how 2))
		 (artist-mouse-draw-2points ev))
		(t (message "Drawing \"%s\"s is not yet implemented"
			    draw-how)))

	  (if artist-trim-line-endings
	      (artist-draw-region-trim-line-endings artist-draw-region-min-y
						    artist-draw-region-max-y))
	  (setq artist-draw-region-min-y orig-draw-region-min-y)
	  (setq artist-draw-region-max-y orig-draw-region-max-y))

      ; This is protected
      (if (eq window-system 'x)
	  (artist-set-pointer-shape orig-pointer-shape))

      (if orig-button-up-binding
	  (define-key (current-global-map) key orig-button-up-binding))

      (artist-mode-line-show-curr-operation artist-key-is-drawing))))