aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love1999-09-13 13:54:33 +0000
committerDave Love1999-09-13 13:54:33 +0000
commita89a9d34dcbc946a137ed30e5666bb3ab49859e9 (patch)
tree96ef6ce642a0ed7a1a020bd1dd95f57089390b57
parentd3d4df42e446de6209783e67ca78c44ecc960ff5 (diff)
downloademacs-a89a9d34dcbc946a137ed30e5666bb3ab49859e9.tar.gz
emacs-a89a9d34dcbc946a137ed30e5666bb3ab49859e9.zip
Remove some compatibility code and checks.
(widget-specify-field, widget-specify-button): Don't use XEmacs properties. (widget-overlay-inactive): Change error message. (widget-button-pressed-face): New variable. (widget-button-click): Use it. (widget-documentation-link-add): Specify mouse and button faces. (widget-echo-help-mouse, widget-stop-mouse-tracking): Functions removed now the functionality is built in.
-rw-r--r--lisp/wid-edit.el94
1 files changed, 27 insertions, 67 deletions
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index e0e58cb3b57..4ac7da42efe 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -1,11 +1,12 @@
1;;; wid-edit.el --- Functions for creating and using widgets. 1;;; wid-edit.el --- Functions for creating and using widgets.
2;; 2;;
3;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. 3;; Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
4;; 4;;
5;; Author: Per Abrahamsen <abraham@dina.kvl.dk> 5;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6;; Maintainer: FSF
6;; Keywords: extensions 7;; Keywords: extensions
7;; Version: 1.9951 8;; Version: 1.9951
8;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ 9;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ (probably obsolete)
9 10
10;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
11 12
@@ -46,18 +47,6 @@
46 (autoload 'Info-goto-node "info") 47 (autoload 'Info-goto-node "info")
47 (autoload 'finder-commentary "finder" nil t) 48 (autoload 'finder-commentary "finder" nil t)
48 49
49 (unless (and (featurep 'custom) (fboundp 'custom-declare-variable))
50 ;; We have the old custom-library, hack around it!
51 (defmacro defgroup (&rest args) nil)
52 (defmacro defcustom (var value doc &rest args)
53 (` (defvar (, var) (, value) (, doc))))
54 (defmacro defface (&rest args) nil)
55 (define-widget-keywords :prefix :tag :load :link :options :type :group)
56 (when (fboundp 'copy-face)
57 (copy-face 'default 'widget-documentation-face)
58 (copy-face 'bold 'widget-button-face)
59 (copy-face 'italic 'widget-field-face)))
60
61 (unless (fboundp 'button-release-event-p) 50 (unless (fboundp 'button-release-event-p)
62 ;; XEmacs function missing from Emacs. 51 ;; XEmacs function missing from Emacs.
63 (defun button-release-event-p (event) 52 (defun button-release-event-p (event)
@@ -89,7 +78,7 @@
89 :group 'faces) 78 :group 'faces)
90 79
91(defvar widget-documentation-face 'widget-documentation-face 80(defvar widget-documentation-face 'widget-documentation-face
92 "Face used for documentation strings in widges. 81 "Face used for documentation strings in widgets.
93This exists as a variable so it can be set locally in certain buffers.") 82This exists as a variable so it can be set locally in certain buffers.")
94 83
95(defface widget-documentation-face '((((class color) 84(defface widget-documentation-face '((((class color)
@@ -104,7 +93,7 @@ This exists as a variable so it can be set locally in certain buffers.")
104 :group 'widget-faces) 93 :group 'widget-faces)
105 94
106(defvar widget-button-face 'widget-button-face 95(defvar widget-button-face 'widget-button-face
107 "Face used for buttons in widges. 96 "Face used for buttons in widgets.
108This exists as a variable so it can be set locally in certain buffers.") 97This exists as a variable so it can be set locally in certain buffers.")
109 98
110(defface widget-button-face '((t (:bold t))) 99(defface widget-button-face '((t (:bold t)))
@@ -340,12 +329,12 @@ new value."
340 (unless (or (stringp help-echo) (null help-echo)) 329 (unless (or (stringp help-echo) (null help-echo))
341 (setq help-echo 'widget-mouse-help)) 330 (setq help-echo 'widget-mouse-help))
342 (widget-put widget :field-overlay overlay) 331 (widget-put widget :field-overlay overlay)
343 (overlay-put overlay 'detachable nil) 332 ;;(overlay-put overlay 'detachable nil)
344 (overlay-put overlay 'field widget) 333 (overlay-put overlay 'field widget)
345 (overlay-put overlay 'local-map map) 334 (overlay-put overlay 'local-map map)
346 (overlay-put overlay 'keymap map) 335 ;;(overlay-put overlay 'keymap map)
347 (overlay-put overlay 'face face) 336 (overlay-put overlay 'face face)
348 (overlay-put overlay 'balloon-help help-echo) 337 ;;(overlay-put overlay 'balloon-help help-echo)
349 (overlay-put overlay 'help-echo help-echo)) 338 (overlay-put overlay 'help-echo help-echo))
350 (widget-specify-secret widget)) 339 (widget-specify-secret widget))
351 340
@@ -377,7 +366,7 @@ new value."
377 (setq help-echo 'widget-mouse-help)) 366 (setq help-echo 'widget-mouse-help))
378 (overlay-put overlay 'button widget) 367 (overlay-put overlay 'button widget)
379 (overlay-put overlay 'mouse-face widget-mouse-face) 368 (overlay-put overlay 'mouse-face widget-mouse-face)
380 (overlay-put overlay 'balloon-help help-echo) 369 ;;(overlay-put overlay 'balloon-help help-echo)
381 (overlay-put overlay 'help-echo help-echo) 370 (overlay-put overlay 'help-echo help-echo)
382 (overlay-put overlay 'face face))) 371 (overlay-put overlay 'face face)))
383 372
@@ -444,15 +433,13 @@ new value."
444 ;; (overlay-put overlay 'mouse-face 'widget-inactive-face) 433 ;; (overlay-put overlay 'mouse-face 'widget-inactive-face)
445 (overlay-put overlay 'evaporate t) 434 (overlay-put overlay 'evaporate t)
446 (overlay-put overlay 'priority 100) 435 (overlay-put overlay 'priority 100)
447 (overlay-put overlay (if (string-match "XEmacs" emacs-version) 436 (overlay-put overlay 'modification-hooks '(widget-overlay-inactive))
448 'read-only
449 'modification-hooks) '(widget-overlay-inactive))
450 (widget-put widget :inactive overlay)))) 437 (widget-put widget :inactive overlay))))
451 438
452(defun widget-overlay-inactive (&rest junk) 439(defun widget-overlay-inactive (&rest junk)
453 "Ignoring the arguments, signal an error." 440 "Ignoring the arguments, signal an error."
454 (unless inhibit-read-only 441 (unless inhibit-read-only
455 (error "Attempt to modify inactive widget"))) 442 (error "The widget here is not active")))
456 443
457 444
458(defun widget-specify-active (widget) 445(defun widget-specify-active (widget)
@@ -502,7 +489,7 @@ Otherwise, just return the value."
502 (widget-apply widget :default-get))) 489 (widget-apply widget :default-get)))
503 490
504(defun widget-match-inline (widget vals) 491(defun widget-match-inline (widget vals)
505 ;; In WIDGET, match the start of VALS. 492 "In WIDGET, match the start of VALS."
506 (cond ((widget-get widget :inline) 493 (cond ((widget-get widget :inline)
507 (widget-apply widget :match-inline vals)) 494 (widget-apply widget :match-inline vals))
508 ((and vals 495 ((and vals
@@ -886,8 +873,7 @@ Recommended as a parent keymap for modes using widgets.")
886 873
887(unless widget-field-keymap 874(unless widget-field-keymap
888 (setq widget-field-keymap (copy-keymap widget-keymap)) 875 (setq widget-field-keymap (copy-keymap widget-keymap))
889 (unless (string-match "XEmacs" (emacs-version)) 876 (define-key widget-field-keymap [menu-bar] 'nil)
890 (define-key widget-field-keymap [menu-bar] 'nil))
891 (define-key widget-field-keymap "\C-k" 'widget-kill-line) 877 (define-key widget-field-keymap "\C-k" 'widget-kill-line)
892 (define-key widget-field-keymap "\M-\t" 'widget-complete) 878 (define-key widget-field-keymap "\M-\t" 'widget-complete)
893 (define-key widget-field-keymap "\C-m" 'widget-field-activate) 879 (define-key widget-field-keymap "\C-m" 'widget-field-activate)
@@ -900,8 +886,7 @@ Recommended as a parent keymap for modes using widgets.")
900 886
901(unless widget-text-keymap 887(unless widget-text-keymap
902 (setq widget-text-keymap (copy-keymap widget-keymap)) 888 (setq widget-text-keymap (copy-keymap widget-keymap))
903 (unless (string-match "XEmacs" (emacs-version)) 889 (define-key widget-text-keymap [menu-bar] 'nil)
904 (define-key widget-text-keymap [menu-bar] 'nil))
905 (define-key widget-text-keymap "\C-a" 'widget-beginning-of-line) 890 (define-key widget-text-keymap "\C-a" 'widget-beginning-of-line)
906 (define-key widget-text-keymap "\C-e" 'widget-end-of-line) 891 (define-key widget-text-keymap "\C-e" 'widget-end-of-line)
907 (set-keymap-parent widget-text-keymap global-map)) 892 (set-keymap-parent widget-text-keymap global-map))
@@ -915,6 +900,10 @@ Recommended as a parent keymap for modes using widgets.")
915 (call-interactively 900 (call-interactively
916 (lookup-key widget-global-map (this-command-keys)))))) 901 (lookup-key widget-global-map (this-command-keys))))))
917 902
903(defvar widget-button-pressed-face 'widget-button-pressed-face
904 "Face used for pressed buttons in widgets.
905This exists as a variable so it can be set locally in certain buffers.")
906
918(defface widget-button-pressed-face 907(defface widget-button-pressed-face
919 '((((class color)) 908 '((((class color))
920 (:foreground "red")) 909 (:foreground "red"))
@@ -940,9 +929,9 @@ Recommended as a parent keymap for modes using widgets.")
940 (unwind-protect 929 (unwind-protect
941 (let ((track-mouse t)) 930 (let ((track-mouse t))
942 (overlay-put overlay 931 (overlay-put overlay
943 'face 'widget-button-pressed-face) 932 'face widget-button-pressed-face)
944 (overlay-put overlay 933 (overlay-put overlay
945 'mouse-face 'widget-button-pressed-face) 934 'mouse-face widget-button-pressed-face)
946 (unless (widget-apply button :mouse-down-action event) 935 (unless (widget-apply button :mouse-down-action event)
947 (while (not (button-release-event-p event)) 936 (while (not (button-release-event-p event))
948 (setq event (widget-read-event) 937 (setq event (widget-read-event)
@@ -953,10 +942,10 @@ Recommended as a parent keymap for modes using widgets.")
953 (progn 942 (progn
954 (overlay-put overlay 943 (overlay-put overlay
955 'face 944 'face
956 'widget-button-pressed-face) 945 widget-button-pressed-face)
957 (overlay-put overlay 946 (overlay-put overlay
958 'mouse-face 947 'mouse-face
959 'widget-button-pressed-face)) 948 widget-button-pressed-face))
960 (overlay-put overlay 'face face) 949 (overlay-put overlay 'face face)
961 (overlay-put overlay 'mouse-face mouse-face)))) 950 (overlay-put overlay 'mouse-face mouse-face))))
962 (when (and pos 951 (when (and pos
@@ -2692,7 +2681,7 @@ when he invoked the menu."
2692;;; The `group' Widget. 2681;;; The `group' Widget.
2693 2682
2694(define-widget 'group 'default 2683(define-widget 'group 'default
2695 "A widget which group other widgets inside." 2684 "A widget which groups other widgets inside."
2696 :convert-widget 'widget-types-convert-widget 2685 :convert-widget 'widget-types-convert-widget
2697 :format "%v" 2686 :format "%v"
2698 :value-create 'widget-group-value-create 2687 :value-create 'widget-group-value-create
@@ -2839,7 +2828,10 @@ link for that string."
2839 (let ((regexp widget-documentation-link-regexp) 2828 (let ((regexp widget-documentation-link-regexp)
2840 (predicate widget-documentation-link-p) 2829 (predicate widget-documentation-link-p)
2841 (type widget-documentation-link-type) 2830 (type widget-documentation-link-type)
2842 (buttons (widget-get widget :buttons))) 2831 (buttons (widget-get widget :buttons))
2832 (widget-mouse-face (default-value 'widget-mouse-face))
2833 (widget-button-face widget-documentation-face)
2834 (widget-button-pressed-face widget-documentation-face))
2843 (save-excursion 2835 (save-excursion
2844 (goto-char from) 2836 (goto-char from)
2845 (while (re-search-forward regexp to t) 2837 (while (re-search-forward regexp to t)
@@ -3542,38 +3534,6 @@ To use this type, you must define :match or :match-alternatives."
3542 3534
3543;;; The Help Echo 3535;;; The Help Echo
3544 3536
3545(defun widget-echo-help-mouse ()
3546 "Display the help message for the widget under the mouse.
3547Enable with (run-with-idle-timer 1 t 'widget-echo-help-mouse)"
3548 (let* ((pos (mouse-position))
3549 (frame (car pos))
3550 (x (car (cdr pos)))
3551 (y (cdr (cdr pos)))
3552 (win (window-at x y frame))
3553 (where (coordinates-in-window-p (cons x y) win)))
3554 (when (consp where)
3555 (save-window-excursion
3556 (progn ; save-excursion
3557 (select-window win)
3558 (let* ((result (compute-motion (window-start win)
3559 '(0 . 0)
3560 (point-max)
3561 where
3562 (window-width win)
3563 (cons (window-hscroll) 0)
3564 win)))
3565 (when (and (eq (nth 1 result) x)
3566 (eq (nth 2 result) y))
3567 (widget-echo-help (nth 0 result))))))))
3568 (unless track-mouse
3569 (setq track-mouse t)
3570 (add-hook 'post-command-hook 'widget-stop-mouse-tracking)))
3571
3572(defun widget-stop-mouse-tracking (&rest args)
3573 "Stop the mouse tracking done while idle."
3574 (remove-hook 'post-command-hook 'widget-stop-mouse-tracking)
3575 (setq track-mouse nil))
3576
3577(defun widget-at (pos) 3537(defun widget-at (pos)
3578 "The button or field at POS." 3538 "The button or field at POS."
3579 (or (get-char-property pos 'button) 3539 (or (get-char-property pos 'button)