annotate lisp/prim/events.el @ 52:461c7ba8286a r19-16-pre1

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