Function: artist-mouse-draw-continuously

artist-mouse-draw-continuously is a byte-compiled function defined in artist.el.gz.

Signature

(artist-mouse-draw-continuously EV)

Documentation

Generic function for shapes that require 1 point as input.

Operation is done continuously while the mouse button is hold down. The event, EV, is the mouse event.

Aliases

artist-mouse-draw-continously (obsolete since 30.1)

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/artist.el.gz
(defun artist-mouse-draw-continuously (ev)
  "Generic function for shapes that require 1 point as input.
Operation is done continuously while the mouse button is hold down.
The event, EV, is the mouse event."
  (let* ((unshifted    (artist-go-get-symbol-shift artist-curr-go nil))
	 (shifted      (artist-go-get-symbol-shift artist-curr-go t))
	 (shift-state  (artist-event-is-shifted ev))
	 (op           (if shift-state shifted unshifted))
	 (draw-how     (artist-go-get-draw-how-from-symbol op))
	 (init-fn      (artist-go-get-init-fn-from-symbol op))
	 (prep-fill-fn (artist-go-get-prep-fill-fn-from-symbol op))
	 (exit-fn      (artist-go-get-exit-fn-from-symbol op))
	 (draw-fn      (artist-go-get-draw-fn-from-symbol op))
	 (interval-fn  (artist-go-get-interval-fn-from-symbol op))
	 (interval     (artist-funcall interval-fn))
	 (arrow-pred   (artist-go-get-arrow-pred-from-symbol op))
	 (arrow-set-fn (artist-go-get-arrow-set-fn-from-symbol op))
	 (ev-start     (event-start ev))
	 (initial-win  (posn-window ev-start))
	 (ev-start-pos (artist-coord-win-to-buf (posn-col-row ev-start t)))
	 (x1           (artist--adjust-x (car ev-start-pos)))
	 (y1           (cdr ev-start-pos))
	 (timer nil))
    (select-window (posn-window ev-start))
    (artist-funcall init-fn x1 y1)
    (if (not artist-rubber-banding)
	(artist-no-rb-set-point1 x1 y1))
    (unwind-protect
        (track-mouse
          ;; We don't want flickering of mouse pointer shape while we
          ;; drag the mouse.
          (setq track-mouse 'dragging)
          (while (or (mouse-movement-p ev)
                     (member 'down (event-modifiers ev)))
            (setq ev-start-pos (artist-coord-win-to-buf
                                (posn-col-row (event-start ev) t)))
            (setq x1 (artist--adjust-x (car ev-start-pos)))
            (setq y1 (cdr ev-start-pos))

            ;; Cancel previous timer
            (if timer
                (cancel-timer timer))

            (if (not (eq initial-win (posn-window (event-start ev))))
                ;; If we moved outside the window, do nothing
                nil

              ;; Still in same window:
              ;;
              ;; Check if user presses or releases shift key
              (if (artist-shift-has-changed shift-state ev)

                  ;; First check that the draw-how is the same as we
                  ;; already have. Otherwise, ignore the changed shift-state.
                  (if (not (eq draw-how
                               (artist-go-get-draw-how-from-symbol
                                (if (not shift-state) shifted unshifted))))
                      (message "Cannot switch to shifted operation")

                    ;; progn is "implicit" since this is the else-part
                    (setq shift-state (not shift-state))
                    (setq op          (if shift-state shifted unshifted))
                    (setq draw-how    (artist-go-get-draw-how-from-symbol op))
                    (setq draw-fn     (artist-go-get-draw-fn-from-symbol op))))

              ;; Draw the new shape
              (artist-funcall draw-fn x1 y1)
              (artist-move-to-xy x1 y1)

              ;; Start the timer to call `draw-fn' repeatedly every
              ;; `interval' second
              (if (and interval draw-fn)
                  (setq timer (run-at-time interval interval draw-fn x1 y1))))

            ;; Read next event
            (setq ev (read--potential-mouse-event))))
      ;; Cleanup: get rid of any active timer.
      (if timer
          (cancel-timer timer)))
    ;; Cancel any timers
    (if timer
	(cancel-timer timer))

    (artist-funcall prep-fill-fn x1 y1)

    (if (artist-funcall arrow-pred)
	(artist-funcall arrow-set-fn x1 y1)
      (artist-clear-arrow-points))

    (artist-funcall exit-fn x1 y1)
    (artist-move-to-xy x1 y1)))