diff options
| author | Gerd Moellmann | 1999-07-21 21:43:03 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 1999-07-21 21:43:03 +0000 |
| commit | cf4eb316c1a3c33882e2fad6cf943abe93933d85 (patch) | |
| tree | ba28d21bd481f6109a01dedc90fa5755788fd5f9 | |
| parent | e724900d94ba3be4271471a46d25fc5297c160a1 (diff) | |
| download | emacs-cf4eb316c1a3c33882e2fad6cf943abe93933d85.tar.gz emacs-cf4eb316c1a3c33882e2fad6cf943abe93933d85.zip | |
(scroll-bar-timer): New.
(scroll-bar-toolkit-scroll): Start and cancel scroll-bar-timer.
(scroll-bar-toolkit-scroll): Handle `top' and `bottom'.
(scroll-bar-toolkit-scroll): New.
(global): Use different key bindings if using toolkit scroll bars.
| -rw-r--r-- | lisp/scroll-bar.el | 73 |
1 files changed, 66 insertions, 7 deletions
diff --git a/lisp/scroll-bar.el b/lisp/scroll-bar.el index d8e21921458..4499c0b0b5f 100644 --- a/lisp/scroll-bar.el +++ b/lisp/scroll-bar.el | |||
| @@ -284,16 +284,75 @@ EVENT should be a scroll bar click." | |||
| 284 | (setq point-before-scroll before-scroll))))) | 284 | (setq point-before-scroll before-scroll))))) |
| 285 | 285 | ||
| 286 | 286 | ||
| 287 | ;;;; Bindings. | 287 | ;;; Tookit scroll bars. |
| 288 | 288 | ||
| 289 | ;;; For now, we'll set things up to work like xterm. | 289 | ;; Due to its event handling, Emacs is currently not able to handle Xt |
| 290 | (global-set-key [vertical-scroll-bar mouse-1] 'scroll-bar-scroll-up) | 290 | ;; timeouts which toolkit scroll bars use to implement auto-repeat. |
| 291 | (global-set-key [vertical-scroll-bar drag-mouse-1] 'scroll-bar-scroll-up) | 291 | ;; As a workaround, we start a timer whenever a scroll bar action |
| 292 | ;; occurs, and remove it again when are notified that the user no | ||
| 293 | ;; longer interacts with the scroll bar. The timer function gives Xt | ||
| 294 | ;; the chance to call Xt timeout functions. | ||
| 295 | |||
| 296 | (defvar scroll-bar-timer nil | ||
| 297 | "Timer running while scroll bar is active.") | ||
| 292 | 298 | ||
| 293 | (global-set-key [vertical-scroll-bar down-mouse-2] 'scroll-bar-drag) | 299 | (defun scroll-bar-toolkit-scroll (event) |
| 300 | (interactive "e") | ||
| 301 | (let* ((end-position (event-end event)) | ||
| 302 | (window (nth 0 end-position)) | ||
| 303 | (part (nth 4 end-position)) | ||
| 304 | before-scroll) | ||
| 305 | (cond ((eq part 'end-scroll) | ||
| 306 | (when scroll-bar-timer | ||
| 307 | (cancel-timer scroll-bar-timer) | ||
| 308 | (setq scroll-bar-timer nil))) | ||
| 309 | (t | ||
| 310 | (with-current-buffer (window-buffer window) | ||
| 311 | (setq before-scroll point-before-scroll)) | ||
| 312 | (save-selected-window | ||
| 313 | (select-window window) | ||
| 314 | (setq before-scroll (or before-scroll (point))) | ||
| 315 | (cond ((eq part 'above-handle) | ||
| 316 | (scroll-up '-)) | ||
| 317 | ((eq part 'below-handle) | ||
| 318 | (scroll-up nil)) | ||
| 319 | ((eq part 'up) | ||
| 320 | (scroll-up -1)) | ||
| 321 | ((eq part 'down) | ||
| 322 | (scroll-up 1)) | ||
| 323 | ((eq part 'top) | ||
| 324 | (set-window-start window (point-min))) | ||
| 325 | ((eq part 'bottom) | ||
| 326 | (goto-char (point-max)) | ||
| 327 | (recenter)) | ||
| 328 | ((eq part 'handle) | ||
| 329 | (scroll-bar-drag-1 event)))) | ||
| 330 | (sit-for 0) | ||
| 331 | (unless scroll-bar-timer | ||
| 332 | (setq scroll-bar-timer | ||
| 333 | (run-with-timer 0.1 0.1 'xt-process-timeouts))) | ||
| 334 | (with-current-buffer (window-buffer window) | ||
| 335 | (setq point-before-scroll before-scroll)))))) | ||
| 294 | 336 | ||
| 295 | (global-set-key [vertical-scroll-bar mouse-3] 'scroll-bar-scroll-down) | 337 | |
| 296 | (global-set-key [vertical-scroll-bar drag-mouse-3] 'scroll-bar-scroll-down) | 338 | |
| 339 | ;;;; Bindings. | ||
| 340 | |||
| 341 | ;;; For now, we'll set things up to work like xterm. | ||
| 342 | (cond (x-toolkit-scroll-bars-p | ||
| 343 | (global-set-key [vertical-scroll-bar mouse-1] | ||
| 344 | 'scroll-bar-toolkit-scroll)) | ||
| 345 | (t | ||
| 346 | (global-set-key [vertical-scroll-bar mouse-1] | ||
| 347 | 'scroll-bar-scroll-up) | ||
| 348 | (global-set-key [vertical-scroll-bar drag-mouse-1] | ||
| 349 | 'scroll-bar-scroll-up) | ||
| 350 | (global-set-key [vertical-scroll-bar down-mouse-2] | ||
| 351 | 'scroll-bar-drag) | ||
| 352 | (global-set-key [vertical-scroll-bar mouse-3] | ||
| 353 | 'scroll-bar-scroll-down) | ||
| 354 | (global-set-key [vertical-scroll-bar drag-mouse-3] | ||
| 355 | 'scroll-bar-scroll-down))) | ||
| 297 | 356 | ||
| 298 | 357 | ||
| 299 | (provide 'scroll-bar) | 358 | (provide 'scroll-bar) |