2
|
1 ;;; w3-e19.el --- Emacs 19.xx specific functions for emacs-w3
|
0
|
2 ;; Author: wmperry
|
185
|
3 ;; Created: 1997/08/12 18:18:03
|
|
4 ;; Version: 1.29
|
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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
30 ;;; Enhancements For Emacs 19
|
|
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
138
|
32 (eval-when-compile
|
|
33 (require 'w3-props))
|
0
|
34 (require 'w3-forms)
|
|
35 (require 'font)
|
102
|
36 (require 'w3-script)
|
|
37
|
0
|
38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
39 ;;; Help menu
|
|
40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
80
|
41 (defvar w3-e19-hotlist-menu nil "A menu for hotlists.")
|
|
42 (defvar w3-e19-links-menu nil "A buffer-local menu for hyperlinks.")
|
|
43 (defvar w3-e19-nav-menu nil "A buffer-local menu for html based <link> tags.")
|
173
|
44 (defvar w3-e19-window-width nil)
|
|
45
|
80
|
46 (mapcar 'make-variable-buffer-local
|
173
|
47 '(w3-e19-hotlist-menu
|
|
48 w3-e19-window-width
|
|
49 w3-e19-links-menu
|
|
50 w3-e19-nav-menu))
|
0
|
51
|
|
52 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
53 ;;; Functions to build menus of urls
|
|
54 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
80
|
55 (defun w3-e19-show-hotlist-menu ()
|
|
56 (interactive)
|
|
57 (let ((keymap (easy-menu-create-keymaps "Hotlist"
|
|
58 (w3-menu-hotlist-constructor nil)))
|
|
59 (x nil)
|
|
60 (y nil))
|
|
61 (setq x (x-popup-menu t keymap)
|
|
62 y (and x (lookup-key keymap (apply 'vector x))))
|
|
63 (if (and x y)
|
|
64 (funcall y))))
|
0
|
65
|
80
|
66 (defun w3-e19-show-links-menu ()
|
|
67 (interactive)
|
0
|
68 (if (not w3-e19-links-menu)
|
|
69 (w3-build-FSF19-menu))
|
80
|
70 (let (x y)
|
|
71 (setq x (x-popup-menu t w3-e19-links-menu)
|
|
72 y (and x (lookup-key w3-e19-links-menu (apply 'vector x))))
|
|
73 (if (and x y)
|
|
74 (funcall y))))
|
|
75
|
|
76 (defun w3-e19-show-navigate-menu ()
|
|
77 (interactive)
|
|
78 (if (not w3-e19-nav-menu)
|
|
79 (w3-build-FSF19-menu))
|
|
80 (let (x y)
|
|
81 (setq x (x-popup-menu t w3-e19-nav-menu)
|
|
82 y (and x (lookup-key w3-e19-nav-menu (apply 'vector x))))
|
0
|
83 (if (and x y)
|
|
84 (funcall y))))
|
|
85
|
|
86 (defun w3-build-FSF19-menu ()
|
|
87 ;; Build emacs19 menus from w3-links-list
|
80
|
88 (let ((links (w3-menu-html-links-constructor nil))
|
|
89 (hlink (w3-menu-links-constructor nil)))
|
|
90 (setq w3-e19-nav-menu (easy-menu-create-keymaps "Navigate" links)
|
|
91 w3-e19-links-menu (easy-menu-create-keymaps "Links" hlink))))
|
0
|
92
|
|
93 (defun w3-setup-version-specifics ()
|
|
94 ;; Set up routine for emacs 19
|
80
|
95 (require 'lmenu) ; for popup-menu
|
|
96 )
|
0
|
97
|
|
98 (defun w3-store-in-clipboard (str)
|
173
|
99 "Store string STR in the system clipboard"
|
|
100 (cond
|
|
101 ((boundp 'interprogram-cut-function)
|
|
102 (if interprogram-cut-function
|
|
103 (funcall interprogram-cut-function str t)))
|
|
104 (t
|
|
105 (case (device-type)
|
|
106 (x (x-select-text str))
|
|
107 (pm (pm-put-clipboard str))
|
|
108 (ns (ns-store-pasteboard-internal str))
|
|
109 (otherwise nil)))))
|
0
|
110
|
|
111 (defun w3-mode-version-specifics ()
|
|
112 ;; Emacs 19 specific stuff for w3-mode
|
118
|
113 (declare (special w3-face-index w3-display-background-properties))
|
0
|
114 (make-local-variable 'track-mouse)
|
173
|
115 (setq w3-e19-window-width (window-width))
|
118
|
116 (if w3-track-mouse (setq track-mouse t))
|
|
117 (if w3-display-background-properties
|
|
118 (let ((face (w3-make-face (intern
|
|
119 (format "w3-style-face-%05d" w3-face-index))
|
|
120 "An Emacs-W3 face... don't edit by hand." t))
|
|
121 (fore (car w3-display-background-properties))
|
|
122 (inhibit-read-only t)
|
|
123 (back (cdr w3-display-background-properties)))
|
|
124 (setq w3-face-index (1+ w3-face-index))
|
|
125 (if fore (font-set-face-foreground face fore))
|
|
126 (if back (font-set-face-background face back))
|
|
127 (fillin-text-property (point-min) (point-max) 'face 'face face))))
|
0
|
128
|
122
|
129 (defun w3-text-pixel-width (str &optional face)
|
|
130 "Return the pixel-width of a chunk of text STR with face FACE."
|
|
131 (* (length str) (frame-char-width)))
|
|
132
|
0
|
133 (defun w3-mouse-handler (e)
|
|
134 "Function to message the url under the mouse cursor"
|
|
135 (interactive "e")
|
|
136 (let* ((pt (posn-point (event-start e)))
|
|
137 (good (eq (posn-window (event-start e)) (selected-window)))
|
102
|
138 (mouse-events nil))
|
|
139 (if (not (and good pt (number-or-marker-p pt)))
|
|
140 nil
|
|
141 (widget-echo-help pt)
|
185
|
142 ;; FIXME!!! Need to handle onmouseover, on mouseout
|
102
|
143 (setq mouse-events (w3-script-find-event-handlers pt 'mouse))
|
|
144 (if (assq 'onmouseover mouse-events)
|
|
145 (w3-script-evaluate-form (cdr (assq 'onmouseover mouse-events)))))))
|
0
|
146
|
173
|
147 (defun w3-window-size-change-function (frame)
|
|
148 (let ((first (frame-first-window frame))
|
|
149 (cur nil))
|
|
150 (while (not (eq cur first))
|
|
151 (setq cur (if cur (next-window cur nil frame) first))
|
|
152 (save-excursion
|
|
153 (set-buffer (window-buffer cur))
|
|
154 (if (and (eq major-mode 'w3-mode)
|
|
155 (not (eq (window-width cur) w3-e19-window-width)))
|
|
156 (w3-refresh-buffer))))))
|
|
157
|
0
|
158
|
|
159 (provide 'w3-emacs19)
|
|
160 (provide 'w3-e19)
|