[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ruler support in hexl mode
From: |
Kim F. Storm |
Subject: |
Re: ruler support in hexl mode |
Date: |
11 Mar 2004 17:27:06 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
Stefan Monnier <address@hidden> writes:
>
> > +;; This function is derived from `ruler-mode-ruler' in ruler-mode.el.
> > +(defun hexl-mode-ruler ()
> > + "Return a string ruler for hexl mode."
> > + (when hexl-use-ruler
> > + (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))
> > + (ruler (make-string fullw ?\ ))
>
> We really need to move this out of ruler-mode into frame.el or some other
> "global" file. And to give it a clean interface so its implementation can
> be improved later.
You can drop all of that ruler-mode- stuff if you use the advanced
pixel-alignment form of :align-to (see xdisp.c around line 17990):
(let ((s " 87654321 0011 2233 4455 6677 8899 aabb ccdd eeff
0123456789abcdef")
(pos 0))
;; Turn spaces in the header into stretch specs so they work
;; regardless of the header-line face.
(while (string-match "[ \t]+" s pos)
(setq pos (match-end 0))
(put-text-property (match-beginning 0) pos 'display
;; Assume fixed-size chars
`(space :align-to (+ (scroll-bar . left)
left-fringe left-margin
,(1- pos)))
s))
;; Highlight the current column.
(put-text-property (+ 11 (/ (* 5 highlight) 2))
(+ 13 (/ (* 5 highlight) 2))
'face 'highlight s))
> Note that the use of the display property also allows us to deal with
> fractional sizes, although lsb and lf don't take advantage of it yet.
The above code snippet does exact pixel alignment !
> Also I wish we could put some more useful info up there, but admittedly,
> I can't think of any.
--
Kim F. Storm <address@hidden> http://www.cua.dk
- ruler support in hexl mode, Masatake YAMATO, 2004/03/08
- Re: ruler support in hexl mode, Stefan Monnier, 2004/03/10
- Re: ruler support in hexl mode, Masatake YAMATO, 2004/03/10
- Re: ruler support in hexl mode,
Kim F. Storm <=
- Re: ruler support in hexl mode, Stefan Monnier, 2004/03/12
- Re: ruler support in hexl mode, Kim F. Storm, 2004/03/12
- Re: ruler support in hexl mode, Masatake YAMATO, 2004/03/12
- Re: ruler support in hexl mode, Stefan Monnier, 2004/03/12
- Re: ruler support in hexl mode, Masatake YAMATO, 2004/03/13
- Re: ruler support in hexl mode, Masatake YAMATO, 2004/03/15
- Re: ruler support in hexl mode, Richard Stallman, 2004/03/15
- Re: ruler support in hexl mode, Kim F. Storm, 2004/03/15
- Re: ruler support in hexl mode, Richard Stallman, 2004/03/16
- Re: ruler support in hexl mode, Kim F. Storm, 2004/03/16