[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ruler support in hexl mode
From: |
Masatake YAMATO |
Subject: |
Re: ruler support in hexl mode |
Date: |
Thu, 11 Mar 2004 15:59:58 +0900 (JST) |
[resending]
> > +(defcustom hexl-follow-line t
> > + "If non-nil then highlight the line address corresponding to point."
> > + :type 'boolean
> > + :group 'hexl)
>
> Any reason why you do not simply use hl-line-mode ?
> Or, better yet, let the user select hl-line-mode if he wants it?
Using hl-line-mode is good idea. However, hl-line-mode hides the
highlighted character associated with the point in ascii area. I will
put other face than highlight on the character associated with the
point.
> > +;; 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.
Are You talking about each functions or generic ruler mechanism?
About former, I have inspect ruler-mode.el again.
(let* ((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 w ruler-mode-basic-graduation-char))
(i 0)
(j (window-hscroll))
k c l1 l2 r2 r1 h1 h2 f1 f2)
Next two functions should be in "global" file:
ruler-mode-left-scroll-bar-cols and ruler-mode-left-fringe-cols.
I think these should be renamed to scroll-bar-columns and
fringe-columns. How do you think?
> > + (o (+ lsb lf lm))
> > + (x o)
> > + (highlight (mod (hexl-current-address) 16)))
> > + ;; "87654321"
> > + (do ((i 8 (1- i)))
> > + ((= i 0))
> > + (aset ruler x (aref (number-to-string i) 0))
> > + (setq x (1+ x)))
> > + ;; "87654321 "
> > + (setq x (+ x 2)) ; ": "
> > + ;; "87654321 0011 2233 4455 6677 8899 aabb ccdd eeff"
> > + (do* ((i 0 (1+ i))
> > + (c (format "%x" i) (format "%x" i)))
> > + ((= i 16))
> > + (aset ruler x (aref c 0))
> > + (setq x (1+ x))
> > + (aset ruler x (aref c 0))
> > + (setq x (1+ x))
> > + (if (= highlight i)
> > + (put-text-property (- x 2) x
> > + 'face 'highlight
> > + ruler))
> > + (when (= (mod i 2) 1)
> > + (aset ruler x ?\ )
> > + (setq x (1+ x))))
> > + ;; "87654321 0011 2233 4455 6677 8899 aabb ccdd eeff "
> > + (setq x (1+ x)) ; " "
> > + ;; "87654321 0011 2233 4455 6677 8899 aabb ccdd eeff
> > 0123456789abcdef"
> > + (do* ((i 0 (1+ i))
> > + (c (format "%x" i) (format "%x" i)))
> > + ((= i 16))
> > + (aset ruler x (aref c 0))
> > + (setq x (1+ x))
> > + (if (= highlight i)
> > + (put-text-property (1- x) x
> > + 'face 'highlight
> > + ruler)))
> > + ruler)))
>
> Isn't this always building the exact same string, except for the size
> (which really does not need to depend on the window's width), the leading
> space (to align it), and the highlighting of the current column?
>
> Couldn't we just do (100% untested code, inspired from buff-menu.el):
...
After modifying a bit, your code works fine.
Masatake YAMATO
- Re: ruler support in hexl mode, (continued)
- 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
- Re: ruler support in hexl mode, Stefan Monnier, 2004/03/16
- Re: ruler support in hexl mode, Kim F. Storm, 2004/03/16
- Re: ruler support in hexl mode, Richard Stallman, 2004/03/19
- Re: ruler support in hexl mode, Kim F. Storm, 2004/03/19
- Re: ruler support in hexl mode, Kim F. Storm, 2004/03/19
Re: ruler support in hexl mode,
Masatake YAMATO <=
Re: ruler support in hexl mode, Miles Bader, 2004/03/10