comparison lisp/ruler-mode.el @ 54399:ad02f6299e9a

2004-03-15 Masatake YAMATO <jet@gyve.org> * hl-line.el (hl-line-range-function): New variable. (hl-line-move): New function. (global-hl-line-highlight): Use `hl-line-move'. (hl-line-highlight): Ditto. * scroll-bar.el (scroll-bar-columns): New function derived from ruler-mode.el. * fringe.el (fringe-columns): New function derived from ruler-mode.el. * ruler-mode.el (top-level): Require scroll-bar and fringe. (ruler-mode-left-fringe-cols) (ruler-mode-right-fringe-cols): Use `fringe-columns'. (ruler-mode-right-scroll-bar-cols) (ruler-mode-left-scroll-bar-cols): Use `scroll-bar-columns'. (ruler-mode-ruler-function): New variable. (ruler-mode-header-line-format): Call `ruler-mode-ruler-function' if the value for `ruler-mode-ruler-function'is given. * hexl.el (hexl-mode-hook): Make the hook customizable. (hexl-address-area, hexl-ascii-area, hexl-ascii-cursor): New customize variables. (hexlify-buffer): Put font-lock-faces on the address area and the ascii area. (hexl-activate-ruler): New function. (hexl-follow-line): New function. (hexl-highlight-line-range): New function. (hexl-mode-ruler): New function.
author Masatake YAMATO <jet@gyve.org>
date Mon, 15 Mar 2004 07:27:02 +0000
parents 615ebe291578
children 7f6dab15e141
comparison
equal deleted inserted replaced
54398:2decd50569f3 54399:ad02f6299e9a
92 ;; All `ruler-mode' faces inherit from `ruler-mode-default-face'. 92 ;; All `ruler-mode' faces inherit from `ruler-mode-default-face'.
93 ;; 93 ;;
94 ;; WARNING: To keep ruler graduations aligned on text columns it is 94 ;; WARNING: To keep ruler graduations aligned on text columns it is
95 ;; important to use the same font family and size for ruler and text 95 ;; important to use the same font family and size for ruler and text
96 ;; areas. 96 ;; areas.
97 ;;
98 ;; You can override the ruler format by defining an appropriate
99 ;; function as the buffer-local value of `ruler-mode-ruler-function'.
97 100
98 ;; Installation 101 ;; Installation
99 ;; 102 ;;
100 ;; To automatically display the ruler in specific major modes use: 103 ;; To automatically display the ruler in specific major modes use:
101 ;; 104 ;;
106 ;; 109 ;;
107 110
108 ;;; Code: 111 ;;; Code:
109 (eval-when-compile 112 (eval-when-compile
110 (require 'wid-edit)) 113 (require 'wid-edit))
114 (require 'scroll-bar)
115 (require 'fringe)
111 116
112 (defgroup ruler-mode nil 117 (defgroup ruler-mode nil
113 "Display a ruler in the header line." 118 "Display a ruler in the header line."
114 :version "21.4" 119 :version "21.4"
115 :group 'convenience) 120 :group 'convenience)
296 301
297 (defsubst ruler-mode-left-fringe-cols (&optional real) 302 (defsubst ruler-mode-left-fringe-cols (&optional real)
298 "Return the width, measured in columns, of the left fringe area. 303 "Return the width, measured in columns, of the left fringe area.
299 If optional argument REAL is non-nil, return a real floating point 304 If optional argument REAL is non-nil, return a real floating point
300 number instead of a rounded integer value." 305 number instead of a rounded integer value."
301 (funcall (if real '/ 'ceiling) 306 (fringe-columns 'left real))
302 (or (car (window-fringes)) 0)
303 (float (frame-char-width))))
304 307
305 (defsubst ruler-mode-right-fringe-cols (&optional real) 308 (defsubst ruler-mode-right-fringe-cols (&optional real)
306 "Return the width, measured in columns, of the right fringe area. 309 "Return the width, measured in columns, of the right fringe area.
307 If optional argument REAL is non-nil, return a real floating point 310 If optional argument REAL is non-nil, return a real floating point
308 number instead of a rounded integer value." 311 number instead of a rounded integer value."
309 (funcall (if real '/ 'ceiling) 312 (fringe-columns 'right real))
310 (or (nth 1 (window-fringes)) 0)
311 (float (frame-char-width))))
312
313 (defun ruler-mode-scroll-bar-cols (side)
314 "Return the width, measured in columns, of the vertical scrollbar on SIDE.
315 SIDE must be the symbol `left' or `right'."
316 (let* ((wsb (window-scroll-bars))
317 (vtype (nth 2 wsb))
318 (cols (nth 1 wsb)))
319 (cond
320 ((not (memq side '(left right)))
321 (error "`left' or `right' expected instead of %S" side))
322 ((and (eq vtype side) cols))
323 ((eq (frame-parameter nil 'vertical-scroll-bars) side)
324 ;; nil means it's a non-toolkit scroll bar, and its width in
325 ;; columns is 14 pixels rounded up.
326 (ceiling (or (frame-parameter nil 'scroll-bar-width) 14)
327 (frame-char-width)))
328 (0))))
329 313
330 (defmacro ruler-mode-right-scroll-bar-cols () 314 (defmacro ruler-mode-right-scroll-bar-cols ()
331 "Return the width, measured in columns, of the right vertical scrollbar." 315 "Return the width, measured in columns, of the right vertical scrollbar."
332 '(ruler-mode-scroll-bar-cols 'right)) 316 '(scroll-bar-columns 'right))
333 317
334 (defmacro ruler-mode-left-scroll-bar-cols () 318 (defmacro ruler-mode-left-scroll-bar-cols ()
335 "Return the width, measured in columns, of the left vertical scrollbar." 319 "Return the width, measured in columns, of the left vertical scrollbar."
336 '(ruler-mode-scroll-bar-cols 'left)) 320 '(scroll-bar-columns 'left))
337 321
338 (defsubst ruler-mode-full-window-width () 322 (defsubst ruler-mode-full-window-width ()
339 "Return the full width of the selected window." 323 "Return the full width of the selected window."
340 (let ((edges (window-edges))) 324 (let ((edges (window-edges)))
341 (- (nth 2 edges) (nth 0 edges)))) 325 (- (nth 2 edges) (nth 0 edges))))
566 550
567 (defvar ruler-mode-header-line-format-old nil 551 (defvar ruler-mode-header-line-format-old nil
568 "Hold previous value of `header-line-format'.") 552 "Hold previous value of `header-line-format'.")
569 (make-variable-buffer-local 'ruler-mode-header-line-format-old) 553 (make-variable-buffer-local 'ruler-mode-header-line-format-old)
570 554
555 (defvar ruler-mode-ruler-function nil
556 "If non-nil, function to call to return ruler string.
557 This variable is expected to be made buffer-local by modes.")
558
571 (defconst ruler-mode-header-line-format 559 (defconst ruler-mode-header-line-format
572 '(:eval (ruler-mode-ruler)) 560 '(:eval (funcall (if ruler-mode-ruler-function
573 "`header-line-format' used in ruler mode.") 561 ruler-mode-ruler-function
562 'ruler-mode-ruler)))
563 "`header-line-format' used in ruler mode.
564 If the non-nil value for ruler-mode-ruler-function is given, use it.
565 Else use `ruler-mode-ruler' is used as default value.")
574 566
575 ;;;###autoload 567 ;;;###autoload
576 (define-minor-mode ruler-mode 568 (define-minor-mode ruler-mode
577 "Display a ruler in the header line if ARG > 0." 569 "Display a ruler in the header line if ARG > 0."
578 nil nil 570 nil nil