2
|
1 ;;; w3-xemac.el --- XEmacs specific functions for emacs-w3
|
0
|
2 ;; Author: wmperry
|
122
|
3 ;; Created: 1997/04/10 00:03:38
|
|
4 ;; Version: 1.18
|
0
|
5 ;; Keywords: faces, help, mouse, hypermedia
|
|
6
|
|
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2
|
8 ;;; Copyright (c) 1993 - 1996 by William M. Perry (wmperry@cs.indiana.edu)
|
82
|
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
|
80
|
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)
|
82
|
33 (require 'w3-forms)
|
102
|
34 (require 'w3-script)
|
0
|
35 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
36 ;;; Enhancements For XEmacs
|
|
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
122
|
38 (defun w3-text-pixel-width (str &optional face)
|
|
39 "Return the pixel-width of a chunk of text STR with face FACE."
|
|
40 (let ((glyph (make-glyph str))
|
|
41 (todo (if (listp face) face (list face)))
|
|
42 (max 0))
|
|
43 (while (progn (set-glyph-face glyph (pop todo)) todo)
|
|
44 (setq max (max (glyph-width glyph) max)))
|
|
45 max))
|
|
46
|
0
|
47 (defun w3-mouse-handler (e)
|
|
48 "Function to message the url under the mouse cursor"
|
2
|
49 (interactive "e")
|
0
|
50 (let* ((pt (event-point e))
|
2
|
51 (good (eq (event-window e) (selected-window)))
|
102
|
52 (mouse-events))
|
|
53 (if (not (and good pt (number-or-marker-p pt)))
|
|
54 nil
|
|
55 (if (and inhibit-help-echo w3-track-mouse)
|
|
56 (widget-echo-help pt))
|
|
57 (setq mouse-events (w3-script-find-event-handlers pt 'mouse))
|
|
58 (if (assq 'onmouseover mouse-events)
|
|
59 (w3-script-evaluate-form (cdr (assq 'onmouseover mouse-events)))))))
|
0
|
60
|
|
61 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
62 ;;; Functions to build menus of urls
|
|
63 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
64 (defun w3-setup-version-specifics ()
|
|
65 "Set up routine for XEmacs 19.12 or later"
|
|
66 ;; Create the toolbar buttons
|
|
67 (and (featurep 'toolbar)
|
|
68 (w3-toolbar-make-buttons))
|
|
69
|
|
70 ;; Register the default set of image conversion utilities
|
|
71 (image-register-netpbm-utilities)
|
|
72
|
|
73 ;; Add our menus, but make sure that we do it to the global menubar
|
|
74 ;; not the current one, which could be anything, but usually GNUS or
|
|
75 ;; VM if not the default.
|
|
76 (if (featurep 'menubar)
|
|
77 (let ((current-menubar (default-value 'current-menubar)))
|
|
78 (if current-menubar
|
|
79 (add-submenu '("Help") (cons "WWW" (cdr w3-menu-help-menu))))))
|
|
80
|
98
|
81 ;; FIXME FIXME: Do sexy things to the default modeline for Emacs-W3
|
|
82
|
|
83 ;; The following is a workaround for XEmacs 19.14 and XEmacs 20.0
|
|
84 ;; The text property implementation is badly broken - you could not have
|
|
85 ;; a text property with a `nil' value. Bad bad bad.
|
|
86 (if (or (and (= emacs-major-version 20)
|
|
87 (= emacs-minor-version 0))
|
|
88 (and (= emacs-major-version 19)
|
|
89 (= emacs-minor-version 14)))
|
|
90 (defun text-prop-extent-paste-function (ext from to)
|
|
91 (let ((prop (extent-property ext 'text-prop nil))
|
|
92 (val nil))
|
|
93 (if (null prop)
|
|
94 (error "Internal error: no text-prop"))
|
|
95 (setq val (extent-property ext prop nil))
|
|
96 (put-text-property from to prop val nil)
|
|
97 nil))
|
|
98 )
|
0
|
99 )
|
|
100
|
|
101 (defun w3-store-in-clipboard (str)
|
|
102 "Store string STR into the clipboard in X"
|
|
103 (cond
|
|
104 ((eq (device-type) 'tty)
|
|
105 nil)
|
|
106 ((eq (device-type) 'x)
|
|
107 (x-own-selection str))
|
|
108 ((eq (device-type) 'ns)
|
|
109 )
|
|
110 (t nil)))
|
|
111
|
|
112 (defun w3-mode-motion-hook (e)
|
|
113 (let* ((glyph (event-glyph e))
|
|
114 (x (and glyph (event-glyph-x-pixel e)))
|
|
115 (y (and glyph (event-glyph-y-pixel e)))
|
|
116 (widget (and glyph (glyph-property glyph 'widget)))
|
|
117 (usemap (and widget (w3-image-widget-usemap widget)))
|
|
118 (ismap (and widget (widget-get widget 'ismap)))
|
|
119 (echo (and widget (widget-get widget 'href))))
|
|
120 (cond
|
|
121 (usemap
|
|
122 (setq echo (w3-point-in-map (vector x y) usemap t)))
|
|
123 (ismap
|
|
124 (setq echo (format "%s?%d,%d" echo x y)))
|
|
125 (t
|
|
126 nil))
|
|
127 (and echo (message "%s" echo))))
|
|
128
|
|
129 (defun w3-mode-version-specifics ()
|
|
130 "XEmacs specific stuff for w3-mode"
|
82
|
131 (if (featurep 'mouse)
|
102
|
132 (progn
|
|
133 (if (not w3-track-mouse)
|
|
134 (setq inhibit-help-echo nil))
|
|
135 (setq mode-motion-hook 'w3-mouse-handler)))
|
110
|
136 (case (device-type)
|
|
137 ((tty stream) ; TTY or batch
|
|
138 nil)
|
|
139 (otherwise
|
|
140 (w3-add-toolbar-to-buffer)))
|
0
|
141 (setq mode-popup-menu w3-popup-menu))
|
|
142
|
|
143 (require 'w3-toolbar)
|
|
144 (provide 'w3-xemacs)
|
|
145 (provide 'w3-xemac)
|