mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Fix ruler-mode text-scaling issues
* lisp/ruler-mode.el (ruler-mode-text-scaled-width): New function for computing scaled text width. (ruler-mode-text-scaled-window-hscroll) (ruler-mode-text-scaled-window-width): Compute text scaled `window-width' value. (ruler-mode-mouse-grab-any-column, ruler-mode-mouse-add-tab-stop) (ruler-mode-ruler): Change `window-hscroll' into `ruler-mode-text-scaled-window-hscroll', and change `window-width' into `ruler-mode-text-scaled-window-width'.
This commit is contained in:
parent
704fea97e4
commit
b0177da7fe
1 changed files with 24 additions and 10 deletions
|
|
@ -360,6 +360,20 @@ START-EVENT is the mouse click event."
|
|||
That is `fill-column', `comment-column', `goal-column', or nil when
|
||||
nothing is dragged.")
|
||||
|
||||
(defun ruler-mode-text-scaled-width (width)
|
||||
"Compute scaled text width according to current font scaling.
|
||||
Convert a width of char units into a text-scaled char width units,
|
||||
Ex. `window-hscroll'."
|
||||
(/ (* width (frame-char-width)) (default-font-width)))
|
||||
|
||||
(defun ruler-mode-text-scaled-window-hscroll ()
|
||||
"Text scaled `window-hscroll'."
|
||||
(ruler-mode-text-scaled-width (window-hscroll)))
|
||||
|
||||
(defun ruler-mode-text-scaled-window-width ()
|
||||
"Text scaled `window-width'."
|
||||
(ruler-mode-text-scaled-width (window-width)))
|
||||
|
||||
(defun ruler-mode-mouse-grab-any-column (start-event)
|
||||
"Drag a column symbol on the ruler.
|
||||
Start dragging on mouse down event START-EVENT, and update the column
|
||||
|
|
@ -372,9 +386,9 @@ dragging. See also the variable `ruler-mode-dragged-symbol'."
|
|||
(save-selected-window
|
||||
(select-window (posn-window start))
|
||||
(setq col (ruler-mode-window-col (car (posn-col-row start)))
|
||||
newc (+ col (window-hscroll)))
|
||||
newc (+ col (ruler-mode-text-scaled-window-hscroll)))
|
||||
(and
|
||||
(>= col 0) (< col (window-width))
|
||||
(>= col 0) (< col (ruler-mode-text-scaled-window-width))
|
||||
(cond
|
||||
|
||||
;; Handle the fill column.
|
||||
|
|
@ -457,8 +471,8 @@ Called on each mouse motion event START-EVENT."
|
|||
(save-selected-window
|
||||
(select-window (posn-window start))
|
||||
(setq col (ruler-mode-window-col (car (posn-col-row end)))
|
||||
newc (+ col (window-hscroll)))
|
||||
(when (and (>= col 0) (< col (window-width)))
|
||||
newc (+ col (ruler-mode-text-scaled-window-hscroll)))
|
||||
(when (and (>= col 0) (< col (ruler-mode-text-scaled-window-width)))
|
||||
(set ruler-mode-dragged-symbol newc)))))
|
||||
|
||||
(defun ruler-mode-mouse-add-tab-stop (start-event)
|
||||
|
|
@ -473,8 +487,8 @@ START-EVENT is the mouse click event."
|
|||
(save-selected-window
|
||||
(select-window (posn-window start))
|
||||
(setq col (ruler-mode-window-col (car (posn-col-row start)))
|
||||
ts (+ col (window-hscroll)))
|
||||
(and (>= col 0) (< col (window-width))
|
||||
ts (+ col (ruler-mode-text-scaled-window-hscroll)))
|
||||
(and (>= col 0) (< col (ruler-mode-text-scaled-window-width))
|
||||
(not (member ts tab-stop-list))
|
||||
(progn
|
||||
(message "Tab stop set to %d" ts)
|
||||
|
|
@ -494,8 +508,8 @@ START-EVENT is the mouse click event."
|
|||
(save-selected-window
|
||||
(select-window (posn-window start))
|
||||
(setq col (ruler-mode-window-col (car (posn-col-row start)))
|
||||
ts (+ col (window-hscroll)))
|
||||
(and (>= col 0) (< col (window-width))
|
||||
ts (+ col (ruler-mode-text-scaled-window-hscroll)))
|
||||
(and (>= col 0) (< col (ruler-mode-text-scaled-window-width))
|
||||
(member ts tab-stop-list)
|
||||
(progn
|
||||
(message "Tab stop at %d deleted" ts)
|
||||
|
|
@ -648,11 +662,11 @@ Optional argument PROPS specifies other text properties to apply."
|
|||
|
||||
(defun ruler-mode-ruler ()
|
||||
"Compute and return a header line ruler."
|
||||
(let* ((w (window-width))
|
||||
(let* ((w (ruler-mode-text-scaled-window-width))
|
||||
(m (window-margins))
|
||||
(f (window-fringes))
|
||||
(i 0)
|
||||
(j (window-hscroll))
|
||||
(j (ruler-mode-text-scaled-window-hscroll))
|
||||
;; Setup the scrollbar, fringes, and margins areas.
|
||||
(lf (ruler-mode-space
|
||||
'left-fringe
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue