• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/emacs-lisp/

Lines Matching refs:event

1 ;;; levents.el --- emulate the Lucid event data type and associated functions
29 ;; It is not possible to emulate current-mouse-event as a variable,
32 ;; We do not have a variable unread-command-event;
40 (defun next-command-event (event)
41 (error "You must rewrite to use `read-command-event' instead of `next-command-event'"))
43 (defun next-event (event)
44 (error "You must rewrite to use `read-event' instead of `next-event'"))
46 (defun dispatch-event (event)
47 (error "`dispatch-event' not supported"))
52 (define-key global-map [menu] 'execute-eval-event)
53 (define-key global-map [timeout] 'execute-eval-event)
54 (define-key global-map [eval] 'execute-eval-event)
56 (defun execute-eval-event (event)
58 (funcall (nth 1 event) (nth 2 event)))
60 (put 'eval 'event-symbol-elements '(eval))
61 (put 'menu 'event-symbol-elements '(eval))
62 (put 'timeout 'event-symbol-elements '(eval))
64 (defun allocate-event ()
65 "Returns an empty event structure.
69 (defun button-press-event-p (obj)
70 "True if the argument is a mouse-button-press event object."
72 (memq 'down (get (car obj) 'event-symbol-elements))))
74 (defun button-release-event-p (obj)
75 "True if the argument is a mouse-button-release event object."
77 (or (memq 'click (get (car obj) 'event-symbol-elements))
78 (memq 'drag (get (car obj) 'event-symbol-elements)))))
80 (defun button-event-p (obj)
81 "True if the argument is a mouse-button press or release event object."
83 (or (memq 'click (get (car obj) 'event-symbol-elements))
84 (memq 'down (get (car obj) 'event-symbol-elements))
85 (memq 'drag (get (car obj) 'event-symbol-elements)))))
87 (defun mouse-event-p (obj)
88 "True if the argument is a mouse-button press or release event object."
91 (memq 'click (get (car obj) 'event-symbol-elements))
92 (memq 'down (get (car obj) 'event-symbol-elements))
93 (memq 'drag (get (car obj) 'event-symbol-elements)))))
95 (defun character-to-event (ch &optional event)
96 "Converts a numeric ASCII value to an event structure, replete with
97 bucky bits. The character is the first argument, and the event to fill
102 Beware that character-to-event and event-to-character are not strictly
107 (defun copy-event (event1 &optional event2)
108 "Make a copy of the given event object.
109 In this emulation, `copy-event' just returns its argument."
112 (defun deallocate-event (event)
113 "Allow the given event structure to be reused.
114 In actual Lucid Emacs, you MUST NOT use this event object after
116 call this function, as event objects are garbage- collected like all
124 (defun enqueue-eval-event: (function object)
125 "Add an eval event to the back of the queue.
126 It will be the next event read after all pending events."
131 (defun eval-event-p (obj)
132 "True if the argument is an eval or menu event object."
135 (defun event-button (event)
136 "Return the button-number of the given mouse-button-press event."
137 (let ((sym (car (get (car event) 'event-symbol-elements))))
141 (defun event-function (event)
142 "Return the callback function of the given timeout, menu, or eval event."
143 (nth 1 event))
145 (defun event-key (event)
146 "Returns the KeySym of the given key-press event.
148 (if (symbolp event)
149 (car (get event 'event-symbol-elements))
150 (let ((base (logand event (1- (lsh 1 18)))))
153 (defun event-object (event)
154 "Returns the function argument of the given timeout, menu, or eval event."
155 (nth 2 event))
157 (defun event-point (event)
158 "Returns the character position of the given mouse-related event.
159 If the event did not occur over a window, or did
161 into the buffer visible in the event's window."
162 (posn-point (event-end event)))
167 (defun event-closest-point-1 (window &optional line)
179 (defun event-closest-point (event &optional start-window)
183 (or start-window (setq start-window (posn-window (event-start event))))
184 (if (eq start-window (posn-window (event-end event)))
185 (if (eq (event-point event) 'vertical-line)
186 (event-closest-point-1 start-window
187 (cdr (posn-col-row (event-end event))))
188 (if (eq (event-point event) 'mode-line)
189 (event-closest-point-1 start-window)
190 (event-point event)))
192 (let* ((end-w (posn-window (event-end event)))
198 (/ (cdr (posn-x-y (event-end event)))
201 (event-closest-point-1 start-window)
204 (defun event-process (event)
205 "Returns the process of the given process-output event."
206 (nth 1 event))
208 (defun event-timestamp (event)
209 "Returns the timestamp of the given event object.
210 In Lucid Emacs, this works for any kind of event.
212 (and (listp event)
213 (posn-timestamp (event-end event))))
215 (defun event-to-character (event &optional lenient)
216 "Returns the closest ASCII approximation to the given event object.
217 If the event isn't a keypress, this returns nil.
224 (if (symbolp event)
226 (cdr (assq event '((backspace . 8) (delete . 127) (tab . 9)
229 (if (integerp event)
230 event nil)))
232 (defun event-window (event)
233 "Returns the window of the given mouse-related event object."
234 (posn-window (event-end event)))
236 (defun event-x (event)
237 "Returns the X position in characters of the given mouse-related event."
238 (/ (car (posn-col-row (event-end event)))
239 (frame-char-width (window-frame (event-window event)))))
241 (defun event-x-pixel (event)
242 "Returns the X position in pixels of the given mouse-related event."
243 (car (posn-col-row (event-end event))))
245 (defun event-y (event)
246 "Returns the Y position in characters of the given mouse-related event."
247 (/ (cdr (posn-col-row (event-end event)))
248 (frame-char-height (window-frame (event-window event)))))
250 (defun event-y-pixel (event)
251 "Returns the Y position in pixels of the given mouse-related event."
252 (cdr (posn-col-row (event-end event))))
254 (defun key-press-event-p (obj)
255 "True if the argument is a keyboard event object."
258 (get obj 'event-symbol-elements))))
260 (defun menu-event-p (obj)
261 "True if the argument is a menu event object."
264 (defun motion-event-p (obj)
265 "True if the argument is a mouse-motion event object."
268 (defun read-command-event ()
269 "Return the next keyboard or mouse event; execute other events.
270 This is similar to the function `next-command-event' of Lucid Emacs,
271 but different in that it returns the event rather than filling in
272 an existing event object."
273 (let (event)
275 (setq event (read-event))
276 (not (or (key-press-event-p event)
277 (button-press-event-p event)
278 (button-release-event-p event)
279 (menu-event-p event))))
280 (let ((type (car-safe event)))
282 (funcall (nth 1 event) (nth 2 event)))
284 (select-frame (nth 1 event))))))
285 event))
287 (defun process-event-p (obj)
288 "True if the argument is a process-output event object.