From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: ruler support in hexl mode Date: 11 Mar 2004 17:27:06 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <20040305.142915.63122255.jet@gyve.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1079099237 28946 80.91.224.253 (12 Mar 2004 13:47:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 12 Mar 2004 13:47:17 +0000 (UTC) Cc: Masatake YAMATO , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri Mar 12 14:47:05 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1B1n0D-0001zX-00 for ; Fri, 12 Mar 2004 14:47:05 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1B1n0D-0003uY-00 for ; Fri, 12 Mar 2004 14:47:05 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B1j0B-0003zh-Mq for emacs-devel@quimby.gnus.org; Fri, 12 Mar 2004 04:30:47 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1B1iNy-0000ef-Gv for emacs-devel@gnu.org; Fri, 12 Mar 2004 03:51:18 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1B1iNL-0000aJ-9c for emacs-devel@gnu.org; Fri, 12 Mar 2004 03:51:10 -0500 Original-Received: from [212.88.64.25] (helo=mail-relay.sonofon.dk) by monty-python.gnu.org with smtp (Exim 4.30) id 1B1S62-0000bi-U1 for emacs-devel@gnu.org; Thu, 11 Mar 2004 10:27:43 -0500 Original-Received: (qmail 30670 invoked from network); 11 Mar 2004 15:27:28 -0000 Original-Received: from unknown (HELO kfs-l.imdomain.dk.cua.dk) (213.83.150.2) by 0 with SMTP; 11 Mar 2004 15:27:28 -0000 Original-To: Stefan Monnier In-Reply-To: Original-Lines: 50 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:20352 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:20352 Stefan Monnier 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 http://www.cua.dk