comparison lisp/scroll-bar.el @ 1954:059d99d03aae

* term/x-win.el (scroll-bar-mode, scroll-bar-mode): Move these functions to scrolbar.el. * scrollbar.el (scroll-bar-mode, scroll-bar-mode): Here they are. Make scroll-bar-mode set the {vertical,horizontal}-scrollbars parameters in default-frame-alist, and modify all extant screens using the correct parameter names.
author Jim Blandy <jimb@redhat.com>
date Thu, 25 Feb 1993 00:38:55 +0000
parents 04fb1d3d6992
children 3a08dacd8bfb
comparison
equal deleted inserted replaced
1953:714df59790af 1954:059d99d03aae
36 ;; We multiply before we divide to maintain precision. 36 ;; We multiply before we divide to maintain precision.
37 ;; We use floating point because the product of a large buffer size 37 ;; We use floating point because the product of a large buffer size
38 ;; with a large scrollbar portion can easily overflow a lisp int. 38 ;; with a large scrollbar portion can easily overflow a lisp int.
39 (truncate (/ (* (float (car num-denom)) whole) (cdr num-denom)))) 39 (truncate (/ (* (float (car num-denom)) whole) (cdr num-denom))))
40 40
41
42 ;;;; Helpful functions for enabling and disabling scroll bars.
43 (defvar scroll-bar-mode nil)
44
45 (defun scroll-bar-mode (flag)
46 "Toggle display of vertical scroll bars on each frame.
47 This command applies to all frames that exist and frames to be
48 created in the future.
49 With a numeric argument, if the argument is negative,
50 turn off scroll bars; otherwise, turn on scroll bars."
51 (interactive "P")
52 (setq scroll-bar-mode (if (null flag) (not scroll-bar-mode)
53 (or (not (numberp flag)) (>= flag 0))))
54 (mapcar
55 (function
56 (lambda (param-name)
57 (let ((parameter (assq param-name default-frame-alist)))
58 (if (consp parameter)
59 (setcdr parameter scroll-bar-mode)
60 (setq default-frame-alist
61 (cons (cons param-name scroll-bar-mode)
62 default-frame-alist))))))
63 '(vertical-scrollbars horizontal-scrollbars))
64 (let ((frames (frame-list)))
65 (while frames
66 (modify-frame-parameters
67 (car frames)
68 (list (cons 'vertical-scrollbars scroll-bar-mode)
69 (cons 'horizontal-scrollbars scroll-bar-mode)))
70 (setq frames (cdr frames)))))
41 71
42 ;;;; Buffer navigation using the scrollbar. 72 ;;;; Buffer navigation using the scrollbar.
43 73
44 (defun scrollbar-set-window-start (event) 74 (defun scrollbar-set-window-start (event)
45 "Set the window start according to where the scrollbar is dragged. 75 "Set the window start according to where the scrollbar is dragged.