[Top][All Lists]
[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 12:57:41 +0200 (CEST) |
Hi All,
>>>(2) use a character with the exact same width as the fringe in the
>>>mode line. If memory serves me, you can make a space of any length
>>>using the display text property.
>>
>>Yup:
>>
>> (setq header-line-format
>> (concat (propertize "|" 'display '(space :width 1)) "hello world"))
>>
>>That makes the first character of the header-line exactly one `default'
>>character wide -- even if the header-line is displayed in a different
>>font....
Thank you very much for all your good ideas!
Here is a patch to use the display :width property for fringes,
margins and scrollbars.
For now it isn't yet well finished but I just would like to know if
it works well.
Good luck!
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 10:48:32 -0000
***************
*** 294,341 ****
"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 ()
--- 294,345 ----
"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-left-scroll-bar-cols (&optional absolute)
"Return the width, measured in columns, of the right vertical scrollbar."
(let* ((wsb (window-scroll-bars))
+ (width (car wsb))
(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 (if absolute width cols)
! (funcall (if absolute '/ '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.
! (float (frame-char-width))))
0)))
! (defun ruler-mode-right-scroll-bar-cols (&optional absolute)
"Return the width, measured in columns, of the right vertical scrollbar."
(let* ((wsb (window-scroll-bars))
+ (width (car wsb))
(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 (if absolute width cols)
! (funcall (if absolute '/ '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.
! (float (frame-char-width))))
0)))
(defsubst ruler-mode-full-window-width ()
***************
*** 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)
--- 651,681 ----
(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 t))
! (lf (ruler-mode-left-fringe-cols t))
(lm (or (car m) 0))
! (rsb (ruler-mode-right-scroll-bar-cols t))
! (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)
--- 777,802 ----
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)
- Re: ruler-mode is broken, (continued)
- Re: ruler-mode is broken, Kim F. Storm, 2003/10/15
- Re: ruler-mode is broken, Miles Bader, 2003/10/15
- Re: ruler-mode is broken, Kim F. Storm, 2003/10/16
- Re: ruler-mode is broken, Miles Bader, 2003/10/16
- Re: ruler-mode is broken, Kim F. Storm, 2003/10/16
- Re: ruler-mode is broken, Lute Kamstra, 2003/10/14
- Re: ruler-mode is broken, Kim F. Storm, 2003/10/14
- Re: ruler-mode is broken, Lute Kamstra, 2003/10/16
- Re: ruler-mode is broken, Richard Stallman, 2003/10/16
- Re: ruler-mode is broken, Kim F. Storm, 2003/10/17
Re: ruler-mode is broken,
David PONCE <=
Re: ruler-mode is broken, David PONCE, 2003/10/10