Commit 1805b4cc authored by Juri Linkov's avatar Juri Linkov

* lisp/image.el: Mouse-wheel scaling on images (bug#38187)

* lisp/image.el (image-mouse-increase-size)
(image-mouse-decrease-size): New commands.
(image-map): Bind C-wheel-down and C-mouse-5 to
image-mouse-decrease-size, C-wheel-up and C-mouse-4 to
image-mouse-increase-size.
parent 9ca40c4e
......@@ -158,6 +158,10 @@ or \"ffmpeg\") is installed."
(let ((map (make-sparse-keymap)))
(define-key map "-" 'image-decrease-size)
(define-key map "+" 'image-increase-size)
(define-key map [C-wheel-down] 'image-mouse-decrease-size)
(define-key map [C-mouse-5] 'image-mouse-decrease-size)
(define-key map [C-wheel-up] 'image-mouse-increase-size)
(define-key map [C-mouse-4] 'image-mouse-increase-size)
(define-key map "r" 'image-rotate)
(define-key map "o" 'image-save)
map))
......@@ -1007,24 +1011,40 @@ has no effect."
(imagemagick-register-types)
(defun image-increase-size (n)
(defun image-increase-size (&optional n)
"Increase the image size by a factor of N.
If N is 3, then the image size will be increased by 30%. The
default is 20%."
(interactive "P")
(image--change-size (if n
(1+ (/ n 10.0))
(1+ (/ (prefix-numeric-value n) 10.0))
1.2)))
(defun image-decrease-size (n)
(defun image-decrease-size (&optional n)
"Decrease the image size by a factor of N.
If N is 3, then the image size will be decreased by 30%. The
default is 20%."
(interactive "P")
(image--change-size (if n
(- 1 (/ n 10.0))
(- 1 (/ (prefix-numeric-value n) 10.0))
0.8)))
(defun image-mouse-increase-size (&optional event)
"Increase the image size using the mouse."
(interactive "e")
(when (listp event)
(save-window-excursion
(posn-set-point (event-start event))
(image-increase-size))))
(defun image-mouse-decrease-size (&optional event)
"Decrease the image size using the mouse."
(interactive "e")
(when (listp event)
(save-window-excursion
(posn-set-point (event-start event))
(image-decrease-size))))
(defun image--get-image ()
"Return the image at point."
(let ((image (get-char-property (point) 'display)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment