Function: artist-move-to-xy
artist-move-to-xy is a byte-compiled function defined in artist.el.gz.
Signature
(artist-move-to-xy X Y)
Documentation
Move to column X, at row Y from the top of buffer. Top line is 0.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/artist.el.gz
(defsubst artist-move-to-xy (x y)
"Move to column X, at row Y from the top of buffer. Top line is 0."
;;
;; Q: Why do we do forward-line twice?
;; A: The documentation for forward-line says
;;
;; "... Returns the count of lines left to move. ... With
;; positive N, a non-empty line at the end counts as one
;; line successfully moved (for the return value)."
;;
;; This means that if we are trying to move forward past the end
;; of the buffer, and that last line happened to be longer than
;; the current column, then we end up at the end of that last
;; line, and forward-line returns one less than we actually
;; wanted to move.
;;
;; Example: In the figure below, the `X' is the very last
;; character in the buffer ("a non-empty line at the
;; end"). Suppose point is at P. Then (forward-line 1)
;; returns 0 and puts point after the `X'.
;;
;; --------top of buffer--------
;;
;; P X
;; -------bottom of buffer------
;;
;; But, if we are at the end of buffer when trying to move
;; forward, then forward-line will return the (for us) correct
;; value, which is good, because we will come to the end of the
;; buffer by the first forward-line. The second forward-line
;; will then get us where we really wanted to go.
;;
;; If we are not moving past the end of the buffer, then the
;; second forward-line will return 0.
;;
;; Q: What happens if we are moving upwards?
;; A: That will work good. insert-char won't insert a negative
;; number of chars, and forward-line will fail silently if we are
;; moving past the beginning of the buffer.
;;
(forward-line (- y (artist-current-line)))
(insert-char ?\n (forward-line (- y (artist-current-line))))
(move-to-column (max x 0) t)
(let ((curr-y (artist-current-line)))
(setq artist-draw-region-min-y (min curr-y artist-draw-region-min-y))
(setq artist-draw-region-max-y (max curr-y artist-draw-region-max-y))))