emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ruler-mode is broken


From: David Ponce
Subject: Re: ruler-mode is broken
Date: Fri, 10 Oct 2003 20:28:15 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6a) Gecko/20031008

> So it seems best that the ruler-mode-*-scroll-bar-cols function use
> columns times the character width (2 * 11), not the width of the
> scrollbar in pixels (16).

This is what the current implementation already do.  Or I am missing
something?

Is the following patch better?

Thanks!
David

Index: lisp/ruler-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ruler-mode.el,v
retrieving revision 1.16
diff -c -r1.16 ruler-mode.el
*** lisp/ruler-mode.el  4 Sep 2003 16:23:25 -0000       1.16
--- lisp/ruler-mode.el  10 Oct 2003 18:17:48 -0000
***************
*** 294,342 ****
    "Face used to highlight the `current-column' character."
    :group 'ruler-mode)
  
! (defmacro ruler-mode-left-fringe-cols ()
    "Return the width, measured in columns, of the left fringe area."
!   '(ceiling (or (car (window-fringes)) 0)
!             (frame-char-width)))

! (defmacro ruler-mode-right-fringe-cols ()
    "Return the width, measured in columns, of the right fringe area."
!   '(ceiling (or (nth 1 (window-fringes)) 0)
!             (frame-char-width)))
!
! (defun ruler-mode-left-scroll-bar-cols ()
!   "Return the width, measured in columns, of the right vertical scrollbar."
    (let* ((wsb   (window-scroll-bars))
           (vtype (nth 2 wsb))
           (cols  (nth 1 wsb)))
!     (if (or (eq vtype 'left)
!             (and (eq vtype t)
!                  (eq (frame-parameter nil 'vertical-scroll-bars) 'left)))
!         (or cols
!             (ceiling
!              ;; nil means it's a non-toolkit scroll bar,
!              ;; and its width in columns is 14 pixels rounded up.
!              (or (frame-parameter nil 'scroll-bar-width) 14)
!              ;; Always round up to multiple of columns.
!              (frame-char-width)))
!       0)))

! (defun ruler-mode-right-scroll-bar-cols ()
    "Return the width, measured in columns, of the right vertical scrollbar."
!   (let* ((wsb   (window-scroll-bars))
!          (vtype (nth 2 wsb))
!          (cols  (nth 1 wsb)))
!     (if (or (eq vtype 'right)
!             (and (eq vtype t)
!                  (eq (frame-parameter nil 'vertical-scroll-bars) 'right)))
!         (or cols
!             (ceiling
!              ;; nil means it's a non-toolkit scroll bar,
!              ;; and its width in columns is 14 pixels rounded up.
!              (or (frame-parameter nil 'scroll-bar-width) 14)
!              ;; Always round up to multiple of columns.
!              (frame-char-width)))
!       0)))

  (defsubst ruler-mode-full-window-width ()
    "Return the full width of the selected window."
--- 294,335 ----
    "Face used to highlight the `current-column' character."
    :group 'ruler-mode)
  
! (defsubst ruler-mode-left-fringe-cols (&optional absolute)
    "Return the width, measured in columns, of the left fringe area."
!   (funcall (if absolute '/ 'ceiling)
!            (or (car (window-fringes)) 0)
!            (float (frame-char-width))))

! (defsubst ruler-mode-right-fringe-cols (&optional absolute)
    "Return the width, measured in columns, of the right fringe area."
!   (funcall (if absolute '/ 'ceiling)
!             (or (nth 1 (window-fringes)) 0)
!             (float (frame-char-width))))
!
! (defun ruler-mode-scroll-bar-cols (side)
!   "Return the width, measured in columns, of the vertical scrollbar on SIDE.
! SIDE must be the symbol `left' or `right'."
    (let* ((wsb   (window-scroll-bars))
           (vtype (nth 2 wsb))
           (cols  (nth 1 wsb)))
!     (cond
!      ((not (memq side '(left right)))
!       (error "`left' or `right' expected instead of %S" side))
!      ((and (eq vtype side) cols))
!      ((eq (frame-parameter nil 'vertical-scroll-bars) side)
!       ;; nil means it's a non-toolkit scroll bar, and its width in
!       ;; columns is 14 pixels rounded up.
!       (ceiling (or (frame-parameter nil 'scroll-bar-width) 14)
!                (frame-char-width)))
!      (0))))

! (defmacro ruler-mode-right-scroll-bar-cols ()
    "Return the width, measured in columns, of the right vertical scrollbar."
!   '(ruler-mode-scroll-bar-cols 'right))
!
! (defmacro ruler-mode-left-scroll-bar-cols ()
!   "Return the width, measured in columns, of the left vertical scrollbar."
!   '(ruler-mode-scroll-bar-cols 'left))

  (defsubst ruler-mode-full-window-width ()
    "Return the full width of the selected window."
***************
*** 647,669 ****
  (defconst ruler-mode-fringe-help-echo
    "%s fringe %S"
    "Help string shown when mouse is over a fringe area.")
  
  (defun ruler-mode-ruler ()
    "Return a string ruler."
    (when ruler-mode
!     (let* ((fullw (ruler-mode-full-window-width))
             (w     (window-width))
             (m     (window-margins))
             (lsb   (ruler-mode-left-scroll-bar-cols))
!            (lf    (ruler-mode-left-fringe-cols))
             (lm    (or (car m) 0))
             (rsb   (ruler-mode-right-scroll-bar-cols))
!            (rf    (ruler-mode-right-fringe-cols))
             (rm    (or (cdr m) 0))
             (ruler (make-string fullw ruler-mode-basic-graduation-char))
             (o     (+ lsb lf lm))
             (x     0)
!            (i     o)
             (j     (window-hscroll))
             k c l1 l2 r2 r1 h1 h2 f1 f2)

--- 640,670 ----
  (defconst ruler-mode-fringe-help-echo
    "%s fringe %S"
    "Help string shown when mouse is over a fringe area.")
+
+ (defsubst ruler-mode-space (char width &rest props)
+   (if (> width 0)
+       ;; Seems that char is always displayed as space when uing the display 
:width property!
+       (apply 'propertize (char-to-string char)
+              'display (list 'space :width width)
+              props)
+     ""))
  
  (defun ruler-mode-ruler ()
    "Return a string ruler."
    (when ruler-mode
!     (let* ((fullw (window-width)) ;;(ruler-mode-full-window-width))
             (w     (window-width))
             (m     (window-margins))
             (lsb   (ruler-mode-left-scroll-bar-cols))
!            (lf    (ruler-mode-left-fringe-cols t))
             (lm    (or (car m) 0))
             (rsb   (ruler-mode-right-scroll-bar-cols))
!            (rf    (ruler-mode-right-fringe-cols t))
             (rm    (or (cdr m) 0))
             (ruler (make-string fullw ruler-mode-basic-graduation-char))
             (o     (+ lsb lf lm))
             (x     0)
!            (i     0 ) ;;o)
             (j     (window-hscroll))
             k c l1 l2 r2 r1 h1 h2 f1 f2)

***************
*** 765,789 ****
                h2 ruler-mode-fringe-help-echo
                f1 'ruler-mode-margins-face
                f2 'ruler-mode-fringes-face))
-       (setq i lsb j (+ i l1))
-       (put-text-property i j 'face f1 ruler)
-       (put-text-property i j 'help-echo (format h1 "Left" l1) ruler)
-       (setq i j j (+ i l2))
-       (put-text-property i j 'face f2 ruler)
-       (put-text-property i j 'help-echo (format h2 "Left" l2) ruler)
-       (setq i (+ o w) j (+ i r2))
-       (put-text-property i j 'face f2 ruler)
-       (put-text-property i j 'help-echo (format h2 "Right" r2) ruler)
-       (setq i j j (+ i r1))
-       (put-text-property i j 'face f1 ruler)
-       (put-text-property i j 'help-echo (format h1 "Right" r1) ruler)
-
-       ;; Show inactive areas.
-       (put-text-property 0 lsb   'face 'ruler-mode-pad-face ruler)
-       (put-text-property j fullw 'face 'ruler-mode-pad-face ruler)
-
        ;; Return the ruler propertized string.
!       ruler)))

  (provide 'ruler-mode)

--- 766,791 ----
                h2 ruler-mode-fringe-help-echo
                f1 'ruler-mode-margins-face
                f2 'ruler-mode-fringes-face))
        ;; Return the ruler propertized string.
!       (list
!        (ruler-mode-space ?\s lsb
!                          'face 'ruler-mode-pad-face)
!        (ruler-mode-space ruler-mode-basic-graduation-char l1
!                          'face f1
!                          'help-echo (format h1 "Left" l1))
!        (ruler-mode-space ruler-mode-basic-graduation-char l2
!                          'face f2
!                          'help-echo (format h2 "Left" l2))
!        ruler
!        (ruler-mode-space ruler-mode-basic-graduation-char r2
!                          'face f2
!                          'help-echo (format h2 "Right" r2))
!        (ruler-mode-space ruler-mode-basic-graduation-char r1
!                          'face f1
!                          'help-echo (format h2 "Right" r1))
!        (ruler-mode-space ?\s rsb
!                          'face 'ruler-mode-pad-face)
!        ))))

  (provide 'ruler-mode)







reply via email to

[Prev in Thread] Current Thread [Next in Thread]