1 ;;; events.el --- event functions for XEmacs.
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
4 ;; Copyright (C) 1996-7 Sun Microsystems, Inc.
5 ;; Copyright (C) 1996 Ben Wing.
7 ;; Maintainer: Martin Buchholz
8 ;; Keywords: internal, event, dumped
10 ;; This file is part of SXEmacs.
12 ;; SXEmacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; SXEmacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ;;; Synched up with: Not in FSF.
29 ;; This file is dumped with SXEmacs.
34 (defun event-console (event)
35 "Return the console that EVENT occurred on.
36 This will be nil for some types of events (e.g. eval events)."
37 (cdfw-console (event-channel event)))
39 (defun event-device (event)
40 "Return the device that EVENT occurred on.
41 This will be nil for some types of events (e.g. keyboard and eval events)."
42 (dfw-device (event-channel event)))
44 (defun event-frame (event)
45 "Return the frame that EVENT occurred on.
46 This will be nil for some types of events (e.g. keyboard and eval events)."
47 (fw-frame (event-channel event)))
49 (defun event-buffer (event)
50 "Return the buffer of the window over which mouse event EVENT occurred.
51 Return nil unless both (mouse-event-p EVENT) and
52 (event-over-text-area-p EVENT) are non-nil."
53 (let ((window (event-window event)))
54 (and (windowp window) (window-buffer window))))
56 (defalias 'allocate-event 'make-event)
59 (defun key-press-event-p (object)
60 "Return t if OBJECT is a key-press event."
61 (and (event-live-p object) (eq 'key-press (event-type object))))
63 (defun button-press-event-p (object)
64 "Return t if OBJECT is a mouse button-press event."
65 (and (event-live-p object) (eq 'button-press (event-type object))))
67 (defun button-release-event-p (object)
68 "Return t if OBJECT is a mouse button-release event."
69 (and (event-live-p object) (eq 'button-release (event-type object))))
71 (defun button-event-p (object)
72 "Return t if OBJECT is a mouse button-press or button-release event."
73 (and (event-live-p object)
74 (memq (event-type object) '(button-press button-release))
77 (defun motion-event-p (object)
78 "Return t if OBJECT is a mouse motion event."
79 (and (event-live-p object) (eq 'motion (event-type object))))
81 (defun mouse-event-p (object)
82 "Return t if OBJECT is a mouse button-press, button-release or motion event."
83 (and (event-live-p object)
84 (memq (event-type object) '(button-press button-release motion))
87 (defun process-event-p (object)
88 "Return t if OBJECT is a process-output event."
89 (and (event-live-p object) (eq 'process (event-type object))))
91 (defun timeout-event-p (object)
92 "Return t if OBJECT is a timeout event."
93 (and (event-live-p object) (eq 'timeout (event-type object))))
95 (defun eval-event-p (object)
96 "Return t if OBJECT is an eval event."
97 (and (event-live-p object) (eq 'eval (event-type object))))
99 (defun misc-user-event-p (object)
100 "Return t if OBJECT is a misc-user event.
101 A misc-user event is a user event that is not a keypress or mouse click;
102 normally this means a menu selection or scrollbar action."
103 (and (event-live-p object) (eq 'misc-user (event-type object))))
105 ;; You could just as easily use event-glyph but we include this for
108 (defun event-over-glyph-p (object)
109 "Return t if OBJECT is a mouse event occurring over a glyph.
110 Mouse events are events of type button-press, button-release or motion."
111 (and (event-live-p object) (event-glyph object) t))
113 (defun keyboard-translate (&rest pairs)
114 "Translate character or keysym FROM to TO at a low level.
115 Multiple FROM-TO pairs may be specified.
117 See `keyboard-translate-table' for more information."
119 (puthash (pop pairs) (pop pairs) keyboard-translate-table)))
121 (put 'tab 'ascii-character ?\t)
122 (put 'linefeed 'ascii-character ?\n)
123 (put 'clear 'ascii-character 12)
124 (put 'return 'ascii-character ?\r)
125 (put 'escape 'ascii-character ?\e)
126 (put 'space 'ascii-character ? )
128 ;; Do the same voodoo for the keypad keys. I used to bind these to keyboard
129 ;; macros (for instance, kp-0 was bound to "0") so that they would track the
130 ;; bindings of the corresponding keys by default, but that made the display
131 ;; of M-x describe-bindings much harder to read, so now we'll just bind them
132 ;; to self-insert by default. Not a big difference...
134 (put 'kp-0 'ascii-character ?0)
135 (put 'kp-1 'ascii-character ?1)
136 (put 'kp-2 'ascii-character ?2)
137 (put 'kp-3 'ascii-character ?3)
138 (put 'kp-4 'ascii-character ?4)
139 (put 'kp-5 'ascii-character ?5)
140 (put 'kp-6 'ascii-character ?6)
141 (put 'kp-7 'ascii-character ?7)
142 (put 'kp-8 'ascii-character ?8)
143 (put 'kp-9 'ascii-character ?9)
145 (put 'kp-space 'ascii-character ? )
146 (put 'kp-tab 'ascii-character ?\t)
147 (put 'kp-enter 'ascii-character ?\r)
148 (put 'kp-equal 'ascii-character ?=)
149 (put 'kp-multiply 'ascii-character ?*)
150 (put 'kp-add 'ascii-character ?+)
151 (put 'kp-separator 'ascii-character ?,)
152 (put 'kp-subtract 'ascii-character ?-)
153 (put 'kp-decimal 'ascii-character ?.)
154 (put 'kp-divide 'ascii-character ?/)
156 ;;; events.el ends here