comparison lisp/ruler-mode.el @ 54401:7f6dab15e141

2004-03-15 David Ponce <david@dponce.com> * ruler-mode.el: (ruler-mode-left-fringe-cols) (ruler-mode-right-fringe-cols, ruler-mode-left-scroll-bar-cols) (ruler-mode-right-scroll-bar-cols): Remove. (ruler-mode-window-col, ruler-mode-mouse-set-left-margin) (ruler-mode-mouse-set-right-margin, ruler-mode-ruler): Use fringe-columns and scroll-bar-columns.
author Masatake YAMATO <jet@gyve.org>
date Mon, 15 Mar 2004 08:39:06 +0000
parents ad02f6299e9a
children aabf30299e6c
comparison
equal deleted inserted replaced
54400:a590d8b32ad7 54401:7f6dab15e141
297 :foreground "yellow" 297 :foreground "yellow"
298 ))) 298 )))
299 "Face used to highlight the `current-column' character." 299 "Face used to highlight the `current-column' character."
300 :group 'ruler-mode) 300 :group 'ruler-mode)
301 301
302 (defsubst ruler-mode-left-fringe-cols (&optional real)
303 "Return the width, measured in columns, of the left fringe area.
304 If optional argument REAL is non-nil, return a real floating point
305 number instead of a rounded integer value."
306 (fringe-columns 'left real))
307
308 (defsubst ruler-mode-right-fringe-cols (&optional real)
309 "Return the width, measured in columns, of the right fringe area.
310 If optional argument REAL is non-nil, return a real floating point
311 number instead of a rounded integer value."
312 (fringe-columns 'right real))
313
314 (defmacro ruler-mode-right-scroll-bar-cols ()
315 "Return the width, measured in columns, of the right vertical scrollbar."
316 '(scroll-bar-columns 'right))
317
318 (defmacro ruler-mode-left-scroll-bar-cols ()
319 "Return the width, measured in columns, of the left vertical scrollbar."
320 '(scroll-bar-columns 'left))
321 302
322 (defsubst ruler-mode-full-window-width () 303 (defsubst ruler-mode-full-window-width ()
323 "Return the full width of the selected window." 304 "Return the full width of the selected window."
324 (let ((edges (window-edges))) 305 (let ((edges (window-edges)))
325 (- (nth 2 edges) (nth 0 edges)))) 306 (- (nth 2 edges) (nth 0 edges))))
328 "Return a column number relative to the selected window. 309 "Return a column number relative to the selected window.
329 N is a column number relative to selected frame." 310 N is a column number relative to selected frame."
330 (- n 311 (- n
331 (car (window-edges)) 312 (car (window-edges))
332 (or (car (window-margins)) 0) 313 (or (car (window-margins)) 0)
333 (ruler-mode-left-fringe-cols) 314 (fringe-columns 'left)
334 (ruler-mode-left-scroll-bar-cols))) 315 (scroll-bar-columns 'left)))
335 316
336 (defun ruler-mode-mouse-set-left-margin (start-event) 317 (defun ruler-mode-mouse-set-left-margin (start-event)
337 "Set left margin end to the graduation where the mouse pointer is on. 318 "Set left margin end to the graduation where the mouse pointer is on.
338 START-EVENT is the mouse click event." 319 START-EVENT is the mouse click event."
339 (interactive "e") 320 (interactive "e")
342 col w lm rm) 323 col w lm rm)
343 (when (eq start end) ;; mouse click 324 (when (eq start end) ;; mouse click
344 (save-selected-window 325 (save-selected-window
345 (select-window (posn-window start)) 326 (select-window (posn-window start))
346 (setq col (- (car (posn-col-row start)) (car (window-edges)) 327 (setq col (- (car (posn-col-row start)) (car (window-edges))
347 (ruler-mode-left-scroll-bar-cols)) 328 (scroll-bar-columns 'left))
348 w (- (ruler-mode-full-window-width) 329 w (- (ruler-mode-full-window-width)
349 (ruler-mode-left-scroll-bar-cols) 330 (scroll-bar-columns 'left)
350 (ruler-mode-right-scroll-bar-cols))) 331 (scroll-bar-columns 'right)))
351 (when (and (>= col 0) (< col w)) 332 (when (and (>= col 0) (< col w))
352 (setq lm (window-margins) 333 (setq lm (window-margins)
353 rm (or (cdr lm) 0) 334 rm (or (cdr lm) 0)
354 lm (or (car lm) 0)) 335 lm (or (car lm) 0))
355 (message "Left margin set to %d (was %d)" col lm) 336 (message "Left margin set to %d (was %d)" col lm)
364 col w lm rm) 345 col w lm rm)
365 (when (eq start end) ;; mouse click 346 (when (eq start end) ;; mouse click
366 (save-selected-window 347 (save-selected-window
367 (select-window (posn-window start)) 348 (select-window (posn-window start))
368 (setq col (- (car (posn-col-row start)) (car (window-edges)) 349 (setq col (- (car (posn-col-row start)) (car (window-edges))
369 (ruler-mode-left-scroll-bar-cols)) 350 (scroll-bar-columns 'left))
370 w (- (ruler-mode-full-window-width) 351 w (- (ruler-mode-full-window-width)
371 (ruler-mode-left-scroll-bar-cols) 352 (scroll-bar-columns 'left)
372 (ruler-mode-right-scroll-bar-cols))) 353 (scroll-bar-columns 'right)))
373 (when (and (>= col 0) (< col w)) 354 (when (and (>= col 0) (< col w))
374 (setq lm (window-margins) 355 (setq lm (window-margins)
375 rm (or (cdr lm) 0) 356 rm (or (cdr lm) 0)
376 lm (or (car lm) 0) 357 lm (or (car lm) 0)
377 col (- w col 1)) 358 col (- w col 1))
647 (defun ruler-mode-ruler () 628 (defun ruler-mode-ruler ()
648 "Return a string ruler." 629 "Return a string ruler."
649 (when ruler-mode 630 (when ruler-mode
650 (let* ((w (window-width)) 631 (let* ((w (window-width))
651 (m (window-margins)) 632 (m (window-margins))
652 (lsb (ruler-mode-left-scroll-bar-cols)) 633 (lsb (scroll-bar-columns 'left))
653 (lf (ruler-mode-left-fringe-cols t)) 634 (lf (fringe-columns 'left t))
654 (lm (or (car m) 0)) 635 (lm (or (car m) 0))
655 (rsb (ruler-mode-right-scroll-bar-cols)) 636 (rsb (scroll-bar-columns 'right))
656 (rf (ruler-mode-right-fringe-cols t)) 637 (rf (fringe-columns 'right t))
657 (rm (or (cdr m) 0)) 638 (rm (or (cdr m) 0))
658 (ruler (make-string w ruler-mode-basic-graduation-char)) 639 (ruler (make-string w ruler-mode-basic-graduation-char))
659 (i 0) 640 (i 0)
660 (j (window-hscroll)) 641 (j (window-hscroll))
661 k c l1 l2 r2 r1 h1 h2 f1 f2) 642 k c l1 l2 r2 r1 h1 h2 f1 f2)