comparison lisp/emacs-lisp/levents.el @ 2057:265b81ff7eee

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Sun, 07 Mar 1993 20:57:30 +0000
parents e062b4567dc6
children 9b4cb6b6d474
comparison
equal deleted inserted replaced
2056:0c95942fc8da 2057:265b81ff7eee
28 28
29 ;; Our read-key-sequence and read-char are not precisely 29 ;; Our read-key-sequence and read-char are not precisely
30 ;; compatible with those in Lucid Emacs, but they should work ok. 30 ;; compatible with those in Lucid Emacs, but they should work ok.
31 31
32 ;;; Code: 32 ;;; Code:
33
34 (defun next-command-event (event)
35 (error "You must rewrite to use `read-command-event' instead of `next-command-event'"))
36
37 (defun next-event (event)
38 (error "You must rewrite to use `read-event' instead of `next-event'"))
39
40 (defun dispatch-event (event)
41 (error "`dispatch-event' not supported"))
33 42
34 ;; Make events of type eval, menu and timeout 43 ;; Make events of type eval, menu and timeout
35 ;; execute properly. 44 ;; execute properly.
36 45
37 (define-key global-map [menu] 'execute-eval-event) 46 (define-key global-map [menu] 'execute-eval-event)
97 deallocate events when you are sure that that is safe. 106 deallocate events when you are sure that that is safe.
98 107
99 This emulation does not actually deallocate or reuse events 108 This emulation does not actually deallocate or reuse events
100 except via garbage collection and `cons'." 109 except via garbage collection and `cons'."
101 nil) 110 nil)
102
103 (defun dispatch-event (event)
104 "Given an event object returned by next-event, execute it."
105 (let ((type (car-safe event)))
106 (cond ((eq type 'eval)
107 (funcall (nth 1 event) (nth 2 event)))
108 ((eq type 'menu)
109 (funcall (nth 1 event) (nth 2 event)))
110 ((eq type 'switch-frame)
111 (internal-select-frame (nth 1 event)))
112 (t (error "keyboard and mouse events not allowed in `dispatch-event'")))))
113 111
114 (defun enqueue-eval-event: (function object) 112 (defun enqueue-eval-event: (function object)
115 "Add an eval event to the back of the queue. 113 "Add an eval event to the back of the queue.
116 It will be the next event read after all pending events." 114 It will be the next event read after all pending events."
117 (setq unread-command-events 115 (setq unread-command-events
259 257
260 (defun motion-event-p (obj) 258 (defun motion-event-p (obj)
261 "True if the argument is a mouse-motion event object." 259 "True if the argument is a mouse-motion event object."
262 (eq (car-safe obj) 'mouse-movement)) 260 (eq (car-safe obj) 'mouse-movement))
263 261
264 (defun next-command-event (event) 262 (defun read-command-event ()
265 "Given an event structure, fills it in with the next keyboard, mouse 263 "Return the next keyboard or mouse event; execute other events.
266 press, or mouse release event available from the user. If there are 264 This is similar to the function `next-command-event' of Lucid Emacs,
267 non-command events available (mouse motion, sub-process output, etc) then 265 but different in that it returns the event rather than filling in
268 these will be executed (with dispatch-event) and discarded." 266 an existing event object."
269 (while (progn 267 (let (event)
270 (next-event event) 268 (while (progn
271 (not (or (key-press-event-p event) 269 (setq event (read-event))
272 (button-press-event-p event) 270 (not (or (key-press-event-p event)
273 (button-release-event-p event) 271 (button-press-event-p event)
274 (menu-event-p event)))) 272 (button-release-event-p event)
275 (dispatch-event event))) 273 (menu-event-p event))))
276 274 (let ((type (car-safe event)))
277 (defun next-event (event &optional ignore) 275 (cond ((eq type 'eval)
278 "Given an event structure, fills it in with the next event available 276 (funcall (nth 1 event) (nth 2 event)))
279 from the window system or terminal driver. Pass this object to 277 ((eq type 'switch-frame)
280 `dispatch-event' to handle it. 278 (internal-select-frame (nth 1 event))))))
281 279 event))
282 See also the function `next-command-event'.
283
284 If the second optional argument is non-nil, then this will never return
285 key-press and mouse-click events, but will delay them until later. You
286 should probably never need to use this option; it is used for implementing
287 the `wait-reading-process-input' function."
288 (read-event))
289 280
290 (defun process-event-p (obj) 281 (defun process-event-p (obj)
291 "True if the argument is a process-output event object. 282 "True if the argument is a process-output event object.
292 GNU Emacs 19 does not currently generate process-output events." 283 GNU Emacs 19 does not currently generate process-output events."
293 (eq (car-safe obj) 'process)) 284 (eq (car-safe obj) 'process))