summaryrefslogtreecommitdiff
path: root/lisp/textmodes/artist.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2020-10-07 05:23:26 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2020-10-07 05:23:26 +0200
commitc842bd993f343d5dce1fe51fd72cb9aa345eef99 (patch)
tree1cedfd24091ce27b49d65afa51b1c2b8e4d4032b /lisp/textmodes/artist.el
parent95c7aa96af9f5f92d69bb856be8632e4a1ca15f2 (diff)
downloademacs-c842bd993f343d5dce1fe51fd72cb9aa345eef99.tar.gz
Make artist-mode work when display-line-numbers-mode is on
* lisp/textmodes/artist.el (artist--adjust-x): New function. (artist-mouse-draw-continously, artist-mouse-draw-poly) (artist-mouse-draw-1point, artist-mouse-draw-2points): Use it to take `display-line-numbers-mode' widths into account.
Diffstat (limited to 'lisp/textmodes/artist.el')
-rw-r--r--lisp/textmodes/artist.el22
1 files changed, 14 insertions, 8 deletions
diff --git a/lisp/textmodes/artist.el b/lisp/textmodes/artist.el
index 80682883c85..7196692001e 100644
--- a/lisp/textmodes/artist.el
+++ b/lisp/textmodes/artist.el
@@ -4943,6 +4943,12 @@ If optional argument STATE is positive, turn borders on."
(cons (+ window-x window-start-x)
(+ window-y window-start-y))))
+(defun artist--adjust-x (x)
+ "Adjust the X position wrt. `display-line-numbers-mode'."
+ (let ((adjust (line-number-display-width)))
+ (if (= adjust 0)
+ x
+ (- x adjust 2))))
(defun artist-mouse-draw-continously (ev)
"Generic function for shapes that require 1 point as input.
@@ -4964,7 +4970,7 @@ The event, EV, is the mouse event."
(ev-start (event-start ev))
(initial-win (posn-window ev-start))
(ev-start-pos (artist-coord-win-to-buf (posn-col-row ev-start)))
- (x1 (car ev-start-pos))
+ (x1 (artist--adjust-x (car ev-start-pos)))
(y1 (cdr ev-start-pos))
(shape)
(timer))
@@ -4981,7 +4987,7 @@ The event, EV, is the mouse event."
(member 'down (event-modifiers ev)))
(setq ev-start-pos (artist-coord-win-to-buf
(posn-col-row (event-start ev))))
- (setq x1 (car ev-start-pos))
+ (setq x1 (artist--adjust-x (car ev-start-pos)))
(setq y1 (cdr ev-start-pos))
;; Cancel previous timer
@@ -5061,7 +5067,7 @@ The event, EV, is the mouse event."
(ev-start (event-start ev))
(initial-win (posn-window ev-start))
(ev-start-pos (artist-coord-win-to-buf (posn-col-row ev-start)))
- (x1-last (car ev-start-pos))
+ (x1-last (artist--adjust-x (car ev-start-pos)))
(y1-last (cdr ev-start-pos))
(x2 x1-last)
(y2 y1-last)
@@ -5153,7 +5159,7 @@ The event, EV, is the mouse event."
;;
(setq ev-start-pos (artist-coord-win-to-buf
(posn-col-row (event-start ev))))
- (setq x2 (car ev-start-pos))
+ (setq x2 (artist--adjust-x (car ev-start-pos)))
(setq y2 (cdr ev-start-pos))
;; Draw the new shape (if not rubber-banding, place both marks)
@@ -5180,7 +5186,7 @@ The event, EV, is the mouse event."
;; set x2 and y2
(setq ev-start-pos (artist-coord-win-to-buf
(posn-col-row (event-start ev))))
- (setq x2 (car ev-start-pos))
+ (setq x2 (artist--adjust-x (car ev-start-pos)))
(setq y2 (cdr ev-start-pos))
;; First undraw last shape
@@ -5265,7 +5271,7 @@ Operation is done once. The event, EV, is the mouse event."
(arrow-set-fn (artist-go-get-arrow-set-fn-from-symbol op))
(ev-start (event-start ev))
(ev-start-pos (artist-coord-win-to-buf (posn-col-row ev-start)))
- (x1 (car ev-start-pos))
+ (x1 (artist--adjust-x (car ev-start-pos)))
(y1 (cdr ev-start-pos)))
(select-window (posn-window ev-start))
(artist-funcall init-fn x1 y1)
@@ -5299,7 +5305,7 @@ The event, EV, is the mouse event."
(ev-start (event-start ev))
(initial-win (posn-window ev-start))
(ev-start-pos (artist-coord-win-to-buf (posn-col-row ev-start)))
- (x1 (car ev-start-pos))
+ (x1 (artist--adjust-x (car ev-start-pos)))
(y1 (cdr ev-start-pos))
(x2)
(y2)
@@ -5313,7 +5319,7 @@ The event, EV, is the mouse event."
(member 'down (event-modifiers ev)))
(setq ev-start-pos (artist-coord-win-to-buf
(posn-col-row (event-start ev))))
- (setq x2 (car ev-start-pos))
+ (setq x2 (artist--adjust-x (car ev-start-pos)))
(setq y2 (cdr ev-start-pos))
(if (not (eq initial-win (posn-window (event-start ev))))