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
(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.
(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)))))
\f
(defun ruler-mode-mouse-add-tab-stop (start-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)
(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)
\f
(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