Function: hexl-mode-ruler

hexl-mode-ruler is a byte-compiled function defined in hexl.el.gz.

Signature

(hexl-mode-ruler)

Documentation

Return a string ruler for Hexl mode.

Source Code

;; Defined in /usr/src/emacs/lisp/hexl.el.gz
(defun hexl-mode-ruler ()
  "Return a string ruler for Hexl mode."
  (let* ((highlight (mod (hexl-current-address) 16))
	 (s (cdr (assq hexl-bits hexl-rulers)))
	 (pos 0)
         (lnum-width
          (if display-line-numbers
              (round (line-number-display-width 'columns))
            0)))
    (set-text-properties 0 (length s) nil s)
    (when (> lnum-width 0)
      (setq s (concat (make-string lnum-width ?  ) s))
      (setq pos (+ pos lnum-width)))
    ;; 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 ,(1- pos))
			 s))
    ;; Highlight the current column.
    (let ( (offset (+ (* 2 highlight) (/ (* 8 highlight) hexl-bits))) )
      (if (> lnum-width 0) (setq offset (+ offset lnum-width)))
      (put-text-property (+ 11 offset) (+ 13 offset) 'face 'highlight s))
    ;; Highlight the current ascii column
    (put-text-property (+ (hexl-ascii-start-column) lnum-width highlight 1)
                       (+ (hexl-ascii-start-column) lnum-width highlight 2)
                       'face 'highlight s)
    s))