Mercurial > hg > xemacs-beta
comparison lisp/hm--html-menus/adapt.el @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children | 8fc7fe29b841 |
comparison
equal
deleted
inserted
replaced
1:c0c6a60d29db | 2:ac2d302a0011 |
---|---|
1 ;;; $Id: adapt.el,v 1.1.1.1 1996/12/18 03:34:31 steve Exp $ | 1 ;;; $Id: adapt.el,v 1.1.1.2 1996/12/18 03:46:45 steve Exp $ |
2 ;;; | 2 ;;; |
3 ;;; Copyright (C) 1993, 1994, 1995 Heiko Muenkel | 3 ;;; Copyright (C) 1993, 1994, 1995 Heiko Muenkel |
4 ;;; email: muenkel@tnt.uni-hannover.de | 4 ;;; email: muenkel@tnt.uni-hannover.de |
5 ;;; | 5 ;;; |
6 ;;; This program is free software; you can redistribute it and/or modify | 6 ;;; This program is free software; you can redistribute it and/or modify |
180 ; (if (not (fboundp 'set-extent-property)) | 180 ; (if (not (fboundp 'set-extent-property)) |
181 ; (defun set-extent-property (extent property value) | 181 ; (defun set-extent-property (extent property value) |
182 ; "Change a property of an extent. | 182 ; "Change a property of an extent. |
183 ;Only a dummy version in Emacs 19.")) | 183 ;Only a dummy version in Emacs 19.")) |
184 | 184 |
185 (if (not (fboundp 'region-active-p)) | |
186 (defun region-active-p () | |
187 "Non-nil iff the region is active. | |
188 If `zmacs-regions' is true, this is equivalent to `region-exists-p'. | |
189 Otherwise, this function always returns false." | |
190 (adapt-region-active-p))) | |
191 | |
192 (if (not (fboundp 'next-command-event)) | |
193 (defun next-command-event (&optional event prompt) | |
194 "Unlike the XEmacs version it reads the next event, if | |
195 it is a command event or not. | |
196 | |
197 Return the next available \"user\" event. | |
198 Pass this object to `dispatch-event' to handle it. | |
199 | |
200 If EVENT is non-nil, it should be an event object and will be filled in | |
201 and returned; otherwise a new event object will be created and returned. | |
202 If PROMPT is non-nil, it should be a string and will be displayed in the | |
203 echo area while this function is waiting for an event. | |
204 | |
205 The event returned will be a keyboard, mouse press, or mouse release event. | |
206 If there are non-command events available (mouse motion, sub-process output, | |
207 etc) then these will be executed (with `dispatch-event') and discarded. This | |
208 function is provided as a convenience; it is equivalent to the lisp code | |
209 | |
210 (while (progn | |
211 (next-event event prompt) | |
212 (not (or (key-press-event-p event) | |
213 (button-press-event-p event) | |
214 (button-release-event-p event) | |
215 (misc-user-event-p event)))) | |
216 (dispatch-event event))" | |
217 (message prompt) | |
218 (or event | |
219 (read-event)))) | |
220 | |
221 (if (not (fboundp 'button-event-p)) | |
222 (defun button-event-p (obj) | |
223 "True if OBJ is a button-press or button-release event object." | |
224 (and (eventp obj) | |
225 (or (eq 'mouse-1 (event-basic-type obj)) | |
226 (eq 'mouse-2 (event-basic-type obj)) | |
227 (eq 'mouse-3 (event-basic-type obj)))))) | |
228 | |
229 (if (not (fboundp 'button-press-event-p)) | |
230 (defun button-press-event-p (obj) | |
231 "True if OBJ is a mouse-button-press event object." | |
232 (and (button-event-p obj) | |
233 (member 'down (event-modifiers obj))))) | |
234 | |
235 (if (not (fboundp 'button-release-event-p)) | |
236 (defun button-release-event-p (obj) | |
237 "True if OBJ is a mouse-button-release event object." | |
238 (and (button-event-p obj) | |
239 (not (button-press-event-p obj))))) | |
240 | |
241 (if (not (fboundp 'event-window)) | |
242 (defun event-window (event) | |
243 "Return the window of the given mouse event. | |
244 This may be nil if the event occurred in the border or over a toolbar. | |
245 The modeline is considered to be in the window it represents." | |
246 (and (eventp event) | |
247 (listp event) | |
248 (listp (cdr event)) | |
249 (listp (car (cdr event))) | |
250 (car (car (cdr event)))))) | |
251 | |
252 (if (not (fboundp 'event-buffer)) | |
253 (defun event-buffer (event) | |
254 "Given a mouse-motion, button-press, or button-release event, return | |
255 the buffer on which that event occurred. This will be nil for non-mouse | |
256 events. If event-over-text-area-p is nil, this will also be nil." | |
257 (if (button-event-p event) | |
258 (window-buffer (event-window event))))) | |
259 | |
260 | |
261 (if (not (fboundp 'event-closest-point)) | |
262 (defun event-closest-point (event) | |
263 "Return the character position of the given mouse event. | |
264 If the event did not occur over a window or over text, return the | |
265 closest point to the location of the event. If the Y pixel position | |
266 overlaps a window and the X pixel position is to the left of that | |
267 window, the closest point is the beginning of the line containing the | |
268 Y position. If the Y pixel position overlaps a window and the X pixel | |
269 position is to the right of that window, the closest point is the end | |
270 of the line containing the Y position. If the Y pixel position is | |
271 above a window, return 0. If it is below a window, return the value | |
272 of (window-end)." | |
273 (posn-point (event-start event)))) | |
274 | |
275 (if (not (fboundp 'add-minor-mode)) | |
276 (defun add-minor-mode (toggle | |
277 name | |
278 &optional | |
279 keymap | |
280 after | |
281 toggle-fun) | |
282 "Add a minor mode to `minor-mode-alist' and `minor-mode-map-alist'. | |
283 TOGGLE is a symbol whose value as a variable specifies whether the | |
284 minor mode is active. NAME is the name that should appear in the | |
285 modeline (it should be a string beginning with a space). KEYMAP is a | |
286 keymap to make active when the minor mode is active. AFTER is the | |
287 toggling symbol used for another minor mode. If AFTER is non-nil, | |
288 then it is used to position the new mode in the minor-mode alists. | |
289 | |
290 TOGGLE-FUN is only a dummy variable in the Emacs 19. In the XEmacs | |
291 it has the following description: | |
292 TOGGLE-FUN specifies an interactive function that is called to toggle | |
293 the mode on and off; this affects what happens when button2 is pressed | |
294 on the mode, and when button3 is pressed somewhere in the list of | |
295 modes. If TOGGLE-FUN is nil and TOGGLE names an interactive function, | |
296 TOGGLE is used as the toggle function. | |
297 | |
298 Example: (add-minor-mode 'view-minor-mode \" View\" view-mode-map) | |
299 | |
300 WARNING: THIS FUNCTION ISN'T READ YET." | |
301 (if after | |
302 (add-minor-mode-1 toggle name keymap after) | |
303 (if (not (assq toggle minor-mode-alist)) | |
304 (progn | |
305 (setq minor-mode-alist | |
306 (cons (list toggle name) | |
307 minor-mode-alist)))) | |
308 (if (not (assq toggle minor-mode-map-alist)) | |
309 (progn | |
310 (setq minor-mode-map-alist | |
311 (cons (cons toggle keymap) | |
312 minor-mode-map-alist)))) | |
313 )) | |
314 ) | |
185 )) | 315 )) |
186 | 316 |
187 | 317 |
188 (provide 'adapt) | 318 (provide 'adapt) |