annotate lisp/w3/w3-xemac.el @ 110:fe104dbd9147 r20-1b7

Import from CVS: tag r20-1b7
author cvs
date Mon, 13 Aug 2007 09:19:45 +0200
parents a145efe76779
children 7d55a9ba150c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1 ;;; w3-xemac.el --- XEmacs specific functions for emacs-w3
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Author: wmperry
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 102
diff changeset
3 ;; Created: 1997/03/09 01:59:33
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 102
diff changeset
4 ;; Version: 1.16
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: faces, help, mouse, hypermedia
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
8 ;;; Copyright (c) 1993 - 1996 by William M. Perry (wmperry@cs.indiana.edu)
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; You should have received a copy of the GNU General Public License
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
24 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
26 ;;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (require 'w3-imap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (require 'images)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (require 'w3-widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (require 'w3-menu)
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
33 (require 'w3-forms)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
34 (require 'w3-script)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; Enhancements For XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defun w3-mouse-handler (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 "Function to message the url under the mouse cursor"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
40 (interactive "e")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (let* ((pt (event-point e))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
42 (good (eq (event-window e) (selected-window)))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
43 (mouse-events))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
44 (if (not (and good pt (number-or-marker-p pt)))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
45 nil
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
46 (if (and inhibit-help-echo w3-track-mouse)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
47 (widget-echo-help pt))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
48 (setq mouse-events (w3-script-find-event-handlers pt 'mouse))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
49 (if (assq 'onmouseover mouse-events)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
50 (w3-script-evaluate-form (cdr (assq 'onmouseover mouse-events)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; Functions to build menus of urls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defun w3-setup-version-specifics ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 "Set up routine for XEmacs 19.12 or later"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; Create the toolbar buttons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (and (featurep 'toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (w3-toolbar-make-buttons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; Register the default set of image conversion utilities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (image-register-netpbm-utilities)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; Add our menus, but make sure that we do it to the global menubar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; not the current one, which could be anything, but usually GNUS or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; VM if not the default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (if (featurep 'menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (let ((current-menubar (default-value 'current-menubar)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (if current-menubar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (add-submenu '("Help") (cons "WWW" (cdr w3-menu-help-menu))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
72 ;; FIXME FIXME: Do sexy things to the default modeline for Emacs-W3
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
73
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
74 ;; The following is a workaround for XEmacs 19.14 and XEmacs 20.0
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
75 ;; The text property implementation is badly broken - you could not have
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
76 ;; a text property with a `nil' value. Bad bad bad.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
77 (if (or (and (= emacs-major-version 20)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
78 (= emacs-minor-version 0))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
79 (and (= emacs-major-version 19)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
80 (= emacs-minor-version 14)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
81 (defun text-prop-extent-paste-function (ext from to)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
82 (let ((prop (extent-property ext 'text-prop nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
83 (val nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
84 (if (null prop)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
85 (error "Internal error: no text-prop"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
86 (setq val (extent-property ext prop nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
87 (put-text-property from to prop val nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
88 nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
89 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (defun w3-store-in-clipboard (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 "Store string STR into the clipboard in X"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ((eq (device-type) 'tty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ((eq (device-type) 'x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (x-own-selection str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ((eq (device-type) 'ns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (defun w3-color-light-p (color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (let (face color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ((or (facep color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (and (symbolp color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (find-face color-or-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (setq color (specifier-instance (face-background color-or-face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ((color-instance-p color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (setq color color-or-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ((color-specifier-p color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (setq color (specifier-instance color-or-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ((stringp color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (setq color (make-color-instance color-or-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (t (signal 'wrong-type-argument 'color-or-face-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (if color
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (not (< (apply '+ (color-instance-rgb-components color))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (/ (apply '+ (color-instance-rgb-components
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (make-color-instance "white"))) 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (defun w3-mode-motion-hook (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (let* ((glyph (event-glyph e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (x (and glyph (event-glyph-x-pixel e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (y (and glyph (event-glyph-y-pixel e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (widget (and glyph (glyph-property glyph 'widget)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (usemap (and widget (w3-image-widget-usemap widget)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (ismap (and widget (widget-get widget 'ismap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (echo (and widget (widget-get widget 'href))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (usemap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (setq echo (w3-point-in-map (vector x y) usemap t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (ismap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (setq echo (format "%s?%d,%d" echo x y)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (and echo (message "%s" echo))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (defun w3-mode-version-specifics ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 "XEmacs specific stuff for w3-mode"
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
142 (if (featurep 'mouse)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
143 (progn
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
144 (if (not w3-track-mouse)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
145 (setq inhibit-help-echo nil))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
146 (setq mode-motion-hook 'w3-mouse-handler)))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 102
diff changeset
147 (case (device-type)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 102
diff changeset
148 ((tty stream) ; TTY or batch
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 102
diff changeset
149 nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 102
diff changeset
150 (otherwise
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 102
diff changeset
151 (w3-add-toolbar-to-buffer)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (setq mode-popup-menu w3-popup-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (require 'w3-toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (provide 'w3-xemacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (provide 'w3-xemac)