0
|
1 ;;; events.el --- event functions.
|
|
2
|
|
3 ;;;; Copyright (C) 1996 Ben Wing.
|
|
4
|
|
5 ;; Maintainer:
|
|
6 ;; Keywords: internal
|
|
7
|
|
8 ;; This file is part of XEmacs.
|
|
9
|
|
10 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
11 ;; under the terms of the GNU General Public License as published by
|
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
13 ;; any later version.
|
|
14
|
|
15 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
18 ;; General Public License for more details.
|
|
19
|
|
20 ;; You should have received a copy of the GNU General Public License
|
16
|
21 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
23 ;; Boston, MA 02111-1307, USA.
|
0
|
24
|
|
25 ;;; Synched up with: Not in FSF.
|
|
26
|
|
27 ;;; Code:
|
|
28
|
|
29
|
|
30 (defun event-console (event)
|
|
31 "Return the console that EVENT occurred on.
|
|
32 This will be nil for some types of events (e.g. eval events)."
|
|
33 (cdfw-console (event-channel event)))
|
|
34
|
|
35 (defun event-device (event)
|
|
36 "Return the device that EVENT occurred on.
|
|
37 This will be nil for some types of events (e.g. keyboard and eval events)."
|
|
38 (dfw-device (event-channel event)))
|
|
39
|
|
40 (defun event-frame (event)
|
|
41 "Return the frame that EVENT occurred on.
|
|
42 This will be nil for some types of events (e.g. keyboard and eval events)."
|
|
43 (fw-frame (event-channel event)))
|
|
44
|
|
45 (defun event-buffer (event)
|
|
46 "Given a mouse-motion, button-press, or button-release event, return
|
|
47 the buffer on which that event occurred. This will be nil for non-mouse
|
|
48 events. If event-over-text-area-p is nil, this will also be nil."
|
|
49 (let ((window (event-window event)))
|
|
50 (and (windowp window) (window-buffer window))))
|
|
51
|
|
52 (defalias 'allocate-event 'make-event)
|
|
53
|
|
54 (defun key-press-event-p (obj)
|
|
55 "True if OBJ is a key-press event object."
|
|
56 (and (event-live-p obj) (eq 'key-press (event-type obj))))
|
|
57
|
|
58 (defun button-press-event-p (obj)
|
|
59 "True if OBJ is a mouse-button-press event object."
|
|
60 (and (event-live-p obj) (eq 'button-press (event-type obj))))
|
|
61
|
|
62 (defun button-release-event-p (obj)
|
|
63 "True if OBJ is a mouse-button-release event object."
|
|
64 (and (event-live-p obj) (eq 'button-release (event-type obj))))
|
|
65
|
|
66 (defun button-event-p (obj)
|
|
67 "True if OBJ is a button-press or button-release event object."
|
|
68 (or (button-press-event-p obj) (button-release-event-p obj)))
|
|
69
|
|
70 (defun motion-event-p (obj)
|
|
71 "True if OBJ is a mouse-motion event object."
|
|
72 (and (event-live-p obj) (eq 'motion (event-type obj))))
|
|
73
|
|
74 (defun mouse-event-p (obj)
|
|
75 "True if OBJ is a button-press, button-release, or mouse-motion event object."
|
|
76 (or (button-event-p obj) (motion-event-p obj)))
|
|
77
|
|
78 (defun process-event-p (obj)
|
|
79 "True if OBJ is a process-output event object."
|
|
80 (and (event-live-p obj) (eq 'process (event-type obj))))
|
|
81
|
|
82 (defun timeout-event-p (obj)
|
|
83 "True if OBJ is a timeout event object."
|
|
84 (and (event-live-p obj) (eq 'timeout (event-type obj))))
|
|
85
|
|
86 (defun eval-event-p (obj)
|
|
87 "True if OBJ is an eval event object."
|
|
88 (and (event-live-p obj) (eq 'eval (event-type obj))))
|
|
89
|
|
90 (defun misc-user-event-p (obj)
|
|
91 "True if OBJ is a misc-user event object.
|
|
92 A misc-user event is a user event that is not a keypress or mouse click;
|
|
93 normally this means a menu selection or scrollbar action."
|
|
94 (and (event-live-p obj) (eq 'misc-user (event-type obj))))
|
|
95
|
|
96 ;; You could just as easily use event-glyph but we include this for
|
|
97 ;; consistency.
|
|
98
|
|
99 (defun event-over-glyph-p (event)
|
|
100 "Given a mouse-motion, button-press, or button-release event, return
|
|
101 t if the event is over a glyph. Otherwise, return nil."
|
|
102 (not (null (event-glyph event))))
|
|
103
|
|
104 (defun keyboard-translate (&rest pairs)
|
|
105 "Translate character or keysym FROM to TO at a low level.
|
|
106 Multiple FROM-TO pairs may be specified.
|
|
107
|
|
108 See `keyboard-translate-table' for more information."
|
|
109 (while pairs
|
|
110 (puthash (car pairs) (car (cdr pairs)) keyboard-translate-table)
|
|
111 (setq pairs (cdr (cdr pairs)))))
|
|
112
|
|
113 (put 'backspace 'ascii-character ?\b)
|
|
114 (put 'delete 'ascii-character ?\177)
|
|
115 (put 'tab 'ascii-character ?\t)
|
|
116 (put 'linefeed 'ascii-character ?\n)
|
|
117 (put 'clear 'ascii-character 12)
|
|
118 (put 'return 'ascii-character ?\r)
|
|
119 (put 'escape 'ascii-character ?\e)
|
|
120 (put 'space 'ascii-character ? )
|
|
121
|
|
122 ;; Do the same voodoo for the keypad keys. I used to bind these to keyboard
|
52
|
123 ;; macros (for instance, kp-0 was bound to "0") so that they would track the
|
0
|
124 ;; bindings of the corresponding keys by default, but that made the display
|
|
125 ;; of M-x describe-bindings much harder to read, so now we'll just bind them
|
|
126 ;; to self-insert by default. Not a big difference...
|
|
127
|
52
|
128 (put 'kp-0 'ascii-character ?0)
|
|
129 (put 'kp-1 'ascii-character ?1)
|
|
130 (put 'kp-2 'ascii-character ?2)
|
|
131 (put 'kp-3 'ascii-character ?3)
|
|
132 (put 'kp-4 'ascii-character ?4)
|
|
133 (put 'kp-5 'ascii-character ?5)
|
|
134 (put 'kp-6 'ascii-character ?6)
|
|
135 (put 'kp-7 'ascii-character ?7)
|
|
136 (put 'kp-8 'ascii-character ?8)
|
|
137 (put 'kp-9 'ascii-character ?9)
|
0
|
138
|
52
|
139 (put 'kp-space 'ascii-character ? )
|
|
140 (put 'kp-tab 'ascii-character ?\t)
|
|
141 (put 'kp-enter 'ascii-character ?\r)
|
|
142 (put 'kp-equal 'ascii-character ?=)
|
|
143 (put 'kp-multiply 'ascii-character ?*)
|
|
144 (put 'kp-add 'ascii-character ?+)
|
|
145 (put 'kp-separator 'ascii-character ?,)
|
|
146 (put 'kp-subtract 'ascii-character ?-)
|
|
147 (put 'kp-decimal 'ascii-character ?.)
|
|
148 (put 'kp-divide 'ascii-character ?/)
|