Mercurial > emacs
annotate lisp/scroll-bar.el @ 108635:e565448628b8
Set rallocobj with configure, not cpp.
* configure.in (REL_ALLOC): Unset on gnu, gnu-linux if DOUG_LEA_MALLOC.
(RALLOC_OBJ): New output variable.
* config.bat (RALLOC_OBJ): Edit to empty if sys_malloc.
* src/Makefile.in (RALLOC_OBJ): New, set by configure.
(rallocobj): Replace with the previous variable.
(otherobj): Use $RALLOC_OBJ.
* src/s/gnu.h (REL_ALLOC) [DOUG_LEA_MALLOC]:
* src/s/gnu-linux.h (REL_ALLOC) [DOUG_LEA_MALLOC]: Move undef to configure.
* msdos/sed1v2.inp (RALLOC_OBJ): Edit to ralloc.o.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Mon, 17 May 2010 19:44:07 -0700 |
parents | dc6153a5f4f7 |
children | 280c8ae2476d |
rev | line source |
---|---|
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
36803
diff
changeset
|
1 ;;; scroll-bar.el --- window system-independent scroll bar support |
1772 | 2 |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64091
diff
changeset
|
3 ;; Copyright (C) 1993, 1994, 1995, 1999, 2000, 2001, 2002, 2003, |
106815 | 4 ;; 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
1772 | 5 |
6 ;; Maintainer: FSF | |
7 ;; Keywords: hardware | |
8 | |
14169 | 9 ;; This file is part of GNU Emacs. |
1772 | 10 |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
14169 | 12 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
1772 | 15 |
14169 | 16 ;; GNU Emacs is distributed in the hope that it will be useful, |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
1772 | 20 |
14169 | 21 ;; You should have received a copy of the GNU General Public License |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
2233
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2232
diff
changeset
|
23 |
2315
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2233
diff
changeset
|
24 ;;; Commentary: |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2233
diff
changeset
|
25 |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2233
diff
changeset
|
26 ;; Window-system-independent bindings of mouse clicks on the scroll bar. |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2233
diff
changeset
|
27 ;; Presently emulates the scroll-bar behavior of xterm. |
14169 | 28 |
2315
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2233
diff
changeset
|
29 ;;; Code: |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2233
diff
changeset
|
30 |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1772
diff
changeset
|
31 (require 'mouse) |
108242
dc6153a5f4f7
Use define-minor-mode in more cases.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107262
diff
changeset
|
32 (eval-when-compile (require 'cl)) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1772
diff
changeset
|
33 |
1772 | 34 |
35 ;;;; Utilities. | |
36 | |
7222
3dae5675cd3e
(scroll-bar-event-ratio): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4469
diff
changeset
|
37 (defun scroll-bar-event-ratio (event) |
3dae5675cd3e
(scroll-bar-event-ratio): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4469
diff
changeset
|
38 "Given a scroll bar event EVENT, return the scroll bar position as a ratio. |
3dae5675cd3e
(scroll-bar-event-ratio): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4469
diff
changeset
|
39 The value is a cons cell (PORTION . WHOLE) containing two integers |
3dae5675cd3e
(scroll-bar-event-ratio): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4469
diff
changeset
|
40 whose ratio gives the event's vertical position in the scroll bar, with 0 |
3dae5675cd3e
(scroll-bar-event-ratio): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4469
diff
changeset
|
41 referring to the top and 1 to the bottom." |
3dae5675cd3e
(scroll-bar-event-ratio): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4469
diff
changeset
|
42 (nth 2 event)) |
3dae5675cd3e
(scroll-bar-event-ratio): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4469
diff
changeset
|
43 |
1981
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
44 (defun scroll-bar-scale (num-denom whole) |
1772 | 45 "Given a pair (NUM . DENOM) and WHOLE, return (/ (* NUM WHOLE) DENOM). |
1981
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
46 This is handy for scaling a position on a scroll bar into real units, |
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
47 like buffer positions. If SCROLL-BAR-POS is the (PORTION . WHOLE) pair |
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
48 from a scroll bar event, then (scroll-bar-scale SCROLL-BAR-POS |
1772 | 49 \(buffer-size)) is the position in the current buffer corresponding to |
1981
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
50 that scroll bar position." |
1772 | 51 ;; We multiply before we divide to maintain precision. |
52 ;; We use floating point because the product of a large buffer size | |
1981
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
53 ;; with a large scroll bar portion can easily overflow a lisp int. |
1772 | 54 (truncate (/ (* (float (car num-denom)) whole) (cdr num-denom)))) |
55 | |
54399
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
56 (defun scroll-bar-columns (side) |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
57 "Return the width, measured in columns, of the vertical scrollbar on SIDE. |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
58 SIDE must be the symbol `left' or `right'." |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
59 (let* ((wsb (window-scroll-bars)) |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
60 (vtype (nth 2 wsb)) |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
61 (cols (nth 1 wsb))) |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
62 (cond |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
63 ((not (memq side '(left right))) |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
64 (error "`left' or `right' expected instead of %S" side)) |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
65 ((and (eq vtype side) cols)) |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
66 ((eq (frame-parameter nil 'vertical-scroll-bars) side) |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
67 ;; nil means it's a non-toolkit scroll bar, and its width in |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
68 ;; columns is 14 pixels rounded up. |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
69 (ceiling (or (frame-parameter nil 'scroll-bar-width) 14) |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
70 (frame-char-width))) |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
71 (0)))) |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52558
diff
changeset
|
72 |
1772 | 73 |
1954
059d99d03aae
* term/x-win.el (scroll-bar-mode, scroll-bar-mode): Move these
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
74 ;;;; Helpful functions for enabling and disabling scroll bars. |
059d99d03aae
* term/x-win.el (scroll-bar-mode, scroll-bar-mode): Move these
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
75 |
18480
f0c705a82dca
(scroll-bar-mode): Extra defvar to avoid warning.
Richard M. Stallman <rms@gnu.org>
parents:
18479
diff
changeset
|
76 (defvar scroll-bar-mode) |
74982
3b9c6c0ac744
(previous-scroll-bar-mode): New variable
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
77 (defvar previous-scroll-bar-mode nil) |
18480
f0c705a82dca
(scroll-bar-mode): Extra defvar to avoid warning.
Richard M. Stallman <rms@gnu.org>
parents:
18479
diff
changeset
|
78 |
18891
86c0d896480e
(scroll-bar-mode-explicit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18480
diff
changeset
|
79 (defvar scroll-bar-mode-explicit nil |
86c0d896480e
(scroll-bar-mode-explicit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18480
diff
changeset
|
80 "Non-nil means `set-scroll-bar-mode' should really do something. |
86c0d896480e
(scroll-bar-mode-explicit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18480
diff
changeset
|
81 This is nil while loading `scroll-bar.el', and t afterward.") |
86c0d896480e
(scroll-bar-mode-explicit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18480
diff
changeset
|
82 |
20129
a68db1ead5cf
(set-scroll-bar-mode): Take just one arg.
Karl Heuer <kwzh@gnu.org>
parents:
20061
diff
changeset
|
83 (defun set-scroll-bar-mode (value) |
18479
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
84 "Set `scroll-bar-mode' to VALUE and put the new value into effect." |
74982
3b9c6c0ac744
(previous-scroll-bar-mode): New variable
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
85 (if scroll-bar-mode |
3b9c6c0ac744
(previous-scroll-bar-mode): New variable
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
86 (setq previous-scroll-bar-mode scroll-bar-mode)) |
3b9c6c0ac744
(previous-scroll-bar-mode): New variable
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
87 |
18479
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
88 (setq scroll-bar-mode value) |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
89 |
18891
86c0d896480e
(scroll-bar-mode-explicit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18480
diff
changeset
|
90 (when scroll-bar-mode-explicit |
83496
f271076dab2d
Fix toolbars on X frames when Emacs is started on a tty. (Reported by Richard Lewis.)
Karoly Lorentey <lorentey@elte.hu>
parents:
68651
diff
changeset
|
91 (modify-all-frames-parameters (list (cons 'vertical-scroll-bars |
f271076dab2d
Fix toolbars on X frames when Emacs is started on a tty. (Reported by Richard Lewis.)
Karoly Lorentey <lorentey@elte.hu>
parents:
68651
diff
changeset
|
92 scroll-bar-mode))))) |
18479
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
93 |
52558
3fb606ea8bf6
(set-scroll-bar-mode): Initialize to new built-in variable
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
94 (defcustom scroll-bar-mode default-frame-scroll-bars |
100171 | 95 "Specify whether to have vertical scroll bars, and on which side. |
18479
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
96 Possible values are nil (no scroll bars), `left' (scroll bars on left) |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
97 and `right' (scroll bars on right). |
22908
53b018832269
(scroll-bar-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
21734
diff
changeset
|
98 To set this variable in a Lisp program, use `set-scroll-bar-mode' |
53b018832269
(scroll-bar-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
21734
diff
changeset
|
99 to make it take real effect. |
53b018832269
(scroll-bar-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
21734
diff
changeset
|
100 Setting the variable with a customization buffer also takes effect." |
50398
1b58100e624c
(scroll-bar-mode): Correctly specify `nil' choice.
Miles Bader <miles@gnu.org>
parents:
49016
diff
changeset
|
101 :type '(choice (const :tag "none (nil)" nil) |
18479
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
102 (const left) |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
103 (const right)) |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
104 :group 'frames |
47494
06a428ab2fcb
(scroll-bar-mode): Specify :initialize.
Richard M. Stallman <rms@gnu.org>
parents:
42851
diff
changeset
|
105 ;; The default value for :initialize would try to use :set |
06a428ab2fcb
(scroll-bar-mode): Specify :initialize.
Richard M. Stallman <rms@gnu.org>
parents:
42851
diff
changeset
|
106 ;; when processing the file in cus-dep.el. |
06a428ab2fcb
(scroll-bar-mode): Specify :initialize.
Richard M. Stallman <rms@gnu.org>
parents:
42851
diff
changeset
|
107 :initialize 'custom-initialize-default |
108242
dc6153a5f4f7
Use define-minor-mode in more cases.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107262
diff
changeset
|
108 :set (lambda (sym val) (set-scroll-bar-mode val))) |
18479
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
109 |
18891
86c0d896480e
(scroll-bar-mode-explicit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18480
diff
changeset
|
110 ;; We just set scroll-bar-mode, but that was the default. |
86c0d896480e
(scroll-bar-mode-explicit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18480
diff
changeset
|
111 ;; If it is set again, that is for real. |
86c0d896480e
(scroll-bar-mode-explicit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18480
diff
changeset
|
112 (setq scroll-bar-mode-explicit t) |
86c0d896480e
(scroll-bar-mode-explicit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18480
diff
changeset
|
113 |
108242
dc6153a5f4f7
Use define-minor-mode in more cases.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107262
diff
changeset
|
114 (defun get-scroll-bar-mode () scroll-bar-mode) |
dc6153a5f4f7
Use define-minor-mode in more cases.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107262
diff
changeset
|
115 (defsetf get-scroll-bar-mode set-scroll-bar-mode) |
dc6153a5f4f7
Use define-minor-mode in more cases.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107262
diff
changeset
|
116 (define-minor-mode scroll-bar-mode |
18479
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
117 "Toggle display of vertical scroll bars on all frames. |
1954
059d99d03aae
* term/x-win.el (scroll-bar-mode, scroll-bar-mode): Move these
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
118 This command applies to all frames that exist and frames to be |
059d99d03aae
* term/x-win.el (scroll-bar-mode, scroll-bar-mode): Move these
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
119 created in the future. |
102248
6a544631f99f
* scroll-bar.el (scroll-bar-mode): Turn off scroll bars when
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
120 With a numeric argument, if the argument is positive |
6a544631f99f
* scroll-bar.el (scroll-bar-mode): Turn off scroll bars when
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
121 turn on scroll bars; otherwise turn off scroll bars." |
108242
dc6153a5f4f7
Use define-minor-mode in more cases.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107262
diff
changeset
|
122 :variable (eq (get-scroll-bar-mode) |
dc6153a5f4f7
Use define-minor-mode in more cases.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107262
diff
changeset
|
123 (or previous-scroll-bar-mode |
dc6153a5f4f7
Use define-minor-mode in more cases.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
107262
diff
changeset
|
124 default-frame-scroll-bars))) |
3613
f37a9c897699
* scroll-bar.el (scroll-bar-mode): Variable deleted.
Jim Blandy <jimb@redhat.com>
parents:
3588
diff
changeset
|
125 |
18479
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
126 (defun toggle-scroll-bar (arg) |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
127 "Toggle whether or not the selected frame has vertical scroll bars. |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
128 With arg, turn vertical scroll bars on if and only if arg is positive. |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
129 The variable `scroll-bar-mode' controls which side the scroll bars are on |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
130 when they are turned on; if it is nil, they go on the left." |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
131 (interactive "P") |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
132 (if (null arg) |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
133 (setq arg |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
134 (if (cdr (assq 'vertical-scroll-bars |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
135 (frame-parameters (selected-frame)))) |
20061
fb0d3082b28c
(toggle-scroll-bar): Call prefix-numeric-value.
Karl Heuer <kwzh@gnu.org>
parents:
19683
diff
changeset
|
136 -1 1)) |
fb0d3082b28c
(toggle-scroll-bar): Call prefix-numeric-value.
Karl Heuer <kwzh@gnu.org>
parents:
19683
diff
changeset
|
137 (setq arg (prefix-numeric-value arg))) |
21734
807f4e7fa560
(scroll-bar-mode, toggle-scroll-bar): By default,
Geoff Voelker <voelker@cs.washington.edu>
parents:
21427
diff
changeset
|
138 (modify-frame-parameters |
807f4e7fa560
(scroll-bar-mode, toggle-scroll-bar): By default,
Geoff Voelker <voelker@cs.washington.edu>
parents:
21427
diff
changeset
|
139 (selected-frame) |
807f4e7fa560
(scroll-bar-mode, toggle-scroll-bar): By default,
Geoff Voelker <voelker@cs.washington.edu>
parents:
21427
diff
changeset
|
140 (list (cons 'vertical-scroll-bars |
807f4e7fa560
(scroll-bar-mode, toggle-scroll-bar): By default,
Geoff Voelker <voelker@cs.washington.edu>
parents:
21427
diff
changeset
|
141 (if (> arg 0) |
52558
3fb606ea8bf6
(set-scroll-bar-mode): Initialize to new built-in variable
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
142 (or scroll-bar-mode default-frame-scroll-bars)))))) |
3613
f37a9c897699
* scroll-bar.el (scroll-bar-mode): Variable deleted.
Jim Blandy <jimb@redhat.com>
parents:
3588
diff
changeset
|
143 |
18479
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
144 (defun toggle-horizontal-scroll-bar (arg) |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
145 "Toggle whether or not the selected frame has horizontal scroll bars. |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
146 With arg, turn horizontal scroll bars on if and only if arg is positive. |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
147 Horizontal scroll bars aren't implemented yet." |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
148 (interactive "P") |
dedaafd841c0
(toggle-scroll-bar): Moved from frame.el.
Richard M. Stallman <rms@gnu.org>
parents:
15264
diff
changeset
|
149 (error "Horizontal scroll bars aren't implemented yet")) |
1954
059d99d03aae
* term/x-win.el (scroll-bar-mode, scroll-bar-mode): Move these
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
150 |
1981
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
151 ;;;; Buffer navigation using the scroll bar. |
1772 | 152 |
105994
009383a57ce8
* x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102248
diff
changeset
|
153 ;; This was used for up-events on button 2, but no longer. |
1981
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
154 (defun scroll-bar-set-window-start (event) |
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
155 "Set the window start according to where the scroll bar is dragged. |
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
156 EVENT should be a scroll bar click or drag event." |
1772 | 157 (interactive "e") |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1772
diff
changeset
|
158 (let* ((end-position (event-end event)) |
1772 | 159 (window (nth 0 end-position)) |
160 (portion-whole (nth 2 end-position))) | |
105994
009383a57ce8
* x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102248
diff
changeset
|
161 (with-current-buffer (window-buffer window) |
1772 | 162 (save-excursion |
3588
9685f1d5545b
* scroll-bar.el (scroll-bar-set-window-start): Remember that the
Jim Blandy <jimb@redhat.com>
parents:
3508
diff
changeset
|
163 (goto-char (+ (point-min) |
9685f1d5545b
* scroll-bar.el (scroll-bar-set-window-start): Remember that the
Jim Blandy <jimb@redhat.com>
parents:
3508
diff
changeset
|
164 (scroll-bar-scale portion-whole |
9685f1d5545b
* scroll-bar.el (scroll-bar-set-window-start): Remember that the
Jim Blandy <jimb@redhat.com>
parents:
3508
diff
changeset
|
165 (- (point-max) (point-min))))) |
1772 | 166 (beginning-of-line) |
167 (set-window-start window (point)))))) | |
168 | |
15215
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
169 (defun scroll-bar-drag-position (portion-whole) |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
170 "Calculate new window start for drag event." |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
171 (save-excursion |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
172 (goto-char (+ (point-min) |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
173 (scroll-bar-scale portion-whole |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
174 (- (point-max) (point-min))))) |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
175 (beginning-of-line) |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
176 (point))) |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
177 |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
178 (defun scroll-bar-maybe-set-window-start (event) |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
179 "Set the window start according to where the scroll bar is dragged. |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
180 Only change window start if the new start is substantially different. |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
181 EVENT should be a scroll bar click or drag event." |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
182 (interactive "e") |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
183 (let* ((end-position (event-end event)) |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
184 (window (nth 0 end-position)) |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
185 (portion-whole (nth 2 end-position)) |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
186 (next-portion-whole (cons (1+ (car portion-whole)) |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
187 (cdr portion-whole))) |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
188 portion-start |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
189 next-portion-start |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
190 (current-start (window-start window))) |
105994
009383a57ce8
* x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102248
diff
changeset
|
191 (with-current-buffer (window-buffer window) |
15215
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
192 (setq portion-start (scroll-bar-drag-position portion-whole)) |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
193 (setq next-portion-start (max |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
194 (scroll-bar-drag-position next-portion-whole) |
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
195 (1+ portion-start))) |
19683
af32e336d12c
(scroll-bar-maybe-set-window-start): Change window
Geoff Voelker <voelker@cs.washington.edu>
parents:
18891
diff
changeset
|
196 (if (or (>= current-start next-portion-start) |
15215
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
197 (< current-start portion-start)) |
15264
0eb55cad57c6
(scroll-bar-maybe-set-window-start): Always set
Karl Heuer <kwzh@gnu.org>
parents:
15215
diff
changeset
|
198 (set-window-start window portion-start) |
0eb55cad57c6
(scroll-bar-maybe-set-window-start): Always set
Karl Heuer <kwzh@gnu.org>
parents:
15215
diff
changeset
|
199 ;; Always set window start, to ensure scroll bar position is updated. |
0eb55cad57c6
(scroll-bar-maybe-set-window-start): Always set
Karl Heuer <kwzh@gnu.org>
parents:
15215
diff
changeset
|
200 (set-window-start window current-start))))) |
15215
681866822119
(scroll-bar-drag-position): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
201 |
2698
6940c6b5d988
(scroll-bar-drag, scroll-bar-drag-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
2315
diff
changeset
|
202 ;; Scroll the window to the proper position for EVENT. |
6940c6b5d988
(scroll-bar-drag, scroll-bar-drag-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
2315
diff
changeset
|
203 (defun scroll-bar-drag-1 (event) |
6940c6b5d988
(scroll-bar-drag, scroll-bar-drag-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
2315
diff
changeset
|
204 (let* ((start-position (event-start event)) |
6940c6b5d988
(scroll-bar-drag, scroll-bar-drag-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
2315
diff
changeset
|
205 (window (nth 0 start-position)) |
6940c6b5d988
(scroll-bar-drag, scroll-bar-drag-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
2315
diff
changeset
|
206 (portion-whole (nth 2 start-position))) |
107262
251ddf5539cc
scroll-bar.el (scroll-bar-drag-1): Add save-excursion, bug #5654.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
207 (save-excursion |
251ddf5539cc
scroll-bar.el (scroll-bar-drag-1): Add save-excursion, bug #5654.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
208 (with-current-buffer (window-buffer window) |
251ddf5539cc
scroll-bar.el (scroll-bar-drag-1): Add save-excursion, bug #5654.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
209 ;; Calculate position relative to the accessible part of the buffer. |
251ddf5539cc
scroll-bar.el (scroll-bar-drag-1): Add save-excursion, bug #5654.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
210 (goto-char (+ (point-min) |
251ddf5539cc
scroll-bar.el (scroll-bar-drag-1): Add save-excursion, bug #5654.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
211 (scroll-bar-scale portion-whole |
251ddf5539cc
scroll-bar.el (scroll-bar-drag-1): Add save-excursion, bug #5654.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
212 (- (point-max) (point-min))))) |
251ddf5539cc
scroll-bar.el (scroll-bar-drag-1): Add save-excursion, bug #5654.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
213 (vertical-motion 0 window) |
251ddf5539cc
scroll-bar.el (scroll-bar-drag-1): Add save-excursion, bug #5654.
Jan D. <jan.h.d@swipnet.se>
parents:
106815
diff
changeset
|
214 (set-window-start window (point)))))) |
2698
6940c6b5d988
(scroll-bar-drag, scroll-bar-drag-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
2315
diff
changeset
|
215 |
6940c6b5d988
(scroll-bar-drag, scroll-bar-drag-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
2315
diff
changeset
|
216 (defun scroll-bar-drag (event) |
6940c6b5d988
(scroll-bar-drag, scroll-bar-drag-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
2315
diff
changeset
|
217 "Scroll the window by dragging the scroll bar slider. |
6940c6b5d988
(scroll-bar-drag, scroll-bar-drag-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
2315
diff
changeset
|
218 If you click outside the slider, the window scrolls to bring the slider there." |
6940c6b5d988
(scroll-bar-drag, scroll-bar-drag-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
2315
diff
changeset
|
219 (interactive "e") |
11145
fb77829412af
(scroll-bar-drag): Bind echo-keystrokes to 0.
Richard M. Stallman <rms@gnu.org>
parents:
10555
diff
changeset
|
220 (let* (done |
21427
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
221 (echo-keystrokes 0) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
222 (end-position (event-end event)) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
223 (window (nth 0 end-position)) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
224 (before-scroll)) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
225 (with-current-buffer (window-buffer window) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
226 (setq before-scroll point-before-scroll)) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
227 (save-selected-window |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
228 (select-window window) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
229 (setq before-scroll |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
230 (or before-scroll (point)))) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
231 (scroll-bar-drag-1 event) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
232 (track-mouse |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
233 (while (not done) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
234 (setq event (read-event)) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
235 (if (eq (car-safe event) 'mouse-movement) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
236 (setq event (read-event))) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
237 (cond ((eq (car-safe event) 'scroll-bar-movement) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
238 (scroll-bar-drag-1 event)) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
239 (t |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
240 ;; Exit when we get the drag event; ignore that event. |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
241 (setq done t))))) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
242 (sit-for 0) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
243 (with-current-buffer (window-buffer window) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
244 (setq point-before-scroll before-scroll)))) |
2698
6940c6b5d988
(scroll-bar-drag, scroll-bar-drag-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
2315
diff
changeset
|
245 |
1981
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
246 (defun scroll-bar-scroll-down (event) |
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
247 "Scroll the window's top line down to the location of the scroll bar click. |
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
248 EVENT should be a scroll bar click." |
1772 | 249 (interactive "e") |
21427
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
250 (let* ((end-position (event-end event)) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
251 (window (nth 0 end-position)) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
252 (before-scroll)) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
253 (with-current-buffer (window-buffer window) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
254 (setq before-scroll point-before-scroll)) |
23248
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
255 (unwind-protect |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
256 (save-selected-window |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
257 (let ((portion-whole (nth 2 end-position))) |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
258 (select-window window) |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
259 (setq before-scroll |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
260 (or before-scroll (point))) |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
261 (scroll-down |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
262 (scroll-bar-scale portion-whole (1- (window-height))))) |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
263 (sit-for 0)) |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
264 (with-current-buffer (window-buffer window) |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
265 (setq point-before-scroll before-scroll))))) |
1772 | 266 |
1981
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
267 (defun scroll-bar-scroll-up (event) |
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
268 "Scroll the line next to the scroll bar click to the top of the window. |
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
269 EVENT should be a scroll bar click." |
1772 | 270 (interactive "e") |
21427
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
271 (let* ((end-position (event-end event)) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
272 (window (nth 0 end-position)) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
273 (before-scroll)) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
274 (with-current-buffer (window-buffer window) |
b5a5ac474741
(scroll-bar-drag): Set point-before-scroll
Richard M. Stallman <rms@gnu.org>
parents:
20129
diff
changeset
|
275 (setq before-scroll point-before-scroll)) |
23248
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
276 (unwind-protect |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
277 (save-selected-window |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
278 (let ((portion-whole (nth 2 end-position))) |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
279 (select-window window) |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
280 (setq before-scroll |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
281 (or before-scroll (point))) |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
282 (scroll-up |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
283 (scroll-bar-scale portion-whole (1- (window-height))))) |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
284 (sit-for 0)) |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
285 (with-current-buffer (window-buffer window) |
6119bb0ddd69
(scroll-bar-scroll-down, scroll-bar-scroll-up):
Karl Heuer <kwzh@gnu.org>
parents:
22908
diff
changeset
|
286 (setq point-before-scroll before-scroll))))) |
1772 | 287 |
288 | |
24981 | 289 ;;; Tookit scroll bars. |
290 | |
291 (defun scroll-bar-toolkit-scroll (event) | |
292 (interactive "e") | |
293 (let* ((end-position (event-end event)) | |
294 (window (nth 0 end-position)) | |
295 (part (nth 4 end-position)) | |
296 before-scroll) | |
27421
34b81c946198
(scroll-bar-timer): Variable removed.
Gerd Moellmann <gerd@gnu.org>
parents:
26510
diff
changeset
|
297 (cond ((eq part 'end-scroll)) |
24981 | 298 (t |
299 (with-current-buffer (window-buffer window) | |
300 (setq before-scroll point-before-scroll)) | |
301 (save-selected-window | |
302 (select-window window) | |
303 (setq before-scroll (or before-scroll (point))) | |
304 (cond ((eq part 'above-handle) | |
305 (scroll-up '-)) | |
306 ((eq part 'below-handle) | |
307 (scroll-up nil)) | |
26510
6866d2a9a421
(scroll-bar-toolkit-scroll): add handling of the `ratio'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24981
diff
changeset
|
308 ((eq part 'ratio) |
6866d2a9a421
(scroll-bar-toolkit-scroll): add handling of the `ratio'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24981
diff
changeset
|
309 (let* ((portion-whole (nth 2 end-position)) |
6866d2a9a421
(scroll-bar-toolkit-scroll): add handling of the `ratio'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24981
diff
changeset
|
310 (lines (scroll-bar-scale portion-whole |
6866d2a9a421
(scroll-bar-toolkit-scroll): add handling of the `ratio'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24981
diff
changeset
|
311 (1- (window-height))))) |
6866d2a9a421
(scroll-bar-toolkit-scroll): add handling of the `ratio'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24981
diff
changeset
|
312 (scroll-up (cond ((not (zerop lines)) lines) |
6866d2a9a421
(scroll-bar-toolkit-scroll): add handling of the `ratio'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24981
diff
changeset
|
313 ((< (car portion-whole) 0) -1) |
6866d2a9a421
(scroll-bar-toolkit-scroll): add handling of the `ratio'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24981
diff
changeset
|
314 (t 1))))) |
24981 | 315 ((eq part 'up) |
316 (scroll-up -1)) | |
317 ((eq part 'down) | |
318 (scroll-up 1)) | |
319 ((eq part 'top) | |
320 (set-window-start window (point-min))) | |
321 ((eq part 'bottom) | |
322 (goto-char (point-max)) | |
323 (recenter)) | |
324 ((eq part 'handle) | |
325 (scroll-bar-drag-1 event)))) | |
326 (sit-for 0) | |
327 (with-current-buffer (window-buffer window) | |
328 (setq point-before-scroll before-scroll)))))) | |
329 | |
330 | |
331 | |
1772 | 332 ;;;; Bindings. |
333 | |
105994
009383a57ce8
* x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102248
diff
changeset
|
334 ;; For now, we'll set things up to work like xterm. |
36803
4b1f1bdaf676
(toplevel): Test if `x-toolkit-scroll-bars' is
Gerd Moellmann <gerd@gnu.org>
parents:
34871
diff
changeset
|
335 (cond ((and (boundp 'x-toolkit-scroll-bars) x-toolkit-scroll-bars) |
24981 | 336 (global-set-key [vertical-scroll-bar mouse-1] |
337 'scroll-bar-toolkit-scroll)) | |
338 (t | |
339 (global-set-key [vertical-scroll-bar mouse-1] | |
340 'scroll-bar-scroll-up) | |
341 (global-set-key [vertical-scroll-bar drag-mouse-1] | |
342 'scroll-bar-scroll-up) | |
343 (global-set-key [vertical-scroll-bar down-mouse-2] | |
344 'scroll-bar-drag) | |
345 (global-set-key [vertical-scroll-bar mouse-3] | |
346 'scroll-bar-scroll-down) | |
347 (global-set-key [vertical-scroll-bar drag-mouse-3] | |
348 'scroll-bar-scroll-down))) | |
1772 | 349 |
350 | |
1973
3a08dacd8bfb
These are in preparation for a more thorough renaming to occur soon.
Jim Blandy <jimb@redhat.com>
parents:
1954
diff
changeset
|
351 (provide 'scroll-bar) |
1772 | 352 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
353 ;; arch-tag: 6f1d01d0-0b1e-4bf8-86db-d491e0f399f3 |
1981
bde0ca7e33b3
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1973
diff
changeset
|
354 ;;; scroll-bar.el ends here |