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