2
|
1 ;;; w3-e19.el --- Emacs 19.xx specific functions for emacs-w3
|
0
|
2 ;; Author: wmperry
|
14
|
3 ;; Created: 1996/12/31 15:38:51
|
|
4 ;; Version: 1.12
|
0
|
5 ;; Keywords: faces, help, mouse, hypermedia
|
|
6
|
|
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2
|
8 ;;; Copyright (c) 1993 - 1996 by William M. Perry (wmperry@cs.indiana.edu)
|
14
|
9 ;;; Copyright (c) 1996 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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
30 ;;; Enhancements For Emacs 19
|
|
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
32 (require 'w3-forms)
|
|
33 (require 'font)
|
|
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
35 ;;; Help menu
|
|
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
14
|
37 (defvar w3-e19-hotlist-menu nil "A menu for hotlists.")
|
|
38 (defvar w3-e19-links-menu nil "A buffer-local menu for hyperlinks.")
|
|
39 (defvar w3-e19-nav-menu nil "A buffer-local menu for html based <link> tags.")
|
|
40 (mapcar 'make-variable-buffer-local
|
|
41 '(w3-e19-hotlist-menu w3-e19-links-menu w3-e19-nav-menu))
|
0
|
42
|
|
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
44 ;;; Functions to build menus of urls
|
|
45 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
14
|
46 (defun w3-e19-show-hotlist-menu ()
|
|
47 (interactive)
|
|
48 (let ((keymap (easy-menu-create-keymaps "Hotlist"
|
|
49 (w3-menu-hotlist-constructor nil)))
|
|
50 (x nil)
|
|
51 (y nil))
|
|
52 (setq x (x-popup-menu t keymap)
|
|
53 y (and x (lookup-key keymap (apply 'vector x))))
|
|
54 (if (and x y)
|
|
55 (funcall y))))
|
0
|
56
|
14
|
57 (defun w3-e19-show-links-menu ()
|
|
58 (interactive)
|
0
|
59 (if (not w3-e19-links-menu)
|
|
60 (w3-build-FSF19-menu))
|
14
|
61 (let (x y)
|
|
62 (setq x (x-popup-menu t w3-e19-links-menu)
|
|
63 y (and x (lookup-key w3-e19-links-menu (apply 'vector x))))
|
|
64 (if (and x y)
|
|
65 (funcall y))))
|
|
66
|
|
67 (defun w3-e19-show-navigate-menu ()
|
|
68 (interactive)
|
|
69 (if (not w3-e19-nav-menu)
|
|
70 (w3-build-FSF19-menu))
|
|
71 (let (x y)
|
|
72 (setq x (x-popup-menu t w3-e19-nav-menu)
|
|
73 y (and x (lookup-key w3-e19-nav-menu (apply 'vector x))))
|
0
|
74 (if (and x y)
|
|
75 (funcall y))))
|
|
76
|
|
77 (defun w3-build-FSF19-menu ()
|
|
78 ;; Build emacs19 menus from w3-links-list
|
14
|
79 (let ((links (w3-menu-html-links-constructor nil))
|
|
80 (hlink (w3-menu-links-constructor nil)))
|
|
81 (setq w3-e19-nav-menu (easy-menu-create-keymaps "Navigate" links)
|
|
82 w3-e19-links-menu (easy-menu-create-keymaps "Links" hlink))))
|
0
|
83
|
|
84 (defun w3-setup-version-specifics ()
|
|
85 ;; Set up routine for emacs 19
|
14
|
86 (require 'lmenu) ; for popup-menu
|
|
87 )
|
0
|
88
|
|
89 (defun w3-store-in-clipboard (str)
|
|
90 "Store string STR in the Xwindows clipboard"
|
|
91 (cond
|
|
92 ((memq (device-type) '(x pm))
|
|
93 (x-select-text str))
|
|
94 ((eq (device-type) 'ns)
|
|
95 (ns-store-pasteboard-internal str))
|
|
96 (t nil)))
|
|
97
|
|
98 (defun w3-mode-version-specifics ()
|
|
99 ;; Emacs 19 specific stuff for w3-mode
|
|
100 (make-local-variable 'track-mouse)
|
|
101 (if w3-track-mouse (setq track-mouse t))
|
14
|
102 '(if (or (memq (device-type) '(x pm ns)))
|
0
|
103 (w3-build-FSF19-menu)))
|
|
104
|
|
105 (defun w3-mouse-handler (e)
|
|
106 "Function to message the url under the mouse cursor"
|
|
107 (interactive "e")
|
|
108 (let* ((pt (posn-point (event-start e)))
|
|
109 (good (eq (posn-window (event-start e)) (selected-window)))
|
|
110 (widget (and good pt (number-or-marker-p pt) (widget-at pt)))
|
14
|
111 (link (and widget (or (widget-get widget 'href)
|
|
112 (widget-get widget 'name))))
|
0
|
113 (form (and widget (widget-get widget 'w3-form-data)))
|
|
114 (imag nil) ; (nth 1 (memq 'w3graphic props))))
|
|
115 )
|
|
116 (cond
|
14
|
117 (link (w3-widget-echo widget))
|
0
|
118 (form
|
|
119 (cond
|
|
120 ((eq 'submit (w3-form-element-type form))
|
|
121 (message "Submit form to %s"
|
|
122 (cdr-safe (assq 'action (w3-form-element-action form)))))
|
|
123 ((eq 'reset (w3-form-element-type form))
|
|
124 (message "Reset form contents"))
|
|
125 (t
|
|
126 (message "Form entry (name=%s, type=%s)" (w3-form-element-name form)
|
|
127 (w3-form-element-type form)))))
|
|
128 (imag (message "Inlined image (%s)" (car imag)))
|
|
129 (t (message "")))))
|
|
130
|
|
131 (defun w3-color-values (color)
|
|
132 (cond
|
|
133 ((eq window-system 'x)
|
|
134 (x-color-values color))
|
2
|
135 ((eq window-system 'pm)
|
|
136 (pm-color-values color))
|
0
|
137 ((eq window-system 'ns)
|
|
138 (ns-color-values color))
|
|
139 (t nil)))
|
|
140
|
|
141 (defun w3-color-light-p (color-or-face)
|
|
142 (let (colors)
|
|
143 (cond
|
|
144 ((null window-system)
|
|
145 nil)
|
|
146 ((facep color-or-face)
|
|
147 (setq color-or-face (face-background color-or-face))
|
|
148 (if (null color-or-face)
|
|
149 (setq color-or-face (cdr-safe
|
|
150 (assq 'background-color (frame-parameters)))))
|
|
151 (setq colors (w3-color-values color-or-face)))
|
|
152 ((stringp color-or-face)
|
|
153 (setq colors (w3-color-values color-or-face)))
|
|
154 ((font-rgb-color-p color-or-face)
|
|
155 (setq colors (list (font-rgb-color-red color-or-face)
|
|
156 (font-rgb-color-green color-or-face)
|
|
157 (font-rgb-color-blue color-or-face))))
|
|
158 (t
|
|
159 (signal 'wrong-type-argument 'color-or-face-p)))
|
|
160 (not (< (apply '+ colors)
|
|
161 (/ (apply '+ (w3-color-values "white")) 3)))))
|
|
162
|
|
163
|
|
164
|
|
165 (provide 'w3-emacs19)
|
|
166 (provide 'w3-e19)
|