;;; scroll-bar.el --- window system-independent scroll bar support
-;; Copyright (C) 1993-1995, 1999-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1995, 1999-2016 Free Software Foundation, Inc.
;; Maintainer: emacs-devel@gnu.org
;; Keywords: hardware
(htype lines)
((frame-parameter nil 'horizontal-scroll-bars)
;; nil means it's a non-toolkit scroll bar (which is currently
- ;; impossible), and its width in columns is 14 pixels rounded up.
+ ;; impossible), and its height in lines is 14 pixels rounded up.
(ceiling (or (frame-parameter nil 'scroll-bar-height) 14)
(frame-char-width)))
(0))))
(if v (or previous-scroll-bar-mode
default-frame-scroll-bars))))))
+(defun horizontal-scroll-bars-available-p ()
+ "Return non-nil when horizontal scroll bars are available on this system."
+ (and (display-graphic-p)
+ (boundp 'x-toolkit-scroll-bars)
+ x-toolkit-scroll-bars))
+
(define-minor-mode horizontal-scroll-bar-mode
"Toggle horizontal scroll bars on all frames (Horizontal Scroll Bar mode).
With a prefix argument ARG, enable Horizontal Scroll Bar mode if
:init-value nil
:global t
:group 'frames
- (dolist (frame (frame-list))
- (set-frame-parameter
- frame 'horizontal-scroll-bars horizontal-scroll-bar-mode))
- ;; Handle `default-frame-alist' entry.
- (setq default-frame-alist
- (cons (cons 'horizontal-scroll-bars horizontal-scroll-bar-mode)
- (assq-delete-all 'horizontal-scroll-bars
- default-frame-alist))))
+ (if (and horizontal-scroll-bar-mode
+ (not (horizontal-scroll-bars-available-p)))
+ (progn
+ (setq horizontal-scroll-bar-mode nil)
+ (message "Horizontal scroll bars are not implemented on this system"))
+ (dolist (frame (frame-list))
+ (set-frame-parameter
+ frame 'horizontal-scroll-bars horizontal-scroll-bar-mode))
+ ;; Handle `default-frame-alist' entry.
+ (setq default-frame-alist
+ (cons (cons 'horizontal-scroll-bars horizontal-scroll-bar-mode)
+ (assq-delete-all 'horizontal-scroll-bars
+ default-frame-alist)))))
(defun toggle-scroll-bar (arg)
"Toggle whether or not the selected frame has vertical scroll bars.
-With arg, turn vertical scroll bars on if and only if arg is positive.
+With ARG, turn vertical scroll bars on if and only if ARG is positive.
The variable `scroll-bar-mode' controls which side the scroll bars are on
when they are turned on; if it is nil, they go on the left."
(interactive "P")
(if (null arg)
(setq arg
- (if (cdr (assq 'vertical-scroll-bars
- (frame-parameters (selected-frame))))
- -1 1))
+ (if (frame-parameter nil 'vertical-scroll-bars) -1 1))
(setq arg (prefix-numeric-value arg)))
(modify-frame-parameters
(selected-frame)
(list (cons 'vertical-scroll-bars
(if (> arg 0)
(or scroll-bar-mode default-frame-scroll-bars))))))
+
+(defun toggle-horizontal-scroll-bar (arg)
+ "Toggle whether or not the selected frame has horizontal scroll bars.
+With ARG, turn vertical scroll bars on if and only if ARG is positive."
+ (interactive "P")
+ (if (null arg)
+ (setq arg
+ (if (frame-parameter nil 'horizontal-scroll-bars) -1 1))
+ (setq arg (prefix-numeric-value arg)))
+ (modify-frame-parameters
+ (selected-frame)
+ (list (cons 'horizontal-scroll-bars
+ (when (> arg 0) 'bottom)))))
\f
;;;; Buffer navigation using the scroll bar.